Browse Source

fixed similar bug as in rev. 6405, but with Using statements, added unit tests

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@6408 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
pull/1/head
Siegfried Pammer 15 years ago
parent
commit
a20f8e7bac
  1. 8
      src/Libraries/NRefactory/Project/Src/Lexer/VBNet/ExpressionFinder.atg
  2. 3847
      src/Libraries/NRefactory/Project/Src/Lexer/VBNet/Parser.cs
  3. 36
      src/Main/Base/Test/VBExpressionFinderTests.cs

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

@ -1228,10 +1228,10 @@ UsingVariable = @@ -1228,10 +1228,10 @@ UsingVariable =
"Explicit", "Equals", "Distinct", "Descending", "Compare", "By",
"Binary", "Auto", "Assembly", "Ascending", "Ansi", "Aggregate", ident)
(
(. PushContext(Context.Identifier, la, t); .) (.OnEachPossiblePath: SetIdentifierExpected(la); .) Identifier (. PopContext(); .)
(. PushContext(Context.Identifier, la, t); .) (.OnEachPossiblePath: SetIdentifierExpected(la); .) Identifier
// HACK: needs to be optional because Expression can start with Identifier too
[
"As" [ EXPECTEDCONFLICT("Where", "UShort", "Until", "Unicode", "ULong", "UInteger", "Text", "Take",
[ (. PopContext(); isAlreadyInExpr = true; .)
( "As" [ EXPECTEDCONFLICT("Where", "UShort", "Until", "Unicode", "ULong", "UInteger", "Text", "Take",
"String", "Skip", "Single", "Short", "SByte", "Preserve", "Out", "Order",
"Off", "Object", "Long", "Key", "Join", "Into", "Integer", "Infer", "Group",
"From", "Explicit", "Equals", "Double", "Distinct", "Descending", "Decimal",
@ -1247,10 +1247,12 @@ UsingVariable = @@ -1247,10 +1247,12 @@ UsingVariable =
.)
ANY /* never reached due to goto above: */
/* this ANY is just so that Coco knows this branch isn't empty */
)
]
)
]
Expression
(. if (!isAlreadyInExpr) PopContext(); isAlreadyInExpr = false; .)
.
UsingStatement =

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

File diff suppressed because it is too large Load Diff

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

@ -590,6 +590,42 @@ End Module", "data", ExpressionContext.Default); @@ -590,6 +590,42 @@ End Module", "data", ExpressionContext.Default);
End Module", "DataGridViewCellStyle", ExpressionContext.Type);
}
[Test]
public void Using1()
{
FindFull(@"Module Test
Sub Main()
Using |x As FileReader = New FileReader()
End Using
End Sub
End Module", "x", ExpressionContext.Default);
FindFull(@"Module Test
Sub Main()
Using x As FileR|eader = New FileReader()
End Using
End Sub
End Module", "FileReader", ExpressionContext.Type);
FindFull(@"Module Test
Sub Main()
Using x As New FileR|eader()
End Using
End Sub
End Module", "FileReader()", ExpressionContext.ObjectCreation);
FindFull(@"Module Test
Sub Main()
Using FileRea|der()
End Using
End Sub
End Module", "FileReader()", ExpressionContext.Default);
}
#region Old Tests
void OldTest(string expr, int offset)
{

Loading…
Cancel
Save