Permalink
be43c6f Sep 9, 2017
2 contributors

Users who have contributed to this file

@hansonw @wbinnssmith
51 lines (36 sloc) 1.54 KB

Code Actions

Code Actions allow you to perform additional actions for diagnostics.

Code Actions can currently be triggered in two ways.

Either by mousing over a diagnostic with code actions:

Datatip

Or by using the diagnostics:show-actions-at-position command / keyboard shortcut while the cursor is on top of a diagnostic with code actions.

Context menu

Service API

Provide the code actions Atom service by adding this to your package.json:

"providedServices": {
  "code-actions": {
    "versions": {
      "0.1.0": "provideCodeActions"
    }
  }
}

Then, in your package entry point, add:

export function provideCodeActions(): CodeActionProvider {
  return ...
}

You must return a CodeActionProvider object as described in atom-ide-code-actions/lib/types.js.

  • grammarScopes should be a list of scope names of grammars that the provider should apply to.
  • priority will be used to determine the ordering of code actions in the case of multiple providers.
  • getCodeActions will be called in the situations described above, with a list of intersecting diagnostics. See screenshots above to see how actions are displayed in the UI.

Once the user clicks an action, your apply() function will be called.