| 1 |
#pragma once |
| 2 |
#include "LibLsp/lsp/method_type.h" |
| 3 |
#include "LibLsp/JsonRpc/message.h" |
| 4 |
#include "LibLsp/lsp/lsp_diagnostic.h" |
| 5 |
#include "LibLsp/lsp/workspace/execute_command.h" |
| 6 |
#include "LibLsp/lsp/lsTextDocumentIdentifier.h" |
| 7 |
#include "LibLsp/lsp/lsCodeAction.h" |
| 8 |
namespace JDT |
| 9 |
{ |
| 10 |
namespace CodeActionKind |
| 11 |
{ |
| 12 |
|
| 13 |
/** |
| 14 |
* Base kind for quickfix actions: 'quickfix' |
| 15 |
*/ |
| 16 |
extern char const* QuickFix; |
| 17 |
|
| 18 |
/** |
| 19 |
* Base kind for refactoring actions: 'refactor' |
| 20 |
*/ |
| 21 |
extern char const* Refactor; |
| 22 |
|
| 23 |
/** |
| 24 |
* Base kind for refactoring extraction actions: 'refactor.extract' |
| 25 |
* |
| 26 |
* Example extract actions: |
| 27 |
* |
| 28 |
* - Extract method - Extract function - Extract variable - Extract interface |
| 29 |
* from class - ... |
| 30 |
*/ |
| 31 |
extern char const* RefactorExtract; |
| 32 |
|
| 33 |
/** |
| 34 |
* Base kind for refactoring inline actions: 'refactor.inline' |
| 35 |
* |
| 36 |
* Example inline actions: |
| 37 |
* |
| 38 |
* - Inline function - Inline variable - Inline constant - ... |
| 39 |
*/ |
| 40 |
extern char const* RefactorInline; |
| 41 |
|
| 42 |
/** |
| 43 |
* Base kind for refactoring rewrite actions: 'refactor.rewrite' |
| 44 |
* |
| 45 |
* Example rewrite actions: |
| 46 |
* |
| 47 |
* - Convert JavaScript function to class - Add or remove parameter - |
| 48 |
* Encapsulate field - Make method static - Move method to base class - ... |
| 49 |
*/ |
| 50 |
extern char const* RefactorRewrite; |
| 51 |
|
| 52 |
/** |
| 53 |
* Base kind for source actions: `source` |
| 54 |
* |
| 55 |
* Source code actions apply to the entire file. |
| 56 |
*/ |
| 57 |
extern char const* Source; |
| 58 |
|
| 59 |
/** |
| 60 |
* Base kind for an organize imports source action: `source.organizeImports` |
| 61 |
*/ |
| 62 |
extern char const* SourceOrganizeImports; |
| 63 |
|
| 64 |
extern char const* COMMAND_ID_APPLY_EDIT; |
| 65 |
}; // namespace CodeActionKind |
| 66 |
|
| 67 |
} // namespace JDT |
| 68 |
struct lsCodeActionContext |
| 69 |
{ |
| 70 |
// An array of diagnostics. |
| 71 |
std::vector<lsDiagnostic> diagnostics; |
| 72 |
/** |
| 73 |
* Requested kind of actions to return. |
| 74 |
* |
| 75 |
* Actions not of this kind are filtered out by the client before being shown. So servers |
| 76 |
* can omit computing them. |
| 77 |
* |
| 78 |
* See {@link CodeActionKind} for allowed values. |
| 79 |
*/ |
| 80 |
optional<std::vector<std::string>> only; |
| 81 |
|
| 82 |
MAKE_SWAP_METHOD(lsCodeActionContext, diagnostics, only); |
| 83 |
}; |
| 84 |
MAKE_REFLECT_STRUCT(lsCodeActionContext, diagnostics, only); |
| 85 |
|
| 86 |
// Params for the CodeActionRequest |
| 87 |
struct lsCodeActionParams |
| 88 |
{ |
| 89 |
// The document in which the command was invoked. |
| 90 |
lsTextDocumentIdentifier textDocument; |
| 91 |
// The range for which the command was invoked. |
| 92 |
lsRange range; |
| 93 |
// Context carrying additional information. |
| 94 |
lsCodeActionContext context; |
| 95 |
|
| 96 |
MAKE_SWAP_METHOD(lsCodeActionParams, textDocument, range, context); |
| 97 |
}; |
| 98 |
MAKE_REFLECT_STRUCT(lsCodeActionParams, textDocument, range, context); |