@@ -953,6 +953,10 @@ namespace FourSlash {
953953 return this . getChecker ( ) . getSymbolsInScope ( node , ts . SymbolFlags . Value | ts . SymbolFlags . Type | ts . SymbolFlags . Namespace ) ;
954954 }
955955
956+ public setTypesRegistry ( map : ts . MapLike < void > ) : void {
957+ this . languageServiceAdapterHost . typesRegistry = ts . createMapFromTemplate ( map ) ;
958+ }
959+
956960 public verifyTypeOfSymbolAtLocation ( range : Range , symbol : ts . Symbol , expected : string ) : void {
957961 const node = this . goToAndGetNode ( range ) ;
958962 const checker = this . getChecker ( ) ;
@@ -2777,16 +2781,26 @@ Actual: ${stringify(fullActual)}`);
27772781 }
27782782 }
27792783
2780- public verifyCodeFixAvailable ( negative : boolean ) {
2781- const codeFix = this . getCodeFixActions ( this . activeFile . fileName ) ;
2784+ public verifyCodeFixAvailable ( negative : boolean , info : FourSlashInterface . VerifyCodeFixAvailableOptions [ ] | undefined ) {
2785+ const codeFixes = this . getCodeFixActions ( this . activeFile . fileName ) ;
27822786
2783- if ( negative && codeFix . length ) {
2784- this . raiseError ( `verifyCodeFixAvailable failed - expected no fixes but found one.` ) ;
2787+ if ( negative ) {
2788+ if ( codeFixes . length ) {
2789+ this . raiseError ( `verifyCodeFixAvailable failed - expected no fixes but found one.` ) ;
2790+ }
2791+ return ;
27852792 }
27862793
2787- if ( ! ( negative || codeFix . length ) ) {
2794+ if ( ! codeFixes . length ) {
27882795 this . raiseError ( `verifyCodeFixAvailable failed - expected code fixes but none found.` ) ;
27892796 }
2797+ if ( info ) {
2798+ assert . equal ( info . length , codeFixes . length ) ;
2799+ ts . zipWith ( codeFixes , info , ( fix , info ) => {
2800+ assert . equal ( fix . description , info . description ) ;
2801+ this . assertObjectsEqual ( fix . commands , info . commands ) ;
2802+ } ) ;
2803+ }
27902804 }
27912805
27922806 public verifyApplicableRefactorAvailableAtMarker ( negative : boolean , markerName : string ) {
@@ -2830,6 +2844,14 @@ Actual: ${stringify(fullActual)}`);
28302844 }
28312845 }
28322846
2847+ public verifyRefactor ( { name, actionName, refactors } : FourSlashInterface . VerifyRefactorOptions ) {
2848+ const selection = this . getSelection ( ) ;
2849+
2850+ const actualRefactors = ( this . languageService . getApplicableRefactors ( this . activeFile . fileName , selection ) || ts . emptyArray )
2851+ . filter ( r => r . name === name && r . actions . some ( a => a . name === actionName ) ) ;
2852+ this . assertObjectsEqual ( actualRefactors , refactors ) ;
2853+ }
2854+
28332855 public verifyApplicableRefactorAvailableForRange ( negative : boolean ) {
28342856 const ranges = this . getRanges ( ) ;
28352857 if ( ! ( ranges && ranges . length === 1 ) ) {
@@ -3614,6 +3636,10 @@ namespace FourSlashInterface {
36143636 public symbolsInScope ( range : FourSlash . Range ) : ts . Symbol [ ] {
36153637 return this . state . symbolsInScope ( range ) ;
36163638 }
3639+
3640+ public setTypesRegistry ( map : ts . MapLike < void > ) : void {
3641+ this . state . setTypesRegistry ( map ) ;
3642+ }
36173643 }
36183644
36193645 export class GoTo {
@@ -3789,8 +3815,8 @@ namespace FourSlashInterface {
37893815 this . state . verifyCodeFix ( options ) ;
37903816 }
37913817
3792- public codeFixAvailable ( ) {
3793- this . state . verifyCodeFixAvailable ( this . negative ) ;
3818+ public codeFixAvailable ( options ?: VerifyCodeFixAvailableOptions [ ] ) {
3819+ this . state . verifyCodeFixAvailable ( this . negative , options ) ;
37943820 }
37953821
37963822 public applicableRefactorAvailableAtMarker ( markerName : string ) {
@@ -3801,6 +3827,10 @@ namespace FourSlashInterface {
38013827 this . state . verifyApplicableRefactorAvailableForRange ( this . negative ) ;
38023828 }
38033829
3830+ public refactor ( options : VerifyRefactorOptions ) {
3831+ this . state . verifyRefactor ( options ) ;
3832+ }
3833+
38043834 public refactorAvailable ( name : string , actionName ?: string ) {
38053835 this . state . verifyRefactorAvailable ( this . negative , name , actionName ) ;
38063836 }
@@ -4449,6 +4479,17 @@ namespace FourSlashInterface {
44494479 index ?: number ;
44504480 }
44514481
4482+ export interface VerifyCodeFixAvailableOptions {
4483+ description : string ;
4484+ commands ?: ts . CodeActionCommand [ ] ;
4485+ }
4486+
4487+ export interface VerifyRefactorOptions {
4488+ name : string ;
4489+ actionName : string ;
4490+ refactors : ts . ApplicableRefactorInfo [ ] ;
4491+ }
4492+
44524493 export interface VerifyCompletionActionOptions extends NewContentOptions {
44534494 name : string ;
44544495 description : string ;
0 commit comments