@@ -98,8 +98,11 @@ namespace ts.server.protocol {
9898 GetSupportedCodeFixes = "getSupportedCodeFixes" ,
9999
100100 GetApplicableRefactors = "getApplicableRefactors" ,
101- GetRefactorCodeActions = "getRefactorCodeActions" ,
102- GetRefactorCodeActionsFull = "getRefactorCodeActions-full" ,
101+ GetEditsForRefactor = "getEditsForRefactor" ,
102+ /* @internal */
103+ GetEditsForRefactorFull = "getEditsForRefactor-full" ,
104+
105+ // NOTE: If updating this, be sure to also update `allCommandNames` in `harness/unittests/session.ts`.
103106 }
104107
105108 /**
@@ -401,52 +404,98 @@ namespace ts.server.protocol {
401404
402405 export type FileLocationOrRangeRequestArgs = FileLocationRequestArgs | FileRangeRequestArgs ;
403406
407+ /**
408+ * Request refactorings at a given position or selection area.
409+ */
404410 export interface GetApplicableRefactorsRequest extends Request {
405411 command : CommandTypes . GetApplicableRefactors ;
406412 arguments : GetApplicableRefactorsRequestArgs ;
407413 }
408-
409414 export type GetApplicableRefactorsRequestArgs = FileLocationOrRangeRequestArgs ;
410415
416+ /**
417+ * Response is a list of available refactorings.
418+ * Each refactoring exposes 1 or more "Actions"; a user selects one action to invoke a refactoring
419+ */
420+ export interface GetApplicableRefactorsResponse extends Response {
421+ body ?: ApplicableRefactorInfo [ ] ;
422+ }
423+
424+ /**
425+ * A set of one or more available refactoring actions, grouped under a parent refactoring.
426+ */
411427 export interface ApplicableRefactorInfo {
428+ /**
429+ * The programmatic name of the refactoring
430+ */
412431 name : string ;
432+ /**
433+ * A description of this refactoring category to show to the user.
434+ * If the refactoring gets inlined (see below), this text will not be visible.
435+ */
413436 description : string ;
414- }
437+ /**
438+ * Inlineable refactorings can have their actions hoisted out to the top level
439+ * of a context menu. Non-inlineanable refactorings should always be shown inside
440+ * their parent grouping.
441+ *
442+ * If not specified, this value is assumed to be 'true'
443+ */
444+ inlineable ?: boolean ;
415445
416- export interface GetApplicableRefactorsResponse extends Response {
417- body ?: ApplicableRefactorInfo [ ] ;
446+ actions : RefactorActionInfo [ ] ;
418447 }
419448
420- export interface GetRefactorCodeActionsRequest extends Request {
421- command : CommandTypes . GetRefactorCodeActions ;
422- arguments : GetRefactorCodeActionsRequestArgs ;
423- }
449+ /**
450+ * Represents a single refactoring action - for example, the "Extract Method..." refactor might
451+ * offer several actions, each corresponding to a surround class or closure to extract into.
452+ */
453+ export type RefactorActionInfo = {
454+ /**
455+ * The programmatic name of the refactoring action
456+ */
457+ name : string ;
424458
425- export type GetRefactorCodeActionsRequestArgs = FileLocationOrRangeRequestArgs & {
426- /* The kind of the applicable refactor */
427- refactorName : string ;
459+ /**
460+ * A description of this refactoring action to show to the user.
461+ * If the parent refactoring is inlined away, this will be the only text shown,
462+ * so this description should make sense by itself if the parent is inlineable=true
463+ */
464+ description : string ;
428465 } ;
429466
430- export type RefactorCodeActions = {
431- actions : protocol . CodeAction [ ] ;
432- renameLocation ?: number
433- } ;
467+ export interface GetEditsForRefactorRequest extends Request {
468+ command : CommandTypes . GetEditsForRefactor ;
469+ arguments : GetEditsForRefactorRequestArgs ;
470+ }
434471
435- /* @internal */
436- export type RefactorCodeActionsFull = {
437- actions : ts . CodeAction [ ] ;
438- renameLocation ?: number
472+ /**
473+ * Request the edits that a particular refactoring action produces.
474+ * Callers must specify the name of the refactor and the name of the action.
475+ */
476+ export type GetEditsForRefactorRequestArgs = FileLocationOrRangeRequestArgs & {
477+ /* The 'name' property from the refactoring that offered this action */
478+ refactor : string ;
479+ /* The 'name' property from the refactoring action */
480+ action : string ;
439481 } ;
440482
441- export interface GetRefactorCodeActionsResponse extends Response {
442- body : RefactorCodeActions ;
443- }
444483
445- /* @internal */
446- export interface GetRefactorCodeActionsFullResponse extends Response {
447- body : RefactorCodeActionsFull ;
484+ export interface GetEditsForRefactorResponse extends Response {
485+ body ?: RefactorEditInfo ;
448486 }
449487
488+ export type RefactorEditInfo = {
489+ edits : FileCodeEdits [ ] ;
490+
491+ /**
492+ * An optional location where the editor should start a rename operation once
493+ * the refactoring edits have been applied
494+ */
495+ renameLocation ?: Location ;
496+ renameFilename ?: string ;
497+ } ;
498+
450499 /**
451500 * Request for the available codefixes at a specific position.
452501 */
0 commit comments