A code action represents a change that can be performed in code, e.g. to fix a problem or to refactor code.
A CodeAction must set either edit
and/or a command
. If both are supplied, the edit
is applied first, then the command
is executed.
Fields
optionalisPreferred:Null<Bool>
Marks this as a preferred action. Preferred actions are used by the auto fix
command and can be targeted
by keybindings.
A quick fix should be marked preferred if it properly addresses the underlying error. A refactoring should be marked preferred if it is the most reasonable choice of actions to take.
3.15.0
.optionaldisabled:Null<{reason:String}>
Marks that the code action cannot currently be applied.
Clients should follow the following guidelines regarding disabled code actions:
-
Disabled code actions are not shown in automatic lightbulb code action menu.
-
Disabled actions are shown as faded out in the code action menu when the user request a more specific type of code action, such as refactorings.
-
If the user has a keybinding that auto applies a code action and only a disabled code actions are returned, the client should show the user an error message with
reason
in the editor.
3.16.0
.