1+ import { GetApplicableRefactorsRequestArgs , GetEditsForRefactorRequestArgs } from "../server/protocol.js" ;
12import {
23 ApplicableRefactorInfo ,
34 CallHierarchyIncomingCall ,
@@ -36,6 +37,7 @@ import {
3637 ImplementationLocation ,
3738 InlayHint ,
3839 InlayHintKind ,
40+ InteractiveRefactorArguments ,
3941 isString ,
4042 JSDocTagInfo ,
4143 LanguageService ,
@@ -52,6 +54,7 @@ import {
5254 Program ,
5355 QuickInfo ,
5456 RefactorEditInfo ,
57+ RefactorTriggerReason ,
5558 ReferencedSymbol ,
5659 ReferenceEntry ,
5760 RenameInfo ,
@@ -787,11 +790,25 @@ export class SessionClient implements LanguageService {
787790 return { file, line, offset, endLine, endOffset } ;
788791 }
789792
790- getApplicableRefactors ( fileName : string , positionOrRange : number | TextRange ) : ApplicableRefactorInfo [ ] {
791- const args = this . createFileLocationOrRangeRequestArgs ( positionOrRange , fileName ) ;
792-
793+ getApplicableRefactors (
794+ fileName : string ,
795+ positionOrRange : number | TextRange ,
796+ preferences : UserPreferences | undefined ,
797+ triggerReason ?: RefactorTriggerReason ,
798+ kind ?: string ,
799+ includeInteractiveActions ?: boolean ) : ApplicableRefactorInfo [ ] {
800+ if ( preferences ) { // Temporarily set preferences
801+ this . configure ( preferences ) ;
802+ }
803+ const args : GetApplicableRefactorsRequestArgs = this . createFileLocationOrRangeRequestArgs ( positionOrRange , fileName ) ;
804+ args . triggerReason = triggerReason ;
805+ args . kind = kind ;
806+ args . includeInteractiveActions = includeInteractiveActions ;
793807 const request = this . processRequest < protocol . GetApplicableRefactorsRequest > ( protocol . CommandTypes . GetApplicableRefactors , args ) ;
794808 const response = this . processResponse < protocol . GetApplicableRefactorsResponse > ( request ) ;
809+ if ( preferences ) { // Restore preferences
810+ this . configure ( this . preferences || { } ) ;
811+ }
795812 return response . body ! ; // TODO: GH#18217
796813 }
797814
@@ -808,11 +825,16 @@ export class SessionClient implements LanguageService {
808825 _formatOptions : FormatCodeSettings ,
809826 positionOrRange : number | TextRange ,
810827 refactorName : string ,
811- actionName : string ) : RefactorEditInfo {
812-
813- const args = this . createFileLocationOrRangeRequestArgs ( positionOrRange , fileName ) as protocol . GetEditsForRefactorRequestArgs ;
828+ actionName : string ,
829+ preferences : UserPreferences | undefined ,
830+ interactiveRefactorArguments ?: InteractiveRefactorArguments ) : RefactorEditInfo { // >> Update here
831+ if ( preferences ) { // Temporarily set preferences
832+ this . configure ( preferences ) ;
833+ }
834+ const args : GetEditsForRefactorRequestArgs = 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