CodeAction
in package
implements
JsonSerializable
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.
Table of Contents
Interfaces
- JsonSerializable
Properties
- $command : Command|null
- A command this code action executes. If a code action provides an edit and a command, first the edit is executed and then the command.
- $data : mixed|null
- A data entry field that is preserved on a code action between a `textDocument/codeAction` and a `codeAction/resolve` request.
- $diagnostics : array<string|int, Diagnostic>|null
- The diagnostics that this code action resolves.
- $disabled : CodeActionDisabled|null
- Marks that the code action cannot currently be applied.
- $edit : WorkspaceEdit|null
- The workspace edit this code action performs.
- $isPreferred : bool|null
- Marks this as a preferred action. Preferred actions are used by the `auto fix` command and can be targeted by keybindings.
- $kind : string|null
- The kind of the code action.
- $title : string
- A short, human-readable, title for this code action.
Methods
- __construct() : mixed
- Undocumented function
- jsonSerialize() : mixed
- This is needed because VSCode Does not like nulls meaning if a null is sent then this will not compute
Properties
$command
A command this code action executes. If a code action provides an edit and a command, first the edit is executed and then the command.
public
Command|null
$command
$data
A data entry field that is preserved on a code action between a `textDocument/codeAction` and a `codeAction/resolve` request.
public
mixed|null
$data
Tags
$diagnostics
The diagnostics that this code action resolves.
public
array<string|int, Diagnostic>|null
$diagnostics
$disabled
Marks that the code action cannot currently be applied.
public
CodeActionDisabled|null
$disabled
Clients should follow the following guidelines regarding disabled code actions:
-
Disabled code actions are not shown in automatic lightbulbs code action menus.
-
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
reasonin the editor.
Tags
$edit
The workspace edit this code action performs.
public
WorkspaceEdit|null
$edit
$isPreferred
Marks this as a preferred action. Preferred actions are used by the `auto fix` command and can be targeted by keybindings.
public
bool|null
$isPreferred
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.
Tags
$kind
The kind of the code action.
public
string|null
$kind
Used to filter code actions.
Tags
$title
A short, human-readable, title for this code action.
public
string
$title
Methods
__construct()
Undocumented function
public
__construct([string|null $title = null ][, string|null $kind = null ][, array<string|int, Diagnostic>|null $diagnostics = null ][, bool|null $isPreferred = null ][, CodeActionDisabled|null $disabled = null ][, WorkspaceEdit|null $edit = null ][, Command|null $command = null ][, mixed $data = null ]) : mixed
Parameters
- $title : string|null = null
- $kind : string|null = null
- $diagnostics : array<string|int, Diagnostic>|null = null
- $isPreferred : bool|null = null
- $disabled : CodeActionDisabled|null = null
- $edit : WorkspaceEdit|null = null
- $command : Command|null = null
- $data : mixed = null
jsonSerialize()
This is needed because VSCode Does not like nulls meaning if a null is sent then this will not compute
public
jsonSerialize() : mixed
Attributes
- #[ReturnTypeWillChange]