Browse Source

- moved some expression contexts to CSharpExpressionContext

- removed IdentifierExpected-Blocks

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/vbnet@6128 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
pull/1/head
Siegfried Pammer 16 years ago
parent
commit
aab8d9b0e0
  1. 2
      src/Libraries/NRefactory/Project/Src/Lexer/VBNet/Block.cs
  2. 30
      src/Libraries/NRefactory/Project/Src/Lexer/VBNet/ExpressionFinder.atg
  3. 13
      src/Libraries/NRefactory/Project/Src/Lexer/VBNet/ExpressionFinder.cs
  4. 1
      src/Libraries/NRefactory/Project/Src/Lexer/VBNet/ExpressionFinderState.cs
  5. 2882
      src/Libraries/NRefactory/Project/Src/Lexer/VBNet/Parser.cs
  6. 2
      src/Libraries/NRefactory/Project/Src/Lexer/VBNet/PushParser.frame
  7. 128
      src/Libraries/NRefactory/Test/Lexer/VBNet/LexerContextTests.cs
  8. 5
      src/Main/Base/Project/Src/Editor/CodeCompletion/MethodInsightProvider.cs
  9. 62
      src/Main/Base/Test/CSharpExpressionFinderTests.cs
  10. 19
      src/Main/Base/Test/NRefactoryResolverTests.cs
  11. 10
      src/Main/Base/Test/VBExpressionFinderTests.cs
  12. 1
      src/Main/ICSharpCode.SharpDevelop.Dom/Project/ICSharpCode.SharpDevelop.Dom.csproj
  13. 59
      src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/CSharp/CSharpExpressionContext.cs
  14. 22
      src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/CSharp/ExpressionFinder.cs
  15. 78
      src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/ExpressionContext.cs
  16. 29
      src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/NRefactoryResolver/NRefactoryResolver.cs
  17. 6
      src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/VBNet/VBNetExpressionFinder.cs

2
src/Libraries/NRefactory/Project/Src/Lexer/VBNet/Block.cs

@ -20,7 +20,7 @@ namespace ICSharpCode.NRefactory.Parser.VB
Type, Type,
Member, Member,
Parameter, Parameter,
IdentifierExpected, Identifier,
Body, Body,
Xml, Xml,
Attribute, Attribute,

30
src/Libraries/NRefactory/Project/Src/Lexer/VBNet/ExpressionFinder.atg

@ -303,7 +303,7 @@ NamespaceMemberDeclaration =
. .
NamespaceDeclaration = NamespaceDeclaration =
"Namespace" (. PushContext(Context.IdentifierExpected, la, t); .) { ANY } (. PopContext(); .) StatementTerminator "Namespace" (. PushContext(Context.Identifier, la, t); .) (.OnEachPossiblePath: SetIdentifierExpected(la); .) { ANY } (. PopContext(); .) StatementTerminator
{ NamespaceMemberDeclaration } { NamespaceMemberDeclaration }
"End" "Namespace" StatementTerminator "End" "Namespace" StatementTerminator
. .
@ -316,7 +316,7 @@ TypeDeclaration =
. .
ClassOrModuleOrStructureTypeDeclaration = ClassOrModuleOrStructureTypeDeclaration =
( "Module" | "Class" | "Structure" ) (. PushContext(Context.IdentifierExpected, la, t); .) ANY (. PopContext(); .) ( "Module" | "Class" | "Structure" ) (. PushContext(Context.Identifier, la, t); .) (.OnEachPossiblePath: SetIdentifierExpected(la); .) ANY (. PopContext(); .)
[ "(" "Of" [ "Out" | "In" ] IdentifierExceptOut [ (. PushContext(Context.Type, la, t); .) "As" GenericConstraintList (. PopContext(); .) ] { "," [ "Out" | "In" ] IdentifierExceptOut [ (. PushContext(Context.Type, la, t); .) "As" GenericConstraintList (. PopContext(); .) ] } ")" ] { ANY } [ StatementTerminator ] [ "(" "Of" [ "Out" | "In" ] IdentifierExceptOut [ (. PushContext(Context.Type, la, t); .) "As" GenericConstraintList (. PopContext(); .) ] { "," [ "Out" | "In" ] IdentifierExceptOut [ (. PushContext(Context.Type, la, t); .) "As" GenericConstraintList (. PopContext(); .) ] } ")" ] { ANY } [ StatementTerminator ]
[ "Inherits" { ANY } StatementTerminator ] [ "Inherits" { ANY } StatementTerminator ]
[ "Implements" { ANY } StatementTerminator ] [ "Implements" { ANY } StatementTerminator ]
@ -336,7 +336,7 @@ GenericConstraintList =
DelegateTypeDeclaration = DelegateTypeDeclaration =
"Delegate" ("Sub" | "Function") "Delegate" ("Sub" | "Function")
(. PushContext(Context.IdentifierExpected, la, t); .) ANY (. PopContext(); .) (. PushContext(Context.Identifier, la, t); .) (.OnEachPossiblePath: SetIdentifierExpected(la); .) ANY (. PopContext(); .)
[ "(" [ ParameterList ] ")" ] [ (. PushContext(Context.Type, la, t); .) "As" TypeName (. PopContext(); .) ] StatementTerminator [ "(" [ ParameterList ] ")" ] [ (. PushContext(Context.Type, la, t); .) "As" TypeName (. PopContext(); .) ] StatementTerminator
. .
@ -356,19 +356,19 @@ MemberDeclaration =
SubOrFunctionDeclaration = SubOrFunctionDeclaration =
("Sub" | "Function") ("Sub" | "Function")
(. PushContext(Context.IdentifierExpected, la, t); .) ANY (. PopContext(); .) (. PushContext(Context.Identifier, la, t); .) (.OnEachPossiblePath: SetIdentifierExpected(la); .) ANY (. PopContext(); .)
[ "(" [ ParameterList ] ")" ] [ (. PushContext(Context.Type, la, t); .) "As" TypeName (. PopContext(); .) ] [ "(" [ ParameterList ] ")" ] [ (. PushContext(Context.Type, la, t); .) "As" TypeName (. PopContext(); .) ]
StatementTerminatorAndBlock StatementTerminatorAndBlock
"End" ("Sub" | "Function") StatementTerminator "End" ("Sub" | "Function") StatementTerminator
. .
ExternalMemberDeclaration = ExternalMemberDeclaration =
"Declare" [ "Ansi" | "Unicode" | "Auto" ] ( "Sub" | "Function" ) (. PushContext(Context.IdentifierExpected, la, t); .) Identifier (. PopContext(); .) "Declare" [ "Ansi" | "Unicode" | "Auto" ] ( "Sub" | "Function" ) (. PushContext(Context.Identifier, la, t); .) (.OnEachPossiblePath: SetIdentifierExpected(la); .) Identifier (. PopContext(); .)
"Lib" LiteralString [ "Alias" LiteralString ] [ "(" [ ParameterList ] ")" ] [ (. PushContext(Context.Type, la, t); .) "As" TypeName (. PopContext(); .) ] StatementTerminator "Lib" LiteralString [ "Alias" LiteralString ] [ "(" [ ParameterList ] ")" ] [ (. PushContext(Context.Type, la, t); .) "As" TypeName (. PopContext(); .) ] StatementTerminator
. .
EventMemberDeclaration = EventMemberDeclaration =
"Event" (. PushContext(Context.IdentifierExpected, la, t); .) Identifier (. PopContext(); .) ( (. PushContext(Context.Type, la, t); .) "As" TypeName (. PopContext(); .) | [ "(" [ ParameterList ] ")" ] ) "Event" (. PushContext(Context.Identifier, la, t); .) (.OnEachPossiblePath: SetIdentifierExpected(la); .) Identifier (. PopContext(); .) ( (. PushContext(Context.Type, la, t); .) "As" TypeName (. PopContext(); .) | [ "(" [ ParameterList ] ")" ] )
[ "Implements" TypeName /*"." IdentifierOrKeyword*/ { "," TypeName /*"." IdentifierOrKeyword*/ } ] [ "Implements" TypeName /*"." IdentifierOrKeyword*/ { "," TypeName /*"." IdentifierOrKeyword*/ } ]
/* the TypeName production already allows the "." IdentifierOrKeyword syntax, so to avoid an ambiguous grammer we just leave that out */ /* the TypeName production already allows the "." IdentifierOrKeyword syntax, so to avoid an ambiguous grammer we just leave that out */
StatementTerminator StatementTerminator
@ -385,14 +385,14 @@ CustomEventMemberDeclaration =
. .
OperatorDeclaration = OperatorDeclaration =
"Operator" (. PushContext(Context.IdentifierExpected, la, t); .) ANY (. PopContext(); .) "(" ParameterList ")" [ "As" { AttributeBlock } (. PushContext(Context.Type, la, t); .) TypeName (. PopContext(); .) ] "Operator" (. PushContext(Context.Identifier, la, t); .) (.OnEachPossiblePath: SetIdentifierExpected(la); .) ANY (. PopContext(); .) "(" ParameterList ")" [ "As" { AttributeBlock } (. PushContext(Context.Type, la, t); .) TypeName (. PopContext(); .) ]
StatementTerminatorAndBlock StatementTerminatorAndBlock
"End" "Operator" StatementTerminator "End" "Operator" StatementTerminator
. .
MemberVariableOrConstantDeclaration = MemberVariableOrConstantDeclaration =
[ "Const" ] [ "Const" ]
(. PushContext(Context.IdentifierExpected, la, t); .) IdentifierForFieldDeclaration (. PopContext(); .) [ (. PushContext(Context.Type, la, t); .) "As" TypeName (. PopContext(); .) ] [ "=" Expression ] StatementTerminator (. PushContext(Context.Identifier, la, t); .) (.OnEachPossiblePath: SetIdentifierExpected(la); .) IdentifierForFieldDeclaration (. PopContext(); .) [ (. PushContext(Context.Type, la, t); .) "As" TypeName (. PopContext(); .) ] [ "=" Expression ] StatementTerminator
. .
ParameterList = ParameterList =
@ -402,7 +402,7 @@ ParameterList =
Parameter = Parameter =
(. PushContext(Context.Parameter, la, t); .) (. PushContext(Context.Parameter, la, t); .)
{ AttributeBlock } { ParameterModifier } { AttributeBlock } { ParameterModifier }
(. PushContext(Context.IdentifierExpected, la, t); .) Identifier (. PopContext(); .) (. PushContext(Context.Identifier, la, t); .) (.OnEachPossiblePath: SetIdentifierExpected(la); .) Identifier (. PopContext(); .)
[ (. PushContext(Context.Type, la, t); .) "As" TypeName (. PopContext(); .) ] [ (. PushContext(Context.Type, la, t); .) "As" TypeName (. PopContext(); .) ]
[ "=" Expression ] [ "=" Expression ]
(. PopContext(); .) (. PopContext(); .)
@ -652,7 +652,7 @@ ExpressionRangeVariable =
"Explicit", "Equals", "Distinct", "Descending", "Compare", "By", "Explicit", "Equals", "Distinct", "Descending", "Compare", "By",
"Binary", "Auto", "Assembly", "Ascending", "Ansi", "Aggregate", ident) "Binary", "Auto", "Assembly", "Ascending", "Ansi", "Aggregate", ident)
( (
(. PushContext(Context.IdentifierExpected, la, t); .) Identifier (. PopContext(); .) (. PushContext(Context.Identifier, la, t); .) (.OnEachPossiblePath: SetIdentifierExpected(la); .) Identifier (. PopContext(); .)
( (
(. PushContext(Context.Type, la, t); .) "As" TypeName (. PopContext(); .) "=" (. PushContext(Context.Type, la, t); .) "As" TypeName (. PopContext(); .) "="
| "=" | "="
@ -671,7 +671,7 @@ ExpressionRangeVariable =
. .
CollectionRangeVariable = CollectionRangeVariable =
(. PushContext(Context.IdentifierExpected, la, t); .) Identifier (. PopContext(); .) [ (. PushContext(Context.Type, la, t); .) "As" TypeName (. PopContext(); .) ] "In" Expression (. PushContext(Context.Identifier, la, t); .) (.OnEachPossiblePath: SetIdentifierExpected(la); .) Identifier (. PopContext(); .) [ (. PushContext(Context.Type, la, t); .) "As" TypeName (. PopContext(); .) ] "In" Expression
. .
/* semantic action will be inserted on all paths that possibly lead to XmlLiteral */ /* semantic action will be inserted on all paths that possibly lead to XmlLiteral */
@ -938,10 +938,10 @@ Statement =
VariableDeclarationStatement = VariableDeclarationStatement =
( "Dim" | "Static" | "Const" ) ( "Dim" | "Static" | "Const" )
(. PushContext(Context.IdentifierExpected, la, t); .) (. PushContext(Context.Identifier, la, t); .)
Identifier (. PopContext(); .) [ "?" ] [ ( "(" { "," } ")" ) ] Identifier (. PopContext(); .) [ "?" ] [ ( "(" { "," } ")" ) ]
{ "," { ","
(. PushContext(Context.IdentifierExpected, la, t); .) (. PushContext(Context.Identifier, la, t); .) (.OnEachPossiblePath: SetIdentifierExpected(la); .)
Identifier (. PopContext(); .) [ "?" ] [ ( "(" { "," } ")" ) ] Identifier (. PopContext(); .) [ "?" ] [ ( "(" { "," } ")" ) ]
} }
[ (. PushContext(Context.Type, la, t); .) [ (. PushContext(Context.Type, la, t); .)
@ -1042,7 +1042,7 @@ ForEachLoopStatement =
. .
ForLoopVariable = ForLoopVariable =
(. PushContext(Context.IdentifierExpected, la, t); .) SimpleExpression (. PopContext(); .) [ "?" ] { ExpressionSuffix } [ (. PushContext(Context.Type, la, t); .) "As" TypeName (. PopContext(); .) ] (. PushContext(Context.Identifier, la, t); .) (.OnEachPossiblePath: SetIdentifierExpected(la); .) SimpleExpression (. PopContext(); .) [ "?" ] { ExpressionSuffix } [ (. PushContext(Context.Type, la, t); .) "As" TypeName (. PopContext(); .) ]
. .
ErrorHandlingStatement = ErrorHandlingStatement =
@ -1059,7 +1059,7 @@ TryStatement =
StatementTerminatorAndBlock StatementTerminatorAndBlock
{ {
"Catch" "Catch"
[ (. PushContext(Context.IdentifierExpected, la, t); .) Identifier (. PopContext(); .) [ (. PushContext(Context.Type, la, t); .) "As" TypeName (. PopContext(); .) ] ] [ (. PushContext(Context.Identifier, la, t); .) (.OnEachPossiblePath: SetIdentifierExpected(la); .) Identifier (. PopContext(); .) [ (. PushContext(Context.Type, la, t); .) "As" TypeName (. PopContext(); .) ] ]
[ "When" Expression ] [ "When" Expression ]
StatementTerminatorAndBlock StatementTerminatorAndBlock
} }

13
src/Libraries/NRefactory/Project/Src/Lexer/VBNet/ExpressionFinder.cs

@ -50,6 +50,7 @@ namespace ICSharpCode.NRefactory.Parser.VB
nextTokenIsPotentialStartOfExpression = state.NextTokenIsPotentialStartOfExpression; nextTokenIsPotentialStartOfExpression = state.NextTokenIsPotentialStartOfExpression;
nextTokenIsStartOfImportsOrAccessExpression = state.NextTokenIsStartOfImportsOrAccessExpression; nextTokenIsStartOfImportsOrAccessExpression = state.NextTokenIsStartOfImportsOrAccessExpression;
readXmlIdentifier = state.ReadXmlIdentifier; readXmlIdentifier = state.ReadXmlIdentifier;
identifierExpected = state.IdentifierExpected;
stateStack = new Stack<int>(state.StateStack.Reverse()); stateStack = new Stack<int>(state.StateStack.Reverse());
stack = new Stack<Block>(state.BlockStack.Select(x => (Block)x.Clone()).Reverse()); stack = new Stack<Block>(state.BlockStack.Select(x => (Block)x.Clone()).Reverse());
currentState = state.CurrentState; currentState = state.CurrentState;
@ -94,9 +95,14 @@ namespace ICSharpCode.NRefactory.Parser.VB
} }
public bool IsIdentifierExpected { public bool IsIdentifierExpected {
get { get { return identifierExpected; }
return stack.Take(2).Any(c => c.context == Context.IdentifierExpected); }
}
void SetIdentifierExpected(Token la)
{
identifierExpected = true;
if (la != null)
CurrentBlock.lastExpressionStart = la.Location;
} }
public bool InContext(Context expected) public bool InContext(Context expected)
@ -134,6 +140,7 @@ namespace ICSharpCode.NRefactory.Parser.VB
NextTokenIsPotentialStartOfExpression = nextTokenIsPotentialStartOfExpression, NextTokenIsPotentialStartOfExpression = nextTokenIsPotentialStartOfExpression,
NextTokenIsStartOfImportsOrAccessExpression = nextTokenIsStartOfImportsOrAccessExpression, NextTokenIsStartOfImportsOrAccessExpression = nextTokenIsStartOfImportsOrAccessExpression,
ReadXmlIdentifier = readXmlIdentifier, ReadXmlIdentifier = readXmlIdentifier,
IdentifierExpected = identifierExpected,
StateStack = new Stack<int>(stateStack.Reverse()), StateStack = new Stack<int>(stateStack.Reverse()),
BlockStack = new Stack<Block>(stack.Select(x => (Block)x.Clone()).Reverse()), BlockStack = new Stack<Block>(stack.Select(x => (Block)x.Clone()).Reverse()),
CurrentState = currentState CurrentState = currentState

1
src/Libraries/NRefactory/Project/Src/Lexer/VBNet/ExpressionFinderState.cs

@ -17,6 +17,7 @@ namespace ICSharpCode.NRefactory.Parser.VB
public bool WasQualifierTokenAtStart { get; set; } public bool WasQualifierTokenAtStart { get; set; }
public bool NextTokenIsPotentialStartOfExpression { get; set; } public bool NextTokenIsPotentialStartOfExpression { get; set; }
public bool ReadXmlIdentifier { get; set; } public bool ReadXmlIdentifier { get; set; }
public bool IdentifierExpected { get; set; }
public bool NextTokenIsStartOfImportsOrAccessExpression { get; set; } public bool NextTokenIsStartOfImportsOrAccessExpression { get; set; }
public Stack<int> StateStack { get; set; } public Stack<int> StateStack { get; set; }
public Stack<Block> BlockStack { get; set; } public Stack<Block> BlockStack { get; set; }

2882
src/Libraries/NRefactory/Project/Src/Lexer/VBNet/Parser.cs

File diff suppressed because it is too large Load Diff

2
src/Libraries/NRefactory/Project/Src/Lexer/VBNet/PushParser.frame

@ -37,6 +37,7 @@ partial class ExpressionFinder {
bool wasQualifierTokenAtStart = false; bool wasQualifierTokenAtStart = false;
bool nextTokenIsPotentialStartOfExpression = false; bool nextTokenIsPotentialStartOfExpression = false;
bool readXmlIdentifier = false; bool readXmlIdentifier = false;
bool identifierExpected = false;
bool nextTokenIsStartOfImportsOrAccessExpression = false; bool nextTokenIsStartOfImportsOrAccessExpression = false;
List<Token> errors = new List<Token>(); List<Token> errors = new List<Token>();
@ -68,6 +69,7 @@ partial class ExpressionFinder {
nextTokenIsPotentialStartOfExpression = false; nextTokenIsPotentialStartOfExpression = false;
readXmlIdentifier = false; readXmlIdentifier = false;
nextTokenIsStartOfImportsOrAccessExpression = false; nextTokenIsStartOfImportsOrAccessExpression = false;
identifierExpected = false;
wasQualifierTokenAtStart = false; wasQualifierTokenAtStart = false;
-->informToken -->informToken
if (la != null) t = la; if (la != null) t = la;

128
src/Libraries/NRefactory/Test/Lexer/VBNet/LexerContextTests.cs

@ -39,15 +39,15 @@ exit Global
End Class End Class
", ",
@"enter Global @"enter Global
enter IdentifierExpected enter Identifier
exit IdentifierExpected exit Identifier
enter TypeDeclaration enter TypeDeclaration
enter Member enter Member
enter IdentifierExpected enter Identifier
exit IdentifierExpected exit Identifier
enter Body enter Body
enter IdentifierExpected enter Identifier
exit IdentifierExpected exit Identifier
enter Expression enter Expression
enter Expression enter Expression
enter Expression enter Expression
@ -77,12 +77,12 @@ exit Global
End Class End Class
", ",
@"enter Global @"enter Global
enter IdentifierExpected enter Identifier
exit IdentifierExpected exit Identifier
enter TypeDeclaration enter TypeDeclaration
enter Member enter Member
enter IdentifierExpected enter Identifier
exit IdentifierExpected exit Identifier
enter Type enter Type
exit Type exit Type
enter Expression enter Expression
@ -95,11 +95,11 @@ End Class
exit Expression exit Expression
exit Member exit Member
enter Member enter Member
enter IdentifierExpected enter Identifier
exit IdentifierExpected exit Identifier
enter Body enter Body
enter IdentifierExpected enter Identifier
exit IdentifierExpected exit Identifier
enter Expression enter Expression
enter Expression enter Expression
enter Expression enter Expression
@ -130,15 +130,15 @@ End Class
@"enter Global @"enter Global
enter Attribute enter Attribute
exit Attribute exit Attribute
enter IdentifierExpected enter Identifier
exit IdentifierExpected exit Identifier
enter TypeDeclaration enter TypeDeclaration
enter Member enter Member
enter IdentifierExpected enter Identifier
exit IdentifierExpected exit Identifier
enter Body enter Body
enter IdentifierExpected enter Identifier
exit IdentifierExpected exit Identifier
enter Expression enter Expression
enter Expression enter Expression
enter Expression enter Expression
@ -167,15 +167,15 @@ End Class
@"enter Global @"enter Global
enter Attribute enter Attribute
exit Attribute exit Attribute
enter IdentifierExpected enter Identifier
exit IdentifierExpected exit Identifier
enter TypeDeclaration enter TypeDeclaration
enter Member enter Member
enter IdentifierExpected enter Identifier
exit IdentifierExpected exit Identifier
enter Body enter Body
enter IdentifierExpected enter Identifier
exit IdentifierExpected exit Identifier
enter Expression enter Expression
enter Expression enter Expression
enter Expression enter Expression
@ -202,17 +202,17 @@ exit Global
End Class End Class
", ",
@"enter Global @"enter Global
enter IdentifierExpected enter Identifier
exit IdentifierExpected exit Identifier
enter TypeDeclaration enter TypeDeclaration
enter Member enter Member
enter Attribute enter Attribute
exit Attribute exit Attribute
enter IdentifierExpected enter Identifier
exit IdentifierExpected exit Identifier
enter Body enter Body
enter IdentifierExpected enter Identifier
exit IdentifierExpected exit Identifier
enter Expression enter Expression
enter Expression enter Expression
enter Expression enter Expression
@ -240,12 +240,12 @@ exit Global
End Class End Class
", ",
@"enter Global @"enter Global
enter IdentifierExpected enter Identifier
exit IdentifierExpected exit Identifier
enter TypeDeclaration enter TypeDeclaration
enter Member enter Member
enter IdentifierExpected enter Identifier
exit IdentifierExpected exit Identifier
enter Body enter Body
enter Expression enter Expression
enter Expression enter Expression
@ -286,17 +286,17 @@ exit Global
End Class End Class
", ",
@"enter Global @"enter Global
enter IdentifierExpected enter Identifier
exit IdentifierExpected exit Identifier
enter TypeDeclaration enter TypeDeclaration
enter Member enter Member
enter IdentifierExpected enter Identifier
exit IdentifierExpected exit Identifier
enter Body enter Body
enter IdentifierExpected enter Identifier
enter Expression enter Expression
exit Expression exit Expression
exit IdentifierExpected exit Identifier
enter Type enter Type
exit Type exit Type
enter Expression enter Expression
@ -311,10 +311,10 @@ End Class
exit Expression exit Expression
enter Body enter Body
exit Body exit Body
enter IdentifierExpected enter Identifier
enter Expression enter Expression
exit Expression exit Expression
exit IdentifierExpected exit Identifier
enter Type enter Type
exit Type exit Type
enter Expression enter Expression
@ -327,8 +327,8 @@ End Class
exit Body exit Body
enter Body enter Body
exit Body exit Body
enter IdentifierExpected enter Identifier
exit IdentifierExpected exit Identifier
enter Type enter Type
exit Type exit Type
enter Body enter Body
@ -354,18 +354,18 @@ exit Global
End Sub End Sub
End Class", End Class",
@"enter Global @"enter Global
enter IdentifierExpected enter Identifier
exit IdentifierExpected exit Identifier
enter TypeDeclaration enter TypeDeclaration
enter Member enter Member
enter IdentifierExpected enter Identifier
exit IdentifierExpected exit Identifier
enter Type enter Type
exit Type exit Type
exit Member exit Member
enter Member enter Member
enter IdentifierExpected enter Identifier
exit IdentifierExpected exit Identifier
enter Body enter Body
enter Expression enter Expression
enter Expression enter Expression
@ -377,10 +377,10 @@ End Class",
exit Expression exit Expression
exit Expression exit Expression
exit Expression exit Expression
enter IdentifierExpected enter Identifier
enter Expression enter Expression
exit Expression exit Expression
exit IdentifierExpected exit Identifier
enter Expression enter Expression
enter Expression enter Expression
enter Expression enter Expression
@ -430,12 +430,12 @@ End Module",
exit Importable exit Importable
enter Importable enter Importable
exit Importable exit Importable
enter IdentifierExpected enter Identifier
exit IdentifierExpected exit Identifier
enter TypeDeclaration enter TypeDeclaration
enter Member enter Member
enter IdentifierExpected enter Identifier
exit IdentifierExpected exit Identifier
enter Body enter Body
enter Expression enter Expression
enter Expression enter Expression
@ -449,16 +449,16 @@ End Module",
exit Expression exit Expression
exit Expression exit Expression
exit Expression exit Expression
enter IdentifierExpected enter Identifier
exit IdentifierExpected exit Identifier
enter Expression enter Expression
enter Expression enter Expression
enter Expression enter Expression
exit Expression exit Expression
exit Expression exit Expression
exit Expression exit Expression
enter IdentifierExpected enter Identifier
exit IdentifierExpected exit Identifier
enter Expression enter Expression
enter Expression enter Expression
enter Expression enter Expression
@ -493,8 +493,8 @@ End Module",
exit Expression exit Expression
exit Expression exit Expression
exit Expression exit Expression
enter IdentifierExpected enter Identifier
exit IdentifierExpected exit Identifier
enter Expression enter Expression
enter Expression enter Expression
enter Expression enter Expression

5
src/Main/Base/Project/Src/Editor/CodeCompletion/MethodInsightProvider.cs

@ -12,6 +12,7 @@ using System.Linq;
using ICSharpCode.Core; using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Dom; using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpDevelop.Dom.CSharp;
namespace ICSharpCode.SharpDevelop.Editor.CodeCompletion namespace ICSharpCode.SharpDevelop.Editor.CodeCompletion
{ {
@ -71,7 +72,7 @@ namespace ICSharpCode.SharpDevelop.Editor.CodeCompletion
} else if (expressionResult.Context.IsObjectCreation) { } else if (expressionResult.Context.IsObjectCreation) {
constructorInsight = true; constructorInsight = true;
expressionResult.Context = ExpressionContext.Type; expressionResult.Context = ExpressionContext.Type;
} else if (expressionResult.Context == ExpressionContext.BaseConstructorCall) { } else if (expressionResult.Context == CSharpExpressionContext.BaseConstructorCall) {
constructorInsight = true; constructorInsight = true;
} }
@ -93,7 +94,7 @@ namespace ICSharpCode.SharpDevelop.Editor.CodeCompletion
List<IMethod> methods = new List<IMethod>(); List<IMethod> methods = new List<IMethod>();
if (constructorInsight) { if (constructorInsight) {
if (trr != null || expressionResult.Context == ExpressionContext.BaseConstructorCall) { if (trr != null || expressionResult.Context == CSharpExpressionContext.BaseConstructorCall) {
if (result.ResolvedType != null) { if (result.ResolvedType != null) {
methods.AddRange(GetConstructors(result.ResolvedType)); methods.AddRange(GetConstructors(result.ResolvedType));
} }

62
src/Main/Base/Test/CSharpExpressionFinderTests.cs

@ -208,7 +208,7 @@ class Main {
public void GlobalNamespace() public void GlobalNamespace()
{ {
// context = context after the found word // context = context after the found word
FindFull(program3, "global", "global", ExpressionContext.FirstParameterType); FindFull(program3, "global", "global", CSharpExpressionContext.FirstParameterType);
FindFull(program3, "System.Ex", "global::System", ExpressionContext.IdentifierExpected); FindFull(program3, "System.Ex", "global::System", ExpressionContext.IdentifierExpected);
FindFull(program3, "Excep", "global::System.Exception", ExpressionContext.Type); FindFull(program3, "Excep", "global::System.Exception", ExpressionContext.Type);
} }
@ -229,8 +229,8 @@ class Main {
[Test] [Test]
public void ConstructorCall() public void ConstructorCall()
{ {
FindFull(program3, "this(", "this()", ExpressionContext.BaseConstructorCall); FindFull(program3, "this(", "this()", CSharpExpressionContext.BaseConstructorCall);
FindFull(program3, "base(", "base(arg + 3)", ExpressionContext.BaseConstructorCall); FindFull(program3, "base(", "base(arg + 3)", CSharpExpressionContext.BaseConstructorCall);
} }
[Test] [Test]
@ -308,10 +308,10 @@ class Main {
} }
}"; }";
FindExpr(propertyProgram, "\t/* in prop", null, ExpressionContext.PropertyDeclaration); FindExpr(propertyProgram, "\t/* in prop", null, CSharpExpressionContext.PropertyDeclaration);
FindExpr(propertyProgram, "\t/* in getter ", null, ExpressionContext.MethodBody); FindExpr(propertyProgram, "\t/* in getter ", null, ExpressionContext.MethodBody);
FindExpr(propertyProgram, "\t/* in setter", null, ExpressionContext.MethodBody); FindExpr(propertyProgram, "\t/* in setter", null, ExpressionContext.MethodBody);
FindExpr(propertyProgram, "\t/* still in prop", null, ExpressionContext.PropertyDeclaration); FindExpr(propertyProgram, "\t/* still in prop", null, CSharpExpressionContext.PropertyDeclaration);
} }
[Test] [Test]
@ -440,7 +440,7 @@ class Main {
body; body;
} }"; } }";
FindFull(program, "base", "base(arg)", ExpressionContext.BaseConstructorCall); FindFull(program, "base", "base(arg)", CSharpExpressionContext.BaseConstructorCall);
FindFull(program, "body", "body", ExpressionContext.MethodBody); FindFull(program, "body", "body", ExpressionContext.MethodBody);
FindFull(program, "arg", "arg", ExpressionContext.Default); FindFull(program, "arg", "arg", ExpressionContext.Default);
} }
@ -549,7 +549,7 @@ class Dictionary<K, ";
class List<T> "; class List<T> ";
ExpressionResult result = ef.FindExpression(program, program.Length); ExpressionResult result = ef.FindExpression(program, program.Length);
Assert.AreEqual("List<T> ", result.Expression); Assert.AreEqual("List<T> ", result.Expression);
Assert.AreEqual(ExpressionContext.ConstraintsStart, result.Context); Assert.AreEqual(CSharpExpressionContext.ConstraintsStart, result.Context);
} }
[Test] [Test]
@ -559,7 +559,7 @@ class List<T> ";
class List<T> where "; class List<T> where ";
ExpressionResult result = ef.FindExpression(program, program.Length); ExpressionResult result = ef.FindExpression(program, program.Length);
Assert.AreEqual("where ", result.Expression); Assert.AreEqual("where ", result.Expression);
Assert.AreEqual(ExpressionContext.Constraints, result.Context); Assert.AreEqual(CSharpExpressionContext.Constraints, result.Context);
} }
[Test] [Test]
@ -569,7 +569,7 @@ class List<T> where ";
class List<T> where T : "; class List<T> where T : ";
ExpressionResult result = ef.FindExpression(program, program.Length); ExpressionResult result = ef.FindExpression(program, program.Length);
Assert.AreEqual(null, result.Expression); Assert.AreEqual(null, result.Expression);
Assert.AreEqual(ExpressionContext.Constraints, result.Context); Assert.AreEqual(CSharpExpressionContext.Constraints, result.Context);
} }
[Test] [Test]
@ -579,7 +579,7 @@ class List<T> where T : ";
class List<T> where T : class, "; class List<T> where T : class, ";
ExpressionResult result = ef.FindExpression(program, program.Length); ExpressionResult result = ef.FindExpression(program, program.Length);
Assert.AreEqual(null, result.Expression); Assert.AreEqual(null, result.Expression);
Assert.AreEqual(ExpressionContext.Constraints, result.Context); Assert.AreEqual(CSharpExpressionContext.Constraints, result.Context);
} }
[Test] [Test]
@ -591,7 +591,7 @@ class Main {
a = new MyType { "; a = new MyType { ";
ExpressionResult result = ef.FindExpression(program, program.Length); ExpressionResult result = ef.FindExpression(program, program.Length);
Assert.AreEqual(ExpressionContext.ObjectInitializer, result.Context); Assert.AreEqual(CSharpExpressionContext.ObjectInitializer, result.Context);
} }
[Test] [Test]
@ -603,7 +603,7 @@ class Main {
a = new MyType<TypeArgument[], int?> { "; a = new MyType<TypeArgument[], int?> { ";
ExpressionResult result = ef.FindExpression(program, program.Length); ExpressionResult result = ef.FindExpression(program, program.Length);
Assert.AreEqual(ExpressionContext.ObjectInitializer, result.Context); Assert.AreEqual(CSharpExpressionContext.ObjectInitializer, result.Context);
} }
[Test] [Test]
@ -615,7 +615,7 @@ class Main {
a = new global::MyNamespace.MyType { "; a = new global::MyNamespace.MyType { ";
ExpressionResult result = ef.FindExpression(program, program.Length); ExpressionResult result = ef.FindExpression(program, program.Length);
Assert.AreEqual(ExpressionContext.ObjectInitializer, result.Context); Assert.AreEqual(CSharpExpressionContext.ObjectInitializer, result.Context);
} }
[Test] [Test]
@ -627,7 +627,7 @@ class Main {
a = new MyType(){ "; a = new MyType(){ ";
ExpressionResult result = ef.FindExpression(program, program.Length); ExpressionResult result = ef.FindExpression(program, program.Length);
Assert.AreEqual(ExpressionContext.ObjectInitializer, result.Context); Assert.AreEqual(CSharpExpressionContext.ObjectInitializer, result.Context);
} }
[Test] [Test]
@ -639,7 +639,7 @@ class Main {
a = new MyType<TypeArgument[], int?> (){ "; a = new MyType<TypeArgument[], int?> (){ ";
ExpressionResult result = ef.FindExpression(program, program.Length); ExpressionResult result = ef.FindExpression(program, program.Length);
Assert.AreEqual(ExpressionContext.ObjectInitializer, result.Context); Assert.AreEqual(CSharpExpressionContext.ObjectInitializer, result.Context);
} }
[Test] [Test]
@ -651,7 +651,7 @@ class Main {
a = new MyType(arg1, ')', arg3) { "; a = new MyType(arg1, ')', arg3) { ";
ExpressionResult result = ef.FindExpression(program, program.Length); ExpressionResult result = ef.FindExpression(program, program.Length);
Assert.AreEqual(ExpressionContext.ObjectInitializer, result.Context); Assert.AreEqual(CSharpExpressionContext.ObjectInitializer, result.Context);
} }
[Test] [Test]
@ -663,7 +663,7 @@ class Main {
a = new MyType { P1 = expr, "; a = new MyType { P1 = expr, ";
ExpressionResult result = ef.FindExpression(program, program.Length); ExpressionResult result = ef.FindExpression(program, program.Length);
Assert.AreEqual(ExpressionContext.ObjectInitializer, result.Context); Assert.AreEqual(CSharpExpressionContext.ObjectInitializer, result.Context);
} }
[Test] [Test]
@ -699,7 +699,7 @@ class Main {
a = new { "; a = new { ";
ExpressionResult result = ef.FindExpression(program, program.Length); ExpressionResult result = ef.FindExpression(program, program.Length);
Assert.AreEqual(ExpressionContext.ObjectInitializer, result.Context); Assert.AreEqual(CSharpExpressionContext.ObjectInitializer, result.Context);
} }
[Test] [Test]
@ -711,7 +711,7 @@ class Main {
a = new { a.B, "; a = new { a.B, ";
ExpressionResult result = ef.FindExpression(program, program.Length); ExpressionResult result = ef.FindExpression(program, program.Length);
Assert.AreEqual(ExpressionContext.ObjectInitializer, result.Context); Assert.AreEqual(CSharpExpressionContext.ObjectInitializer, result.Context);
} }
[Test] [Test]
@ -723,7 +723,7 @@ class Main {
a = new SomeType { SomeProperty = { "; a = new SomeType { SomeProperty = { ";
ExpressionResult result = ef.FindExpression(program, program.Length); ExpressionResult result = ef.FindExpression(program, program.Length);
Assert.AreEqual(ExpressionContext.ObjectInitializer, result.Context); Assert.AreEqual(CSharpExpressionContext.ObjectInitializer, result.Context);
} }
[Test] [Test]
@ -735,7 +735,7 @@ class Main {
a = new SomeType { SomeProperty = new SomeOtherType { "; a = new SomeType { SomeProperty = new SomeOtherType { ";
ExpressionResult result = ef.FindExpression(program, program.Length); ExpressionResult result = ef.FindExpression(program, program.Length);
Assert.AreEqual(ExpressionContext.ObjectInitializer, result.Context); Assert.AreEqual(CSharpExpressionContext.ObjectInitializer, result.Context);
} }
[Test] [Test]
@ -801,7 +801,7 @@ class Main {
public int this["; public int this[";
ExpressionResult result = ef.FindExpression(program, program.Length); ExpressionResult result = ef.FindExpression(program, program.Length);
Assert.AreEqual(ExpressionContext.ParameterType, result.Context); Assert.AreEqual(CSharpExpressionContext.ParameterType, result.Context);
} }
[Test] [Test]
@ -812,7 +812,7 @@ class Main {
public int this[int index] { "; public int this[int index] { ";
ExpressionResult result = ef.FindExpression(program, program.Length); ExpressionResult result = ef.FindExpression(program, program.Length);
Assert.AreEqual(ExpressionContext.PropertyDeclaration, result.Context); Assert.AreEqual(CSharpExpressionContext.PropertyDeclaration, result.Context);
} }
[Test] [Test]
@ -979,7 +979,7 @@ delegate void Test<T>(";
ExpressionResult result = ef.FindExpression(program, program.Length); ExpressionResult result = ef.FindExpression(program, program.Length);
Assert.IsNull(result.Expression); Assert.IsNull(result.Expression);
Assert.AreEqual(ExpressionContext.ParameterType, result.Context); Assert.AreEqual(CSharpExpressionContext.ParameterType, result.Context);
} }
[Test] [Test]
@ -990,7 +990,7 @@ delegate void Test<T>(ref ";
ExpressionResult result = ef.FindExpression(program, program.Length); ExpressionResult result = ef.FindExpression(program, program.Length);
Assert.IsNull(result.Expression); Assert.IsNull(result.Expression);
Assert.AreEqual(ExpressionContext.ParameterType, result.Context); Assert.AreEqual(CSharpExpressionContext.ParameterType, result.Context);
} }
[Test] [Test]
@ -1012,7 +1012,7 @@ delegate void Test<T>(ref T name) ";
ExpressionResult result = ef.FindExpression(program, program.Length); ExpressionResult result = ef.FindExpression(program, program.Length);
Assert.AreEqual("Test<T>(ref T name) ", result.Expression); Assert.AreEqual("Test<T>(ref T name) ", result.Expression);
Assert.AreEqual(ExpressionContext.ConstraintsStart, result.Context); Assert.AreEqual(CSharpExpressionContext.ConstraintsStart, result.Context);
} }
[Test] [Test]
@ -1023,7 +1023,7 @@ delegate void Test<T>(ref T name) where ";
ExpressionResult result = ef.FindExpression(program, program.Length); ExpressionResult result = ef.FindExpression(program, program.Length);
Assert.AreEqual("where ", result.Expression); Assert.AreEqual("where ", result.Expression);
Assert.AreEqual(ExpressionContext.Constraints, result.Context); Assert.AreEqual(CSharpExpressionContext.Constraints, result.Context);
} }
[Test] [Test]
@ -1045,7 +1045,7 @@ void Test<T>(";
ExpressionResult result = ef.FindExpression(program, program.Length); ExpressionResult result = ef.FindExpression(program, program.Length);
Assert.IsNull(result.Expression); Assert.IsNull(result.Expression);
Assert.AreEqual(ExpressionContext.FirstParameterType, result.Context); Assert.AreEqual(CSharpExpressionContext.FirstParameterType, result.Context);
} }
[Test] [Test]
@ -1056,7 +1056,7 @@ void Test<T>(ref ";
ExpressionResult result = ef.FindExpression(program, program.Length); ExpressionResult result = ef.FindExpression(program, program.Length);
Assert.IsNull(result.Expression); Assert.IsNull(result.Expression);
Assert.AreEqual(ExpressionContext.ParameterType, result.Context); Assert.AreEqual(CSharpExpressionContext.ParameterType, result.Context);
} }
[Test] [Test]
@ -1078,7 +1078,7 @@ void Test<T>(ref T name) ";
ExpressionResult result = ef.FindExpression(program, program.Length); ExpressionResult result = ef.FindExpression(program, program.Length);
Assert.AreEqual("Test<T>(ref T name) ", result.Expression); Assert.AreEqual("Test<T>(ref T name) ", result.Expression);
Assert.AreEqual(ExpressionContext.ConstraintsStart, result.Context); Assert.AreEqual(CSharpExpressionContext.ConstraintsStart, result.Context);
} }
[Test] [Test]
@ -1089,7 +1089,7 @@ void Test<T>(ref T name) where ";
ExpressionResult result = ef.FindExpression(program, program.Length); ExpressionResult result = ef.FindExpression(program, program.Length);
Assert.AreEqual("where ", result.Expression); Assert.AreEqual("where ", result.Expression);
Assert.AreEqual(ExpressionContext.Constraints, result.Context); Assert.AreEqual(CSharpExpressionContext.Constraints, result.Context);
} }
[Test] [Test]

19
src/Main/Base/Test/NRefactoryResolverTests.cs

@ -13,6 +13,7 @@ using System.Linq;
using ICSharpCode.Core; using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Dom; using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpDevelop.Dom.CSharp;
using ICSharpCode.SharpDevelop.Dom.NRefactoryResolver; using ICSharpCode.SharpDevelop.Dom.NRefactoryResolver;
using ICSharpCode.SharpDevelop.Project; using ICSharpCode.SharpDevelop.Project;
using NUnit.Framework; using NUnit.Framework;
@ -1951,13 +1952,13 @@ public class MyCollectionType : System.Collections.IEnumerable
[Test] [Test]
public void ObjectInitializerCtrlSpaceCompletion() public void ObjectInitializerCtrlSpaceCompletion()
{ {
var results = CtrlSpaceResolveCSharp(objectInitializerTestProgram, 5, ExpressionContext.ObjectInitializer); var results = CtrlSpaceResolveCSharp(objectInitializerTestProgram, 5, CSharpExpressionContext.ObjectInitializer);
Assert.AreEqual(new[] { "P1", "P2" }, (from IMember p in results orderby p.Name select p.Name).ToArray() ); Assert.AreEqual(new[] { "P1", "P2" }, (from IMember p in results orderby p.Name select p.Name).ToArray() );
results = CtrlSpaceResolveCSharp(objectInitializerTestProgram, 9, ExpressionContext.ObjectInitializer); results = CtrlSpaceResolveCSharp(objectInitializerTestProgram, 9, CSharpExpressionContext.ObjectInitializer);
Assert.AreEqual(new[] { "X", "Y" }, (from IMember p in results orderby p.Name select p.Name).ToArray() ); Assert.AreEqual(new[] { "X", "Y" }, (from IMember p in results orderby p.Name select p.Name).ToArray() );
results = CtrlSpaceResolveCSharp(objectInitializerTestProgram, 13, ExpressionContext.ObjectInitializer); results = CtrlSpaceResolveCSharp(objectInitializerTestProgram, 13, CSharpExpressionContext.ObjectInitializer);
// collection type: expect system types // collection type: expect system types
Assert.IsTrue(results.OfType<IClass>().Any((IClass c) => c.FullyQualifiedName == "System.Int32")); Assert.IsTrue(results.OfType<IClass>().Any((IClass c) => c.FullyQualifiedName == "System.Int32"));
Assert.IsTrue(results.OfType<IClass>().Any((IClass c) => c.FullyQualifiedName == "System.AppDomain")); Assert.IsTrue(results.OfType<IClass>().Any((IClass c) => c.FullyQualifiedName == "System.AppDomain"));
@ -1968,30 +1969,30 @@ public class MyCollectionType : System.Collections.IEnumerable
Assert.IsFalse(results.OfType<IField>().Any((IField f) => f.FullyQualifiedName == "MyCollectionType.ReadOnlyValueTypeField")); Assert.IsFalse(results.OfType<IField>().Any((IField f) => f.FullyQualifiedName == "MyCollectionType.ReadOnlyValueTypeField"));
Assert.IsFalse(results.OfType<IProperty>().Any((IProperty f) => f.FullyQualifiedName == "MyCollectionType.ReadOnlyValueTypeProperty")); Assert.IsFalse(results.OfType<IProperty>().Any((IProperty f) => f.FullyQualifiedName == "MyCollectionType.ReadOnlyValueTypeProperty"));
results = CtrlSpaceResolveCSharp(objectInitializerTestProgram, 17, ExpressionContext.ObjectInitializer); results = CtrlSpaceResolveCSharp(objectInitializerTestProgram, 17, CSharpExpressionContext.ObjectInitializer);
Assert.AreEqual(new[] { "X", "Y" }, (from IMember p in results orderby p.Name select p.Name).ToArray() ); Assert.AreEqual(new[] { "X", "Y" }, (from IMember p in results orderby p.Name select p.Name).ToArray() );
} }
[Test] [Test]
public void ObjectInitializerCompletion() public void ObjectInitializerCompletion()
{ {
MemberResolveResult mrr = (MemberResolveResult)Resolve(objectInitializerTestProgram, "P2", 5, 1, ExpressionContext.ObjectInitializer); MemberResolveResult mrr = (MemberResolveResult)Resolve(objectInitializerTestProgram, "P2", 5, 1, CSharpExpressionContext.ObjectInitializer);
Assert.IsNotNull(mrr); Assert.IsNotNull(mrr);
Assert.AreEqual("Rectangle.P2", mrr.ResolvedMember.FullyQualifiedName); Assert.AreEqual("Rectangle.P2", mrr.ResolvedMember.FullyQualifiedName);
mrr = (MemberResolveResult)Resolve(objectInitializerTestProgram, "X", 9, 1, ExpressionContext.ObjectInitializer); mrr = (MemberResolveResult)Resolve(objectInitializerTestProgram, "X", 9, 1, CSharpExpressionContext.ObjectInitializer);
Assert.IsNotNull(mrr); Assert.IsNotNull(mrr);
Assert.AreEqual("Point.X", mrr.ResolvedMember.FullyQualifiedName); Assert.AreEqual("Point.X", mrr.ResolvedMember.FullyQualifiedName);
mrr = (MemberResolveResult)Resolve(objectInitializerTestProgram, "Field", 13, 1, ExpressionContext.ObjectInitializer); mrr = (MemberResolveResult)Resolve(objectInitializerTestProgram, "Field", 13, 1, CSharpExpressionContext.ObjectInitializer);
Assert.IsNotNull(mrr); Assert.IsNotNull(mrr);
Assert.AreEqual("MyCollectionType.Field", mrr.ResolvedMember.FullyQualifiedName); Assert.AreEqual("MyCollectionType.Field", mrr.ResolvedMember.FullyQualifiedName);
LocalResolveResult lrr = (LocalResolveResult)Resolve(objectInitializerTestProgram, "r1", 13, 1, ExpressionContext.ObjectInitializer); LocalResolveResult lrr = (LocalResolveResult)Resolve(objectInitializerTestProgram, "r1", 13, 1, CSharpExpressionContext.ObjectInitializer);
Assert.IsNotNull(lrr); Assert.IsNotNull(lrr);
Assert.AreEqual("r1", lrr.Field.Name); Assert.AreEqual("r1", lrr.Field.Name);
mrr = (MemberResolveResult)Resolve(objectInitializerTestProgram, "X", 17, 1, ExpressionContext.ObjectInitializer); mrr = (MemberResolveResult)Resolve(objectInitializerTestProgram, "X", 17, 1, CSharpExpressionContext.ObjectInitializer);
Assert.IsNotNull(mrr); Assert.IsNotNull(mrr);
Assert.AreEqual("Point.X", mrr.ResolvedMember.FullyQualifiedName); Assert.AreEqual("Point.X", mrr.ResolvedMember.FullyQualifiedName);
} }

10
src/Main/Base/Test/VBExpressionFinderTests.cs

@ -151,7 +151,7 @@ End Module", "(", 1, "", ExpressionContext.Parameter);
[Test] [Test]
public void ContextAfterDim() public void ContextAfterDim()
{ {
ContextTest(program4, "Dim ", "Dim".Length, ExpressionContext.IdentifierExpected); ContextTest(program4, "Dim ", "Dim".Length, ExpressionContext.MethodBody);
} }
#endregion #endregion
@ -171,7 +171,7 @@ End Module", "(", 1, "", ExpressionContext.Parameter);
[Test] [Test]
public void Underscore() public void Underscore()
{ {
FindFull(program1, "der_score_field", "under_score_field", ExpressionContext.IdentifierExpected); FindFull(program1, "der_score_field", "under_score_field", ExpressionContext.Default);
} }
[Test] [Test]
@ -183,7 +183,7 @@ End Module", "(", 1, "", ExpressionContext.Parameter);
[Test] [Test]
public void LocalVariableDecl() public void LocalVariableDecl()
{ {
FindFull(program1, "ext", "text", ExpressionContext.IdentifierExpected); FindFull(program1, "ext", "text", ExpressionContext.Default);
} }
[Test] [Test]
@ -201,13 +201,13 @@ End Module", "(", 1, "", ExpressionContext.Parameter);
[Test] [Test]
public void ClassName() public void ClassName()
{ {
FindFull(program1, "ainClas", "MainClass", ExpressionContext.IdentifierExpected); FindFull(program1, "ainClas", "MainClass", ExpressionContext.Default);
} }
[Test] [Test]
public void SubName() public void SubName()
{ {
FindFull(program1, "omeMe", "SomeMethod", ExpressionContext.IdentifierExpected); FindFull(program1, "omeMe", "SomeMethod", ExpressionContext.Default);
} }
#region Old Tests #region Old Tests

1
src/Main/ICSharpCode.SharpDevelop.Dom/Project/ICSharpCode.SharpDevelop.Dom.csproj

@ -64,6 +64,7 @@
<Link>Configuration\GlobalAssemblyInfo.cs</Link> <Link>Configuration\GlobalAssemblyInfo.cs</Link>
</Compile> </Compile>
<Compile Include="Src\BusyManager.cs" /> <Compile Include="Src\BusyManager.cs" />
<Compile Include="Src\CSharp\CSharpExpressionContext.cs" />
<Compile Include="Src\CSharp\OverloadResolution.cs" /> <Compile Include="Src\CSharp\OverloadResolution.cs" />
<Compile Include="Src\CSharp\TypeInference.cs" /> <Compile Include="Src\CSharp\TypeInference.cs" />
<Compile Include="Src\DomCache.cs" /> <Compile Include="Src\DomCache.cs" />

59
src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/CSharp/CSharpExpressionContext.cs

@ -0,0 +1,59 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Daniel Grunwald" email="daniel@danielgrunwald.de"/>
// <version>$Revision: 5529 $</version>
// </file>
using System;
using ICSharpCode.SharpDevelop.Dom;
namespace ICSharpCode.SharpDevelop.Dom.CSharp
{
public static class CSharpExpressionContext
{
/// <summary>The context is the body of a property declaration.</summary>
/// <example>string Name { *expr* }</example>
public readonly static ExpressionContext PropertyDeclaration = new ExpressionContext.DefaultExpressionContext("PropertyDeclaration");
/// <summary>The context is the body of a property declaration inside an interface.</summary>
/// <example>string Name { *expr* }</example>
public readonly static ExpressionContext InterfacePropertyDeclaration = new ExpressionContext.DefaultExpressionContext("InterfacePropertyDeclaration");
/// <summary>The context is the body of a event declaration.</summary>
/// <example>event EventHandler NameChanged { *expr* }</example>
public readonly static ExpressionContext EventDeclaration = new ExpressionContext.DefaultExpressionContext("EventDeclaration");
/// <summary>The context is after the type parameters of a type/method declaration.
/// The only valid keyword is "where"</summary>
/// <example>class &lt;T&gt; *expr*</example>
public readonly static ExpressionContext ConstraintsStart = new ExpressionContext.DefaultExpressionContext("ConstraintsStart");
/// <summary>The context is after the 'where' of a constraints list.</summary>
/// <example>class &lt;T&gt; where *expr*</example>
public readonly static ExpressionContext Constraints = new ExpressionContext.NonStaticTypeExpressionContext("Constraints", false);
/// <summary>The context is the body of an interface declaration.</summary>
public readonly static ExpressionContext InterfaceDeclaration = new ExpressionContext.NonStaticTypeExpressionContext("InterfaceDeclaration", true);
/// <summary>Context expects "base" or "this".</summary>
/// <example>public ClassName() : *expr*</example>
public readonly static ExpressionContext BaseConstructorCall = new ExpressionContext.DefaultExpressionContext("BaseConstructorCall");
/// <summary>The first parameter</summary>
/// <example>void MethodName(*expr*)</example>
public readonly static ExpressionContext FirstParameterType = new ExpressionContext.NonStaticTypeExpressionContext("FirstParameterType", false);
/// <summary>Another parameter</summary>
/// <example>void MethodName(..., *expr*)</example>
public readonly static ExpressionContext ParameterType = new ExpressionContext.NonStaticTypeExpressionContext("ParameterType", false);
/// <summary>Context expects a fully qualified type name.</summary>
/// <example>using Alias = *expr*;</example>
public readonly static ExpressionContext FullyQualifiedType = new ExpressionContext.DefaultExpressionContext("FullyQualifiedType");
/// <summary>Context expects is a property name in an object initializer.</summary>
/// <example>new *type* [(args)] { *expr* = ... }</example>
public readonly static ExpressionContext ObjectInitializer = new ExpressionContext.DefaultExpressionContext("ObjectInitializer");
}
}

22
src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/CSharp/ExpressionFinder.cs

@ -222,7 +222,7 @@ namespace ICSharpCode.SharpDevelop.Dom.CSharp
SetContext(ExpressionContext.InheritableType); SetContext(ExpressionContext.InheritableType);
} }
} else if (state == FrameState.Constraints) { } else if (state == FrameState.Constraints) {
SetContext(ExpressionContext.Constraints); SetContext(CSharpExpressionContext.Constraints);
} else if (state == FrameState.UsingNamespace) { } else if (state == FrameState.UsingNamespace) {
SetContext(ExpressionContext.Namespace); SetContext(ExpressionContext.Namespace);
} else { } else {
@ -238,29 +238,29 @@ namespace ICSharpCode.SharpDevelop.Dom.CSharp
SetContext(ExpressionContext.IdentifierExpected); SetContext(ExpressionContext.IdentifierExpected);
break; break;
case FrameType.Interface: case FrameType.Interface:
SetContext(ExpressionContext.InterfaceDeclaration); SetContext(CSharpExpressionContext.InterfaceDeclaration);
break; break;
case FrameType.Event: case FrameType.Event:
SetContext(ExpressionContext.EventDeclaration); SetContext(CSharpExpressionContext.EventDeclaration);
break; break;
case FrameType.Property: case FrameType.Property:
if (parent != null && parent.type == FrameType.Interface) { if (parent != null && parent.type == FrameType.Interface) {
SetContext(ExpressionContext.InterfacePropertyDeclaration); SetContext(CSharpExpressionContext.InterfacePropertyDeclaration);
} else { } else {
SetContext(ExpressionContext.PropertyDeclaration); SetContext(CSharpExpressionContext.PropertyDeclaration);
} }
break; break;
case FrameType.Statements: case FrameType.Statements:
SetContext(ExpressionContext.MethodBody); SetContext(ExpressionContext.MethodBody);
break; break;
case FrameType.ParameterList: case FrameType.ParameterList:
SetContext(ExpressionContext.ParameterType); SetContext(CSharpExpressionContext.ParameterType);
break; break;
case FrameType.ObjectInitializer: case FrameType.ObjectInitializer:
if (state == FrameState.ObjectInitializerValue) { if (state == FrameState.ObjectInitializerValue) {
SetContext(ExpressionContext.Default); SetContext(ExpressionContext.Default);
} else { } else {
SetContext(ExpressionContext.ObjectInitializer); SetContext(CSharpExpressionContext.ObjectInitializer);
} }
break; break;
case FrameType.AttributeSection: case FrameType.AttributeSection:
@ -479,7 +479,7 @@ namespace ICSharpCode.SharpDevelop.Dom.CSharp
{ {
frame.type = FrameType.TypeParameterDecl; frame.type = FrameType.TypeParameterDecl;
frame.SetContext(ExpressionContext.IdentifierExpected); frame.SetContext(ExpressionContext.IdentifierExpected);
frame.parent.SetContext(ExpressionContext.ConstraintsStart); frame.parent.SetContext(CSharpExpressionContext.ConstraintsStart);
} else { } else {
frame.SetContext(ExpressionContext.Type); frame.SetContext(ExpressionContext.Type);
} }
@ -588,7 +588,7 @@ namespace ICSharpCode.SharpDevelop.Dom.CSharp
break; break;
case Tokens.Assign: case Tokens.Assign:
if (frame.type == FrameType.Global) { if (frame.type == FrameType.Global) {
frame.SetContext(ExpressionContext.FullyQualifiedType); frame.SetContext(CSharpExpressionContext.FullyQualifiedType);
break; break;
} else if (frame.type == FrameType.Enum) { } else if (frame.type == FrameType.Enum) {
frame.SetContext(ExpressionContext.Default); frame.SetContext(ExpressionContext.Default);
@ -609,7 +609,7 @@ namespace ICSharpCode.SharpDevelop.Dom.CSharp
} }
case Tokens.Colon: case Tokens.Colon:
if (frame.state == FrameState.MethodDecl && lastToken == Tokens.CloseParenthesis) { if (frame.state == FrameState.MethodDecl && lastToken == Tokens.CloseParenthesis) {
frame.SetContext(ExpressionContext.BaseConstructorCall); frame.SetContext(CSharpExpressionContext.BaseConstructorCall);
frame.parenthesisChildType = FrameType.Expression; frame.parenthesisChildType = FrameType.Expression;
} else { } else {
if (frame.curlyChildType == FrameType.TypeDecl || frame.curlyChildType == FrameType.Interface || frame.curlyChildType == FrameType.Enum) { if (frame.curlyChildType == FrameType.TypeDecl || frame.curlyChildType == FrameType.Interface || frame.curlyChildType == FrameType.Enum) {
@ -692,7 +692,7 @@ namespace ICSharpCode.SharpDevelop.Dom.CSharp
|| frame.parent.state == FrameState.FieldDecl)) || frame.parent.state == FrameState.FieldDecl))
{ {
frame.type = FrameType.ParameterList; frame.type = FrameType.ParameterList;
frame.SetContext(ExpressionContext.FirstParameterType); frame.SetContext(CSharpExpressionContext.FirstParameterType);
frame.parent.state = FrameState.MethodDecl; frame.parent.state = FrameState.MethodDecl;
frame.parent.curlyChildType = FrameType.Statements; frame.parent.curlyChildType = FrameType.Statements;
} }

78
src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/ExpressionContext.cs

@ -59,67 +59,6 @@ namespace ICSharpCode.SharpDevelop.Dom
} }
#endregion #endregion
#region C# specific contexts (public static fields) * MOVE TO ANOTHER CLASS *
/// <summary>The context expects a new identifier</summary>
/// <example>class *expr* {}; string *expr*;</example>
public readonly static ExpressionContext IdentifierExpected = new DefaultExpressionContext("IdentifierExpected");
/// <summary>The context is outside of any type declaration, expecting a global-level keyword.</summary>
public readonly static ExpressionContext Global = new DefaultExpressionContext("Global");
/// <summary>The context is the body of a property declaration.</summary>
/// <example>string Name { *expr* }</example>
public readonly static ExpressionContext PropertyDeclaration = new DefaultExpressionContext("PropertyDeclaration");
/// <summary>The context is the body of a property declaration inside an interface.</summary>
/// <example>string Name { *expr* }</example>
public readonly static ExpressionContext InterfacePropertyDeclaration = new DefaultExpressionContext("InterfacePropertyDeclaration");
/// <summary>The context is the body of a event declaration.</summary>
/// <example>event EventHandler NameChanged { *expr* }</example>
public readonly static ExpressionContext EventDeclaration = new DefaultExpressionContext("EventDeclaration");
/// <summary>The context is the body of a method.</summary>
/// <example>void Main () { *expr* }</example>
public readonly static ExpressionContext MethodBody = new DefaultExpressionContext("MethodBody");
/// <summary>The context is after the type parameters of a type/method declaration.
/// The only valid keyword is "where"</summary>
/// <example>class &lt;T&gt; *expr*</example>
public readonly static ExpressionContext ConstraintsStart = new DefaultExpressionContext("ConstraintsStart");
/// <summary>The context is after the 'where' of a constraints list.</summary>
/// <example>class &lt;T&gt; where *expr*</example>
public readonly static ExpressionContext Constraints = new NonStaticTypeExpressionContext("Constraints", false);
/// <summary>The context is the body of a type declaration.</summary>
public readonly static ExpressionContext TypeDeclaration = new NonStaticTypeExpressionContext("TypeDeclaration", true);
/// <summary>The context is the body of an interface declaration.</summary>
public readonly static ExpressionContext InterfaceDeclaration = new NonStaticTypeExpressionContext("InterfaceDeclaration", true);
/// <summary>Context expects "base" or "this".</summary>
/// <example>public ClassName() : *expr*</example>
public readonly static ExpressionContext BaseConstructorCall = new DefaultExpressionContext("BaseConstructorCall");
/// <summary>The first parameter</summary>
/// <example>void MethodName(*expr*)</example>
public readonly static ExpressionContext FirstParameterType = new NonStaticTypeExpressionContext("FirstParameterType", false);
/// <summary>Another parameter</summary>
/// <example>void MethodName(..., *expr*)</example>
public readonly static ExpressionContext ParameterType = new NonStaticTypeExpressionContext("ParameterType", false);
/// <summary>Context expects a fully qualified type name.</summary>
/// <example>using Alias = *expr*;</example>
public readonly static ExpressionContext FullyQualifiedType = new DefaultExpressionContext("FullyQualifiedType");
/// <summary>Context expects is a property name in an object initializer.</summary>
/// <example>new *type* [(args)] { *expr* = ... }</example>
public readonly static ExpressionContext ObjectInitializer = new DefaultExpressionContext("ObjectInitializer");
#endregion
#region VB specific contexts (public static fields) * MOVE TO ANOTHER CLASS * #region VB specific contexts (public static fields) * MOVE TO ANOTHER CLASS *
/// <summary>The context expects a new parameter declaration</summary> /// <summary>The context expects a new parameter declaration</summary>
/// <example>Function Test(*expr*, *expr*, ...)</example> /// <example>Function Test(*expr*, *expr*, ...)</example>
@ -185,10 +124,23 @@ namespace ICSharpCode.SharpDevelop.Dom
/// <example>public event *expr*</example> /// <example>public event *expr*</example>
public readonly static ExpressionContext DelegateType = new ClassTypeExpressionContext(ClassType.Delegate); public readonly static ExpressionContext DelegateType = new ClassTypeExpressionContext(ClassType.Delegate);
/// <summary>The context expects a new identifier</summary>
/// <example>class *expr* {}; string *expr*;</example>
public readonly static ExpressionContext IdentifierExpected = new DefaultExpressionContext("IdentifierExpected");
/// <summary>The context is outside of any type declaration, expecting a global-level keyword.</summary>
public readonly static ExpressionContext Global = new DefaultExpressionContext("Global");
/// <summary>The context is the body of a type declaration.</summary>
public readonly static ExpressionContext TypeDeclaration = new ExpressionContext.NonStaticTypeExpressionContext("TypeDeclaration", true);
/// <summary>The context is the body of a method.</summary>
/// <example>void Main () { *expr* }</example>
public readonly static ExpressionContext MethodBody = new ExpressionContext.DefaultExpressionContext("MethodBody");
#endregion #endregion
#region DefaultExpressionContext #region DefaultExpressionContext
sealed class DefaultExpressionContext : ExpressionContext internal sealed class DefaultExpressionContext : ExpressionContext
{ {
string name; string name;
@ -500,7 +452,7 @@ namespace ICSharpCode.SharpDevelop.Dom
#endregion #endregion
#region NonStaticTypeExpressionContext #region NonStaticTypeExpressionContext
sealed class NonStaticTypeExpressionContext : ExpressionContext internal sealed class NonStaticTypeExpressionContext : ExpressionContext
{ {
string name; string name;
bool allowVoid; bool allowVoid;

29
src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/NRefactoryResolver/NRefactoryResolver.cs

@ -7,14 +7,15 @@
using System; using System;
using System.Collections; using System.Collections;
using System.Collections.ObjectModel;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.Collections.ObjectModel;
using System.Diagnostics; using System.Diagnostics;
using System.IO;
using System.Linq; using System.Linq;
using ICSharpCode.NRefactory.Ast; using ICSharpCode.NRefactory.Ast;
using ICSharpCode.NRefactory.Visitors; using ICSharpCode.NRefactory.Visitors;
using ICSharpCode.SharpDevelop.Dom.CSharp;
using NR = ICSharpCode.NRefactory; using NR = ICSharpCode.NRefactory;
namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
@ -236,7 +237,7 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
ResolveResult rr; ResolveResult rr;
if (expressionResult.Context == ExpressionContext.Attribute) { if (expressionResult.Context == ExpressionContext.Attribute) {
return ResolveAttribute(expr, new NR.Location(caretColumn, caretLine)); return ResolveAttribute(expr, new NR.Location(caretColumn, caretLine));
} else if (expressionResult.Context == ExpressionContext.ObjectInitializer && expr is IdentifierExpression) { } else if (expressionResult.Context == CSharpExpressionContext.ObjectInitializer && expr is IdentifierExpression) {
bool isCollectionInitializer; bool isCollectionInitializer;
rr = ResolveObjectInitializer((expr as IdentifierExpression).Identifier, fileContent, out isCollectionInitializer); rr = ResolveObjectInitializer((expr as IdentifierExpression).Identifier, fileContent, out isCollectionInitializer);
if (!isCollectionInitializer || rr != null) { if (!isCollectionInitializer || rr != null) {
@ -1145,7 +1146,7 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
AddCSharpKeywords(result, NR.Parser.CSharp.Tokens.TypeLevel); AddCSharpKeywords(result, NR.Parser.CSharp.Tokens.TypeLevel);
AddCSharpPrimitiveTypes(result); AddCSharpPrimitiveTypes(result);
CtrlSpaceInternal(result, fileContent, showEntriesFromAllNamespaces); CtrlSpaceInternal(result, fileContent, showEntriesFromAllNamespaces);
} else if (context == ExpressionContext.InterfaceDeclaration) { } else if (context == CSharpExpressionContext.InterfaceDeclaration) {
AddCSharpKeywords(result, NR.Parser.CSharp.Tokens.InterfaceLevel); AddCSharpKeywords(result, NR.Parser.CSharp.Tokens.InterfaceLevel);
AddCSharpPrimitiveTypes(result); AddCSharpPrimitiveTypes(result);
CtrlSpaceInternal(result, fileContent, showEntriesFromAllNamespaces); CtrlSpaceInternal(result, fileContent, showEntriesFromAllNamespaces);
@ -1156,15 +1157,15 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
CtrlSpaceInternal(result, fileContent, showEntriesFromAllNamespaces); CtrlSpaceInternal(result, fileContent, showEntriesFromAllNamespaces);
} else if (context == ExpressionContext.Global) { } else if (context == ExpressionContext.Global) {
AddCSharpKeywords(result, NR.Parser.CSharp.Tokens.GlobalLevel); AddCSharpKeywords(result, NR.Parser.CSharp.Tokens.GlobalLevel);
} else if (context == ExpressionContext.InterfacePropertyDeclaration) { } else if (context == CSharpExpressionContext.InterfacePropertyDeclaration) {
result.Add(new KeywordEntry("get")); result.Add(new KeywordEntry("get"));
result.Add(new KeywordEntry("set")); result.Add(new KeywordEntry("set"));
} else if (context == ExpressionContext.BaseConstructorCall) { } else if (context == CSharpExpressionContext.BaseConstructorCall) {
result.Add(new KeywordEntry("this")); result.Add(new KeywordEntry("this"));
result.Add(new KeywordEntry("base")); result.Add(new KeywordEntry("base"));
} else if (context == ExpressionContext.ConstraintsStart) { } else if (context == CSharpExpressionContext.ConstraintsStart) {
result.Add(new KeywordEntry("where")); result.Add(new KeywordEntry("where"));
} else if (context == ExpressionContext.Constraints) { } else if (context == CSharpExpressionContext.Constraints) {
result.Add(new KeywordEntry("where")); result.Add(new KeywordEntry("where"));
result.Add(new KeywordEntry("new")); result.Add(new KeywordEntry("new"));
result.Add(new KeywordEntry("struct")); result.Add(new KeywordEntry("struct"));
@ -1175,24 +1176,24 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
result.Add(new KeywordEntry("where")); // the inheritance list can be followed by constraints result.Add(new KeywordEntry("where")); // the inheritance list can be followed by constraints
AddCSharpPrimitiveTypes(result); AddCSharpPrimitiveTypes(result);
CtrlSpaceInternal(result, fileContent, showEntriesFromAllNamespaces); CtrlSpaceInternal(result, fileContent, showEntriesFromAllNamespaces);
} else if (context == ExpressionContext.PropertyDeclaration) { } else if (context == CSharpExpressionContext.PropertyDeclaration) {
AddCSharpKeywords(result, NR.Parser.CSharp.Tokens.InPropertyDeclaration); AddCSharpKeywords(result, NR.Parser.CSharp.Tokens.InPropertyDeclaration);
} else if (context == ExpressionContext.EventDeclaration) { } else if (context == CSharpExpressionContext.EventDeclaration) {
AddCSharpKeywords(result, NR.Parser.CSharp.Tokens.InEventDeclaration); AddCSharpKeywords(result, NR.Parser.CSharp.Tokens.InEventDeclaration);
} else if (context == ExpressionContext.FullyQualifiedType) { } else if (context == CSharpExpressionContext.FullyQualifiedType) {
cu.ProjectContent.AddNamespaceContents(result, "", languageProperties, true); cu.ProjectContent.AddNamespaceContents(result, "", languageProperties, true);
} else if (context == ExpressionContext.ParameterType || context == ExpressionContext.FirstParameterType) { } else if (context == CSharpExpressionContext.ParameterType || context == CSharpExpressionContext.FirstParameterType) {
result.Add(new KeywordEntry("ref")); result.Add(new KeywordEntry("ref"));
result.Add(new KeywordEntry("out")); result.Add(new KeywordEntry("out"));
result.Add(new KeywordEntry("params")); result.Add(new KeywordEntry("params"));
if (context == ExpressionContext.FirstParameterType && languageProperties.SupportsExtensionMethods) { if (context == CSharpExpressionContext.FirstParameterType && languageProperties.SupportsExtensionMethods) {
if (callingMember != null && callingMember.IsStatic) { if (callingMember != null && callingMember.IsStatic) {
result.Add(new KeywordEntry("this")); result.Add(new KeywordEntry("this"));
} }
} }
AddCSharpPrimitiveTypes(result); AddCSharpPrimitiveTypes(result);
CtrlSpaceInternal(result, fileContent, showEntriesFromAllNamespaces); CtrlSpaceInternal(result, fileContent, showEntriesFromAllNamespaces);
} else if (context == ExpressionContext.ObjectInitializer) { } else if (context == CSharpExpressionContext.ObjectInitializer) {
bool isCollectionInitializer; bool isCollectionInitializer;
result.AddRange(ObjectInitializerCtrlSpace(fileContent, out isCollectionInitializer)); result.AddRange(ObjectInitializerCtrlSpace(fileContent, out isCollectionInitializer));
if (isCollectionInitializer) { if (isCollectionInitializer) {

6
src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/VBNet/VBNetExpressionFinder.cs

@ -77,9 +77,6 @@ namespace ICSharpCode.SharpDevelop.Dom.VBNet
p.Advance(); p.Advance();
} }
if (p.IsIdentifierExpected)
context = ExpressionContext.IdentifierExpected;
BitArray expectedSet; BitArray expectedSet;
try { try {
@ -93,7 +90,6 @@ namespace ICSharpCode.SharpDevelop.Dom.VBNet
int lastExpressionStartOffset = LocationToOffset(block.lastExpressionStart); int lastExpressionStartOffset = LocationToOffset(block.lastExpressionStart);
if (lastExpressionStartOffset < 0) if (lastExpressionStartOffset < 0)
return new ExpressionResult(null, DomRegion.Empty, context, expectedSet); return new ExpressionResult(null, DomRegion.Empty, context, expectedSet);
@ -133,8 +129,6 @@ namespace ICSharpCode.SharpDevelop.Dom.VBNet
switch (block.context) { switch (block.context) {
case Context.Global: case Context.Global:
return ExpressionContext.Global; return ExpressionContext.Global;
case Context.IdentifierExpected:
return ExpressionContext.IdentifierExpected;
case Context.TypeDeclaration: case Context.TypeDeclaration:
return ExpressionContext.TypeDeclaration; return ExpressionContext.TypeDeclaration;
case Context.Type: case Context.Type:

Loading…
Cancel
Save