Files

20 lines
1.0 KiB
Markdown
Raw Permalink Normal View History

2019-05-30 18:18:14 -07:00
# Code Action Provider Sample
2020-02-19 12:18:49 +03:00
This sample shows how to provide code actions in the editor. Code actions are used to implement quick fixes and [refactoring](https://code.visualstudio.com/docs/editor/refactoring) in VS Code.
2019-05-30 18:18:14 -07:00
The sample uses the [`CodeActionProvider`](https://code.visualstudio.com/api/references/vscode-api#CodeActionProvider) api to implement a simple set of code actions that convert `:)` to a smiley emoji in markdown files:
2019-07-18 15:26:53 +02:00
![Emoji code actions](example.gif)
2019-05-30 18:18:14 -07:00
2019-07-18 15:26:53 +02:00
Second example of code action provider shows how to associate code actions with diagnostic (e.g. compilation) problems.
![Diagnostic code actions](example_diagnostic.gif)
2019-05-30 18:18:14 -07:00
## VS Code API
### `vscode` module
- [`languages.registerCodeActionsProvider`](https://code.visualstudio.com/api/references/vscode-api#languages.registerCodeActionsProvider)
2019-07-18 15:26:53 +02:00
- [`Diagnostic.code`](https://code.visualstudio.com/api/references/vscode-api#Diagnostic)
- [`CodeActionContext.diagnostics`](https://code.visualstudio.com/api/references/vscode-api#CodeActionContext)