@@ -1435,16 +1435,15 @@ Actual: ${stringify(fullActual)}`);
1435
1435
}
1436
1436
}
1437
1437
1438
- public verifyNoSignatureHelp ( markers : ReadonlyArray < string > ) {
1438
+ public verifyNoSignatureHelp ( triggerCharacter : ts . SignatureHelpTriggerCharacter | undefined , markers : ReadonlyArray < string > ) {
1439
1439
if ( markers . length ) {
1440
1440
for ( const marker of markers ) {
1441
1441
this . goToMarker ( marker ) ;
1442
- this . verifyNoSignatureHelp ( ts . emptyArray ) ;
1442
+ this . verifyNoSignatureHelp ( triggerCharacter , ts . emptyArray ) ;
1443
1443
}
1444
1444
return ;
1445
1445
}
1446
-
1447
- const actual = this . getSignatureHelp ( ) ;
1446
+ const actual = this . getSignatureHelp ( { triggerCharacter } ) ;
1448
1447
if ( actual ) {
1449
1448
this . raiseError ( `Expected no signature help, but got "${ stringify ( actual ) } "` ) ;
1450
1449
}
@@ -1465,7 +1464,7 @@ Actual: ${stringify(fullActual)}`);
1465
1464
}
1466
1465
1467
1466
private verifySignatureHelpWorker ( options : FourSlashInterface . VerifySignatureHelpOptions ) {
1468
- const help = this . getSignatureHelp ( ) ! ;
1467
+ const help = this . getSignatureHelp ( { triggerCharacter : options . triggerCharacter } ) ! ;
1469
1468
const selectedItem = help . items [ help . selectedItemIndex ] ;
1470
1469
// Argument index may exceed number of parameters
1471
1470
const currentParameter = selectedItem . parameters [ help . argumentIndex ] as ts . SignatureHelpParameter | undefined ;
@@ -1507,6 +1506,7 @@ Actual: ${stringify(fullActual)}`);
1507
1506
1508
1507
const allKeys : ReadonlyArray < keyof FourSlashInterface . VerifySignatureHelpOptions > = [
1509
1508
"marker" ,
1509
+ "triggerCharacter" ,
1510
1510
"overloadsCount" ,
1511
1511
"docComment" ,
1512
1512
"text" ,
@@ -1733,7 +1733,7 @@ Actual: ${stringify(fullActual)}`);
1733
1733
}
1734
1734
1735
1735
public printCurrentParameterHelp ( ) {
1736
- const help = this . languageService . getSignatureHelpItems ( this . activeFile . fileName , this . currentCaretPosition ) ;
1736
+ const help = this . languageService . getSignatureHelpItems ( this . activeFile . fileName , this . currentCaretPosition , /*options*/ undefined ) ;
1737
1737
Harness . IO . log ( stringify ( help ) ) ;
1738
1738
}
1739
1739
@@ -1774,12 +1774,14 @@ Actual: ${stringify(fullActual)}`);
1774
1774
}
1775
1775
1776
1776
public printCurrentSignatureHelp ( ) {
1777
- const help = this . getSignatureHelp ( ) ! ;
1777
+ const help = this . getSignatureHelp ( ts . emptyOptions ) ! ;
1778
1778
Harness . IO . log ( stringify ( help . items [ help . selectedItemIndex ] ) ) ;
1779
1779
}
1780
1780
1781
- private getSignatureHelp ( ) : ts . SignatureHelpItems | undefined {
1782
- return this . languageService . getSignatureHelpItems ( this . activeFile . fileName , this . currentCaretPosition ) ;
1781
+ private getSignatureHelp ( { triggerCharacter } : FourSlashInterface . VerifySignatureHelpOptions ) : ts . SignatureHelpItems | undefined {
1782
+ return this . languageService . getSignatureHelpItems ( this . activeFile . fileName , this . currentCaretPosition , {
1783
+ triggerCharacter
1784
+ } ) ;
1783
1785
}
1784
1786
1785
1787
public printCompletionListMembers ( preferences : ts . UserPreferences | undefined ) {
@@ -1875,13 +1877,13 @@ Actual: ${stringify(fullActual)}`);
1875
1877
offset ++ ;
1876
1878
1877
1879
if ( highFidelity ) {
1878
- if ( ch === "(" || ch === "," ) {
1880
+ if ( ch === "(" || ch === "," || ch === "<" ) {
1879
1881
/* Signature help*/
1880
- this . languageService . getSignatureHelpItems ( this . activeFile . fileName , offset ) ;
1882
+ this . languageService . getSignatureHelpItems ( this . activeFile . fileName , offset , { triggerCharacter : ch } ) ;
1881
1883
}
1882
1884
else if ( prevChar === " " && / A - Z a - z _ / . test ( ch ) ) {
1883
1885
/* Completions */
1884
- this . languageService . getCompletionsAtPosition ( this . activeFile . fileName , offset , ts . defaultPreferences ) ;
1886
+ this . languageService . getCompletionsAtPosition ( this . activeFile . fileName , offset , ts . emptyOptions ) ;
1885
1887
}
1886
1888
1887
1889
if ( i % checkCadence === 0 ) {
@@ -2514,7 +2516,7 @@ Actual: ${stringify(fullActual)}`);
2514
2516
`Expected '${ fixId } '. Available action ids: ${ ts . mapDefined ( this . getCodeFixes ( this . activeFile . fileName ) , a => a . fixId ) } ` ) ;
2515
2517
ts . Debug . assertEqual ( fixWithId ! . fixAllDescription , fixAllDescription ) ;
2516
2518
2517
- const { changes, commands } = this . languageService . getCombinedCodeFix ( { type : "file" , fileName : this . activeFile . fileName } , fixId , this . formatCodeSettings , ts . defaultPreferences ) ;
2519
+ const { changes, commands } = this . languageService . getCombinedCodeFix ( { type : "file" , fileName : this . activeFile . fileName } , fixId , this . formatCodeSettings , ts . emptyOptions ) ;
2518
2520
assert . deepEqual < ReadonlyArray < { } > | undefined > ( commands , expectedCommands ) ;
2519
2521
assert ( changes . every ( c => c . fileName === this . activeFile . fileName ) , "TODO: support testing codefixes that touch multiple files" ) ;
2520
2522
this . applyChanges ( changes ) ;
@@ -2594,7 +2596,7 @@ Actual: ${stringify(fullActual)}`);
2594
2596
* Rerieves a codefix satisfying the parameters, or undefined if no such codefix is found.
2595
2597
* @param fileName Path to file where error should be retrieved from.
2596
2598
*/
2597
- private getCodeFixes ( fileName : string , errorCode ?: number , preferences : ts . UserPreferences = ts . defaultPreferences ) : ts . CodeFixAction [ ] {
2599
+ private getCodeFixes ( fileName : string , errorCode ?: number , preferences : ts . UserPreferences = ts . emptyOptions ) : ts . CodeFixAction [ ] {
2598
2600
const diagnosticsForCodeFix = this . getDiagnostics ( fileName , /*includeSuggestions*/ true ) . map ( diagnostic => ( {
2599
2601
start : diagnostic . start ,
2600
2602
length : diagnostic . length ,
@@ -3072,7 +3074,7 @@ Actual: ${stringify(fullActual)}`);
3072
3074
this . raiseError ( `Expected action description to be ${ JSON . stringify ( actionDescription ) } , got: ${ JSON . stringify ( action . description ) } ` ) ;
3073
3075
}
3074
3076
3075
- const editInfo = this . languageService . getEditsForRefactor ( this . activeFile . fileName , this . formatCodeSettings , range , refactorName , actionName , ts . defaultPreferences ) ! ;
3077
+ const editInfo = this . languageService . getEditsForRefactor ( this . activeFile . fileName , this . formatCodeSettings , range , refactorName , actionName , ts . emptyOptions ) ! ;
3076
3078
for ( const edit of editInfo . edits ) {
3077
3079
this . applyEdits ( edit . fileName , edit . textChanges , /*isFormattingEdit*/ false ) ;
3078
3080
}
@@ -3124,7 +3126,7 @@ Actual: ${stringify(fullActual)}`);
3124
3126
const action = ts . first ( refactor . actions ) ;
3125
3127
assert ( action . name === "Move to a new file" && action . description === "Move to a new file" ) ;
3126
3128
3127
- const editInfo = this . languageService . getEditsForRefactor ( this . activeFile . fileName , this . formatCodeSettings , range , refactor . name , action . name , options . preferences || ts . defaultPreferences ) ! ;
3129
+ const editInfo = this . languageService . getEditsForRefactor ( this . activeFile . fileName , this . formatCodeSettings , range , refactor . name , action . name , options . preferences || ts . emptyOptions ) ! ;
3128
3130
this . testNewFileContents ( editInfo . edits , options . newFileContents ) ;
3129
3131
}
3130
3132
@@ -3162,14 +3164,14 @@ Actual: ${stringify(fullActual)}`);
3162
3164
formattingOptions = formattingOptions || this . formatCodeSettings ;
3163
3165
const markerPos = this . getMarkerByName ( markerName ) . position ;
3164
3166
3165
- const applicableRefactors = this . languageService . getApplicableRefactors ( this . activeFile . fileName , markerPos , ts . defaultPreferences ) ;
3167
+ const applicableRefactors = this . languageService . getApplicableRefactors ( this . activeFile . fileName , markerPos , ts . emptyOptions ) ;
3166
3168
const applicableRefactorToApply = ts . find ( applicableRefactors , refactor => refactor . name === refactorNameToApply ) ;
3167
3169
3168
3170
if ( ! applicableRefactorToApply ) {
3169
3171
this . raiseError ( `The expected refactor: ${ refactorNameToApply } is not available at the marker location.` ) ;
3170
3172
}
3171
3173
3172
- const editInfo = this . languageService . getEditsForRefactor ( this . activeFile . fileName , formattingOptions , markerPos , refactorNameToApply , actionName , ts . defaultPreferences ) ! ;
3174
+ const editInfo = this . languageService . getEditsForRefactor ( this . activeFile . fileName , formattingOptions , markerPos , refactorNameToApply , actionName , ts . emptyOptions ) ! ;
3173
3175
3174
3176
for ( const edit of editInfo . edits ) {
3175
3177
this . applyEdits ( edit . fileName , edit . textChanges , /*isFormattingEdit*/ false ) ;
@@ -3358,11 +3360,11 @@ Actual: ${stringify(fullActual)}`);
3358
3360
}
3359
3361
3360
3362
public getEditsForFileRename ( options : FourSlashInterface . GetEditsForFileRenameOptions ) : void {
3361
- const changes = this . languageService . getEditsForFileRename ( options . oldPath , options . newPath , this . formatCodeSettings , ts . defaultPreferences ) ;
3363
+ const changes = this . languageService . getEditsForFileRename ( options . oldPath , options . newPath , this . formatCodeSettings , ts . emptyOptions ) ;
3362
3364
this . testNewFileContents ( changes , options . newFileContents ) ;
3363
3365
}
3364
3366
3365
- private getApplicableRefactors ( positionOrRange : number | ts . TextRange , preferences = ts . defaultPreferences ) : ReadonlyArray < ts . ApplicableRefactorInfo > {
3367
+ private getApplicableRefactors ( positionOrRange : number | ts . TextRange , preferences = ts . emptyOptions ) : ReadonlyArray < ts . ApplicableRefactorInfo > {
3366
3368
return this . languageService . getApplicableRefactors ( this . activeFile . fileName , positionOrRange , preferences ) || ts . emptyArray ;
3367
3369
}
3368
3370
}
@@ -4038,7 +4040,11 @@ namespace FourSlashInterface {
4038
4040
}
4039
4041
4040
4042
public noSignatureHelp ( ...markers : string [ ] ) : void {
4041
- this . state . verifyNoSignatureHelp ( markers ) ;
4043
+ this . state . verifyNoSignatureHelp ( /*triggerCharacter*/ undefined , markers ) ;
4044
+ }
4045
+
4046
+ public noSignatureHelpForTriggerCharacter ( triggerCharacter : ts . SignatureHelpTriggerCharacter , ...markers : string [ ] ) : void {
4047
+ this . state . verifyNoSignatureHelp ( triggerCharacter , markers ) ;
4042
4048
}
4043
4049
4044
4050
public signatureHelp ( ...options : VerifySignatureHelpOptions [ ] ) : void {
@@ -4765,6 +4771,7 @@ namespace FourSlashInterface {
4765
4771
readonly isVariadic ?: boolean ;
4766
4772
/** @default ts.emptyArray */
4767
4773
readonly tags ?: ReadonlyArray < ts . JSDocTagInfo > ;
4774
+ readonly triggerCharacter ?: ts . SignatureHelpTriggerCharacter ;
4768
4775
}
4769
4776
4770
4777
export type ArrayOrSingle < T > = T | ReadonlyArray < T > ;
0 commit comments