|
12 | 12 |
|
13 | 13 | import Foundation
|
14 | 14 | import LSPLogging
|
| 15 | +import LSPTestSupport |
15 | 16 | import LanguageServerProtocol
|
16 | 17 | import RegexBuilder
|
17 | 18 | @_spi(Testing) import SKCore
|
| 19 | +import SourceKitLSP |
18 | 20 | import XCTest
|
19 | 21 |
|
20 | 22 | import enum PackageLoading.Platform
|
@@ -105,13 +107,26 @@ public enum SkipUnless {
|
105 | 107 | ) {
|
106 | 108 | let testClient = try await TestSourceKitLSPClient()
|
107 | 109 | let uri = DocumentURI.for(.swift)
|
108 |
| - testClient.openDocument("func test() {}", uri: uri) |
109 |
| - do { |
110 |
| - _ = try await testClient.send(DocumentSemanticTokensRequest(textDocument: TextDocumentIdentifier(uri))) |
111 |
| - } catch let error as ResponseError { |
112 |
| - return !error.message.contains("unknown request: source.request.semantic_tokens") |
113 |
| - } |
114 |
| - return true |
| 110 | + testClient.openDocument("0.bitPattern", uri: uri) |
| 111 | + let response = try unwrap( |
| 112 | + await testClient.send(DocumentSemanticTokensRequest(textDocument: TextDocumentIdentifier(uri))) |
| 113 | + ) |
| 114 | + let tokens = [SyntaxHighlightingToken](lspEncodedTokens: response.data) |
| 115 | + |
| 116 | + // If we don't have semantic token support in sourcekitd, the second token is an identifier based on the syntax |
| 117 | + // tree, not a property. |
| 118 | + return tokens != [ |
| 119 | + SyntaxHighlightingToken( |
| 120 | + range: Position(line: 0, utf16index: 0)..<Position(line: 0, utf16index: 1), |
| 121 | + kind: .number, |
| 122 | + modifiers: [] |
| 123 | + ), |
| 124 | + SourceKitLSP.SyntaxHighlightingToken( |
| 125 | + range: Position(line: 0, utf16index: 2)..<Position(line: 0, utf16index: 12), |
| 126 | + kind: .identifier, |
| 127 | + modifiers: [] |
| 128 | + ), |
| 129 | + ] |
115 | 130 | }
|
116 | 131 | }
|
117 | 132 |
|
|
0 commit comments