Browse Source

Fixed SD2-1405: VB ! operator does not parse

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@3125 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 18 years ago
parent
commit
134fd3a2f9
  1. 3
      src/Libraries/NRefactory/Project/Src/Ast/Enums.cs
  2. 2
      src/Libraries/NRefactory/Project/Src/Lexer/VBNet/KeywordList.txt
  3. 54
      src/Libraries/NRefactory/Project/Src/Lexer/VBNet/Lexer.cs
  4. 372
      src/Libraries/NRefactory/Project/Src/Lexer/VBNet/Tokens.cs
  5. 3847
      src/Libraries/NRefactory/Project/Src/Parser/VBNet/Parser.cs
  6. 5
      src/Libraries/NRefactory/Project/Src/Parser/VBNet/VBNET.ATG
  7. 6
      src/Libraries/NRefactory/Project/Src/PrettyPrinter/CSharp/CSharpOutputVisitor.cs
  8. 13
      src/Libraries/NRefactory/Project/Src/PrettyPrinter/VBNet/VBNetOutputVisitor.cs
  9. 77
      src/Libraries/NRefactory/Test/Lexer/VBNet/CustomLexerTests.cs
  10. 14
      src/Libraries/NRefactory/Test/Lexer/VBNet/LexerTests.cs
  11. 6
      src/Libraries/NRefactory/Test/Output/VBNet/VBNetOutputTest.cs
  12. 11
      src/Libraries/NRefactory/Test/Parser/TypeLevel/MethodDeclarationTests.cs

3
src/Libraries/NRefactory/Project/Src/Ast/Enums.cs

@ -200,6 +200,9 @@ namespace ICSharpCode.NRefactory.Ast
Like, Like,
/// <summary>C#: ??</summary> /// <summary>C#: ??</summary>
NullCoalescing, NullCoalescing,
/// <summary>VB-only: !</summary>
DictionaryAccess
} }
public enum CastType public enum CastType

2
src/Libraries/NRefactory/Project/Src/Lexer/VBNet/KeywordList.txt

@ -34,6 +34,8 @@ ConcatString = "&"
Power = "^" Power = "^"
# Question mark is not needed by VB8, but we use it inside the IDE # Question mark is not needed by VB8, but we use it inside the IDE
QuestionMark = "?" QuestionMark = "?"
# Exclamation mark = Dictionary access operator (not always a token, sometimes it's a type character)
ExclamationMark = "!"
OpenCurlyBrace = "{" OpenCurlyBrace = "{"
CloseCurlyBrace = "}" CloseCurlyBrace = "}"

54
src/Libraries/NRefactory/Project/Src/Lexer/VBNet/Lexer.cs

@ -48,8 +48,14 @@ namespace ICSharpCode.NRefactory.Parser.VB
return curToken; return curToken;
} }
bool misreadExclamationMarkAsTypeCharacter;
protected override Token Next() protected override Token Next()
{ {
if (misreadExclamationMarkAsTypeCharacter) {
misreadExclamationMarkAsTypeCharacter = false;
return new Token(Tokens.ExclamationMark, Col - 1, Line);
}
unchecked { unchecked {
int nextChar; int nextChar;
while ((nextChar = ReaderRead()) != -1) { while ((nextChar = ReaderRead()) != -1) {
@ -149,21 +155,24 @@ namespace ICSharpCode.NRefactory.Parser.VB
if (Char.IsLetter(ch)) { if (Char.IsLetter(ch)) {
int x = Col - 1; int x = Col - 1;
int y = Line; int y = Line;
string s = ReadIdent(ch); char typeCharacter;
int keyWordToken = Keywords.GetToken(s); string s = ReadIdent(ch, out typeCharacter);
if (keyWordToken >= 0) { if (typeCharacter == '\0') {
lineEnd = false; int keyWordToken = Keywords.GetToken(s);
return new Token(keyWordToken, x, y, s); if (keyWordToken >= 0) {
} // handle 'REM' comments
if (keyWordToken == Tokens.Rem) {
// handle 'REM' comments ReadComment();
if (s.Equals("REM", StringComparison.InvariantCultureIgnoreCase)) { if (!lineEnd) {
ReadComment(); lineEnd = true;
if (!lineEnd) { return new Token(Tokens.EOL, Col, Line, "\n");
lineEnd = true; }
return new Token(Tokens.EOL, Col, Line, "\n"); continue;
}
lineEnd = false;
return new Token(keyWordToken, x, y, s);
} }
continue;
} }
lineEnd = false; lineEnd = false;
@ -226,6 +235,14 @@ namespace ICSharpCode.NRefactory.Parser.VB
string ReadIdent(char ch) string ReadIdent(char ch)
{ {
char typeCharacter;
return ReadIdent(ch, out typeCharacter);
}
string ReadIdent(char ch, out char typeCharacter)
{
typeCharacter = '\0';
sb.Length = 0; sb.Length = 0;
sb.Append(ch); sb.Append(ch);
int peek; int peek;
@ -238,7 +255,14 @@ namespace ICSharpCode.NRefactory.Parser.VB
} }
if ("%&@!#$".IndexOf((char)peek) != -1) { if ("%&@!#$".IndexOf((char)peek) != -1) {
typeCharacter = (char)peek;
ReaderRead(); ReaderRead();
if (typeCharacter == '!') {
peek = ReaderPeek();
if (peek != -1 && (peek == '_' || peek == '[' || char.IsLetter((char)peek))) {
misreadExclamationMarkAsTypeCharacter = true;
}
}
} }
return sb.ToString(); return sb.ToString();
} }
@ -711,6 +735,8 @@ namespace ICSharpCode.NRefactory.Parser.VB
return new Token(Tokens.CloseCurlyBrace, x, y); return new Token(Tokens.CloseCurlyBrace, x, y);
case '?': case '?':
return new Token(Tokens.QuestionMark, x, y); return new Token(Tokens.QuestionMark, x, y);
case '!':
return new Token(Tokens.ExclamationMark, x, y);
} }
return null; return null;
} }

372
src/Libraries/NRefactory/Project/Src/Lexer/VBNet/Tokens.cs

@ -31,194 +31,195 @@ namespace ICSharpCode.NRefactory.Parser.VB
public const int ConcatString = 19; public const int ConcatString = 19;
public const int Power = 20; public const int Power = 20;
public const int QuestionMark = 21; public const int QuestionMark = 21;
public const int OpenCurlyBrace = 22; public const int ExclamationMark = 22;
public const int CloseCurlyBrace = 23; public const int OpenCurlyBrace = 23;
public const int OpenParenthesis = 24; public const int CloseCurlyBrace = 24;
public const int CloseParenthesis = 25; public const int OpenParenthesis = 25;
public const int GreaterThan = 26; public const int CloseParenthesis = 26;
public const int LessThan = 27; public const int GreaterThan = 27;
public const int NotEqual = 28; public const int LessThan = 28;
public const int GreaterEqual = 29; public const int NotEqual = 29;
public const int LessEqual = 30; public const int GreaterEqual = 30;
public const int ShiftLeft = 31; public const int LessEqual = 31;
public const int ShiftRight = 32; public const int ShiftLeft = 32;
public const int PlusAssign = 33; public const int ShiftRight = 33;
public const int PowerAssign = 34; public const int PlusAssign = 34;
public const int MinusAssign = 35; public const int PowerAssign = 35;
public const int TimesAssign = 36; public const int MinusAssign = 36;
public const int DivAssign = 37; public const int TimesAssign = 37;
public const int DivIntegerAssign = 38; public const int DivAssign = 38;
public const int ShiftLeftAssign = 39; public const int DivIntegerAssign = 39;
public const int ShiftRightAssign = 40; public const int ShiftLeftAssign = 40;
public const int ConcatStringAssign = 41; public const int ShiftRightAssign = 41;
public const int ConcatStringAssign = 42;
// ----- keywords ----- // ----- keywords -----
public const int AddHandler = 42; public const int AddHandler = 43;
public const int AddressOf = 43; public const int AddressOf = 44;
public const int Alias = 44; public const int Alias = 45;
public const int And = 45; public const int And = 46;
public const int AndAlso = 46; public const int AndAlso = 47;
public const int Ansi = 47; public const int Ansi = 48;
public const int As = 48; public const int As = 49;
public const int Assembly = 49; public const int Assembly = 50;
public const int Auto = 50; public const int Auto = 51;
public const int Binary = 51; public const int Binary = 52;
public const int Boolean = 52; public const int Boolean = 53;
public const int ByRef = 53; public const int ByRef = 54;
public const int Byte = 54; public const int Byte = 55;
public const int ByVal = 55; public const int ByVal = 56;
public const int Call = 56; public const int Call = 57;
public const int Case = 57; public const int Case = 58;
public const int Catch = 58; public const int Catch = 59;
public const int CBool = 59; public const int CBool = 60;
public const int CByte = 60; public const int CByte = 61;
public const int CChar = 61; public const int CChar = 62;
public const int CDate = 62; public const int CDate = 63;
public const int CDbl = 63; public const int CDbl = 64;
public const int CDec = 64; public const int CDec = 65;
public const int Char = 65; public const int Char = 66;
public const int CInt = 66; public const int CInt = 67;
public const int Class = 67; public const int Class = 68;
public const int CLng = 68; public const int CLng = 69;
public const int CObj = 69; public const int CObj = 70;
public const int Compare = 70; public const int Compare = 71;
public const int Const = 71; public const int Const = 72;
public const int CShort = 72; public const int CShort = 73;
public const int CSng = 73; public const int CSng = 74;
public const int CStr = 74; public const int CStr = 75;
public const int CType = 75; public const int CType = 76;
public const int Date = 76; public const int Date = 77;
public const int Decimal = 77; public const int Decimal = 78;
public const int Declare = 78; public const int Declare = 79;
public const int Default = 79; public const int Default = 80;
public const int Delegate = 80; public const int Delegate = 81;
public const int Dim = 81; public const int Dim = 82;
public const int DirectCast = 82; public const int DirectCast = 83;
public const int Do = 83; public const int Do = 84;
public const int Double = 84; public const int Double = 85;
public const int Each = 85; public const int Each = 86;
public const int Else = 86; public const int Else = 87;
public const int ElseIf = 87; public const int ElseIf = 88;
public const int End = 88; public const int End = 89;
public const int EndIf = 89; public const int EndIf = 90;
public const int Enum = 90; public const int Enum = 91;
public const int Erase = 91; public const int Erase = 92;
public const int Error = 92; public const int Error = 93;
public const int Event = 93; public const int Event = 94;
public const int Exit = 94; public const int Exit = 95;
public const int Explicit = 95; public const int Explicit = 96;
public const int False = 96; public const int False = 97;
public const int Finally = 97; public const int Finally = 98;
public const int For = 98; public const int For = 99;
public const int Friend = 99; public const int Friend = 100;
public const int Function = 100; public const int Function = 101;
public const int Get = 101; public const int Get = 102;
new public const int GetType = 102; new public const int GetType = 103;
public const int GoSub = 103; public const int GoSub = 104;
public const int GoTo = 104; public const int GoTo = 105;
public const int Handles = 105; public const int Handles = 106;
public const int If = 106; public const int If = 107;
public const int Implements = 107; public const int Implements = 108;
public const int Imports = 108; public const int Imports = 109;
public const int In = 109; public const int In = 110;
public const int Inherits = 110; public const int Inherits = 111;
public const int Integer = 111; public const int Integer = 112;
public const int Interface = 112; public const int Interface = 113;
public const int Is = 113; public const int Is = 114;
public const int Let = 114; public const int Let = 115;
public const int Lib = 115; public const int Lib = 116;
public const int Like = 116; public const int Like = 117;
public const int Long = 117; public const int Long = 118;
public const int Loop = 118; public const int Loop = 119;
public const int Me = 119; public const int Me = 120;
public const int Mod = 120; public const int Mod = 121;
public const int Module = 121; public const int Module = 122;
public const int MustInherit = 122; public const int MustInherit = 123;
public const int MustOverride = 123; public const int MustOverride = 124;
public const int MyBase = 124; public const int MyBase = 125;
public const int MyClass = 125; public const int MyClass = 126;
public const int Namespace = 126; public const int Namespace = 127;
public const int New = 127; public const int New = 128;
public const int Next = 128; public const int Next = 129;
public const int Not = 129; public const int Not = 130;
public const int Nothing = 130; public const int Nothing = 131;
public const int NotInheritable = 131; public const int NotInheritable = 132;
public const int NotOverridable = 132; public const int NotOverridable = 133;
public const int Object = 133; public const int Object = 134;
public const int Off = 134; public const int Off = 135;
public const int On = 135; public const int On = 136;
public const int Option = 136; public const int Option = 137;
public const int Optional = 137; public const int Optional = 138;
public const int Or = 138; public const int Or = 139;
public const int OrElse = 139; public const int OrElse = 140;
public const int Overloads = 140; public const int Overloads = 141;
public const int Overridable = 141; public const int Overridable = 142;
public const int Overrides = 142; public const int Overrides = 143;
public const int ParamArray = 143; public const int ParamArray = 144;
public const int Preserve = 144; public const int Preserve = 145;
public const int Private = 145; public const int Private = 146;
public const int Property = 146; public const int Property = 147;
public const int Protected = 147; public const int Protected = 148;
public const int Public = 148; public const int Public = 149;
public const int RaiseEvent = 149; public const int RaiseEvent = 150;
public const int ReadOnly = 150; public const int ReadOnly = 151;
public const int ReDim = 151; public const int ReDim = 152;
public const int RemoveHandler = 152; public const int RemoveHandler = 153;
public const int Resume = 153; public const int Resume = 154;
public const int Return = 154; public const int Return = 155;
public const int Select = 155; public const int Select = 156;
public const int Set = 156; public const int Set = 157;
public const int Shadows = 157; public const int Shadows = 158;
public const int Shared = 158; public const int Shared = 159;
public const int Short = 159; public const int Short = 160;
public const int Single = 160; public const int Single = 161;
public const int Static = 161; public const int Static = 162;
public const int Step = 162; public const int Step = 163;
public const int Stop = 163; public const int Stop = 164;
public const int Strict = 164; public const int Strict = 165;
public const int String = 165; public const int String = 166;
public const int Structure = 166; public const int Structure = 167;
public const int Sub = 167; public const int Sub = 168;
public const int SyncLock = 168; public const int SyncLock = 169;
public const int Text = 169; public const int Text = 170;
public const int Then = 170; public const int Then = 171;
public const int Throw = 171; public const int Throw = 172;
public const int To = 172; public const int To = 173;
public const int True = 173; public const int True = 174;
public const int Try = 174; public const int Try = 175;
public const int TypeOf = 175; public const int TypeOf = 176;
public const int Unicode = 176; public const int Unicode = 177;
public const int Until = 177; public const int Until = 178;
public const int Variant = 178; public const int Variant = 179;
public const int Wend = 179; public const int Wend = 180;
public const int When = 180; public const int When = 181;
public const int While = 181; public const int While = 182;
public const int With = 182; public const int With = 183;
public const int WithEvents = 183; public const int WithEvents = 184;
public const int WriteOnly = 184; public const int WriteOnly = 185;
public const int Xor = 185; public const int Xor = 186;
public const int Rem = 186; public const int Rem = 187;
public const int Continue = 187; public const int Continue = 188;
public const int Operator = 188; public const int Operator = 189;
public const int Using = 189; public const int Using = 190;
public const int IsNot = 190; public const int IsNot = 191;
public const int SByte = 191; public const int SByte = 192;
public const int UInteger = 192; public const int UInteger = 193;
public const int ULong = 193; public const int ULong = 194;
public const int UShort = 194; public const int UShort = 195;
public const int CSByte = 195; public const int CSByte = 196;
public const int CUShort = 196; public const int CUShort = 197;
public const int CUInt = 197; public const int CUInt = 198;
public const int CULng = 198; public const int CULng = 199;
public const int Global = 199; public const int Global = 200;
public const int TryCast = 200; public const int TryCast = 201;
public const int Of = 201; public const int Of = 202;
public const int Narrowing = 202; public const int Narrowing = 203;
public const int Widening = 203; public const int Widening = 204;
public const int Partial = 204; public const int Partial = 205;
public const int Custom = 205; public const int Custom = 206;
public const int MaxToken = 206; public const int MaxToken = 207;
static BitArray NewSet(params int[] values) static BitArray NewSet(params int[] values)
{ {
BitArray bitArray = new BitArray(MaxToken); BitArray bitArray = new BitArray(MaxToken);
@ -256,6 +257,7 @@ namespace ICSharpCode.NRefactory.Parser.VB
"&", "&",
"^", "^",
"?", "?",
"!",
"{", "{",
"}", "}",
"(", "(",

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

File diff suppressed because it is too large Load Diff

5
src/Libraries/NRefactory/Project/Src/Parser/VBNet/VBNET.ATG

@ -35,6 +35,7 @@ TOKENS
"&" "&"
"^" "^"
"?" "?"
"!"
"{" "{"
"}" "}"
"(" "("
@ -1582,10 +1583,12 @@ AssignmentOperator<out AssignmentOperatorType op>
/* 11.4 */ /* 11.4 */
SimpleExpr<out Expression pexpr> SimpleExpr<out Expression pexpr>
(. string name; .)
= =
SimpleNonInvocationExpression<out pexpr> SimpleNonInvocationExpression<out pexpr>
{ (. string name; .) {
"." IdentifierOrKeyword<out name> (. pexpr = new MemberReferenceExpression(pexpr, name); .) "." IdentifierOrKeyword<out name> (. pexpr = new MemberReferenceExpression(pexpr, name); .)
| "!" IdentifierOrKeyword<out name> (. pexpr = new BinaryOperatorExpression(pexpr, BinaryOperatorType.DictionaryAccess, new PrimitiveExpression(name, name)); .)
| InvocationExpression<ref pexpr> | InvocationExpression<ref pexpr>
} }
. .

6
src/Libraries/NRefactory/Project/Src/PrettyPrinter/CSharp/CSharpOutputVisitor.cs

@ -1835,6 +1835,12 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
TrackVisit(binaryOperatorExpression.Right, data); TrackVisit(binaryOperatorExpression.Right, data);
outputFormatter.PrintToken(Tokens.CloseParenthesis); outputFormatter.PrintToken(Tokens.CloseParenthesis);
return null; return null;
case BinaryOperatorType.DictionaryAccess:
TrackVisit(binaryOperatorExpression.Left, data);
outputFormatter.PrintToken(Tokens.OpenSquareBracket);
TrackVisit(binaryOperatorExpression.Right, data);
outputFormatter.PrintToken(Tokens.CloseSquareBracket);
return null;
} }
TrackVisit(binaryOperatorExpression.Left, data); TrackVisit(binaryOperatorExpression.Left, data);
switch (binaryOperatorExpression.Op) { switch (binaryOperatorExpression.Op) {

13
src/Libraries/NRefactory/Project/Src/PrettyPrinter/VBNet/VBNetOutputVisitor.cs

@ -2198,6 +2198,19 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
TrackedVisit(binaryOperatorExpression.Right, data); TrackedVisit(binaryOperatorExpression.Right, data);
outputFormatter.PrintToken(Tokens.CloseParenthesis); outputFormatter.PrintToken(Tokens.CloseParenthesis);
return null; return null;
case BinaryOperatorType.DictionaryAccess:
{
PrimitiveExpression pright = binaryOperatorExpression.Right as PrimitiveExpression;
TrackedVisit(binaryOperatorExpression.Left, data);
if (pright != null && pright.Value is string) {
outputFormatter.PrintText("!" + (string)pright.Value);
} else {
outputFormatter.PrintToken(Tokens.OpenParenthesis);
TrackedVisit(binaryOperatorExpression.Right, data);
outputFormatter.PrintToken(Tokens.CloseParenthesis);
}
return null;
}
case BinaryOperatorType.LessThan: case BinaryOperatorType.LessThan:
op = Tokens.LessThan; op = Tokens.LessThan;
break; break;

77
src/Libraries/NRefactory/Test/Lexer/VBNet/CustomLexerTests.cs

@ -42,5 +42,82 @@ namespace ICSharpCode.NRefactory.Tests.Lexer.VB
Assert.That(lexer.NextToken().kind, Is.EqualTo(Tokens.EOL)); Assert.That(lexer.NextToken().kind, Is.EqualTo(Tokens.EOL));
Assert.That(lexer.NextToken().kind, Is.EqualTo(Tokens.EOF)); Assert.That(lexer.NextToken().kind, Is.EqualTo(Tokens.EOF));
} }
[Test]
public void EscapedIdentifier()
{
ILexer lexer = GenerateLexer(new StringReader("[Stop]"));
Assert.That(lexer.NextToken().kind, Is.EqualTo(Tokens.Identifier));
Assert.That(lexer.NextToken().kind, Is.EqualTo(Tokens.EOL));
Assert.That(lexer.NextToken().kind, Is.EqualTo(Tokens.EOF));
}
[Test]
public void IdentifierWithTypeCharacter()
{
ILexer lexer = GenerateLexer(new StringReader("Stop$"));
Assert.That(lexer.NextToken().kind, Is.EqualTo(Tokens.Identifier));
Assert.That(lexer.NextToken().kind, Is.EqualTo(Tokens.EOL));
Assert.That(lexer.NextToken().kind, Is.EqualTo(Tokens.EOF));
}
[Test]
public void ExclamationMarkIsTypeCharacter()
{
ILexer lexer = GenerateLexer(new StringReader("a!=b"));
Assert.That(lexer.NextToken().kind, Is.EqualTo(Tokens.Identifier));
Assert.That(lexer.NextToken().kind, Is.EqualTo(Tokens.Assign));
Assert.That(lexer.NextToken().kind, Is.EqualTo(Tokens.Identifier));
Assert.That(lexer.NextToken().kind, Is.EqualTo(Tokens.EOL));
Assert.That(lexer.NextToken().kind, Is.EqualTo(Tokens.EOF));
}
[Test]
public void ExclamationMarkIsTypeCharacter2()
{
ILexer lexer = GenerateLexer(new StringReader("a! b"));
Assert.That(lexer.NextToken().kind, Is.EqualTo(Tokens.Identifier));
Assert.That(lexer.NextToken().kind, Is.EqualTo(Tokens.Identifier));
Assert.That(lexer.NextToken().kind, Is.EqualTo(Tokens.EOL));
Assert.That(lexer.NextToken().kind, Is.EqualTo(Tokens.EOF));
}
[Test]
public void ExclamationMarkIsIdentifier()
{
ILexer lexer = GenerateLexer(new StringReader("a!b"));
Assert.That(lexer.NextToken().kind, Is.EqualTo(Tokens.Identifier));
Assert.That(lexer.NextToken().kind, Is.EqualTo(Tokens.ExclamationMark));
Assert.That(lexer.NextToken().kind, Is.EqualTo(Tokens.Identifier));
Assert.That(lexer.NextToken().kind, Is.EqualTo(Tokens.EOL));
Assert.That(lexer.NextToken().kind, Is.EqualTo(Tokens.EOF));
}
[Test]
public void ExclamationMarkIsIdentifier2()
{
ILexer lexer = GenerateLexer(new StringReader("a![b]"));
Assert.That(lexer.NextToken().kind, Is.EqualTo(Tokens.Identifier));
Assert.That(lexer.NextToken().kind, Is.EqualTo(Tokens.ExclamationMark));
Assert.That(lexer.NextToken().kind, Is.EqualTo(Tokens.Identifier));
Assert.That(lexer.NextToken().kind, Is.EqualTo(Tokens.EOL));
Assert.That(lexer.NextToken().kind, Is.EqualTo(Tokens.EOF));
}
[Test]
public void RemCommentTest()
{
ILexer lexer = GenerateLexer(new StringReader("a rem b"));
Assert.That(lexer.NextToken().kind, Is.EqualTo(Tokens.Identifier));
Assert.That(lexer.NextToken().kind, Is.EqualTo(Tokens.EOL));
Assert.That(lexer.NextToken().kind, Is.EqualTo(Tokens.EOF));
}
[Test]
public void RemCommentTest2()
{
ILexer lexer = GenerateLexer(new StringReader("REM c"));
Assert.That(lexer.NextToken().kind, Is.EqualTo(Tokens.EOF));
}
} }
} }

14
src/Libraries/NRefactory/Test/Lexer/VBNet/LexerTests.cs

@ -106,6 +106,13 @@ namespace ICSharpCode.NRefactory.Tests.Lexer.VB
Assert.AreEqual(Tokens.QuestionMark, lexer.NextToken().kind); Assert.AreEqual(Tokens.QuestionMark, lexer.NextToken().kind);
} }
[Test]
public void TestExclamationMark()
{
ILexer lexer = GenerateLexer(new StringReader("!"));
Assert.AreEqual(Tokens.ExclamationMark, lexer.NextToken().kind);
}
[Test] [Test]
public void TestOpenCurlyBrace() public void TestOpenCurlyBrace()
{ {
@ -239,6 +246,13 @@ namespace ICSharpCode.NRefactory.Tests.Lexer.VB
Assert.AreEqual(Tokens.ShiftRightAssign, lexer.NextToken().kind); Assert.AreEqual(Tokens.ShiftRightAssign, lexer.NextToken().kind);
} }
[Test]
public void TestConcatStringAssign()
{
ILexer lexer = GenerateLexer(new StringReader("&="));
Assert.AreEqual(Tokens.ConcatStringAssign, lexer.NextToken().kind);
}
[Test()] [Test()]
public void TestAddHandler() public void TestAddHandler()
{ {

6
src/Libraries/NRefactory/Test/Output/VBNet/VBNetOutputTest.cs

@ -203,6 +203,12 @@ End Using");
TestExpression("12"); TestExpression("12");
} }
[Test]
public void DictionaryAccess()
{
TestExpression("c!key");
}
[Test] [Test]
public void GenericMethodInvocation() public void GenericMethodInvocation()
{ {

11
src/Libraries/NRefactory/Test/Parser/TypeLevel/MethodDeclarationTests.cs

@ -402,6 +402,17 @@ End Interface
Assert.AreEqual(new string[] { "MyBase.Event", "Button1.Click" }, md.HandlesClause.ToArray()); Assert.AreEqual(new string[] { "MyBase.Event", "Button1.Click" }, md.HandlesClause.ToArray());
} }
[Test]
public void VBNetMethodWithTypeCharactersTest()
{
const string program = @"Public Function Func!(ByVal Param&)
Func! = CSingle(Param&)
End Function";
MethodDeclaration md = ParseUtilVBNet.ParseTypeMember<MethodDeclaration>(program);
Assert.AreEqual(Modifiers.Public, md.Modifier);
}
#endregion #endregion
} }
} }

Loading…
Cancel
Save