@@ -36,6 +36,7 @@ import {
3636 ImplementationLocation ,
3737 InlayHint ,
3838 InlayHintKind ,
39+ InteractiveRefactorArguments ,
3940 isString ,
4041 JSDocTagInfo ,
4142 LanguageService ,
@@ -52,6 +53,7 @@ import {
5253 Program ,
5354 QuickInfo ,
5455 RefactorEditInfo ,
56+ RefactorTriggerReason ,
5557 ReferencedSymbol ,
5658 ReferenceEntry ,
5759 RenameInfo ,
@@ -787,11 +789,25 @@ export class SessionClient implements LanguageService {
787789 return { file, line, offset, endLine, endOffset } ;
788790 }
789791
790- getApplicableRefactors ( fileName : string , positionOrRange : number | TextRange ) : ApplicableRefactorInfo [ ] {
791- const args = this . createFileLocationOrRangeRequestArgs ( positionOrRange , fileName ) ;
792-
792+ getApplicableRefactors (
793+ fileName : string ,
794+ positionOrRange : number | TextRange ,
795+ preferences : UserPreferences | undefined ,
796+ triggerReason ?: RefactorTriggerReason ,
797+ kind ?: string ,
798+ includeInteractiveActions ?: boolean ) : ApplicableRefactorInfo [ ] {
799+ if ( preferences ) { // Temporarily set preferences
800+ this . configure ( preferences ) ;
801+ }
802+ const args : protocol . GetApplicableRefactorsRequestArgs = this . createFileLocationOrRangeRequestArgs ( positionOrRange , fileName ) ;
803+ args . triggerReason = triggerReason ;
804+ args . kind = kind ;
805+ args . includeInteractiveActions = includeInteractiveActions ;
793806 const request = this . processRequest < protocol . GetApplicableRefactorsRequest > ( protocol . CommandTypes . GetApplicableRefactors , args ) ;
794807 const response = this . processResponse < protocol . GetApplicableRefactorsResponse > ( request ) ;
808+ if ( preferences ) { // Restore preferences
809+ this . configure ( this . preferences || { } ) ;
810+ }
795811 return response . body ! ; // TODO: GH#18217
796812 }
797813
@@ -808,11 +824,17 @@ export class SessionClient implements LanguageService {
808824 _formatOptions : FormatCodeSettings ,
809825 positionOrRange : number | TextRange ,
810826 refactorName : string ,
811- actionName : string ) : RefactorEditInfo {
812-
813- const args = this . createFileLocationOrRangeRequestArgs ( positionOrRange , fileName ) as protocol . GetEditsForRefactorRequestArgs ;
827+ actionName : string ,
828+ preferences : UserPreferences | undefined ,
829+ interactiveRefactorArguments ?: InteractiveRefactorArguments ) : RefactorEditInfo {
830+ if ( preferences ) { // Temporarily set preferences
831+ this . configure ( preferences ) ;
832+ }
833+ const args =
834+ this . createFileLocationOrRangeRequestArgs ( positionOrRange , fileName ) as protocol . GetEditsForRefactorRequestArgs ;
814835 args . refactor = refactorName ;
815836 args . action = actionName ;
837+ args . interactiveRefactorArguments = interactiveRefactorArguments ;
816838
817839 const request = this . processRequest < protocol . GetEditsForRefactorRequest > ( protocol . CommandTypes . GetEditsForRefactor , args ) ;
818840 const response = this . processResponse < protocol . GetEditsForRefactorResponse > ( request ) ;
@@ -829,6 +851,10 @@ export class SessionClient implements LanguageService {
829851 renameLocation = this . lineOffsetToPosition ( renameFilename , response . body . renameLocation ! ) ;
830852 }
831853
854+ if ( preferences ) { // Restore preferences
855+ this . configure ( this . preferences || { } ) ;
856+ }
857+
832858 return {
833859 edits,
834860 renameFilename,
0 commit comments