Skip to content

Commit c6a0f86

Browse files
committed
Add test case for raw identifier semantic tokens
1 parent d8a2a24 commit c6a0f86

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

Tests/SourceKitLSPTests/SemanticTokensTests.swift

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -881,6 +881,37 @@ final class SemanticTokensTests: XCTestCase {
881881
)
882882
}
883883

884+
func testRawIdentifier() async throws {
885+
try await assertSemanticTokens(
886+
markedContents: """
887+
1️⃣func 2️⃣`square returns x * x`() {}
888+
3️⃣`square returns x * x`()
889+
""",
890+
expected: [
891+
TokenSpec(marker: "1️⃣", length: 4, kind: .keyword),
892+
TokenSpec(marker: "2️⃣", length: 22, kind: .identifier),
893+
TokenSpec(marker: "3️⃣", length: 22, kind: .function),
894+
])
895+
try await assertSemanticTokens(
896+
markedContents: """
897+
1️⃣struct 2️⃣S {
898+
3️⃣static 4️⃣var 5️⃣`foo bar` = 6️⃣0
899+
}
900+
7️⃣S.8️⃣`foo bar`
901+
""",
902+
expected: [
903+
TokenSpec(marker: "1️⃣", length: 6, kind: .keyword),
904+
TokenSpec(marker: "2️⃣", length: 1, kind: .identifier),
905+
TokenSpec(marker: "3️⃣", length: 6, kind: .keyword),
906+
TokenSpec(marker: "4️⃣", length: 3, kind: .keyword),
907+
TokenSpec(marker: "5️⃣", length: 9, kind: .identifier),
908+
TokenSpec(marker: "6️⃣", length: 1, kind: .number),
909+
TokenSpec(marker: "7️⃣", length: 1, kind: .struct),
910+
TokenSpec(marker: "8️⃣", length: 9, kind: .property),
911+
]
912+
)
913+
}
914+
884915
func testClang() async throws {
885916
try await assertSemanticTokens(
886917
markedContents: """

0 commit comments

Comments
 (0)