@@ -117,33 +117,25 @@ final class SemanticTokensTests: XCTestCase {
117
117
}
118
118
119
119
private func performSemanticTokensRequest( range: Range < Position > ? = nil ) async throws -> [ Token ] {
120
- let response : DocumentSemanticTokensResponse !
120
+ do {
121
+ let response : DocumentSemanticTokensResponse !
121
122
122
- if let range = range {
123
- response = try await testClient. send (
124
- DocumentSemanticTokensRangeRequest (
125
- textDocument: TextDocumentIdentifier ( uri) ,
126
- range: range
123
+ if let range = range {
124
+ response = try await testClient. send (
125
+ DocumentSemanticTokensRangeRequest (
126
+ textDocument: TextDocumentIdentifier ( uri) ,
127
+ range: range
128
+ )
127
129
)
128
- )
129
- } else {
130
- response = try await testClient . send (
131
- DocumentSemanticTokensRequest (
132
- textDocument : TextDocumentIdentifier ( uri )
130
+ } else {
131
+ response = try await testClient . send (
132
+ DocumentSemanticTokensRequest (
133
+ textDocument : TextDocumentIdentifier ( uri )
134
+ )
133
135
)
134
- )
135
- }
136
-
137
- return [ Token] ( lspEncodedTokens: response. data)
138
- }
136
+ }
139
137
140
- private func openAndPerformSemanticTokensRequest(
141
- text: String ,
142
- range: Range < Position > ? = nil
143
- ) async throws -> [ Token ] {
144
- openDocument ( text: text)
145
- do {
146
- return try await performSemanticTokensRequest ( range: range)
138
+ return [ Token] ( lspEncodedTokens: response. data)
147
139
} catch let error as ResponseError {
148
140
// FIXME: Remove when the semantic tokens request is widely available in sourcekitd
149
141
if error. message. contains ( " unknown request: source.request.semantic_tokens " ) {
@@ -154,6 +146,14 @@ final class SemanticTokensTests: XCTestCase {
154
146
}
155
147
}
156
148
149
+ private func openAndPerformSemanticTokensRequest(
150
+ text: String ,
151
+ range: Range < Position > ? = nil
152
+ ) async throws -> [ Token ] {
153
+ openDocument ( text: text)
154
+ return try await performSemanticTokensRequest ( range: range)
155
+ }
156
+
157
157
func testIntArrayCoding( ) {
158
158
let tokens = [
159
159
Token (
0 commit comments