Skip to content

Commit 5b93c16

Browse files
committed
Update semantic token test case
1 parent abbd963 commit 5b93c16

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

Tests/SourceKitLSPTests/SemanticTokensTests.swift

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,10 @@ final class SemanticTokensTests: XCTestCase {
102102
let tokens = performSemanticTokensRequest(text: text, range: start..<end)
103103
XCTAssertEqual(tokens, [
104104
SemanticToken(start: Position(line: 1, utf16index: 0), length: 3, kind: .keyword),
105+
SemanticToken(start: Position(line: 1, utf16index: 4), length: 1, kind: .variable, modifiers: .declaration),
105106
SemanticToken(start: Position(line: 1, utf16index: 8), length: 1, kind: .number),
106107
SemanticToken(start: Position(line: 2, utf16index: 0), length: 3, kind: .keyword),
108+
SemanticToken(start: Position(line: 2, utf16index: 4), length: 1, kind: .variable, modifiers: .declaration),
107109
])
108110
}
109111

@@ -151,9 +153,11 @@ final class SemanticTokensTests: XCTestCase {
151153
XCTAssertEqual(tokens, [
152154
// let x = 3
153155
SemanticToken(start: Position(line: 0, utf16index: 0), length: 3, kind: .keyword),
156+
SemanticToken(start: Position(line: 0, utf16index: 4), length: 1, kind: .variable, modifiers: .declaration),
154157
SemanticToken(start: Position(line: 0, utf16index: 8), length: 1, kind: .number),
155158
// var y = "test"
156159
SemanticToken(start: Position(line: 1, utf16index: 0), length: 3, kind: .keyword),
160+
SemanticToken(start: Position(line: 1, utf16index: 4), length: 1, kind: .variable, modifiers: .declaration),
157161
SemanticToken(start: Position(line: 1, utf16index: 8), length: 6, kind: .string),
158162
// /* abc */ // 123
159163
SemanticToken(start: Position(line: 2, utf16index: 0), length: 9, kind: .comment),
@@ -178,17 +182,22 @@ final class SemanticTokensTests: XCTestCase {
178182
XCTAssertEqual(tokens, [
179183
// struct X {}
180184
SemanticToken(start: Position(line: 0, utf16index: 0), length: 6, kind: .keyword),
185+
SemanticToken(start: Position(line: 0, utf16index: 7), length: 1, kind: .struct, modifiers: .declaration),
181186
// let x = X()
182187
SemanticToken(start: Position(line: 2, utf16index: 0), length: 3, kind: .keyword),
188+
SemanticToken(start: Position(line: 2, utf16index: 4), length: 1, kind: .variable, modifiers: .declaration),
183189
SemanticToken(start: Position(line: 2, utf16index: 8), length: 1, kind: .struct),
184190
// let y = x + x
185191
SemanticToken(start: Position(line: 3, utf16index: 0), length: 3, kind: .keyword),
192+
SemanticToken(start: Position(line: 3, utf16index: 4), length: 1, kind: .variable, modifiers: .declaration),
186193
SemanticToken(start: Position(line: 3, utf16index: 8), length: 1, kind: .variable),
187194
SemanticToken(start: Position(line: 3, utf16index: 12), length: 1, kind: .variable),
188195
// func a() {}
189196
SemanticToken(start: Position(line: 5, utf16index: 0), length: 4, kind: .keyword),
197+
SemanticToken(start: Position(line: 5, utf16index: 5), length: 3, kind: .function, modifiers: .declaration),
190198
// let b = {}
191199
SemanticToken(start: Position(line: 6, utf16index: 0), length: 3, kind: .keyword),
200+
SemanticToken(start: Position(line: 6, utf16index: 4), length: 1, kind: .variable, modifiers: .declaration),
192201
// a()
193202
SemanticToken(start: Position(line: 8, utf16index: 0), length: 1, kind: .function),
194203
// b()
@@ -209,15 +218,20 @@ final class SemanticTokensTests: XCTestCase {
209218
XCTAssertEqual(tokens, [
210219
// protocol X {}
211220
SemanticToken(start: Position(line: 0, utf16index: 0), length: 8, kind: .keyword),
221+
SemanticToken(start: Position(line: 0, utf16index: 9), length: 1, kind: .interface, modifiers: .declaration),
212222
// class Y: X {}
213223
SemanticToken(start: Position(line: 1, utf16index: 0), length: 5, kind: .keyword),
224+
SemanticToken(start: Position(line: 1, utf16index: 6), length: 1, kind: .class, modifiers: .declaration),
214225
SemanticToken(start: Position(line: 1, utf16index: 9), length: 1, kind: .interface),
215226
// let y: Y = X()
216227
SemanticToken(start: Position(line: 3, utf16index: 0), length: 3, kind: .keyword),
228+
SemanticToken(start: Position(line: 3, utf16index: 4), length: 1, kind: .variable, modifiers: .declaration),
217229
SemanticToken(start: Position(line: 3, utf16index: 7), length: 1, kind: .class),
218230
SemanticToken(start: Position(line: 3, utf16index: 11), length: 1, kind: .interface),
219231
// func f<T: X>() {}
220232
SemanticToken(start: Position(line: 5, utf16index: 0), length: 4, kind: .keyword),
233+
SemanticToken(start: Position(line: 5, utf16index: 5), length: 9, kind: .function, modifiers: .declaration),
234+
SemanticToken(start: Position(line: 5, utf16index: 7), length: 1, kind: .typeParameter, modifiers: .declaration),
221235
SemanticToken(start: Position(line: 5, utf16index: 10), length: 1, kind: .interface),
222236
])
223237
}

0 commit comments

Comments
 (0)