11
11
using Microsoft . PowerShell . EditorServices . Services . TextDocument ;
12
12
using Microsoft . PowerShell . EditorServices . Handlers ;
13
13
using OmniSharp . Extensions . LanguageServer . Protocol ;
14
- using OmniSharp . Extensions . LanguageServer . Protocol . Document . Proposals ;
15
14
using OmniSharp . Extensions . LanguageServer . Protocol . Models . Proposals ;
16
15
using Xunit ;
17
16
@@ -42,20 +41,20 @@ function Get-Sum {
42
41
case "function" :
43
42
case "param" :
44
43
case "return" :
45
- Assert . Collection ( mappedTokens , sToken => Assert . Equal ( SemanticTokenType . Keyword , mappedTokens [ 0 ] . Type ) ) ;
44
+ Assert . Single ( mappedTokens , sToken => SemanticTokenType . Keyword == sToken . Type ) ;
46
45
break ;
47
46
case "Get-Sum" :
48
- Assert . Collection ( mappedTokens , sToken => Assert . Equal ( SemanticTokenType . Function , mappedTokens [ 0 ] . Type ) ) ;
47
+ Assert . Single ( mappedTokens , sToken => SemanticTokenType . Function == sToken . Type ) ;
49
48
break ;
50
49
case "$a" :
51
50
case "$b" :
52
- Assert . Collection ( mappedTokens , sToken => Assert . Equal ( SemanticTokenType . Variable , mappedTokens [ 0 ] . Type ) ) ;
51
+ Assert . Single ( mappedTokens , sToken => SemanticTokenType . Variable == sToken . Type ) ;
53
52
break ;
54
53
case "[int]" :
55
- Assert . Collection ( mappedTokens , sToken => Assert . Equal ( SemanticTokenType . Type , mappedTokens [ 0 ] . Type ) ) ;
54
+ Assert . Single ( mappedTokens , sToken => SemanticTokenType . Type == sToken . Type ) ;
56
55
break ;
57
56
case "+" :
58
- Assert . Collection ( mappedTokens , sToken => Assert . Equal ( SemanticTokenType . Operator , mappedTokens [ 0 ] . Type ) ) ;
57
+ Assert . Single ( mappedTokens , sToken => SemanticTokenType . Operator == sToken . Type ) ;
59
58
break ;
60
59
}
61
60
}
@@ -73,8 +72,7 @@ public async Task TokenizesStringExpansion()
73
72
74
73
Token commandToken = scriptFile . ScriptTokens [ 0 ] ;
75
74
List < SemanticToken > mappedTokens = new List < SemanticToken > ( PsesSemanticTokensHandler . ConvertToSemanticTokens ( commandToken ) ) ;
76
- Assert . Single ( mappedTokens ) ;
77
- Assert . Equal ( SemanticTokenType . Function , mappedTokens [ 0 ] . Type ) ;
75
+ Assert . Single ( mappedTokens , sToken => SemanticTokenType . Function == sToken . Type ) ;
78
76
79
77
Token stringExpandableToken = scriptFile . ScriptTokens [ 1 ] ;
80
78
mappedTokens = new List < SemanticToken > ( PsesSemanticTokensHandler . ConvertToSemanticTokens ( stringExpandableToken ) ) ;
@@ -105,10 +103,10 @@ function Get-A*A {
105
103
switch ( t . Text )
106
104
{
107
105
case "function" :
108
- Assert . Collection ( mappedTokens , sToken => Assert . Equal ( SemanticTokenType . Keyword , mappedTokens [ 0 ] . Type ) ) ;
106
+ Assert . Single ( mappedTokens , sToken => SemanticTokenType . Keyword == sToken . Type ) ;
109
107
break ;
110
108
case "Get-A*A" :
111
- Assert . Collection ( mappedTokens , sToken => Assert . Equal ( SemanticTokenType . Function , mappedTokens [ 0 ] . Type ) ) ;
109
+ Assert . Single ( mappedTokens , sToken => SemanticTokenType . Function == sToken . Type ) ;
112
110
break ;
113
111
}
114
112
}
@@ -130,10 +128,10 @@ public async Task RecognizesArrayMemberInExpandableString()
130
128
switch ( t . Text )
131
129
{
132
130
case "$Array" :
133
- Assert . Collection ( mappedTokens , sToken => Assert . Equal ( SemanticTokenType . Variable , mappedTokens [ 0 ] . Type ) ) ;
131
+ Assert . Single ( mappedTokens , sToken => SemanticTokenType . Variable == sToken . Type ) ;
134
132
break ;
135
133
case "Count" :
136
- Assert . Collection ( mappedTokens , sToken => Assert . Equal ( SemanticTokenType . Member , mappedTokens [ 0 ] . Type ) ) ;
134
+ Assert . Single ( mappedTokens , sToken => SemanticTokenType . Member == sToken . Type ) ;
137
135
break ;
138
136
}
139
137
}
@@ -150,11 +148,11 @@ public async Task RecognizesCurlyQuotedString()
150
148
Version . Parse ( "5.0" ) ) ;
151
149
152
150
List < SemanticToken > mappedTokens = new List < SemanticToken > ( PsesSemanticTokensHandler . ConvertToSemanticTokens ( scriptFile . ScriptTokens [ 0 ] ) ) ;
153
- Assert . Collection ( mappedTokens , sToken => Assert . Equal ( SemanticTokenType . String , mappedTokens [ 0 ] . Type ) ) ;
151
+ Assert . Single ( mappedTokens , sToken => SemanticTokenType . String == sToken . Type ) ;
154
152
}
155
153
156
154
[ Fact ]
157
- public async Task RecognizeDoubleQuotedHereString ( )
155
+ public async Task RecognizeEnum ( )
158
156
{
159
157
string text = @"
160
158
enum MyEnum{
@@ -175,13 +173,13 @@ enum MyEnum{
175
173
switch ( t . Text )
176
174
{
177
175
case "enum" :
178
- Assert . Collection ( mappedTokens , sToken => Assert . Equal ( SemanticTokenType . Keyword , mappedTokens [ 0 ] . Type ) ) ;
176
+ Assert . Single ( mappedTokens , sToken => SemanticTokenType . Keyword == sToken . Type ) ;
179
177
break ;
180
178
case "MyEnum" :
181
179
case "one" :
182
180
case "two" :
183
181
case "three" :
184
- Assert . Collection ( mappedTokens , sToken => Assert . Equal ( SemanticTokenType . Member , mappedTokens [ 0 ] . Type ) ) ;
182
+ Assert . Single ( mappedTokens , sToken => SemanticTokenType . Member == sToken . Type ) ;
185
183
break ;
186
184
}
187
185
}
0 commit comments