Browse Source

added "Infer" keyword;

ordered keywords;

memberreferenceexpression vs. typereferenceexpression

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@3380 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Markus Palme 18 years ago
parent
commit
ead3e0d612
  1. 65
      src/Libraries/NRefactory/Project/Src/Lexer/VBNet/KeywordList.txt
  2. 43
      src/Libraries/NRefactory/Project/Src/Lexer/VBNet/Keywords.cs
  3. 342
      src/Libraries/NRefactory/Project/Src/Lexer/VBNet/Tokens.cs
  4. 2736
      src/Libraries/NRefactory/Project/Src/Parser/VBNet/Parser.cs
  5. 106
      src/Libraries/NRefactory/Project/Src/Parser/VBNet/VBNET.ATG
  6. 44
      src/Libraries/NRefactory/Project/Src/Parser/VBNet/VBNetParser.cs
  7. 303
      src/Libraries/NRefactory/Test/Lexer/VBNet/LexerTests.cs
  8. 10
      src/Libraries/NRefactory/Test/Parser/Expressions/AddressOfExpressionTests.cs
  9. 45
      src/Libraries/NRefactory/Test/Parser/Expressions/MemberReferenceExpressionTests.cs

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

@ -21,21 +21,20 @@ LiteralDecimal @@ -21,21 +21,20 @@ LiteralDecimal
LiteralDate
# SPECIAL_CHARACTERS
Dot = "."
Assign = "="
Comma = ","
Colon =":"
Plus = "+"
Minus = "-"
Times = "*"
Comma = ","
ConcatString = "&"
Div ="/"
DivInteger = "\\"
ConcatString = "&"
Power = "^"
# Question mark is not needed by VB8, but we use it inside the IDE
QuestionMark = "?"
Dot = "."
# Exclamation mark = Dictionary access operator (not always a token, sometimes it's a type character)
ExclamationMark = "!"
Minus = "-"
Plus = "+"
Power = "^"
QuestionMark = "?"
Times = "*"
OpenCurlyBrace = "{"
CloseCurlyBrace = "}"
@ -95,10 +94,16 @@ ConcatStringAssign = "&=" @@ -95,10 +94,16 @@ ConcatStringAssign = "&="
"CObj"
"Compare"
"Const"
"Continue"
"CSByte"
"CShort"
"CSng"
"CStr"
"CType"
"CUInt"
"CULng"
"CUShort"
"Custom"
"Date"
"Decimal"
"Declare"
@ -126,6 +131,7 @@ ConcatStringAssign = "&=" @@ -126,6 +131,7 @@ ConcatStringAssign = "&="
"Function"
"Get"
"GetType"
"Global"
"GoSub"
"GoTo"
"Handles"
@ -133,10 +139,13 @@ ConcatStringAssign = "&=" @@ -133,10 +139,13 @@ ConcatStringAssign = "&="
"Implements"
"Imports"
"In"
"Infer"
"Inherits"
"Integer"
"Interface"
"Is"
"IsNot"
# Note: IsTrue and IsFalse are 'NOT' keywords they're only valid in Operator declarations (like get/set/value are no C# 'keywords')
"Let"
"Lib"
"Like"
@ -150,6 +159,7 @@ ConcatStringAssign = "&=" @@ -150,6 +159,7 @@ ConcatStringAssign = "&="
"MyBase"
"MyClass"
"Namespace"
"Narrowing"
"New"
"Next"
"Not"
@ -157,8 +167,10 @@ ConcatStringAssign = "&=" @@ -157,8 +167,10 @@ ConcatStringAssign = "&="
"NotInheritable"
"NotOverridable"
"Object"
"Of"
"Off"
"On"
"Operator"
"Option"
"Optional"
"Or"
@ -167,6 +179,7 @@ ConcatStringAssign = "&=" @@ -167,6 +179,7 @@ ConcatStringAssign = "&="
"Overridable"
"Overrides"
"ParamArray"
"Partial"
"Preserve"
"Private"
"Property"
@ -175,9 +188,12 @@ ConcatStringAssign = "&=" @@ -175,9 +188,12 @@ ConcatStringAssign = "&="
"RaiseEvent"
"ReadOnly"
"ReDim"
# has to be in the keyword list for the output formatter
"Rem"
"RemoveHandler"
"Resume"
"Return"
"SByte"
"Select"
"Set"
"Shadows"
@ -198,42 +214,23 @@ ConcatStringAssign = "&=" @@ -198,42 +214,23 @@ ConcatStringAssign = "&="
"To"
"True"
"Try"
"TryCast"
"TypeOf"
"UInteger"
"ULong"
"Unicode"
"Until"
"UShort"
"Using"
"Variant"
"Wend"
"When"
"While"
"Widening"
"With"
"WithEvents"
"WriteOnly"
"Xor"
# Rem never gets passed to the parser because it is handled by the lexer, but it still
# has to be in the keyword list for the output formatter
"Rem"
# VB.NET 2.0 Keywords:
"Continue"
"Operator"
"Using"
"IsNot"
# Note: IsTrue and IsFalse are 'NOT' keywords they're only valid in Operator declarations (like get/set/value are no C# 'keywords')
"SByte"
"UInteger"
"ULong"
"UShort"
"CSByte"
"CUShort"
"CUInt"
"CULng"
"Global"
"TryCast"
"Of"
"Narrowing"
"Widening"
"Partial"
"Custom"
#Sets
Null("Nothing")

43
src/Libraries/NRefactory/Project/Src/Lexer/VBNet/Keywords.cs

@ -36,10 +36,16 @@ namespace ICSharpCode.NRefactory.Parser.VB @@ -36,10 +36,16 @@ namespace ICSharpCode.NRefactory.Parser.VB
"COBJ",
"COMPARE",
"CONST",
"CONTINUE",
"CSBYTE",
"CSHORT",
"CSNG",
"CSTR",
"CTYPE",
"CUINT",
"CULNG",
"CUSHORT",
"CUSTOM",
"DATE",
"DECIMAL",
"DECLARE",
@ -67,6 +73,7 @@ namespace ICSharpCode.NRefactory.Parser.VB @@ -67,6 +73,7 @@ namespace ICSharpCode.NRefactory.Parser.VB
"FUNCTION",
"GET",
"GETTYPE",
"GLOBAL",
"GOSUB",
"GOTO",
"HANDLES",
@ -74,10 +81,12 @@ namespace ICSharpCode.NRefactory.Parser.VB @@ -74,10 +81,12 @@ namespace ICSharpCode.NRefactory.Parser.VB
"IMPLEMENTS",
"IMPORTS",
"IN",
"INFER",
"INHERITS",
"INTEGER",
"INTERFACE",
"IS",
"ISNOT",
"LET",
"LIB",
"LIKE",
@ -91,6 +100,7 @@ namespace ICSharpCode.NRefactory.Parser.VB @@ -91,6 +100,7 @@ namespace ICSharpCode.NRefactory.Parser.VB
"MYBASE",
"MYCLASS",
"NAMESPACE",
"NARROWING",
"NEW",
"NEXT",
"NOT",
@ -98,8 +108,10 @@ namespace ICSharpCode.NRefactory.Parser.VB @@ -98,8 +108,10 @@ namespace ICSharpCode.NRefactory.Parser.VB
"NOTINHERITABLE",
"NOTOVERRIDABLE",
"OBJECT",
"OF",
"OFF",
"ON",
"OPERATOR",
"OPTION",
"OPTIONAL",
"OR",
@ -108,6 +120,7 @@ namespace ICSharpCode.NRefactory.Parser.VB @@ -108,6 +120,7 @@ namespace ICSharpCode.NRefactory.Parser.VB
"OVERRIDABLE",
"OVERRIDES",
"PARAMARRAY",
"PARTIAL",
"PRESERVE",
"PRIVATE",
"PROPERTY",
@ -116,9 +129,11 @@ namespace ICSharpCode.NRefactory.Parser.VB @@ -116,9 +129,11 @@ namespace ICSharpCode.NRefactory.Parser.VB
"RAISEEVENT",
"READONLY",
"REDIM",
"REM",
"REMOVEHANDLER",
"RESUME",
"RETURN",
"SBYTE",
"SELECT",
"SET",
"SHADOWS",
@ -139,37 +154,23 @@ namespace ICSharpCode.NRefactory.Parser.VB @@ -139,37 +154,23 @@ namespace ICSharpCode.NRefactory.Parser.VB
"TO",
"TRUE",
"TRY",
"TRYCAST",
"TYPEOF",
"UINTEGER",
"ULONG",
"UNICODE",
"UNTIL",
"USHORT",
"USING",
"VARIANT",
"WEND",
"WHEN",
"WHILE",
"WIDENING",
"WITH",
"WITHEVENTS",
"WRITEONLY",
"XOR",
"REM",
"CONTINUE",
"OPERATOR",
"USING",
"ISNOT",
"SBYTE",
"UINTEGER",
"ULONG",
"USHORT",
"CSBYTE",
"CUSHORT",
"CUINT",
"CULNG",
"GLOBAL",
"TRYCAST",
"OF",
"NARROWING",
"WIDENING",
"PARTIAL",
"CUSTOM"
"XOR"
};
static LookupTable keywords = new LookupTable(false);

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

@ -19,19 +19,19 @@ namespace ICSharpCode.NRefactory.Parser.VB @@ -19,19 +19,19 @@ namespace ICSharpCode.NRefactory.Parser.VB
public const int LiteralDate = 9;
// ----- special character -----
public const int Dot = 10;
public const int Assign = 11;
public const int Assign = 10;
public const int Colon = 11;
public const int Comma = 12;
public const int Colon = 13;
public const int Plus = 14;
public const int Minus = 15;
public const int Times = 16;
public const int Div = 17;
public const int DivInteger = 18;
public const int ConcatString = 19;
public const int ConcatString = 13;
public const int Div = 14;
public const int DivInteger = 15;
public const int Dot = 16;
public const int ExclamationMark = 17;
public const int Minus = 18;
public const int Plus = 19;
public const int Power = 20;
public const int QuestionMark = 21;
public const int ExclamationMark = 22;
public const int Times = 22;
public const int OpenCurlyBrace = 23;
public const int CloseCurlyBrace = 24;
public const int OpenParenthesis = 25;
@ -84,142 +84,143 @@ namespace ICSharpCode.NRefactory.Parser.VB @@ -84,142 +84,143 @@ namespace ICSharpCode.NRefactory.Parser.VB
public const int CObj = 70;
public const int Compare = 71;
public const int Const = 72;
public const int CShort = 73;
public const int CSng = 74;
public const int CStr = 75;
public const int CType = 76;
public const int Date = 77;
public const int Decimal = 78;
public const int Declare = 79;
public const int Default = 80;
public const int Delegate = 81;
public const int Dim = 82;
public const int DirectCast = 83;
public const int Do = 84;
public const int Double = 85;
public const int Each = 86;
public const int Else = 87;
public const int ElseIf = 88;
public const int End = 89;
public const int EndIf = 90;
public const int Enum = 91;
public const int Erase = 92;
public const int Error = 93;
public const int Event = 94;
public const int Exit = 95;
public const int Explicit = 96;
public const int False = 97;
public const int Finally = 98;
public const int For = 99;
public const int Friend = 100;
public const int Function = 101;
public const int Get = 102;
new public const int GetType = 103;
public const int GoSub = 104;
public const int GoTo = 105;
public const int Handles = 106;
public const int If = 107;
public const int Implements = 108;
public const int Imports = 109;
public const int In = 110;
public const int Inherits = 111;
public const int Integer = 112;
public const int Interface = 113;
public const int Is = 114;
public const int Let = 115;
public const int Lib = 116;
public const int Like = 117;
public const int Long = 118;
public const int Loop = 119;
public const int Me = 120;
public const int Mod = 121;
public const int Module = 122;
public const int MustInherit = 123;
public const int MustOverride = 124;
public const int MyBase = 125;
public const int MyClass = 126;
public const int Namespace = 127;
public const int New = 128;
public const int Next = 129;
public const int Not = 130;
public const int Nothing = 131;
public const int NotInheritable = 132;
public const int NotOverridable = 133;
public const int Object = 134;
public const int Off = 135;
public const int On = 136;
public const int Option = 137;
public const int Optional = 138;
public const int Or = 139;
public const int OrElse = 140;
public const int Overloads = 141;
public const int Overridable = 142;
public const int Overrides = 143;
public const int ParamArray = 144;
public const int Preserve = 145;
public const int Private = 146;
public const int Property = 147;
public const int Protected = 148;
public const int Public = 149;
public const int RaiseEvent = 150;
public const int ReadOnly = 151;
public const int ReDim = 152;
public const int RemoveHandler = 153;
public const int Resume = 154;
public const int Return = 155;
public const int Select = 156;
public const int Set = 157;
public const int Shadows = 158;
public const int Shared = 159;
public const int Short = 160;
public const int Single = 161;
public const int Static = 162;
public const int Step = 163;
public const int Stop = 164;
public const int Strict = 165;
public const int String = 166;
public const int Structure = 167;
public const int Sub = 168;
public const int SyncLock = 169;
public const int Text = 170;
public const int Then = 171;
public const int Throw = 172;
public const int To = 173;
public const int True = 174;
public const int Try = 175;
public const int TypeOf = 176;
public const int Unicode = 177;
public const int Until = 178;
public const int Variant = 179;
public const int Wend = 180;
public const int When = 181;
public const int While = 182;
public const int With = 183;
public const int WithEvents = 184;
public const int WriteOnly = 185;
public const int Xor = 186;
public const int Rem = 187;
public const int Continue = 188;
public const int Operator = 189;
public const int Using = 190;
public const int IsNot = 191;
public const int SByte = 192;
public const int Continue = 73;
public const int CSByte = 74;
public const int CShort = 75;
public const int CSng = 76;
public const int CStr = 77;
public const int CType = 78;
public const int CUInt = 79;
public const int CULng = 80;
public const int CUShort = 81;
public const int Custom = 82;
public const int Date = 83;
public const int Decimal = 84;
public const int Declare = 85;
public const int Default = 86;
public const int Delegate = 87;
public const int Dim = 88;
public const int DirectCast = 89;
public const int Do = 90;
public const int Double = 91;
public const int Each = 92;
public const int Else = 93;
public const int ElseIf = 94;
public const int End = 95;
public const int EndIf = 96;
public const int Enum = 97;
public const int Erase = 98;
public const int Error = 99;
public const int Event = 100;
public const int Exit = 101;
public const int Explicit = 102;
public const int False = 103;
public const int Finally = 104;
public const int For = 105;
public const int Friend = 106;
public const int Function = 107;
public const int Get = 108;
new public const int GetType = 109;
public const int Global = 110;
public const int GoSub = 111;
public const int GoTo = 112;
public const int Handles = 113;
public const int If = 114;
public const int Implements = 115;
public const int Imports = 116;
public const int In = 117;
public const int Infer = 118;
public const int Inherits = 119;
public const int Integer = 120;
public const int Interface = 121;
public const int Is = 122;
public const int IsNot = 123;
public const int Let = 124;
public const int Lib = 125;
public const int Like = 126;
public const int Long = 127;
public const int Loop = 128;
public const int Me = 129;
public const int Mod = 130;
public const int Module = 131;
public const int MustInherit = 132;
public const int MustOverride = 133;
public const int MyBase = 134;
public const int MyClass = 135;
public const int Namespace = 136;
public const int Narrowing = 137;
public const int New = 138;
public const int Next = 139;
public const int Not = 140;
public const int Nothing = 141;
public const int NotInheritable = 142;
public const int NotOverridable = 143;
public const int Object = 144;
public const int Of = 145;
public const int Off = 146;
public const int On = 147;
public const int Operator = 148;
public const int Option = 149;
public const int Optional = 150;
public const int Or = 151;
public const int OrElse = 152;
public const int Overloads = 153;
public const int Overridable = 154;
public const int Overrides = 155;
public const int ParamArray = 156;
public const int Partial = 157;
public const int Preserve = 158;
public const int Private = 159;
public const int Property = 160;
public const int Protected = 161;
public const int Public = 162;
public const int RaiseEvent = 163;
public const int ReadOnly = 164;
public const int ReDim = 165;
public const int Rem = 166;
public const int RemoveHandler = 167;
public const int Resume = 168;
public const int Return = 169;
public const int SByte = 170;
public const int Select = 171;
public const int Set = 172;
public const int Shadows = 173;
public const int Shared = 174;
public const int Short = 175;
public const int Single = 176;
public const int Static = 177;
public const int Step = 178;
public const int Stop = 179;
public const int Strict = 180;
public const int String = 181;
public const int Structure = 182;
public const int Sub = 183;
public const int SyncLock = 184;
public const int Text = 185;
public const int Then = 186;
public const int Throw = 187;
public const int To = 188;
public const int True = 189;
public const int Try = 190;
public const int TryCast = 191;
public const int TypeOf = 192;
public const int UInteger = 193;
public const int ULong = 194;
public const int UShort = 195;
public const int CSByte = 196;
public const int CUShort = 197;
public const int CUInt = 198;
public const int CULng = 199;
public const int Global = 200;
public const int TryCast = 201;
public const int Of = 202;
public const int Narrowing = 203;
public const int Widening = 204;
public const int Partial = 205;
public const int Custom = 206;
public const int Unicode = 195;
public const int Until = 196;
public const int UShort = 197;
public const int Using = 198;
public const int Variant = 199;
public const int Wend = 200;
public const int When = 201;
public const int While = 202;
public const int Widening = 203;
public const int With = 204;
public const int WithEvents = 205;
public const int WriteOnly = 206;
public const int Xor = 207;
public const int MaxToken = 207;
public const int MaxToken = 208;
static BitArray NewSet(params int[] values)
{
BitArray bitArray = new BitArray(MaxToken);
@ -245,19 +246,19 @@ namespace ICSharpCode.NRefactory.Parser.VB @@ -245,19 +246,19 @@ namespace ICSharpCode.NRefactory.Parser.VB
"<LiteralDecimal>",
"<LiteralDate>",
// ----- special character -----
".",
"=",
",",
":",
"+",
"-",
"*",
",",
"&",
"/",
"\\",
"&",
".",
"!",
"-",
"+",
"^",
"?",
"!",
"*",
"{",
"}",
"(",
@ -309,10 +310,16 @@ namespace ICSharpCode.NRefactory.Parser.VB @@ -309,10 +310,16 @@ namespace ICSharpCode.NRefactory.Parser.VB
"CObj",
"Compare",
"Const",
"Continue",
"CSByte",
"CShort",
"CSng",
"CStr",
"CType",
"CUInt",
"CULng",
"CUShort",
"Custom",
"Date",
"Decimal",
"Declare",
@ -340,6 +347,7 @@ namespace ICSharpCode.NRefactory.Parser.VB @@ -340,6 +347,7 @@ namespace ICSharpCode.NRefactory.Parser.VB
"Function",
"Get",
"GetType",
"Global",
"GoSub",
"GoTo",
"Handles",
@ -347,10 +355,12 @@ namespace ICSharpCode.NRefactory.Parser.VB @@ -347,10 +355,12 @@ namespace ICSharpCode.NRefactory.Parser.VB
"Implements",
"Imports",
"In",
"Infer",
"Inherits",
"Integer",
"Interface",
"Is",
"IsNot",
"Let",
"Lib",
"Like",
@ -364,6 +374,7 @@ namespace ICSharpCode.NRefactory.Parser.VB @@ -364,6 +374,7 @@ namespace ICSharpCode.NRefactory.Parser.VB
"MyBase",
"MyClass",
"Namespace",
"Narrowing",
"New",
"Next",
"Not",
@ -371,8 +382,10 @@ namespace ICSharpCode.NRefactory.Parser.VB @@ -371,8 +382,10 @@ namespace ICSharpCode.NRefactory.Parser.VB
"NotInheritable",
"NotOverridable",
"Object",
"Of",
"Off",
"On",
"Operator",
"Option",
"Optional",
"Or",
@ -381,6 +394,7 @@ namespace ICSharpCode.NRefactory.Parser.VB @@ -381,6 +394,7 @@ namespace ICSharpCode.NRefactory.Parser.VB
"Overridable",
"Overrides",
"ParamArray",
"Partial",
"Preserve",
"Private",
"Property",
@ -389,9 +403,11 @@ namespace ICSharpCode.NRefactory.Parser.VB @@ -389,9 +403,11 @@ namespace ICSharpCode.NRefactory.Parser.VB
"RaiseEvent",
"ReadOnly",
"ReDim",
"Rem",
"RemoveHandler",
"Resume",
"Return",
"SByte",
"Select",
"Set",
"Shadows",
@ -412,37 +428,23 @@ namespace ICSharpCode.NRefactory.Parser.VB @@ -412,37 +428,23 @@ namespace ICSharpCode.NRefactory.Parser.VB
"To",
"True",
"Try",
"TryCast",
"TypeOf",
"UInteger",
"ULong",
"Unicode",
"Until",
"UShort",
"Using",
"Variant",
"Wend",
"When",
"While",
"Widening",
"With",
"WithEvents",
"WriteOnly",
"Xor",
"Rem",
"Continue",
"Operator",
"Using",
"IsNot",
"SByte",
"UInteger",
"ULong",
"UShort",
"CSByte",
"CUShort",
"CUInt",
"CULng",
"Global",
"TryCast",
"Of",
"Narrowing",
"Widening",
"Partial",
"Custom",
};
public static string GetTokenString(int token)
{

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

File diff suppressed because it is too large Load Diff

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

@ -23,19 +23,19 @@ TOKENS @@ -23,19 +23,19 @@ TOKENS
LiteralDate
/* ----- special character ----- */
"."
"="
","
":"
"+"
"-"
"*"
","
"&"
"/"
"\\"
"&"
"."
"!"
"-"
"+"
"^"
"?"
"!"
"*"
"{"
"}"
"("
@ -88,10 +88,16 @@ TOKENS @@ -88,10 +88,16 @@ TOKENS
"CObj"
"Compare"
"Const"
"Continue"
"CSByte"
"CShort"
"CSng"
"CStr"
"CType"
"CUInt"
"CULng"
"CUShort"
"Custom"
"Date"
"Decimal"
"Declare"
@ -119,6 +125,7 @@ TOKENS @@ -119,6 +125,7 @@ TOKENS
"Function"
"Get"
"GetType"
"Global"
"GoSub"
"GoTo"
"Handles"
@ -126,10 +133,12 @@ TOKENS @@ -126,10 +133,12 @@ TOKENS
"Implements"
"Imports"
"In"
"Infer"
"Inherits"
"Integer"
"Interface"
"Is"
"IsNot"
"Let"
"Lib"
"Like"
@ -143,6 +152,7 @@ TOKENS @@ -143,6 +152,7 @@ TOKENS
"MyBase"
"MyClass"
"Namespace"
"Narrowing"
"New"
"Next"
"Not"
@ -150,8 +160,10 @@ TOKENS @@ -150,8 +160,10 @@ TOKENS
"NotInheritable"
"NotOverridable"
"Object"
"Of"
"Off"
"On"
"Operator"
"Option"
"Optional"
"Or"
@ -160,6 +172,7 @@ TOKENS @@ -160,6 +172,7 @@ TOKENS
"Overridable"
"Overrides"
"ParamArray"
"Partial"
"Preserve"
"Private"
"Property"
@ -168,9 +181,11 @@ TOKENS @@ -168,9 +181,11 @@ TOKENS
"RaiseEvent"
"ReadOnly"
"ReDim"
"Rem"
"RemoveHandler"
"Resume"
"Return"
"SByte"
"Select"
"Set"
"Shadows"
@ -191,40 +206,25 @@ TOKENS @@ -191,40 +206,25 @@ TOKENS
"To"
"True"
"Try"
"TryCast"
"TypeOf"
"UInteger"
"ULong"
"Unicode"
"Until"
"UShort"
"Using"
"Variant"
"Wend"
"When"
"While"
"Widening"
"With"
"WithEvents"
"WriteOnly"
"Xor"
"Rem"
"Continue"
"Operator"
"Using"
"IsNot"
"SByte"
"UInteger"
"ULong"
"UShort"
"CSByte"
"CUShort"
"CUInt"
"CULng"
"Global"
"TryCast"
"Of"
"Narrowing"
"Widening"
"Partial"
"Custom"
/* END AUTOGENERATED TOKENS SECTION */
PRODUCTIONS
VBNET
@ -1615,9 +1615,13 @@ SimpleExpr<out Expression pexpr> @@ -1615,9 +1615,13 @@ SimpleExpr<out Expression pexpr>
=
SimpleNonInvocationExpression<out pexpr>
{
"." IdentifierOrKeyword<out name> (. pexpr = new MemberReferenceExpression(pexpr, name); .)
| "!" IdentifierOrKeyword<out name> (. pexpr = new BinaryOperatorExpression(pexpr, BinaryOperatorType.DictionaryAccess, new PrimitiveExpression(name, name)); .)
| InvocationExpression<ref pexpr>
"." IdentifierOrKeyword<out name>
(. pexpr = new MemberReferenceExpression(pexpr, name); .)
[ IF (la.kind == Tokens.OpenParenthesis && Peek(1).kind == Tokens.Of)
"(" "Of" TypeArgumentList<((MemberReferenceExpression)pexpr).TypeArguments> ")"
]
| "!" IdentifierOrKeyword<out name> (. pexpr = new BinaryOperatorExpression(pexpr, BinaryOperatorType.DictionaryAccess, new PrimitiveExpression(name, name)); .)
| InvocationExpression<ref pexpr>
}
.
@ -1644,8 +1648,9 @@ SimpleNonInvocationExpression<out Expression pexpr> @@ -1644,8 +1648,9 @@ SimpleNonInvocationExpression<out Expression pexpr>
| "Nothing" (.pexpr = new PrimitiveExpression(null, "null"); .)
| /* 11.4.2 */ "(" Expr<out expr> ")" (. pexpr = new ParenthesizedExpression(expr); .)
| /* 11.4.4 */ Identifier
(. pexpr = new IdentifierExpression(t.val); .)
(. pexpr.StartLocation = t.Location; pexpr.EndLocation = t.EndLocation; .)
(. pexpr = new IdentifierExpression(t.val);
pexpr.StartLocation = t.Location; pexpr.EndLocation = t.EndLocation;
.)
[ IF (la.kind == Tokens.OpenParenthesis && Peek(1).kind == Tokens.Of)
"(" "Of" TypeArgumentList<((IdentifierExpression)pexpr).TypeArguments> ")"
]
@ -1719,36 +1724,15 @@ ConditionalExpression<out Expression expr> @@ -1719,36 +1724,15 @@ ConditionalExpression<out Expression expr>
.
InvocationExpression<ref Expression pexpr>
(. List<TypeReference> typeParameters = new List<TypeReference>();
List<Expression> parameters = null;
TypeReference type; .)
(. List<Expression> parameters = null; .)
=
"(" (. Location start = t.Location; .)
( "Of"
TypeName<out type> (. if (type != null) typeParameters.Add(type); .)
{
","
TypeName<out type> (. if (type != null) typeParameters.Add(type); .)
}
")"
(
"." Identifier
(. pexpr = new MemberReferenceExpression(GetTypeReferenceExpression(pexpr, typeParameters), t.val); .)
| "("
ArgumentList<out parameters>
")"
(.
pexpr = CreateInvocationExpression(pexpr, parameters, typeParameters);
SetParent(parameters, pexpr);
.)
)
| ArgumentList<out parameters>
")"
(.
pexpr = CreateInvocationExpression(pexpr, parameters, typeParameters);
SetParent(parameters, pexpr);
.)
)
ArgumentList<out parameters>
")"
(.
pexpr = new InvocationExpression(pexpr, parameters);
SetParent(parameters, pexpr);
.)
(. pexpr.StartLocation = start; pexpr.EndLocation = t.Location; .)
.

44
src/Libraries/NRefactory/Project/Src/Parser/VBNet/VBNetParser.cs

@ -209,34 +209,6 @@ namespace ICSharpCode.NRefactory.Parser.VB @@ -209,34 +209,6 @@ namespace ICSharpCode.NRefactory.Parser.VB
return m.Contains(Modifiers.Abstract);
}
TypeReferenceExpression GetTypeReferenceExpression(Expression expr, List<TypeReference> genericTypes)
{
TypeReferenceExpression tre = expr as TypeReferenceExpression;
if (tre != null) {
return new TypeReferenceExpression(new TypeReference(tre.TypeReference.Type, tre.TypeReference.PointerNestingLevel, tre.TypeReference.RankSpecifier, genericTypes));
}
StringBuilder b = new StringBuilder();
if (!WriteFullTypeName(b, expr)) {
// there is some TypeReferenceExpression hidden in the expression
while (expr is MemberReferenceExpression) {
expr = ((MemberReferenceExpression)expr).TargetObject;
}
tre = expr as TypeReferenceExpression;
if (tre != null) {
TypeReference typeRef = tre.TypeReference;
if (typeRef.GenericTypes.Count == 0) {
typeRef = typeRef.Clone();
typeRef.Type += "." + b.ToString();
typeRef.GenericTypes.AddRange(genericTypes);
} else {
typeRef = new InnerClassTypeReference(typeRef, b.ToString(), genericTypes);
}
return new TypeReferenceExpression(typeRef);
}
}
return new TypeReferenceExpression(new TypeReference(b.ToString(), 0, null, genericTypes));
}
/* Writes the type name represented through the expression into the string builder. */
/* Returns true when the expression was converted successfully, returns false when */
/* There was an unknown expression (e.g. TypeReferenceExpression) in it */
@ -271,21 +243,7 @@ namespace ICSharpCode.NRefactory.Parser.VB @@ -271,21 +243,7 @@ namespace ICSharpCode.NRefactory.Parser.VB
if (!(expr is PrimitiveExpression) || (expr as PrimitiveExpression).StringValue != "0")
Error("lower bound of array must be zero");
}
InvocationExpression CreateInvocationExpression(Expression target, List<Expression> parameters, List<TypeReference> typeArguments)
{
if (typeArguments != null && typeArguments.Count > 0) {
if (target is IdentifierExpression) {
((IdentifierExpression)target).TypeArguments = typeArguments;
} else if (target is MemberReferenceExpression) {
((MemberReferenceExpression)target).TypeArguments = typeArguments;
} else {
Error("Type arguments only allowed on IdentifierExpression and MemberReferenceExpression");
}
}
return new InvocationExpression(target, parameters);
}
/// <summary>
/// Adds a child item to a collection stored in the parent node.
/// Also set's the item's parent to <paramref name="parent"/>.

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

@ -1,13 +1,7 @@ @@ -1,13 +1,7 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Daniel Grunwald" email="daniel@danielgrunwald.de"/>
// <version>$Revision$</version>
// </file>
using System;
using System.IO;
using NUnit.Framework;
using ICSharpCode.NRefactory.Parser;
using ICSharpCode.NRefactory.Parser.VB;
using ICSharpCode.NRefactory.PrettyPrinter;
@ -23,17 +17,17 @@ namespace ICSharpCode.NRefactory.Tests.Lexer.VB @@ -23,17 +17,17 @@ namespace ICSharpCode.NRefactory.Tests.Lexer.VB
}
[Test]
public void TestDot()
public void TestAssign()
{
ILexer lexer = GenerateLexer(new StringReader("."));
Assert.AreEqual(Tokens.Dot, lexer.NextToken().kind);
ILexer lexer = GenerateLexer(new StringReader("="));
Assert.AreEqual(Tokens.Assign, lexer.NextToken().kind);
}
[Test]
public void TestAssign()
public void TestColon()
{
ILexer lexer = GenerateLexer(new StringReader("="));
Assert.AreEqual(Tokens.Assign, lexer.NextToken().kind);
ILexer lexer = GenerateLexer(new StringReader(":"));
Assert.AreEqual(Tokens.Colon, lexer.NextToken().kind);
}
[Test]
@ -44,52 +38,52 @@ namespace ICSharpCode.NRefactory.Tests.Lexer.VB @@ -44,52 +38,52 @@ namespace ICSharpCode.NRefactory.Tests.Lexer.VB
}
[Test]
public void TestColon()
public void TestConcatString()
{
ILexer lexer = GenerateLexer(new StringReader(":"));
Assert.AreEqual(Tokens.Colon, lexer.NextToken().kind);
ILexer lexer = GenerateLexer(new StringReader("&"));
Assert.AreEqual(Tokens.ConcatString, lexer.NextToken().kind);
}
[Test]
public void TestPlus()
public void TestDiv()
{
ILexer lexer = GenerateLexer(new StringReader("+"));
Assert.AreEqual(Tokens.Plus, lexer.NextToken().kind);
ILexer lexer = GenerateLexer(new StringReader("/"));
Assert.AreEqual(Tokens.Div, lexer.NextToken().kind);
}
[Test]
public void TestMinus()
public void TestDivInteger()
{
ILexer lexer = GenerateLexer(new StringReader("-"));
Assert.AreEqual(Tokens.Minus, lexer.NextToken().kind);
ILexer lexer = GenerateLexer(new StringReader("\\"));
Assert.AreEqual(Tokens.DivInteger, lexer.NextToken().kind);
}
[Test]
public void TestTimes()
public void TestDot()
{
ILexer lexer = GenerateLexer(new StringReader("*"));
Assert.AreEqual(Tokens.Times, lexer.NextToken().kind);
ILexer lexer = GenerateLexer(new StringReader("."));
Assert.AreEqual(Tokens.Dot, lexer.NextToken().kind);
}
[Test]
public void TestDiv()
public void TestExclamationMark()
{
ILexer lexer = GenerateLexer(new StringReader("/"));
Assert.AreEqual(Tokens.Div, lexer.NextToken().kind);
ILexer lexer = GenerateLexer(new StringReader("!"));
Assert.AreEqual(Tokens.ExclamationMark, lexer.NextToken().kind);
}
[Test]
public void TestDivInteger()
public void TestMinus()
{
ILexer lexer = GenerateLexer(new StringReader("\\"));
Assert.AreEqual(Tokens.DivInteger, lexer.NextToken().kind);
ILexer lexer = GenerateLexer(new StringReader("-"));
Assert.AreEqual(Tokens.Minus, lexer.NextToken().kind);
}
[Test]
public void TestConcatString()
public void TestPlus()
{
ILexer lexer = GenerateLexer(new StringReader("&"));
Assert.AreEqual(Tokens.ConcatString, lexer.NextToken().kind);
ILexer lexer = GenerateLexer(new StringReader("+"));
Assert.AreEqual(Tokens.Plus, lexer.NextToken().kind);
}
[Test]
@ -107,10 +101,10 @@ namespace ICSharpCode.NRefactory.Tests.Lexer.VB @@ -107,10 +101,10 @@ namespace ICSharpCode.NRefactory.Tests.Lexer.VB
}
[Test]
public void TestExclamationMark()
public void TestTimes()
{
ILexer lexer = GenerateLexer(new StringReader("!"));
Assert.AreEqual(Tokens.ExclamationMark, lexer.NextToken().kind);
ILexer lexer = GenerateLexer(new StringReader("*"));
Assert.AreEqual(Tokens.Times, lexer.NextToken().kind);
}
[Test]
@ -434,6 +428,18 @@ namespace ICSharpCode.NRefactory.Tests.Lexer.VB @@ -434,6 +428,18 @@ namespace ICSharpCode.NRefactory.Tests.Lexer.VB
Assert.AreEqual(Tokens.Const, lexer.NextToken().kind);
}
[Test()]
public void TestContinue()
{
ILexer lexer = GenerateLexer(new StringReader("Continue"));
Assert.AreEqual(Tokens.Continue, lexer.NextToken().kind);
}
[Test()]
public void TestCSByte()
{
ILexer lexer = GenerateLexer(new StringReader("CSByte"));
Assert.AreEqual(Tokens.CSByte, lexer.NextToken().kind);
}
[Test()]
public void TestCShort()
{
ILexer lexer = GenerateLexer(new StringReader("CShort"));
@ -458,6 +464,30 @@ namespace ICSharpCode.NRefactory.Tests.Lexer.VB @@ -458,6 +464,30 @@ namespace ICSharpCode.NRefactory.Tests.Lexer.VB
Assert.AreEqual(Tokens.CType, lexer.NextToken().kind);
}
[Test()]
public void TestCUInt()
{
ILexer lexer = GenerateLexer(new StringReader("CUInt"));
Assert.AreEqual(Tokens.CUInt, lexer.NextToken().kind);
}
[Test()]
public void TestCULng()
{
ILexer lexer = GenerateLexer(new StringReader("CULng"));
Assert.AreEqual(Tokens.CULng, lexer.NextToken().kind);
}
[Test()]
public void TestCUShort()
{
ILexer lexer = GenerateLexer(new StringReader("CUShort"));
Assert.AreEqual(Tokens.CUShort, lexer.NextToken().kind);
}
[Test()]
public void TestCustom()
{
ILexer lexer = GenerateLexer(new StringReader("Custom"));
Assert.AreEqual(Tokens.Custom, lexer.NextToken().kind);
}
[Test()]
public void TestDate()
{
ILexer lexer = GenerateLexer(new StringReader("Date"));
@ -620,6 +650,12 @@ namespace ICSharpCode.NRefactory.Tests.Lexer.VB @@ -620,6 +650,12 @@ namespace ICSharpCode.NRefactory.Tests.Lexer.VB
Assert.AreEqual(Tokens.GetType, lexer.NextToken().kind);
}
[Test()]
public void TestGlobal()
{
ILexer lexer = GenerateLexer(new StringReader("Global"));
Assert.AreEqual(Tokens.Global, lexer.NextToken().kind);
}
[Test()]
public void TestGoSub()
{
ILexer lexer = GenerateLexer(new StringReader("GoSub"));
@ -662,6 +698,12 @@ namespace ICSharpCode.NRefactory.Tests.Lexer.VB @@ -662,6 +698,12 @@ namespace ICSharpCode.NRefactory.Tests.Lexer.VB
Assert.AreEqual(Tokens.In, lexer.NextToken().kind);
}
[Test()]
public void TestInfer()
{
ILexer lexer = GenerateLexer(new StringReader("Infer"));
Assert.AreEqual(Tokens.Infer, lexer.NextToken().kind);
}
[Test()]
public void TestInherits()
{
ILexer lexer = GenerateLexer(new StringReader("Inherits"));
@ -686,6 +728,12 @@ namespace ICSharpCode.NRefactory.Tests.Lexer.VB @@ -686,6 +728,12 @@ namespace ICSharpCode.NRefactory.Tests.Lexer.VB
Assert.AreEqual(Tokens.Is, lexer.NextToken().kind);
}
[Test()]
public void TestIsNot()
{
ILexer lexer = GenerateLexer(new StringReader("IsNot"));
Assert.AreEqual(Tokens.IsNot, lexer.NextToken().kind);
}
[Test()]
public void TestLet()
{
ILexer lexer = GenerateLexer(new StringReader("Let"));
@ -764,6 +812,12 @@ namespace ICSharpCode.NRefactory.Tests.Lexer.VB @@ -764,6 +812,12 @@ namespace ICSharpCode.NRefactory.Tests.Lexer.VB
Assert.AreEqual(Tokens.Namespace, lexer.NextToken().kind);
}
[Test()]
public void TestNarrowing()
{
ILexer lexer = GenerateLexer(new StringReader("Narrowing"));
Assert.AreEqual(Tokens.Narrowing, lexer.NextToken().kind);
}
[Test()]
public void TestNew()
{
ILexer lexer = GenerateLexer(new StringReader("New"));
@ -806,6 +860,12 @@ namespace ICSharpCode.NRefactory.Tests.Lexer.VB @@ -806,6 +860,12 @@ namespace ICSharpCode.NRefactory.Tests.Lexer.VB
Assert.AreEqual(Tokens.Object, lexer.NextToken().kind);
}
[Test()]
public void TestOf()
{
ILexer lexer = GenerateLexer(new StringReader("Of"));
Assert.AreEqual(Tokens.Of, lexer.NextToken().kind);
}
[Test()]
public void TestOff()
{
ILexer lexer = GenerateLexer(new StringReader("Off"));
@ -818,6 +878,12 @@ namespace ICSharpCode.NRefactory.Tests.Lexer.VB @@ -818,6 +878,12 @@ namespace ICSharpCode.NRefactory.Tests.Lexer.VB
Assert.AreEqual(Tokens.On, lexer.NextToken().kind);
}
[Test()]
public void TestOperator()
{
ILexer lexer = GenerateLexer(new StringReader("Operator"));
Assert.AreEqual(Tokens.Operator, lexer.NextToken().kind);
}
[Test()]
public void TestOption()
{
ILexer lexer = GenerateLexer(new StringReader("Option"));
@ -866,6 +932,12 @@ namespace ICSharpCode.NRefactory.Tests.Lexer.VB @@ -866,6 +932,12 @@ namespace ICSharpCode.NRefactory.Tests.Lexer.VB
Assert.AreEqual(Tokens.ParamArray, lexer.NextToken().kind);
}
[Test()]
public void TestPartial()
{
ILexer lexer = GenerateLexer(new StringReader("Partial"));
Assert.AreEqual(Tokens.Partial, lexer.NextToken().kind);
}
[Test()]
public void TestPreserve()
{
ILexer lexer = GenerateLexer(new StringReader("Preserve"));
@ -913,6 +985,7 @@ namespace ICSharpCode.NRefactory.Tests.Lexer.VB @@ -913,6 +985,7 @@ namespace ICSharpCode.NRefactory.Tests.Lexer.VB
ILexer lexer = GenerateLexer(new StringReader("ReDim"));
Assert.AreEqual(Tokens.ReDim, lexer.NextToken().kind);
}
[Test()]
public void TestRemoveHandler()
{
@ -932,6 +1005,12 @@ namespace ICSharpCode.NRefactory.Tests.Lexer.VB @@ -932,6 +1005,12 @@ namespace ICSharpCode.NRefactory.Tests.Lexer.VB
Assert.AreEqual(Tokens.Return, lexer.NextToken().kind);
}
[Test()]
public void TestSByte()
{
ILexer lexer = GenerateLexer(new StringReader("SByte"));
Assert.AreEqual(Tokens.SByte, lexer.NextToken().kind);
}
[Test()]
public void TestSelect()
{
ILexer lexer = GenerateLexer(new StringReader("Select"));
@ -1052,12 +1131,30 @@ namespace ICSharpCode.NRefactory.Tests.Lexer.VB @@ -1052,12 +1131,30 @@ namespace ICSharpCode.NRefactory.Tests.Lexer.VB
Assert.AreEqual(Tokens.Try, lexer.NextToken().kind);
}
[Test()]
public void TestTryCast()
{
ILexer lexer = GenerateLexer(new StringReader("TryCast"));
Assert.AreEqual(Tokens.TryCast, lexer.NextToken().kind);
}
[Test()]
public void TestTypeOf()
{
ILexer lexer = GenerateLexer(new StringReader("TypeOf"));
Assert.AreEqual(Tokens.TypeOf, lexer.NextToken().kind);
}
[Test()]
public void TestUInteger()
{
ILexer lexer = GenerateLexer(new StringReader("UInteger"));
Assert.AreEqual(Tokens.UInteger, lexer.NextToken().kind);
}
[Test()]
public void TestULong()
{
ILexer lexer = GenerateLexer(new StringReader("ULong"));
Assert.AreEqual(Tokens.ULong, lexer.NextToken().kind);
}
[Test()]
public void TestUnicode()
{
ILexer lexer = GenerateLexer(new StringReader("Unicode"));
@ -1070,6 +1167,18 @@ namespace ICSharpCode.NRefactory.Tests.Lexer.VB @@ -1070,6 +1167,18 @@ namespace ICSharpCode.NRefactory.Tests.Lexer.VB
Assert.AreEqual(Tokens.Until, lexer.NextToken().kind);
}
[Test()]
public void TestUShort()
{
ILexer lexer = GenerateLexer(new StringReader("UShort"));
Assert.AreEqual(Tokens.UShort, lexer.NextToken().kind);
}
[Test()]
public void TestUsing()
{
ILexer lexer = GenerateLexer(new StringReader("Using"));
Assert.AreEqual(Tokens.Using, lexer.NextToken().kind);
}
[Test()]
public void TestVariant()
{
ILexer lexer = GenerateLexer(new StringReader("Variant"));
@ -1094,6 +1203,12 @@ namespace ICSharpCode.NRefactory.Tests.Lexer.VB @@ -1094,6 +1203,12 @@ namespace ICSharpCode.NRefactory.Tests.Lexer.VB
Assert.AreEqual(Tokens.While, lexer.NextToken().kind);
}
[Test()]
public void TestWidening()
{
ILexer lexer = GenerateLexer(new StringReader("Widening"));
Assert.AreEqual(Tokens.Widening, lexer.NextToken().kind);
}
[Test()]
public void TestWith()
{
ILexer lexer = GenerateLexer(new StringReader("With"));
@ -1117,119 +1232,5 @@ namespace ICSharpCode.NRefactory.Tests.Lexer.VB @@ -1117,119 +1232,5 @@ namespace ICSharpCode.NRefactory.Tests.Lexer.VB
ILexer lexer = GenerateLexer(new StringReader("Xor"));
Assert.AreEqual(Tokens.Xor, lexer.NextToken().kind);
}
[Test()]
public void TestContinue()
{
ILexer lexer = GenerateLexer(new StringReader("Continue"));
Assert.AreEqual(Tokens.Continue, lexer.NextToken().kind);
}
[Test()]
public void TestOperator()
{
ILexer lexer = GenerateLexer(new StringReader("Operator"));
Assert.AreEqual(Tokens.Operator, lexer.NextToken().kind);
}
[Test()]
public void TestUsing()
{
ILexer lexer = GenerateLexer(new StringReader("Using"));
Assert.AreEqual(Tokens.Using, lexer.NextToken().kind);
}
[Test()]
public void TestIsNot()
{
ILexer lexer = GenerateLexer(new StringReader("IsNot"));
Assert.AreEqual(Tokens.IsNot, lexer.NextToken().kind);
}
[Test()]
public void TestSByte()
{
ILexer lexer = GenerateLexer(new StringReader("SByte"));
Assert.AreEqual(Tokens.SByte, lexer.NextToken().kind);
}
[Test()]
public void TestUInteger()
{
ILexer lexer = GenerateLexer(new StringReader("UInteger"));
Assert.AreEqual(Tokens.UInteger, lexer.NextToken().kind);
}
[Test()]
public void TestULong()
{
ILexer lexer = GenerateLexer(new StringReader("ULong"));
Assert.AreEqual(Tokens.ULong, lexer.NextToken().kind);
}
[Test()]
public void TestUShort()
{
ILexer lexer = GenerateLexer(new StringReader("UShort"));
Assert.AreEqual(Tokens.UShort, lexer.NextToken().kind);
}
[Test()]
public void TestCSByte()
{
ILexer lexer = GenerateLexer(new StringReader("CSByte"));
Assert.AreEqual(Tokens.CSByte, lexer.NextToken().kind);
}
[Test()]
public void TestCUShort()
{
ILexer lexer = GenerateLexer(new StringReader("CUShort"));
Assert.AreEqual(Tokens.CUShort, lexer.NextToken().kind);
}
[Test()]
public void TestCUInt()
{
ILexer lexer = GenerateLexer(new StringReader("CUInt"));
Assert.AreEqual(Tokens.CUInt, lexer.NextToken().kind);
}
[Test()]
public void TestCULng()
{
ILexer lexer = GenerateLexer(new StringReader("CULng"));
Assert.AreEqual(Tokens.CULng, lexer.NextToken().kind);
}
[Test()]
public void TestGlobal()
{
ILexer lexer = GenerateLexer(new StringReader("Global"));
Assert.AreEqual(Tokens.Global, lexer.NextToken().kind);
}
[Test()]
public void TestTryCast()
{
ILexer lexer = GenerateLexer(new StringReader("TryCast"));
Assert.AreEqual(Tokens.TryCast, lexer.NextToken().kind);
}
[Test()]
public void TestOf()
{
ILexer lexer = GenerateLexer(new StringReader("Of"));
Assert.AreEqual(Tokens.Of, lexer.NextToken().kind);
}
[Test()]
public void TestNarrowing()
{
ILexer lexer = GenerateLexer(new StringReader("Narrowing"));
Assert.AreEqual(Tokens.Narrowing, lexer.NextToken().kind);
}
[Test()]
public void TestWidening()
{
ILexer lexer = GenerateLexer(new StringReader("Widening"));
Assert.AreEqual(Tokens.Widening, lexer.NextToken().kind);
}
[Test()]
public void TestPartial()
{
ILexer lexer = GenerateLexer(new StringReader("Partial"));
Assert.AreEqual(Tokens.Partial, lexer.NextToken().kind);
}
[Test()]
public void TestCustom()
{
ILexer lexer = GenerateLexer(new StringReader("Custom"));
Assert.AreEqual(Tokens.Custom, lexer.NextToken().kind);
}
}
}

10
src/Libraries/NRefactory/Test/Parser/Expressions/AddressOfExpressionTests.cs

@ -38,6 +38,16 @@ namespace ICSharpCode.NRefactory.Tests.Ast @@ -38,6 +38,16 @@ namespace ICSharpCode.NRefactory.Tests.Ast
Assert.AreEqual("X", ((IdentifierExpression)ae.Expression).TypeArguments[0].Type);
}
[Test]
public void MemberReferenceAddressOfExpressionTest()
{
AddressOfExpression ae = ParseUtilVBNet.ParseExpression<AddressOfExpression>("AddressOf Me.t(Of X)");
Assert.IsNotNull(ae);
Assert.IsInstanceOfType(typeof(MemberReferenceExpression), ae.Expression);
Assert.AreEqual("t", ((MemberReferenceExpression)ae.Expression).MemberName, "t");
Assert.IsInstanceOfType(typeof(ThisReferenceExpression), ((MemberReferenceExpression)ae.Expression).TargetObject);
}
#endregion
#region C#

45
src/Libraries/NRefactory/Test/Parser/Expressions/MemberReferenceExpressionTests.cs

@ -103,11 +103,9 @@ namespace ICSharpCode.NRefactory.Tests.Ast @@ -103,11 +103,9 @@ namespace ICSharpCode.NRefactory.Tests.Ast
{
MemberReferenceExpression fre = ParseUtilVBNet.ParseExpression<MemberReferenceExpression>("SomeClass(of string).myField");
Assert.AreEqual("myField", fre.MemberName);
Assert.IsTrue(fre.TargetObject is TypeReferenceExpression);
TypeReference tr = ((TypeReferenceExpression)fre.TargetObject).TypeReference;
Assert.AreEqual("SomeClass", tr.Type);
Assert.AreEqual(1, tr.GenericTypes.Count);
Assert.AreEqual("System.String", tr.GenericTypes[0].SystemType);
Assert.IsInstanceOfType(typeof(IdentifierExpression), fre.TargetObject);
TypeReference tr = ((IdentifierExpression)fre.TargetObject).TypeArguments[0];
Assert.AreEqual("String", tr.Type);
}
[Test]
@ -115,11 +113,12 @@ namespace ICSharpCode.NRefactory.Tests.Ast @@ -115,11 +113,12 @@ namespace ICSharpCode.NRefactory.Tests.Ast
{
MemberReferenceExpression fre = ParseUtilVBNet.ParseExpression<MemberReferenceExpression>("System.Subnamespace.SomeClass(of string).myField");
Assert.AreEqual("myField", fre.MemberName);
Assert.IsTrue(fre.TargetObject is TypeReferenceExpression);
TypeReference tr = ((TypeReferenceExpression)fre.TargetObject).TypeReference;
Assert.AreEqual("System.Subnamespace.SomeClass", tr.Type);
Assert.AreEqual(1, tr.GenericTypes.Count);
Assert.AreEqual("System.String", tr.GenericTypes[0].SystemType);
Assert.IsInstanceOfType(typeof(MemberReferenceExpression), fre.TargetObject);
MemberReferenceExpression inner = (MemberReferenceExpression)fre.TargetObject;
Assert.AreEqual("SomeClass", inner.MemberName);
Assert.AreEqual(1, inner.TypeArguments.Count);
Assert.AreEqual("System.String", inner.TypeArguments[0].SystemType);
}
[Test]
@ -127,13 +126,12 @@ namespace ICSharpCode.NRefactory.Tests.Ast @@ -127,13 +126,12 @@ namespace ICSharpCode.NRefactory.Tests.Ast
{
MemberReferenceExpression fre = ParseUtilVBNet.ParseExpression<MemberReferenceExpression>("Global.System.Subnamespace.SomeClass(of string).myField");
Assert.AreEqual("myField", fre.MemberName);
Assert.IsTrue(fre.TargetObject is TypeReferenceExpression);
TypeReference tr = ((TypeReferenceExpression)fre.TargetObject).TypeReference;
Assert.IsFalse(tr is InnerClassTypeReference);
Assert.AreEqual("System.Subnamespace.SomeClass", tr.Type);
Assert.AreEqual(1, tr.GenericTypes.Count);
Assert.AreEqual("System.String", tr.GenericTypes[0].SystemType);
Assert.IsTrue(tr.IsGlobal);
Assert.IsInstanceOfType(typeof(MemberReferenceExpression), fre.TargetObject);
MemberReferenceExpression inner = (MemberReferenceExpression)fre.TargetObject;
Assert.AreEqual("SomeClass", inner.MemberName);
Assert.AreEqual(1, inner.TypeArguments.Count);
Assert.AreEqual("System.String", inner.TypeArguments[0].SystemType);
}
[Test]
@ -141,15 +139,12 @@ namespace ICSharpCode.NRefactory.Tests.Ast @@ -141,15 +139,12 @@ namespace ICSharpCode.NRefactory.Tests.Ast
{
MemberReferenceExpression fre = ParseUtilVBNet.ParseExpression<MemberReferenceExpression>("MyType(of string).InnerClass(of integer).myField");
Assert.AreEqual("myField", fre.MemberName);
Assert.IsTrue(fre.TargetObject is TypeReferenceExpression);
InnerClassTypeReference ic = (InnerClassTypeReference)((TypeReferenceExpression)fre.TargetObject).TypeReference;
Assert.AreEqual("InnerClass", ic.Type);
Assert.AreEqual(1, ic.GenericTypes.Count);
Assert.AreEqual("System.Int32", ic.GenericTypes[0].SystemType);
Assert.AreEqual("MyType", ic.BaseType.Type);
Assert.AreEqual(1, ic.BaseType.GenericTypes.Count);
Assert.AreEqual("System.String", ic.BaseType.GenericTypes[0].SystemType);
Assert.IsInstanceOfType(typeof(MemberReferenceExpression), fre.TargetObject);
MemberReferenceExpression inner = (MemberReferenceExpression)fre.TargetObject;
Assert.AreEqual("InnerClass", inner.MemberName);
}
#endregion
}
}

Loading…
Cancel
Save