2323namespace FourSlash {
2424 ts . disableIncrementalParsing = false ;
2525
26- import Many = FourSlashInterface . Many ;
26+ import ArrayOrSingle = FourSlashInterface . Many ;
2727
2828 // Represents a parsed source file with metadata
2929 interface FourSlashFile {
@@ -627,11 +627,11 @@ namespace FourSlash {
627627 }
628628 }
629629
630- public verifyGoToDefinitionIs ( endMarker : Many < string > ) {
630+ public verifyGoToDefinitionIs ( endMarker : ArrayOrSingle < string > ) {
631631 this . verifyGoToXWorker ( toArray ( endMarker ) , ( ) => this . getGoToDefinition ( ) ) ;
632632 }
633633
634- public verifyGoToDefinition ( arg0 : any , endMarkerNames ?: Many < string > ) {
634+ public verifyGoToDefinition ( arg0 : any , endMarkerNames ?: ArrayOrSingle < string > ) {
635635 this . verifyGoToX ( arg0 , endMarkerNames , ( ) => this . getGoToDefinitionAndBoundSpan ( ) ) ;
636636 }
637637
@@ -643,23 +643,23 @@ namespace FourSlash {
643643 return this . languageService . getDefinitionAndBoundSpan ( this . activeFile . fileName , this . currentCaretPosition ) ;
644644 }
645645
646- public verifyGoToType ( arg0 : any , endMarkerNames ?: Many < string > ) {
646+ public verifyGoToType ( arg0 : any , endMarkerNames ?: ArrayOrSingle < string > ) {
647647 this . verifyGoToX ( arg0 , endMarkerNames , ( ) =>
648648 this . languageService . getTypeDefinitionAtPosition ( this . activeFile . fileName , this . currentCaretPosition ) ) ;
649649 }
650650
651- private verifyGoToX ( arg0 : any , endMarkerNames : Many < string > | undefined , getDefs : ( ) => ts . DefinitionInfo [ ] | ts . DefinitionInfoAndBoundSpan | undefined ) {
651+ private verifyGoToX ( arg0 : any , endMarkerNames : ArrayOrSingle < string > | undefined , getDefs : ( ) => ts . DefinitionInfo [ ] | ts . DefinitionInfoAndBoundSpan | undefined ) {
652652 if ( endMarkerNames ) {
653653 this . verifyGoToXPlain ( arg0 , endMarkerNames , getDefs ) ;
654654 }
655655 else if ( ts . isArray ( arg0 ) ) {
656- const pairs = arg0 as ReadonlyArray < [ Many < string > , Many < string > ] > ;
656+ const pairs = arg0 as ReadonlyArray < [ ArrayOrSingle < string > , ArrayOrSingle < string > ] > ;
657657 for ( const [ start , end ] of pairs ) {
658658 this . verifyGoToXPlain ( start , end , getDefs ) ;
659659 }
660660 }
661661 else {
662- const obj : { [ startMarkerName : string ] : Many < string > } = arg0 ;
662+ const obj : { [ startMarkerName : string ] : ArrayOrSingle < string > } = arg0 ;
663663 for ( const startMarkerName in obj ) {
664664 if ( ts . hasProperty ( obj , startMarkerName ) ) {
665665 this . verifyGoToXPlain ( startMarkerName , obj [ startMarkerName ] , getDefs ) ;
@@ -668,7 +668,7 @@ namespace FourSlash {
668668 }
669669 }
670670
671- private verifyGoToXPlain ( startMarkerNames : Many < string > , endMarkerNames : Many < string > , getDefs : ( ) => ts . DefinitionInfo [ ] | ts . DefinitionInfoAndBoundSpan | undefined ) {
671+ private verifyGoToXPlain ( startMarkerNames : ArrayOrSingle < string > , endMarkerNames : ArrayOrSingle < string > , getDefs : ( ) => ts . DefinitionInfo [ ] | ts . DefinitionInfoAndBoundSpan | undefined ) {
672672 for ( const start of toArray ( startMarkerNames ) ) {
673673 this . verifyGoToXSingle ( start , endMarkerNames , getDefs ) ;
674674 }
@@ -680,7 +680,7 @@ namespace FourSlash {
680680 }
681681 }
682682
683- private verifyGoToXSingle ( startMarkerName : string , endMarkerNames : Many < string > , getDefs : ( ) => ReadonlyArray < ts . DefinitionInfo > | ts . DefinitionInfoAndBoundSpan | undefined ) {
683+ private verifyGoToXSingle ( startMarkerName : string , endMarkerNames : ArrayOrSingle < string > , getDefs : ( ) => ReadonlyArray < ts . DefinitionInfo > | ts . DefinitionInfoAndBoundSpan | undefined ) {
684684 this . goToMarker ( startMarkerName ) ;
685685 this . verifyGoToXWorker ( toArray ( endMarkerNames ) , getDefs , startMarkerName ) ;
686686 }
@@ -843,19 +843,21 @@ namespace FourSlash {
843843 }
844844
845845 public verifyCompletions ( options : FourSlashInterface . VerifyCompletionsOptions ) {
846- if ( options . at ! == undefined ) {
847- if ( typeof options . at === "string" ) {
848- this . goToMarker ( options . at ) ;
849- }
850- else {
851- for ( const a of options . at ) this . verifyCompletions ( { ... options , at : a } ) ;
852- return ;
846+ if ( options . marker = == undefined ) {
847+ this . verifyCompletionsWorker ( options ) ;
848+ }
849+ else {
850+ for ( const marker of toArray ( options . marker ) ) {
851+ this . goToMarker ( marker ) ;
852+ this . verifyCompletionsWorker ( options ) ;
853853 }
854854 }
855+ }
855856
857+ private verifyCompletionsWorker ( options : FourSlashInterface . VerifyCompletionsOptions ) : void {
856858 const actualCompletions = this . getCompletionListAtCaret ( { ...options . preferences , triggerCharacter : options . triggerCharacter } ) ;
857859 if ( ! actualCompletions ) {
858- if ( options . are === undefined ) return ;
860+ if ( options . exact === undefined ) return ;
859861 this . raiseError ( `No completions at position '${ this . currentCaretPosition } '.` ) ;
860862 }
861863
@@ -874,9 +876,10 @@ namespace FourSlash {
874876 }
875877 }
876878
877- if ( "are" in options ) {
878- if ( options . are === undefined ) this . raiseError ( "Expected no completions" ) ;
879- this . verifyCompletionsAreExactly ( actualCompletions . entries , toArray ( options . are ) ) ;
879+ if ( "exact" in options ) {
880+ ts . Debug . assert ( ! ( "includes" in options ) && ! ( "excludes" in options ) ) ;
881+ if ( options . exact === undefined ) this . raiseError ( "Expected no completions" ) ;
882+ this . verifyCompletionsAreExactly ( actualCompletions . entries , toArray ( options . exact ) ) ;
880883 }
881884 else {
882885 if ( options . includes ) {
@@ -887,7 +890,7 @@ namespace FourSlash {
887890 this . verifyCompletionEntry ( found , include ) ;
888891 }
889892 }
890- else {
893+ if ( options . excludes ) {
891894 for ( const exclude of toArray ( options . excludes ) ) {
892895 if ( typeof exclude === "string" ) {
893896 if ( actualByName . has ( exclude ) ) {
@@ -954,7 +957,7 @@ namespace FourSlash {
954957 }
955958
956959 public verifyCompletionsAt ( markerName : string | ReadonlyArray < string > , expected : ReadonlyArray < FourSlashInterface . ExpectedCompletionEntry > , options ?: FourSlashInterface . CompletionsAtOptions ) {
957- this . verifyCompletions ( { at : markerName , are : expected , isNewIdentifierLocation : options && options . isNewIdentifierLocation , preferences : options , triggerCharacter : options && options . triggerCharacter } ) ;
960+ this . verifyCompletions ( { marker : markerName , exact : expected , isNewIdentifierLocation : options && options . isNewIdentifierLocation , preferences : options , triggerCharacter : options && options . triggerCharacter } ) ;
958961 }
959962
960963 public verifyCompletionListContains ( entryId : ts . Completions . CompletionEntryIdentifier , text ?: string , documentation ?: string , kind ?: string | { kind ?: string , kindModifiers ?: string } , spanIndex ?: number , hasAction ?: boolean , options ?: FourSlashInterface . VerifyCompletionListContainsOptions ) {
@@ -1190,7 +1193,7 @@ namespace FourSlash {
11901193 }
11911194 }
11921195
1193- public verifyReferenceGroups ( starts : Many < string > | Many < Range > , parts : ReadonlyArray < FourSlashInterface . ReferenceGroup > | undefined ) : void {
1196+ public verifyReferenceGroups ( starts : ArrayOrSingle < string > | ArrayOrSingle < Range > , parts : ReadonlyArray < FourSlashInterface . ReferenceGroup > | undefined ) : void {
11941197 interface ReferenceGroupJson {
11951198 definition : string | { text : string , range : ts . TextSpan } ;
11961199 references : ts . ReferenceEntry [ ] ;
@@ -1425,7 +1428,7 @@ Actual: ${stringify(fullActual)}`);
14251428 }
14261429 }
14271430
1428- public verifyRenameLocations ( startRanges : Many < Range > , options : Range [ ] | { findInStrings ?: boolean , findInComments ?: boolean , ranges : Range [ ] } ) {
1431+ public verifyRenameLocations ( startRanges : ArrayOrSingle < Range > , options : Range [ ] | { findInStrings ?: boolean , findInComments ?: boolean , ranges : Range [ ] } ) {
14291432 let findInStrings : boolean , findInComments : boolean , ranges : Range [ ] ;
14301433 if ( ts . isArray ( options ) ) {
14311434 findInStrings = findInComments = false ;
@@ -3815,7 +3818,7 @@ ${code}
38153818 return ts . arrayFrom ( set . keys ( ) ) ;
38163819 }
38173820
3818- function toArray < T > ( x : Many < T > ) : ReadonlyArray < T > {
3821+ function toArray < T > ( x : ArrayOrSingle < T > ) : ReadonlyArray < T > {
38193822 return ts . isArray ( x ) ? x : [ x ] ;
38203823 }
38213824
@@ -4763,9 +4766,9 @@ namespace FourSlashInterface {
47634766 }
47644767
47654768 export interface VerifyCompletionsOptions {
4766- readonly at ?: Many < string > ;
4769+ readonly marker ?: Many < string > ;
47674770 readonly isNewIdentifierLocation ?: boolean ;
4768- readonly are ?: Many < ExpectedCompletionEntry > ;
4771+ readonly exact ?: Many < ExpectedCompletionEntry > ;
47694772 readonly includes ?: Many < ExpectedCompletionEntry > ;
47704773 readonly excludes ?: Many < string | { readonly name : string , readonly source : string } > ;
47714774 readonly preferences : ts . UserPreferences ;
0 commit comments