Skip to content

Commit 0540e51

Browse files
authored
Merge pull request swiftlang#2200 from hamishknight/add-test-6.2
[6.2] Add test case for raw identifier semantic tokens
2 parents 1c49cf1 + 2b19235 commit 0540e51

File tree

5 files changed

+48
-12
lines changed

5 files changed

+48
-12
lines changed

Sources/SemanticIndex/PreparationTaskDescription.swift

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,10 @@ package struct PreparationTaskDescription: IndexTaskDescription {
6363
targetsToPrepare: [BuildTargetIdentifier],
6464
buildSystemManager: BuildSystemManager,
6565
preparationUpToDateTracker: UpToDateTracker<BuildTargetIdentifier, DummySecondaryKey>,
66-
logMessageToIndexLog: @escaping @Sendable (
67-
_ message: String, _ type: WindowMessageType, _ structure: StructuredLogKind
68-
) -> Void,
66+
logMessageToIndexLog:
67+
@escaping @Sendable (
68+
_ message: String, _ type: WindowMessageType, _ structure: StructuredLogKind
69+
) -> Void,
6970
hooks: IndexHooks
7071
) {
7172
self.targetsToPrepare = targetsToPrepare

Sources/SemanticIndex/SemanticIndexManager.swift

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -261,9 +261,10 @@ package final actor SemanticIndexManager {
261261
updateIndexStoreTimeout: Duration,
262262
hooks: IndexHooks,
263263
indexTaskScheduler: TaskScheduler<AnyIndexTaskDescription>,
264-
logMessageToIndexLog: @escaping @Sendable (
265-
_ message: String, _ type: WindowMessageType, _ structure: StructuredLogKind
266-
) -> Void,
264+
logMessageToIndexLog:
265+
@escaping @Sendable (
266+
_ message: String, _ type: WindowMessageType, _ structure: StructuredLogKind
267+
) -> Void,
267268
indexTasksWereScheduled: @escaping @Sendable (Int) -> Void,
268269
indexProgressStatusDidChange: @escaping @Sendable () -> Void
269270
) {

Sources/SemanticIndex/UpdateIndexStoreTaskDescription.swift

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,9 +146,10 @@ package struct UpdateIndexStoreTaskDescription: IndexTaskDescription {
146146
index: UncheckedIndex,
147147
indexStoreUpToDateTracker: UpToDateTracker<DocumentURI, BuildTargetIdentifier>,
148148
indexFilesWithUpToDateUnit: Bool,
149-
logMessageToIndexLog: @escaping @Sendable (
150-
_ message: String, _ type: WindowMessageType, _ structure: StructuredLogKind
151-
) -> Void,
149+
logMessageToIndexLog:
150+
@escaping @Sendable (
151+
_ message: String, _ type: WindowMessageType, _ structure: StructuredLogKind
152+
) -> Void,
152153
timeout: Duration,
153154
hooks: IndexHooks
154155
) {

Sources/SourceKitLSP/SourceKitLSPServer.swift

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -390,9 +390,10 @@ package actor SourceKitLSPServer {
390390

391391
private func handleRequest<RequestType: TextDocumentRequest>(
392392
for request: RequestAndReply<RequestType>,
393-
requestHandler: @Sendable @escaping (
394-
RequestType, Workspace, LanguageService
395-
) async throws ->
393+
requestHandler:
394+
@Sendable @escaping (
395+
RequestType, Workspace, LanguageService
396+
) async throws ->
396397
RequestType.Response
397398
) async {
398399
await request.reply {

Tests/SourceKitLSPTests/SemanticTokensTests.swift

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -881,6 +881,38 @@ 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+
)
896+
try await assertSemanticTokens(
897+
markedContents: """
898+
1️⃣struct 2️⃣S {
899+
3️⃣static 4️⃣var 5️⃣`foo bar` = 6️⃣0
900+
}
901+
7️⃣S.8️⃣`foo bar`
902+
""",
903+
expected: [
904+
TokenSpec(marker: "1️⃣", length: 6, kind: .keyword),
905+
TokenSpec(marker: "2️⃣", length: 1, kind: .identifier),
906+
TokenSpec(marker: "3️⃣", length: 6, kind: .keyword),
907+
TokenSpec(marker: "4️⃣", length: 3, kind: .keyword),
908+
TokenSpec(marker: "5️⃣", length: 9, kind: .identifier),
909+
TokenSpec(marker: "6️⃣", length: 1, kind: .number),
910+
TokenSpec(marker: "7️⃣", length: 1, kind: .struct),
911+
TokenSpec(marker: "8️⃣", length: 9, kind: .property),
912+
]
913+
)
914+
}
915+
884916
func testClang() async throws {
885917
try await assertSemanticTokens(
886918
markedContents: """

0 commit comments

Comments
 (0)