Options
All
  • Public
  • Public/Protected
  • All
Menu

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.

层级

  • CodeAction

索引

Constructors(1)

Properties(7)

Constructors(1)

constructor

Properties(7)

title

title: string

A short, human-readable, title for this code action.

Optional edit

A workspace edit this code action performs.

Optional diagnostics

diagnostics: Diagnostic[]

Diagnostics that this code action resolves.

Optional command

command: Command

A Command this code action executes.

If this command throws an exception, the editor displays the exception message to users in the editor at the current cursor position.

Optional kind

Kind of the code action.

Used to filter code actions.

Optional isPreferred

isPreferred: boolean

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.

Optional disabled

disabled: { reason: string }

Marks that the code action cannot currently be applied.

  • 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 editor will show the user an error message with reason in the editor.

Type declaration

  • Readonly reason: string

    Human readable description of why the code action is currently disabled.

    This is displayed in the code actions UI.

友链:VS Code 中文文档 | VS Code 官网文档 | VS Code 扩展市场

Generated by TypeDoc. Maintained by 洛竹