@@ -48,8 +48,7 @@ declare namespace ts.server.protocol {
48
48
GetCodeFixes = "getCodeFixes" ,
49
49
GetSupportedCodeFixes = "getSupportedCodeFixes" ,
50
50
GetApplicableRefactors = "getApplicableRefactors" ,
51
- GetRefactorCodeActions = "getRefactorCodeActions" ,
52
- GetRefactorCodeActionsFull = "getRefactorCodeActions-full" ,
51
+ GetEditsForRefactor = "getEditsForRefactor" ,
53
52
}
54
53
/**
55
54
* A TypeScript Server message
@@ -291,32 +290,84 @@ declare namespace ts.server.protocol {
291
290
offset : number ;
292
291
}
293
292
type FileLocationOrRangeRequestArgs = FileLocationRequestArgs | FileRangeRequestArgs ;
293
+ /**
294
+ * Request refactorings at a given position or selection area.
295
+ */
294
296
interface GetApplicableRefactorsRequest extends Request {
295
297
command : CommandTypes . GetApplicableRefactors ;
296
298
arguments : GetApplicableRefactorsRequestArgs ;
297
299
}
298
300
type GetApplicableRefactorsRequestArgs = FileLocationOrRangeRequestArgs ;
299
- interface ApplicableRefactorInfo {
300
- name : string ;
301
- description : string ;
302
- }
301
+ /**
302
+ * Response is a list of available refactorings.
303
+ * Each refactoring exposes one or more "Actions"; a user selects one action to invoke a refactoring
304
+ */
303
305
interface GetApplicableRefactorsResponse extends Response {
304
306
body ?: ApplicableRefactorInfo [ ] ;
305
307
}
306
- interface GetRefactorCodeActionsRequest extends Request {
307
- command : CommandTypes . GetRefactorCodeActions ;
308
- arguments : GetRefactorCodeActionsRequestArgs ;
308
+ /**
309
+ * A set of one or more available refactoring actions, grouped under a parent refactoring.
310
+ */
311
+ interface ApplicableRefactorInfo {
312
+ /**
313
+ * The programmatic name of the refactoring
314
+ */
315
+ name : string ;
316
+ /**
317
+ * A description of this refactoring category to show to the user.
318
+ * If the refactoring gets inlined (see below), this text will not be visible.
319
+ */
320
+ description : string ;
321
+ /**
322
+ * Inlineable refactorings can have their actions hoisted out to the top level
323
+ * of a context menu. Non-inlineanable refactorings should always be shown inside
324
+ * their parent grouping.
325
+ *
326
+ * If not specified, this value is assumed to be 'true'
327
+ */
328
+ inlineable ?: boolean ;
329
+ actions : RefactorActionInfo [ ] ;
309
330
}
310
- type GetRefactorCodeActionsRequestArgs = FileLocationOrRangeRequestArgs & {
311
- refactorName : string ;
331
+ /**
332
+ * Represents a single refactoring action - for example, the "Extract Method..." refactor might
333
+ * offer several actions, each corresponding to a surround class or closure to extract into.
334
+ */
335
+ type RefactorActionInfo = {
336
+ /**
337
+ * The programmatic name of the refactoring action
338
+ */
339
+ name : string ;
340
+ /**
341
+ * A description of this refactoring action to show to the user.
342
+ * If the parent refactoring is inlined away, this will be the only text shown,
343
+ * so this description should make sense by itself if the parent is inlineable=true
344
+ */
345
+ description : string ;
312
346
} ;
313
- type RefactorCodeActions = {
314
- actions : protocol . CodeAction [ ] ;
315
- renameLocation ?: number ;
347
+ interface GetEditsForRefactorRequest extends Request {
348
+ command : CommandTypes . GetEditsForRefactor ;
349
+ arguments : GetEditsForRefactorRequestArgs ;
350
+ }
351
+ /**
352
+ * Request the edits that a particular refactoring action produces.
353
+ * Callers must specify the name of the refactor and the name of the action.
354
+ */
355
+ type GetEditsForRefactorRequestArgs = FileLocationOrRangeRequestArgs & {
356
+ refactor : string ;
357
+ action : string ;
316
358
} ;
317
- interface GetRefactorCodeActionsResponse extends Response {
318
- body : RefactorCodeActions ;
359
+ interface GetEditsForRefactorResponse extends Response {
360
+ body ?: RefactorEditInfo ;
319
361
}
362
+ type RefactorEditInfo = {
363
+ edits : FileCodeEdits [ ] ;
364
+ /**
365
+ * An optional location where the editor should start a rename operation once
366
+ * the refactoring edits have been applied
367
+ */
368
+ renameLocation ?: Location ;
369
+ renameFilename ?: string ;
370
+ } ;
320
371
/**
321
372
* Request for the available codefixes at a specific position.
322
373
*/
0 commit comments