ide на основе vs code · VibeGit
ide на основе vs code Это ide на основе vs code(code oss), в ней будет встроенный умный апи роутинг, свой маркет с плагинами(агент харнесс, поддержка java/kotlin/мобильной разработки, командная разработка проектов, orca, оркестратор агентов
krutaya-ide-na-osnove-vs-code / extensions / html-language-features / server / src / test / semanticTokens.test.ts 233 строк · изменён 14 нояб., 04:52
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
import { suite, test } from 'node:test' ;
import assert from 'node:assert/strict' ;
import { TextDocument, getLanguageModes, ClientCapabilities, Range, Position } from '../modes/languageModes.js' ;
import { newSemanticTokenProvider } from '../modes/semanticTokens.js' ;
import { getNodeFileFS } from '../node/nodeFs.js' ;
interface ExpectedToken {
startLine: number ;
character: number ;
length: number ;
tokenClassifiction:
lines expected ExpectedToken ranges Range message
document TextDocument lines
workspace
settings
folders name uri
languageModes css javascript workspace ClientCapabilities
semanticTokensProvider languageModes
legend semanticTokensProvider legend
actual semanticTokensProvider document ranges
actualRanges
lastLine
lastCharacter
i i actual length i
lineDelta actual i charDelta actual i len actual i typeIdx actual i modSet actual i
line lastLine lineDelta
character lineDelta lastCharacter charDelta charDelta
tokenClassifiction legend types typeIdx legend modifiers _ i modSet i
actualRanges line character len tokenClassifiction
lastLine line
lastCharacter character
assert actualRanges expected message
languageModes
startLine character length tokenClassifiction ExpectedToken
startLine character length tokenClassifiction
input
input
input
input
input
input
input
input
input
input
input
input
input
input
input
input
Range Position Position
input
Range Position Position
string
;
}
async
function
assertTokens
(
:
string
[
]
,
:
[
]
,
?
:
[
]
,
?
:
string
)
:
Promise
<
void
>
{
const
=
.
create
(
'test://foo/bar.html'
,
'html'
,
1
,
.
join
(
'\n'
)
)
;
const
=
{
:
{
}
,
:
[
{
:
'foo'
,
:
'test://foo'
}
]
}
;
const
=
getLanguageModes
(
{
:
true
,
:
true
}
,
,
.
LATEST
,
getNodeFileFS
(
)
)
;
const
=
newSemanticTokenProvider
(
)
;
try
{
const
=
.
;
const
=
await
.
getSemanticTokens
(
,
)
;
const
=
[
]
;
let
=
0
;
let
=
0
;
for
(
let
=
0
;
<
.
;
+=
5
)
{
const
=
[
]
,
=
[
+
1
]
,
=
[
+
2
]
,
=
[
+
3
]
,
=
[
+
4
]
;
const
=
+
;
const
=
===
0
?
+
:
;
const
=
[
.
[
]
,
...
.
.
filter
(
(
,
)
=>
&
1
<<
)
]
.
join
(
'.'
)
;
.
push
(
t
(
,
,
,
)
)
;
=
;
=
;
}
.
deepStrictEqual
(
,
,
)
;
}
finally
{
.
dispose
(
)
;
}
}
function
t
(
:
number
,
:
number
,
:
number
,
:
string
)
:
{
return
{
,
,
,
}
;
}
suite
(
'HTML Semantic Tokens'
,
(
)
=>
{
test
(
'Variables'
,
async
(
)
=>
{
const
=
[
'<html>'
,
'<head>'
,
'<script>'
,
' var x = 9, y1 = [x];'
,
' try {'
,
' for (const s of y1) { x = s }'
,
' } catch (e) {'
,
' throw y1;'
,
' }'
,
'</script>'
,
'</head>'
,
'</html>'
,
]
;
await
assertTokens
(
,
[
t
(
3
,
6
,
1
,
'variable.declaration'
)
,
t
(
3
,
13
,
2
,
'variable.declaration'
)
,
t
(
3
,
19
,
1
,
'variable'
)
,
t
(
5
,
15
,
1
,
'variable.declaration.readonly.local'
)
,
t
(
5
,
20
,
2
,
'variable'
)
,
t
(
5
,
26
,
1
,
'variable'
)
,
t
(
5
,
30
,
1
,
'variable.readonly.local'
)
,
t
(
6
,
11
,
1
,
'variable.declaration.local'
)
,
t
(
7
,
10
,
2
,
'variable'
)
]
)
;
}
)
;
test
(
'Functions'
,
async
(
)
=>
{
const
=
[
'<html>'
,
'<head>'
,
'<script>'
,
' function foo(p1) {'
,
' return foo(Math.abs(p1))'
,
' }'
,
' `/${window.location}`.split("/").forEach(s => foo(s));'
,
'</script>'
,
'</head>'
,
'</html>'
,
]
;
await
assertTokens
(
,
[
t
(
3
,
11
,
3
,
'function.declaration'
)
,
t
(
3
,
15
,
2
,
'parameter.declaration'
)
,
t
(
4
,
11
,
3
,
'function'
)
,
t
(
4
,
15
,
4
,
'variable.defaultLibrary'
)
,
t
(
4
,
20
,
3
,
'method.defaultLibrary'
)
,
t
(
4
,
24
,
2
,
'parameter'
)
,
t
(
6
,
6
,
6
,
'variable.defaultLibrary'
)
,
t
(
6
,
13
,
8
,
'property.defaultLibrary'
)
,
t
(
6
,
24
,
5
,
'method.defaultLibrary'
)
,
t
(
6
,
35
,
7
,
'method.defaultLibrary'
)
,
t
(
6
,
43
,
1
,
'parameter.declaration'
)
,
t
(
6
,
48
,
3
,
'function'
)
,
t
(
6
,
52
,
1
,
'parameter'
)
]
)
;
}
)
;
test
(
'Members'
,
async
(
)
=>
{
const
=
[
'<html>'
,
'<head>'
,
'<script>'
,
' class A {'
,
' static x = 9;'
,
' f = 9;'
,
' async m() { return A.x + await this.m(); };'
,
' get s() { return this.f; '
,
' static t() { return new A().f; };'
,
' constructor() {}'
,
' }'
,
'</script>'
,
'</head>'
,
'</html>'
,
]
;
await
assertTokens
(
,
[
t
(
3
,
8
,
1
,
'class.declaration'
)
,
t
(
4
,
11
,
1
,
'property.declaration.static'
)
,
t
(
5
,
4
,
1
,
'property.declaration'
)
,
t
(
6
,
10
,
1
,
'method.declaration.async'
)
,
t
(
6
,
23
,
1
,
'class'
)
,
t
(
6
,
25
,
1
,
'property.static'
)
,
t
(
6
,
40
,
1
,
'method.async'
)
,
t
(
7
,
8
,
1
,
'property.declaration'
)
,
t
(
7
,
26
,
1
,
'property'
)
,
t
(
8
,
11
,
1
,
'method.declaration.static'
)
,
t
(
8
,
28
,
1
,
'class'
)
,
t
(
8
,
32
,
1
,
'property'
)
,
]
)
;
}
)
;
test
(
'Interfaces'
,
async
(
)
=>
{
const
=
[
'<html>'
,
'<head>'
,
'<script type="text/typescript">'
,
' interface Position { x: number, y: number };'
,
' const p = { x: 1, y: 2 } as Position;'
,
' const foo = (o: Position) => o.x + o.y;'
,
'</script>'
,
'</head>'
,
'</html>'
,
]
;
await
assertTokens
(
,
[
t
(
3
,
12
,
8
,
'interface.declaration'
)
,
t
(
3
,
23
,
1
,
'property.declaration'
)
,
t
(
3
,
34
,
1
,
'property.declaration'
)
,
t
(
4
,
8
,
1
,
'variable.declaration.readonly'
)
,
t
(
4
,
14
,
1
,
'property.declaration'
)
,
t
(
4
,
20
,
1
,
'property.declaration'
)
,
t
(
4
,
30
,
8
,
'interface'
)
,
t
(
5
,
8
,
3
,
'function.declaration.readonly'
)
,
t
(
5
,
15
,
1
,
'parameter.declaration'
)
,
t
(
5
,
18
,
8
,
'interface'
)
,
t
(
5
,
31
,
1
,
'parameter'
)
,
t
(
5
,
33
,
1
,
'property'
)
,
t
(
5
,
37
,
1
,
'parameter'
)
,
t
(
5
,
39
,
1
,
'property'
)
]
)
;
}
)
;
test
(
'Readonly'
,
async
(
)
=>
{
const
=
[
'<html>'
,
'<head>'
,
'<script type="text/typescript">'
,
' const f = 9;'
,
' class A { static readonly t = 9; static url: URL; }'
,
' const enum E { A = 9, B = A + 1 }'
,
' console.log(f + A.t + A.url.origin);'
,
'</script>'
,
'</head>'
,
'</html>'
,
]
;
await
assertTokens
(
,
[
t
(
3
,
8
,
1
,
'variable.declaration.readonly'
)
,
t
(
4
,
8
,
1
,
'class.declaration'
)
,
t
(
4
,
28
,
1
,
'property.declaration.static.readonly'
)
,
t
(
4
,
42
,
3
,
'property.declaration.static'
)
,
t
(
4
,
47
,
3
,
'interface.defaultLibrary'
)
,
t
(
5
,
13
,
1
,
'enum.declaration'
)
,
t
(
5
,
17
,
1
,
'enumMember.declaration.readonly'
)
,
t
(
5
,
24
,
1
,
'enumMember.declaration.readonly'
)
,
t
(
5
,
28
,
1
,
'enumMember.readonly'
)
,
t
(
6
,
2
,
7
,
'variable.defaultLibrary'
)
,
t
(
6
,
10
,
3
,
'method.defaultLibrary'
)
,
t
(
6
,
14
,
1
,
'variable.readonly'
)
,
t
(
6
,
18
,
1
,
'class'
)
,
t
(
6
,
20
,
1
,
'property.static.readonly'
)
,
t
(
6
,
24
,
1
,
'class'
)
,
t
(
6
,
26
,
3
,
'property.static'
)
,
t
(
6
,
30
,
6
,
'property.readonly.defaultLibrary'
)
,
]
)
;
}
)
;
test
(
'Type aliases and type parameters'
,
async
(
)
=>
{
const
=
[
'<html>'
,
'<head>'
,
'<script type="text/typescript">'
,
' type MyMap = Map<string, number>;'
,
' function f<T extends MyMap>(t: T | number) : T { '
,
' return <T> <unknown> new Map<string, MyMap>();'
,
' }'
,
'</script>'
,
'</head>'
,
'</html>'
,
]
;
await
assertTokens
(
,
[
t
(
3
,
7
,
5
,
'type.declaration'
)
,
t
(
3
,
15
,
3
,
'interface.defaultLibrary'
)
,
t
(
4
,
11
,
1
,
'function.declaration'
)
,
t
(
4
,
13
,
1
,
'typeParameter.declaration'
)
,
t
(
4
,
23
,
5
,
'type'
)
,
t
(
4
,
30
,
1
,
'parameter.declaration'
)
,
t
(
4
,
33
,
1
,
'typeParameter'
)
,
t
(
4
,
47
,
1
,
'typeParameter'
)
,
t
(
5
,
12
,
1
,
'typeParameter'
)
,
t
(
5
,
29
,
3
,
'class.defaultLibrary'
)
,
t
(
5
,
41
,
5
,
'type'
)
,
]
)
;
}
)
;
test
(
'TS and JS'
,
async
(
)
=>
{
const
=
[
'<html>'
,
'<head>'
,
'<script type="text/typescript">'
,
' function f<T>(p1: T): T[] { return [ p1 ]; }'
,
'</script>'
,
'<script>'
,
' window.alert("Hello");'
,
'</script>'
,
'</head>'
,
'</html>'
,
]
;
await
assertTokens
(
,
[
t
(
3
,
11
,
1
,
'function.declaration'
)
,
t
(
3
,
13
,
1
,
'typeParameter.declaration'
)
,
t
(
3
,
16
,
2
,
'parameter.declaration'
)
,
t
(
3
,
20
,
1
,
'typeParameter'
)
,
t
(
3
,
24
,
1
,
'typeParameter'
)
,
t
(
3
,
39
,
2
,
'parameter'
)
,
t
(
6
,
2
,
6
,
'variable.defaultLibrary'
)
,
t
(
6
,
9
,
5
,
'method.defaultLibrary'
)
]
)
;
}
)
;
test
(
'Ranges'
,
async
(
)
=>
{
const
=
[
'<html>'
,
'<head>'
,
'<script>'
,
' window.alert("Hello");'
,
'</script>'
,
'<script>'
,
' window.alert("World");'
,
'</script>'
,
'</head>'
,
'</html>'
,
]
;
await
assertTokens
(
,
[
t
(
3
,
2
,
6
,
'variable.defaultLibrary'
)
,
t
(
3
,
9
,
5
,
'method.defaultLibrary'
)
]
,
[
.
create
(
.
create
(
2
,
0
)
,
.
create
(
4
,
0
)
)
]
)
;
await
assertTokens
(
,
[
t
(
6
,
2
,
6
,
'variable.defaultLibrary'
)
,
]
,
[
.
create
(
.
create
(
6
,
2
)
,
.
create
(
6
,
8
)
)
]
)
;
}
)
;
}
)
;