@@ -20,6 +20,7 @@ import {
20
20
TextEditor ,
21
21
} from 'atom' ;
22
22
import * as ac from 'atom/autocomplete-plus' ;
23
+ import { Suggestion , TextSuggestion , SnippetSuggestion } from 'atom-ide' ;
23
24
24
25
/**
25
26
* Holds a list of suggestions generated from the CompletionItem[]
@@ -35,7 +36,7 @@ interface SuggestionCacheEntry {
35
36
originalBufferPoint : Point ;
36
37
/** The trigger string that caused the autocomplete (if any) */
37
38
triggerChar : string ;
38
- suggestionMap : Map < ac . Suggestion , PossiblyResolvedCompletionItem > ;
39
+ suggestionMap : Map < Suggestion , PossiblyResolvedCompletionItem > ;
39
40
}
40
41
41
42
type CompletionItemAdjuster =
@@ -137,7 +138,7 @@ export default class AutocompleteAdapter {
137
138
triggerChar : string ,
138
139
triggerOnly : boolean ,
139
140
onDidConvertCompletionItem ?: CompletionItemAdjuster ,
140
- ) : Promise < ac . Suggestion [ ] > {
141
+ ) : Promise < Suggestion [ ] > {
141
142
const cache = this . _suggestionCache . get ( server ) ;
142
143
143
144
const triggerColumn = ( triggerChar !== '' && triggerOnly )
@@ -336,16 +337,16 @@ export default class AutocompleteAdapter {
336
337
request : ac . SuggestionsRequestedEvent ,
337
338
triggerColumns : [ number , number ] ,
338
339
onDidConvertCompletionItem ?: CompletionItemAdjuster ,
339
- ) : Map < ac . Suggestion , PossiblyResolvedCompletionItem > {
340
+ ) : Map < Suggestion , PossiblyResolvedCompletionItem > {
340
341
const completionsArray = Array . isArray ( completionItems )
341
342
? completionItems
342
343
: ( completionItems && completionItems . items ) || [ ] ;
343
344
return new Map ( completionsArray
344
345
. sort ( ( a , b ) => ( a . sortText || a . label ) . localeCompare ( b . sortText || b . label ) )
345
- . map < [ ac . Suggestion , PossiblyResolvedCompletionItem ] > (
346
+ . map < [ Suggestion , PossiblyResolvedCompletionItem ] > (
346
347
( s ) => [
347
348
AutocompleteAdapter . completionItemToSuggestion (
348
- s , { } as ac . Suggestion , request , triggerColumns , onDidConvertCompletionItem ) ,
349
+ s , { } as Suggestion , request , triggerColumns , onDidConvertCompletionItem ) ,
349
350
new PossiblyResolvedCompletionItem ( s , false ) ,
350
351
] ,
351
352
) ,
@@ -364,16 +365,16 @@ export default class AutocompleteAdapter {
364
365
*/
365
366
public static completionItemToSuggestion (
366
367
item : CompletionItem ,
367
- suggestion : ac . Suggestion ,
368
+ suggestion : Suggestion ,
368
369
request : ac . SuggestionsRequestedEvent ,
369
370
triggerColumns : [ number , number ] ,
370
371
onDidConvertCompletionItem ?: CompletionItemAdjuster ,
371
- ) : ac . Suggestion {
372
- AutocompleteAdapter . applyCompletionItemToSuggestion ( item , suggestion as ac . TextSuggestion ) ;
372
+ ) : Suggestion {
373
+ AutocompleteAdapter . applyCompletionItemToSuggestion ( item , suggestion as TextSuggestion ) ;
373
374
AutocompleteAdapter . applyTextEditToSuggestion (
374
- item . textEdit , request . editor , triggerColumns , request . bufferPosition , suggestion as ac . TextSuggestion ,
375
+ item . textEdit , request . editor , triggerColumns , request . bufferPosition , suggestion as TextSuggestion ,
375
376
) ;
376
- AutocompleteAdapter . applySnippetToSuggestion ( item , suggestion as ac . SnippetSuggestion ) ;
377
+ AutocompleteAdapter . applySnippetToSuggestion ( item , suggestion as SnippetSuggestion ) ;
377
378
if ( onDidConvertCompletionItem != null ) {
378
379
onDidConvertCompletionItem ( item , suggestion as ac . AnySuggestion , request ) ;
379
380
}
@@ -385,12 +386,12 @@ export default class AutocompleteAdapter {
385
386
* Public: Convert the primary parts of a language server protocol CompletionItem to an AutoComplete+ suggestion.
386
387
*
387
388
* @param item An {CompletionItem} containing the completion items to be merged into.
388
- * @param suggestion The {ac. Suggestion} to merge the conversion into.
389
- * @returns The {ac. Suggestion} with details added from the {CompletionItem}.
389
+ * @param suggestion The {Suggestion} to merge the conversion into.
390
+ * @returns The {Suggestion} with details added from the {CompletionItem}.
390
391
*/
391
392
public static applyCompletionItemToSuggestion (
392
393
item : CompletionItem ,
393
- suggestion : ac . TextSuggestion ,
394
+ suggestion : TextSuggestion ,
394
395
) : void {
395
396
suggestion . text = item . insertText || item . label ;
396
397
suggestion . filterText = item . filterText || item . label ;
@@ -401,7 +402,7 @@ export default class AutocompleteAdapter {
401
402
402
403
public static applyDetailsToSuggestion (
403
404
item : CompletionItem ,
404
- suggestion : ac . Suggestion ,
405
+ suggestion : Suggestion ,
405
406
) : void {
406
407
suggestion . rightLabel = item . detail ;
407
408
@@ -434,7 +435,7 @@ export default class AutocompleteAdapter {
434
435
editor : TextEditor ,
435
436
triggerColumns : [ number , number ] ,
436
437
originalBufferPosition : Point ,
437
- suggestion : ac . TextSuggestion ,
438
+ suggestion : TextSuggestion ,
438
439
) : void {
439
440
if ( ! textEdit ) { return ; }
440
441
if ( textEdit . range . start . character !== triggerColumns [ 0 ] ) {
@@ -451,7 +452,7 @@ export default class AutocompleteAdapter {
451
452
* @param item An {CompletionItem} containing the completion items to be merged into.
452
453
* @param suggestion The {atom$AutocompleteSuggestion} to merge the conversion into.
453
454
*/
454
- public static applySnippetToSuggestion ( item : CompletionItem , suggestion : ac . SnippetSuggestion ) : void {
455
+ public static applySnippetToSuggestion ( item : CompletionItem , suggestion : SnippetSuggestion ) : void {
455
456
if ( item . insertTextFormat === InsertTextFormat . Snippet ) {
456
457
suggestion . snippet = item . textEdit != null ? item . textEdit . newText : ( item . insertText || '' ) ;
457
458
}
0 commit comments