Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CodeAction interface #34597

Closed
mjbvz opened this issue Sep 18, 2017 · 3 comments
Closed

Add CodeAction interface #34597

mjbvz opened this issue Sep 18, 2017 · 3 comments
Assignees
Labels
api editor-code-actions Editor inplace actions (Ctrl + .) feature-request Request for new features or functionality under-discussion Issue is under discussion for relevance, priority, approach

Comments

@mjbvz
Copy link
Collaborator

mjbvz commented Sep 18, 2017

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

@mjbvz mjbvz added the api label Sep 18, 2017
@mjbvz mjbvz self-assigned this Sep 18, 2017
@jrieken jrieken assigned jrieken and unassigned mjbvz Sep 19, 2017
@jrieken jrieken added editor-code-actions Editor inplace actions (Ctrl + .) feature-request Request for new features or functionality labels Sep 19, 2017
@jrieken
Copy link
Member

jrieken commented Sep 19, 2017

CodeAction type yes, in that shape probably not. Folks also want a preview of the textual changes, so instead/in addition to a command we should support text edits or a workspace edit. This needs proper thinking. @mjbvz What are your scenarios?

@mjbvz mjbvz added the under-discussion Issue is under discussion for relevance, priority, approach label Sep 19, 2017
@mjbvz
Copy link
Collaborator Author

mjbvz commented Sep 19, 2017

@jrieken Kai and I talked about this today and I've put together a more complete proposal based on that discussion: #34664

That proposal also would not provide workspace/text edits in its current form, but has been designed so that they could be accommodated in the future

@jrieken
Copy link
Member

jrieken commented Sep 20, 2017

ok, closing this as dupe of #34664

@jrieken jrieken closed this as completed Sep 20, 2017
@vscodebot vscodebot bot locked and limited conversation to collaborators Nov 17, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
api editor-code-actions Editor inplace actions (Ctrl + .) feature-request Request for new features or functionality under-discussion Issue is under discussion for relevance, priority, approach
Projects
None yet
Development

No branches or pull requests

2 participants