@@ -818,13 +818,13 @@ namespace FourSlash {
818
818
} ) ;
819
819
}
820
820
821
- public verifyCompletionListContains ( symbol : string , text ?: string , documentation ?: string , kind ?: string , spanIndex ?: number , hasAction ?: boolean ) {
821
+ public verifyCompletionListContains ( entryId : ts . Completions . CompletionEntryIdentifier , text ?: string , documentation ?: string , kind ?: string , spanIndex ?: number , hasAction ?: boolean ) {
822
822
const completions = this . getCompletionListAtCaret ( ) ;
823
823
if ( completions ) {
824
- this . assertItemInCompletionList ( completions . entries , symbol , text , documentation , kind , spanIndex , hasAction ) ;
824
+ this . assertItemInCompletionList ( completions . entries , entryId , text , documentation , kind , spanIndex , hasAction ) ;
825
825
}
826
826
else {
827
- this . raiseError ( `No completions at position '${ this . currentCaretPosition } ' when looking for '${ symbol } '.` ) ;
827
+ this . raiseError ( `No completions at position '${ this . currentCaretPosition } ' when looking for '${ JSON . stringify ( entryId ) } '.` ) ;
828
828
}
829
829
}
830
830
@@ -839,7 +839,7 @@ namespace FourSlash {
839
839
* @param expectedKind the kind of symbol (see ScriptElementKind)
840
840
* @param spanIndex the index of the range that the completion item's replacement text span should match
841
841
*/
842
- public verifyCompletionListDoesNotContain ( symbol : string , expectedText ?: string , expectedDocumentation ?: string , expectedKind ?: string , spanIndex ?: number ) {
842
+ public verifyCompletionListDoesNotContain ( entryId : ts . Completions . CompletionEntryIdentifier , expectedText ?: string , expectedDocumentation ?: string , expectedKind ?: string , spanIndex ?: number ) {
843
843
const that = this ;
844
844
let replacementSpan : ts . TextSpan ;
845
845
if ( spanIndex !== undefined ) {
@@ -868,14 +868,14 @@ namespace FourSlash {
868
868
869
869
const completions = this . getCompletionListAtCaret ( ) ;
870
870
if ( completions ) {
871
- let filterCompletions = completions . entries . filter ( e => e . name === symbol ) ;
871
+ let filterCompletions = completions . entries . filter ( e => e . name === entryId . name && e . source === entryId . source ) ;
872
872
filterCompletions = expectedKind ? filterCompletions . filter ( e => e . kind === expectedKind ) : filterCompletions ;
873
873
filterCompletions = filterCompletions . filter ( filterByTextOrDocumentation ) ;
874
874
if ( filterCompletions . length !== 0 ) {
875
875
// After filtered using all present criterion, if there are still symbol left in the list
876
876
// then these symbols must meet the criterion for Not supposed to be in the list. So we
877
877
// raise an error
878
- let error = " Completion list did contain \'" + symbol + " \'." ;
878
+ let error = ` Completion list did contain ' ${ JSON . stringify ( entryId ) } \'.` ;
879
879
const details = this . getCompletionEntryDetails ( filterCompletions [ 0 ] . name ) ;
880
880
if ( expectedText ) {
881
881
error += "Expected text: " + expectedText + " to equal: " + ts . displayPartsToString ( details . displayParts ) + "." ;
@@ -1165,8 +1165,8 @@ Actual: ${stringify(fullActual)}`);
1165
1165
return this . languageService . getCompletionsAtPosition ( this . activeFile . fileName , this . currentCaretPosition ) ;
1166
1166
}
1167
1167
1168
- private getCompletionEntryDetails ( entryName : string ) {
1169
- return this . languageService . getCompletionEntryDetails ( this . activeFile . fileName , this . currentCaretPosition , entryName , this . formatCodeSettings ) ;
1168
+ private getCompletionEntryDetails ( entryName : string , source ?: string ) {
1169
+ return this . languageService . getCompletionEntryDetails ( this . activeFile . fileName , this . currentCaretPosition , entryName , this . formatCodeSettings , source ) ;
1170
1170
}
1171
1171
1172
1172
private getReferencesAtCaret ( ) {
@@ -1675,7 +1675,7 @@ Actual: ${stringify(fullActual)}`);
1675
1675
const longestNameLength = max ( entries , m => m . name . length ) ;
1676
1676
const longestKindLength = max ( entries , m => m . kind . length ) ;
1677
1677
entries . sort ( ( m , n ) => m . sortText > n . sortText ? 1 : m . sortText < n . sortText ? - 1 : m . name > n . name ? 1 : m . name < n . name ? - 1 : 0 ) ;
1678
- const membersString = entries . map ( m => `${ pad ( m . name , longestNameLength ) } ${ pad ( m . kind , longestKindLength ) } ${ m . kindModifiers } ` ) . join ( "\n" ) ;
1678
+ const membersString = entries . map ( m => `${ pad ( m . name , longestNameLength ) } ${ pad ( m . kind , longestKindLength ) } ${ m . kindModifiers } ${ m . source === undefined ? "" : m . source } ` ) . join ( "\n" ) ;
1679
1679
Harness . IO . log ( membersString ) ;
1680
1680
}
1681
1681
@@ -2331,13 +2331,13 @@ Actual: ${stringify(fullActual)}`);
2331
2331
public applyCodeActionFromCompletion ( markerName : string , options : FourSlashInterface . VerifyCompletionActionOptions ) {
2332
2332
this . goToMarker ( markerName ) ;
2333
2333
2334
- const actualCompletion = this . getCompletionListAtCaret ( ) . entries . find ( e => e . name === options . name ) ;
2334
+ const actualCompletion = this . getCompletionListAtCaret ( ) . entries . find ( e => e . name === options . name && e . source === options . source ) ;
2335
2335
2336
2336
if ( ! actualCompletion . hasAction ) {
2337
2337
this . raiseError ( `Completion for ${ options . name } does not have an associated action.` ) ;
2338
2338
}
2339
2339
2340
- const details = this . getCompletionEntryDetails ( options . name ) ;
2340
+ const details = this . getCompletionEntryDetails ( options . name , actualCompletion . source ) ;
2341
2341
if ( details . codeActions . length !== 1 ) {
2342
2342
this . raiseError ( `Expected one code action, got ${ details . codeActions . length } ` ) ;
2343
2343
}
@@ -3019,33 +3019,35 @@ Actual: ${stringify(fullActual)}`);
3019
3019
3020
3020
private assertItemInCompletionList (
3021
3021
items : ts . CompletionEntry [ ] ,
3022
- name : string ,
3022
+ entryId : ts . Completions . CompletionEntryIdentifier ,
3023
3023
text : string | undefined ,
3024
3024
documentation : string | undefined ,
3025
3025
kind : string | undefined ,
3026
3026
spanIndex : number | undefined ,
3027
3027
hasAction : boolean | undefined ,
3028
3028
) {
3029
3029
for ( const item of items ) {
3030
- if ( item . name === name ) {
3031
- if ( documentation !== undefined || text !== undefined ) {
3032
- const details = this . getCompletionEntryDetails ( item . name ) ;
3030
+ if ( item . name === entryId . name && item . source === entryId . source ) {
3031
+ if ( documentation !== undefined || text !== undefined || entryId . source !== undefined ) {
3032
+ const details = this . getCompletionEntryDetails ( item . name , item . source ) ;
3033
3033
3034
3034
if ( documentation !== undefined ) {
3035
- assert . equal ( ts . displayPartsToString ( details . documentation ) , documentation , this . assertionMessageAtLastKnownMarker ( "completion item documentation for " + name ) ) ;
3035
+ assert . equal ( ts . displayPartsToString ( details . documentation ) , documentation , this . assertionMessageAtLastKnownMarker ( "completion item documentation for " + entryId ) ) ;
3036
3036
}
3037
3037
if ( text !== undefined ) {
3038
- assert . equal ( ts . displayPartsToString ( details . displayParts ) , text , this . assertionMessageAtLastKnownMarker ( "completion item detail text for " + name ) ) ;
3038
+ assert . equal ( ts . displayPartsToString ( details . displayParts ) , text , this . assertionMessageAtLastKnownMarker ( "completion item detail text for " + entryId ) ) ;
3039
3039
}
3040
+
3041
+ assert . deepEqual ( details . source , entryId . source === undefined ? undefined : [ ts . textPart ( entryId . source ) ] ) ;
3040
3042
}
3041
3043
3042
3044
if ( kind !== undefined ) {
3043
- assert . equal ( item . kind , kind , this . assertionMessageAtLastKnownMarker ( "completion item kind for " + name ) ) ;
3045
+ assert . equal ( item . kind , kind , this . assertionMessageAtLastKnownMarker ( "completion item kind for " + entryId ) ) ;
3044
3046
}
3045
3047
3046
3048
if ( spanIndex !== undefined ) {
3047
3049
const span = this . getTextSpanForRangeAtIndex ( spanIndex ) ;
3048
- assert . isTrue ( TestState . textSpansEqual ( span , item . replacementSpan ) , this . assertionMessageAtLastKnownMarker ( stringify ( span ) + " does not equal " + stringify ( item . replacementSpan ) + " replacement span for " + name ) ) ;
3050
+ assert . isTrue ( TestState . textSpansEqual ( span , item . replacementSpan ) , this . assertionMessageAtLastKnownMarker ( stringify ( span ) + " does not equal " + stringify ( item . replacementSpan ) + " replacement span for " + entryId ) ) ;
3049
3051
}
3050
3052
3051
3053
assert . equal ( item . hasAction , hasAction ) ;
@@ -3056,7 +3058,7 @@ Actual: ${stringify(fullActual)}`);
3056
3058
3057
3059
const itemsString = items . map ( item => stringify ( { name : item . name , kind : item . kind } ) ) . join ( ",\n" ) ;
3058
3060
3059
- this . raiseError ( `Expected "${ stringify ( { name , text, documentation, kind } ) } " to be in list [${ itemsString } ]` ) ;
3061
+ this . raiseError ( `Expected "${ stringify ( { entryId , text, documentation, kind } ) } " to be in list [${ itemsString } ]` ) ;
3060
3062
}
3061
3063
3062
3064
private findFile ( indexOrName : any ) {
@@ -3767,12 +3769,15 @@ namespace FourSlashInterface {
3767
3769
3768
3770
// Verifies the completion list contains the specified symbol. The
3769
3771
// completion list is brought up if necessary
3770
- public completionListContains ( symbol : string , text ?: string , documentation ?: string , kind ?: string , spanIndex ?: number , hasAction ?: boolean ) {
3772
+ public completionListContains ( entryId : string | ts . Completions . CompletionEntryIdentifier , text ?: string , documentation ?: string , kind ?: string , spanIndex ?: number , hasAction ?: boolean ) {
3773
+ if ( typeof entryId === "string" ) {
3774
+ entryId = { name : entryId , source : undefined } ;
3775
+ }
3771
3776
if ( this . negative ) {
3772
- this . state . verifyCompletionListDoesNotContain ( symbol , text , documentation , kind , spanIndex ) ;
3777
+ this . state . verifyCompletionListDoesNotContain ( entryId , text , documentation , kind , spanIndex ) ;
3773
3778
}
3774
3779
else {
3775
- this . state . verifyCompletionListContains ( symbol , text , documentation , kind , spanIndex , hasAction ) ;
3780
+ this . state . verifyCompletionListContains ( entryId , text , documentation , kind , spanIndex , hasAction ) ;
3776
3781
}
3777
3782
}
3778
3783
@@ -4528,6 +4533,7 @@ namespace FourSlashInterface {
4528
4533
4529
4534
export interface VerifyCompletionActionOptions extends NewContentOptions {
4530
4535
name : string ;
4536
+ source ?: string ;
4531
4537
description : string ;
4532
4538
}
4533
4539
}
0 commit comments