CodeActionProvider

Provides contextual actions for code. Code actions typically either fix problems or beautify/refactor code.

Code actions are surfaced to users in a few different ways:

  • The lightbulb feature, which shows a list of code actions at the current cursor position. The lightbulb's list of actions includes both quick fixes and refactorings.

  • As commands that users can run, such as Refactor. Users can run these from the command palette or with keybindings.

  • As source actions, such Organize Imports.

  • Quick fixes are shown in the problems view.

  • Change applied on save by the editor.codeActionsOnSave setting.

Online Documentation

Properties

Link copied to clipboard
abstract var resolveCodeAction: (codeAction: T, token: CancellationToken) -> ProviderResult<T>?

Given a code action fill in its edit-property. Changes to all other properties, like title, are ignored. A code action that has an edit will not be resolved.

Functions

Link copied to clipboard
abstract fun provideCodeActions(document: TextDocument, range: Range, context: CodeActionContext, token: CancellationToken): ProviderResult<ReadonlyArray<ERROR CLASS: Symbol not found for JsAny>>

Get code actions for a given range in a document.

abstract fun provideCodeActions(document: TextDocument, range: Selection, context: CodeActionContext, token: CancellationToken): ProviderResult<ReadonlyArray<ERROR CLASS: Symbol not found for JsAny>>