Skip to content

Add CodeAction interface #34597

@mjbvz

Description

@mjbvz

Part of #33555

Problem
Code actions are currently just a list of Command. These commands provide have no information about what the code action actually does. We'd like to be able to do the following:

  • Sort code actions so that fixes for errors show up first
  • Group code actions by type / by the error they fix
  • Provide a better UI for code actions that tells users which actions address which problems in the code

Proposal
Introduce a new CodeAction interface that defines additional information about a code action. To start, I propose we add two additional field to this interface: a type and a list of diagnostics:

enum class CodeActionType {
    // Standard type. Would be used for existing CodeActionProviders that return Commands
    Default = 0 ,

    // Fixes a diagnostic in the CodeActionContext
    QuickFix = 1,    

    // Perform a refactorng
    Refactoring  =2
}

interface CodeAction {
    // Command the performs the action
    command: Command

    type: CodeActionType

    // List of diagnostics this code action resolves
    diagnostics?: Diagnostic[]
}

// cc @jrieken

Metadata

Metadata

Assignees

Labels

apieditor-code-actionsEditor inplace actions (Ctrl + .)feature-requestRequest for new features or functionalityunder-discussionIssue is under discussion for relevance, priority, approach

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions