(item: ls.CompletionItem)
| 267 | } |
| 268 | |
| 269 | function asCompletionItem(item: ls.CompletionItem): ProtocolCompletionItem { |
| 270 | let result = new ProtocolCompletionItem(item.label); |
| 271 | if (item.detail) { result.detail = item.detail; } |
| 272 | if (item.documentation) { |
| 273 | result.documentation = asDocumentation(item.documentation); |
| 274 | result.documentationFormat = Is.string(item.documentation) ? '$string' : item.documentation.kind; |
| 275 | }; |
| 276 | if (item.filterText) { result.filterText = item.filterText; } |
| 277 | let insertText = asCompletionInsertText(item); |
| 278 | if (insertText) { |
| 279 | result.insertText = insertText.text; |
| 280 | result.range = insertText.range; |
| 281 | result.fromEdit = insertText.fromEdit; |
| 282 | } |
| 283 | if (Is.number(item.kind)) { |
| 284 | let [itemKind, original] = asCompletionItemKind(item.kind); |
| 285 | result.kind = itemKind; |
| 286 | if (original) { |
| 287 | result.originalItemKind = original; |
| 288 | } |
| 289 | } |
| 290 | if (item.sortText) { result.sortText = item.sortText; } |
| 291 | if (item.additionalTextEdits) { result.additionalTextEdits = asTextEdits(item.additionalTextEdits); } |
| 292 | if (Is.stringArray(item.commitCharacters)) { result.commitCharacters = item.commitCharacters.slice(); } |
| 293 | if (item.command) { result.command = asCommand(item.command); } |
| 294 | if (item.data !== void 0 && item.data !== null) { result.data = item.data; } |
| 295 | return result; |
| 296 | } |
| 297 | |
| 298 | function asCompletionInsertText(item: ls.CompletionItem): { text: string | code.SnippetString, range?: code.Range, fromEdit: boolean } | undefined { |
| 299 | if (item.textEdit) { |
nothing calls this directly
no test coverage detected