@@ -54,9 +54,9 @@ final class SemanticTokensTests: XCTestCase {
54
54
55
55
// We wait for the first refresh request to make sure that the semantic tokens are ready
56
56
57
- let expectation = XCTestExpectation ( description: " performSemanticTokensRequest - refresh received " )
57
+ let refreshExpectation = expectation ( description: " performSemanticTokensRequest - refresh received " )
58
58
sk. handleNextRequest { ( req: Request < WorkspaceSemanticTokensRefreshRequest > ) in
59
- expectation . fulfill ( )
59
+ refreshExpectation . fulfill ( )
60
60
req. reply ( VoidResponse ( ) )
61
61
}
62
62
@@ -67,10 +67,7 @@ final class SemanticTokensTests: XCTestCase {
67
67
text: text
68
68
) ) )
69
69
70
- let waitResult = XCTWaiter . wait ( for: [ expectation] , timeout: 15 )
71
- if waitResult != . completed {
72
- fatalError ( " error \( waitResult) while waiting for semantic token refresh " )
73
- }
70
+ wait ( for: [ refreshExpectation] , timeout: 15 )
74
71
75
72
let textDocument = TextDocumentIdentifier ( url)
76
73
let response : DocumentSemanticTokensResponse !
@@ -84,31 +81,6 @@ final class SemanticTokensTests: XCTestCase {
84
81
return [ SyntaxHighlightingToken] ( lspEncodedTokens: response. data)
85
82
}
86
83
87
- func testEmpty( ) {
88
- let text = " "
89
- let tokens = performSemanticTokensRequest ( text: text)
90
- XCTAssertEqual ( tokens, [ ] )
91
- }
92
-
93
- func testRanged( ) {
94
- let text = """
95
- let x = 1
96
- let y = 2
97
- let z = 3
98
- let w = 4
99
- """
100
- let start = Position ( line: 1 , utf16index: 0 )
101
- let end = Position ( line: 2 , utf16index: 5 )
102
- let tokens = performSemanticTokensRequest ( text: text, range: start..< end)
103
- XCTAssertEqual ( tokens, [
104
- SyntaxHighlightingToken ( start: Position ( line: 1 , utf16index: 0 ) , length: 3 , kind: . keyword) ,
105
- SyntaxHighlightingToken ( start: Position ( line: 1 , utf16index: 4 ) , length: 1 , kind: . variable, modifiers: . declaration) ,
106
- SyntaxHighlightingToken ( start: Position ( line: 1 , utf16index: 8 ) , length: 1 , kind: . number) ,
107
- SyntaxHighlightingToken ( start: Position ( line: 2 , utf16index: 0 ) , length: 3 , kind: . keyword) ,
108
- SyntaxHighlightingToken ( start: Position ( line: 2 , utf16index: 4 ) , length: 1 , kind: . variable, modifiers: . declaration) ,
109
- ] )
110
- }
111
-
112
84
func testIntArrayCoding( ) {
113
85
let tokens = [
114
86
SyntaxHighlightingToken (
@@ -143,6 +115,31 @@ final class SemanticTokensTests: XCTestCase {
143
115
XCTAssertEqual ( decoded, tokens)
144
116
}
145
117
118
+ func testEmpty( ) {
119
+ let text = " "
120
+ let tokens = performSemanticTokensRequest ( text: text)
121
+ XCTAssertEqual ( tokens, [ ] )
122
+ }
123
+
124
+ func testRanged( ) {
125
+ let text = """
126
+ let x = 1
127
+ let test = 20
128
+ let abc = 333
129
+ let y = 4
130
+ """
131
+ let start = Position ( line: 1 , utf16index: 0 )
132
+ let end = Position ( line: 2 , utf16index: 5 )
133
+ let tokens = performSemanticTokensRequest ( text: text, range: start..< end)
134
+ XCTAssertEqual ( tokens, [
135
+ SyntaxHighlightingToken ( start: Position ( line: 1 , utf16index: 0 ) , length: 3 , kind: . keyword) ,
136
+ SyntaxHighlightingToken ( start: Position ( line: 1 , utf16index: 4 ) , length: 4 , kind: . variable, modifiers: . declaration) ,
137
+ SyntaxHighlightingToken ( start: Position ( line: 1 , utf16index: 11 ) , length: 2 , kind: . number) ,
138
+ SyntaxHighlightingToken ( start: Position ( line: 2 , utf16index: 0 ) , length: 3 , kind: . keyword) ,
139
+ SyntaxHighlightingToken ( start: Position ( line: 2 , utf16index: 4 ) , length: 3 , kind: . variable, modifiers: . declaration) ,
140
+ ] )
141
+ }
142
+
146
143
func testSyntacticTokens( ) {
147
144
let text = """
148
145
let x = 3
0 commit comments