Skip to content

Commit 3740394

Browse files
committed
Test semantic tokens for function signatures
1 parent 250228b commit 3740394

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

Tests/SourceKitLSPTests/SemanticTokensTests.swift

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,4 +235,18 @@ final class SemanticTokensTests: XCTestCase {
235235
SemanticToken(start: Position(line: 5, utf16index: 10), length: 1, kind: .interface),
236236
])
237237
}
238+
239+
func testSemanticTokensForFunctionSignatures() {
240+
// Function declarations generate a big token that spans
241+
// the entire function signature.
242+
let text = "func f(x: Int, _ y: String) {}"
243+
let tokens = performSemanticTokensRequest(text: text)
244+
XCTAssertEqual(tokens, [
245+
SemanticToken(start: Position(line: 0, utf16index: 0), length: 4, kind: .keyword),
246+
SemanticToken(start: Position(line: 0, utf16index: 5), length: 22, kind: .function, modifiers: .declaration),
247+
SemanticToken(start: Position(line: 0, utf16index: 10), length: 3, kind: .struct),
248+
SemanticToken(start: Position(line: 0, utf16index: 15), length: 1, kind: .keyword),
249+
SemanticToken(start: Position(line: 0, utf16index: 20), length: 6, kind: .struct),
250+
])
251+
}
238252
}

Tests/SourceKitLSPTests/XCTestManifests.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ extension SemanticTokensTests {
164164
("testRanged", testRanged),
165165
("testSemanticTokens", testSemanticTokens),
166166
("testSemanticTokensForProtocols", testSemanticTokensForProtocols),
167+
("testSemanticTokensForFunctionSignatures", testSemanticTokensForFunctionSignatures),
167168
("testSyntacticTokens", testSyntacticTokens),
168169
]
169170
}

0 commit comments

Comments
 (0)