summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clangd/Protocol.h
diff options
context:
space:
mode:
Diffstat (limited to 'clang-tools-extra/clangd/Protocol.h')
-rw-r--r--clang-tools-extra/clangd/Protocol.h26
1 files changed, 23 insertions, 3 deletions
diff --git a/clang-tools-extra/clangd/Protocol.h b/clang-tools-extra/clangd/Protocol.h
index 447611906cd..3007dc368a4 100644
--- a/clang-tools-extra/clangd/Protocol.h
+++ b/clang-tools-extra/clangd/Protocol.h
@@ -82,6 +82,7 @@ struct TextDocumentIdentifier {
/// The text document's URI.
URIForFile uri;
};
+json::Expr toJSON(const TextDocumentIdentifier &);
bool fromJSON(const json::Expr &, TextDocumentIdentifier &);
struct Position {
@@ -424,6 +425,17 @@ struct WorkspaceEdit {
bool fromJSON(const json::Expr &, WorkspaceEdit &);
json::Expr toJSON(const WorkspaceEdit &WE);
+struct IncludeInsertion {
+ /// The document in which the command was invoked.
+ TextDocumentIdentifier textDocument;
+
+ /// The header to be inserted. This could be either a URI ir a literal string
+ /// quoted with <> or "" that can be #included directly.
+ std::string header;
+};
+bool fromJSON(const json::Expr &, IncludeInsertion &);
+json::Expr toJSON(const IncludeInsertion &II);
+
/// Exact commands are not specified in the protocol so we define the
/// ones supported by Clangd here. The protocol specifies the command arguments
/// to be "any[]" but to make this safer and more manageable, each command we
@@ -435,15 +447,25 @@ json::Expr toJSON(const WorkspaceEdit &WE);
struct ExecuteCommandParams {
// Command to apply fix-its. Uses WorkspaceEdit as argument.
const static llvm::StringLiteral CLANGD_APPLY_FIX_COMMAND;
+ // Command to insert an #include into code.
+ const static llvm::StringLiteral CLANGD_INSERT_HEADER_INCLUDE;
/// The command identifier, e.g. CLANGD_APPLY_FIX_COMMAND
std::string command;
// Arguments
llvm::Optional<WorkspaceEdit> workspaceEdit;
+
+ llvm::Optional<IncludeInsertion> includeInsertion;
};
bool fromJSON(const json::Expr &, ExecuteCommandParams &);
+struct Command : public ExecuteCommandParams {
+ std::string title;
+};
+
+json::Expr toJSON(const Command &C);
+
struct ApplyWorkspaceEditParams {
WorkspaceEdit edit;
};
@@ -560,12 +582,10 @@ struct CompletionItem {
/// themselves.
std::vector<TextEdit> additionalTextEdits;
+ llvm::Optional<Command> command;
// TODO(krasimir): The following optional fields defined by the language
// server protocol are unsupported:
//
- // command?: Command - An optional command that is executed *after* inserting
- // this completion.
- //
// data?: any - A data entry field that is preserved on a completion item
// between a completion and a completion resolve request.
};
OpenPOWER on IntegriCloud