@@ -23,6 +23,7 @@ final class SwiftCompletionTests: XCTestCase {
23
23
/// Base document text to use for completion tests.
24
24
let text : String = """
25
25
struct S {
26
+ /// Documentation for `abc`.
26
27
var abc: Int
27
28
28
29
func test(a: Int) {
@@ -103,7 +104,7 @@ final class SwiftCompletionTests: XCTestCase {
103
104
104
105
let selfDot = try ! sk. sendSync ( CompletionRequest (
105
106
textDocument: TextDocumentIdentifier ( url) ,
106
- position: Position ( line: 4 , utf16index: 9 ) ) )
107
+ position: Position ( line: 5 , utf16index: 9 ) ) )
107
108
108
109
XCTAssertEqual ( selfDot. isIncomplete, options. serverSideFiltering)
109
110
XCTAssertGreaterThanOrEqual ( selfDot. items. count, 2 )
@@ -112,16 +113,17 @@ final class SwiftCompletionTests: XCTestCase {
112
113
if let abc = abc {
113
114
XCTAssertEqual ( abc. kind, . property)
114
115
XCTAssertEqual ( abc. detail, " Int " )
116
+ XCTAssertEqual ( abc. documentation, . markupContent( MarkupContent ( kind: . markdown, value: " Documentation for abc. " ) ) )
115
117
XCTAssertEqual ( abc. filterText, " abc " )
116
- XCTAssertEqual ( abc. textEdit, TextEdit ( range: Position ( line: 4 , utf16index: 9 ) ..< Position ( line: 4 , utf16index: 9 ) , newText: " abc " ) )
118
+ XCTAssertEqual ( abc. textEdit, TextEdit ( range: Position ( line: 5 , utf16index: 9 ) ..< Position ( line: 5 , utf16index: 9 ) , newText: " abc " ) )
117
119
XCTAssertEqual ( abc. insertText, " abc " )
118
120
XCTAssertEqual ( abc. insertTextFormat, . plain)
119
121
}
120
122
121
123
for col in 10 ... 12 {
122
124
let inIdent = try ! sk. sendSync ( CompletionRequest (
123
125
textDocument: TextDocumentIdentifier ( url) ,
124
- position: Position ( line: 4 , utf16index: col) ) )
126
+ position: Position ( line: 5 , utf16index: col) ) )
125
127
guard let abc = inIdent. items. first ( where: { $0. label == " abc " } ) else {
126
128
XCTFail ( " No completion item with label 'abc' " )
127
129
return
@@ -130,15 +132,16 @@ final class SwiftCompletionTests: XCTestCase {
130
132
// If we switch to server-side filtering this will change.
131
133
XCTAssertEqual ( abc. kind, . property)
132
134
XCTAssertEqual ( abc. detail, " Int " )
135
+ XCTAssertEqual ( abc. documentation, . markupContent( MarkupContent ( kind: . markdown, value: " Documentation for abc. " ) ) )
133
136
XCTAssertEqual ( abc. filterText, " abc " )
134
- XCTAssertEqual ( abc. textEdit, TextEdit ( range: Position ( line: 4 , utf16index: 9 ) ..< Position ( line: 4 , utf16index: col) , newText: " abc " ) )
137
+ XCTAssertEqual ( abc. textEdit, TextEdit ( range: Position ( line: 5 , utf16index: 9 ) ..< Position ( line: 5 , utf16index: col) , newText: " abc " ) )
135
138
XCTAssertEqual ( abc. insertText, " abc " )
136
139
XCTAssertEqual ( abc. insertTextFormat, . plain)
137
140
}
138
141
139
142
let after = try ! sk. sendSync ( CompletionRequest (
140
143
textDocument: TextDocumentIdentifier ( url) ,
141
- position: Position ( line: 5 , utf16index: 0 ) ) )
144
+ position: Position ( line: 6 , utf16index: 0 ) ) )
142
145
XCTAssertNotEqual ( after, selfDot)
143
146
}
144
147
@@ -158,11 +161,11 @@ final class SwiftCompletionTests: XCTestCase {
158
161
}
159
162
160
163
func getTestMethodACompletion( ) -> CompletionItem ? {
161
- return getTestMethodCompletion ( Position ( line: 4 , utf16index: 9 ) , label: " test(a: Int) " )
164
+ return getTestMethodCompletion ( Position ( line: 5 , utf16index: 9 ) , label: " test(a: Int) " )
162
165
}
163
166
164
167
func getTestMethodBCompletion( ) -> CompletionItem ? {
165
- return getTestMethodCompletion ( Position ( line: 8 , utf16index: 9 ) , label: " test(b: Int) " )
168
+ return getTestMethodCompletion ( Position ( line: 9 , utf16index: 9 ) , label: " test(b: Int) " )
166
169
}
167
170
168
171
var test = getTestMethodACompletion ( )
@@ -171,7 +174,7 @@ final class SwiftCompletionTests: XCTestCase {
171
174
XCTAssertEqual ( test. kind, . method)
172
175
XCTAssertEqual ( test. detail, " Void " )
173
176
XCTAssertEqual ( test. filterText, " test(a:) " )
174
- XCTAssertEqual ( test. textEdit, TextEdit ( range: Position ( line: 4 , utf16index: 9 ) ..< Position ( line: 4 , utf16index: 9 ) , newText: " test(a: ${1:Int}) " ) )
177
+ XCTAssertEqual ( test. textEdit, TextEdit ( range: Position ( line: 5 , utf16index: 9 ) ..< Position ( line: 5 , utf16index: 9 ) , newText: " test(a: ${1:Int}) " ) )
175
178
XCTAssertEqual ( test. insertText, " test(a: ${1:Int}) " )
176
179
XCTAssertEqual ( test. insertTextFormat, . snippet)
177
180
}
@@ -182,7 +185,7 @@ final class SwiftCompletionTests: XCTestCase {
182
185
XCTAssertEqual ( test. kind, . method)
183
186
XCTAssertEqual ( test. detail, " Void " )
184
187
XCTAssertEqual ( test. filterText, " test(:) " )
185
- XCTAssertEqual ( test. textEdit, TextEdit ( range: Position ( line: 8 , utf16index: 9 ) ..< Position ( line: 8 , utf16index: 9 ) , newText: " test(${1:b: Int}) " ) )
188
+ XCTAssertEqual ( test. textEdit, TextEdit ( range: Position ( line: 9 , utf16index: 9 ) ..< Position ( line: 9 , utf16index: 9 ) , newText: " test(${1:b: Int}) " ) )
186
189
XCTAssertEqual ( test. insertText, " test(${1:b: Int}) " )
187
190
XCTAssertEqual ( test. insertTextFormat, . snippet)
188
191
}
@@ -198,7 +201,7 @@ final class SwiftCompletionTests: XCTestCase {
198
201
XCTAssertEqual ( test. kind, . method)
199
202
XCTAssertEqual ( test. detail, " Void " )
200
203
XCTAssertEqual ( test. filterText, " test(a:) " )
201
- XCTAssertEqual ( test. textEdit, TextEdit ( range: Position ( line: 4 , utf16index: 9 ) ..< Position ( line: 4 , utf16index: 9 ) , newText: " test(a: ) " ) )
204
+ XCTAssertEqual ( test. textEdit, TextEdit ( range: Position ( line: 5 , utf16index: 9 ) ..< Position ( line: 5 , utf16index: 9 ) , newText: " test(a: ) " ) )
202
205
XCTAssertEqual ( test. insertText, " test(a: ) " )
203
206
XCTAssertEqual ( test. insertTextFormat, . plain)
204
207
}
@@ -210,7 +213,7 @@ final class SwiftCompletionTests: XCTestCase {
210
213
XCTAssertEqual ( test. detail, " Void " )
211
214
XCTAssertEqual ( test. filterText, " test(:) " )
212
215
// FIXME:
213
- XCTAssertEqual ( test. textEdit, TextEdit ( range: Position ( line: 8 , utf16index: 9 ) ..< Position ( line: 8 , utf16index: 9 ) , newText: " test() " ) )
216
+ XCTAssertEqual ( test. textEdit, TextEdit ( range: Position ( line: 9 , utf16index: 9 ) ..< Position ( line: 9 , utf16index: 9 ) , newText: " test() " ) )
214
217
XCTAssertEqual ( test. insertText, " test() " )
215
218
XCTAssertEqual ( test. insertTextFormat, . plain)
216
219
}
0 commit comments