24 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_PROTOCOL_H 25 #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_PROTOCOL_H 29 #include "llvm/ADT/Optional.h" 30 #include "llvm/Support/JSON.h" 53 class LSPError :
public llvm::ErrorInfo<LSPError> {
60 : Message(std::move(Message)), Code(Code) {}
62 void log(llvm::raw_ostream &OS)
const override {
63 OS << int(Code) <<
": " <<
Message;
66 return llvm::inconvertibleErrorCode();
85 llvm::StringRef TUPath);
87 static llvm::Expected<URIForFile> fromURI(
const URI &U,
88 llvm::StringRef HintPath);
93 explicit operator bool()
const {
return !
File.empty(); }
97 return LHS.File == RHS.File;
101 return !(LHS == RHS);
105 return LHS.File < RHS.File;
139 return !(LHS == RHS);
165 return !(LHS == RHS);
173 return start <= Rng.
start && Rng.
end <= end;
190 return !(LHS == RHS);
345 bool DiagnosticFixes =
false;
350 bool DiagnosticCategory =
false;
354 bool CompletionSnippets =
false;
357 bool HierarchicalDocumentSymbol =
false;
365 bool CodeActionStructure =
false;
513 bool insertSpaces =
false;
627 llvm::Optional<std::map<std::string, std::vector<TextEdit>>>
changes;
671 llvm::Optional<std::string>
kind;
678 llvm::Optional<WorkspaceEdit>
edit;
751 llvm::Optional<SymbolID>
ID;
887 bool deprecated =
false;
904 bool isIncomplete =
false;
935 llvm::raw_ostream &
operator<<(llvm::raw_ostream &,
945 int activeSignature = 0;
948 int activeParameter = 0;
986 int LHSKind =
static_cast<int>(LHS.
kind);
987 int RHSKind =
static_cast<int>(RHS.
kind);
988 return std::tie(LHS.
range, LHSKind) < std::tie(RHS.
range, RHSKind);
1020 template <>
struct format_provider<
clang::clangd::Position> {
1023 assert(Style.empty() &&
"style modifiers for this type are not supported");
std::string insertText
A string that should be inserted to a document when selecting this completion.
std::string USR
Unified Symbol Resolution identifier This is an opaque string uniquely identifying a symbol...
const tooling::CompileCommand & Command
friend bool operator<(const Location &LHS, const Location &RHS)
URIForFile uri
The file's URI.
llvm::json::Value toJSON(const FuzzyFindRequest &Request)
friend bool operator==(const Location &LHS, const Location &RHS)
llvm::Optional< TextEdit > textEdit
An edit which is applied to a document when selecting this completion.
Exact commands are not specified in the protocol so we define the ones supported by Clangd here...
llvm::Optional< SymbolKindBitset > WorkspaceSymbolKinds
The supported set of SymbolKinds for workspace/symbol.
Some operations such as code completion produce a set of candidates.
llvm::Optional< URIForFile > rootUri
The rootUri of the workspace.
Position start
The range's start position.
friend bool operator==(const URIForFile &LHS, const URIForFile &RHS)
ConfigurationSettings settings
Represents a collection of completion items to be presented in the editor.
Range range
The range this highlight applies to.
llvm::Optional< bool > wantDiagnostics
Forces diagnostics to be generated, or to not be generated, for this version of the file...
friend bool operator<=(const Position &LHS, const Position &RHS)
std::vector< std::string > compilationCommand
Range range
The range for which the command was invoked.
CodeActionContext context
Context carrying additional information.
static const llvm::StringLiteral CLANGD_APPLY_FIX_COMMAND
Clangd extension: parameters configurable at initialize time.
std::vector< CompletionItem > items
The completion items.
Documents are synced by always sending the full content of the document.
Documents are synced by sending the full content on open.
llvm::Optional< std::vector< CodeAction > > codeActions
Clangd extension: code actions related to this diagnostic.
llvm::Optional< std::map< std::string, std::vector< TextEdit > > > changes
Holds changes to existing resources.
llvm::Optional< std::string > kind
The kind of the code action.
bool operator==(const SymbolLocation::Position &L, const SymbolLocation::Position &R)
bool operator()(const Diagnostic &LHS, const Diagnostic &RHS) const
std::string title
A short, human-readable, title for this code action.
llvm::Optional< Range > range
An optional range is a range inside a text document that is used to visualize a hover, e.g.
TextDocumentIdentifier textDocument
The document that was closed.
std::string state
The human-readable string presents the current state of the file, can be shown in the UI (e...
An Event<T> allows events of type T to be broadcast to listeners.
A code action represents a change that can be performed in code, e.g.
friend bool operator!=(const URIForFile &LHS, const URIForFile &RHS)
URIForFile uri
The text document's URI.
std::string text
The new text of the range/document.
friend bool operator!=(const Position &LHS, const Position &RHS)
llvm::Optional< WorkspaceEdit > edit
The workspace edit this code action performs.
Range selectionRange
The range that should be selected and revealed when this symbol is being picked, e.g the name of a function.
Values in a Context are indexed by typed keys.
constexpr auto SymbolKindMin
llvm::Optional< std::string > compilationDatabasePath
std::string sortText
A string that should be used when comparing this item with other items.
constexpr auto CompletionItemKindMin
static const StringRef Message
friend bool operator!=(const Range &LHS, const Range &RHS)
std::bitset< CompletionItemKindMax+1 > CompletionItemKindBitset
Documents should not be synced at all.
std::string documentation
A human-readable string that represents a doc-comment.
InsertTextFormat
Defines whether the insert text in a completion item should be interpreted as plain text or a snippet...
Range range
The range enclosing this symbol not including leading/trailing whitespace but everything else like co...
URIForFile uri
The text document's URI.
std::vector< TextEdit > additionalTextEdits
An optional array of additional text edits that are applied when selecting this completion.
constexpr auto CompletionItemKindMax
Represents programming constructs like variables, classes, interfaces etc.
llvm::Optional< int > processId
The process Id of the parent process that started the server.
bool operator==(const TextEdit &rhs) const
CompletionItemKind
The kind of a completion entry.
bool operator<(const SymbolLocation::Position &L, const SymbolLocation::Position &R)
ConfigurationSettings ConfigSettings
TextDocumentSyncKind
Defines how the host (editor) should sync document changes to the language server.
MarkupContent contents
The hover's content.
std::error_code convertToErrorCode() const override
A document highlight is a range inside a text document which deserves special attention.
URIForFile uri
The text document's URI.
std::string detail
A human-readable string with additional information about this item, like type or symbol information...
llvm::Optional< SymbolID > ID
LSPError(std::string Message, ErrorCode Code)
static URI createFile(llvm::StringRef AbsolutePath)
This creates a file:// URI for AbsolutePath. The path must be absolute.
TextDocumentIdentifier textDocument
The document that was opened.
std::string newText
The string to be inserted.
std::string newName
The new name of the symbol.
Clangd extension: parameters configurable at any time, via the workspace/didChangeConfiguration notif...
std::string command
The command identifier, e.g. CLANGD_APPLY_FIX_COMMAND.
InitializationOptions initializationOptions
User-provided initialization options.
TextDocumentIdentifier textDocument
std::string filterText
A string that should be used when filtering a set of completion items.
friend bool operator<(const Position &LHS, const Position &RHS)
TextDocumentIdentifier textDocument
The document in which the command was invoked.
Range range
The range of the text document to be manipulated.
std::vector< std::string > fallbackFlags
friend bool operator<(const Range &LHS, const Range &RHS)
llvm::Optional< Range > range
The range of the document that changed.
llvm::Optional< std::string > category
The diagnostic's category.
Position position
The position inside the text document.
std::string containerName
std::vector< DocumentSymbol > children
Children of this symbol, e.g. properties of a class.
Position argListStart
Position of the start of the argument list, including opening paren.
std::vector< SignatureInformation > signatures
The resulting signatures.
llvm::Optional< int > rangeLength
The length of the range that got replaced.
static llvm::SmallString< 128 > canonicalize(llvm::StringRef Path)
std::string name
The name of this symbol.
Completion was triggered by typing an identifier (24x7 code complete), manual invocation (e...
ClientCapabilities capabilities
The capabilities provided by the client (editor or tool)
TextDocumentItem textDocument
The document that was opened.
TextDocumentIdentifier textDocument
The document that did change.
std::map< std::string, ClangdCompileCommand > compilationDatabaseChanges
std::string detail
More detail for this symbol, e.g the signature of a function.
Completion was triggered by a trigger character specified by the triggerCharacters properties of the ...
std::vector< FileEvent > changes
The actual file events.
llvm::Optional< CompletionItemKindBitset > CompletionItemKinds
The supported set of CompletionItemKinds for textDocument/completion.
std::string languageId
The text document's language identifier.
llvm::Optional< std::string > rootPath
The rootPath of the workspace.
bool fromJSON(const llvm::json::Value &Parameters, FuzzyFindRequest &Request)
A LSP-specific comparator used to find diagnostic in a container like std:map.
int line
Line position in a document (zero-based).
std::vector< TextDocumentContentChangeEvent > contentChanges
The actual content changes.
friend bool operator<(const DocumentHighlight &LHS, const DocumentHighlight &RHS)
int character
Character offset on a line in a document (zero-based).
CompletionContext context
bool contains(Position Pos) const
Represents the signature of a callable.
std::string query
A non-empty query string.
SymbolKind kind
The kind of this symbol.
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
std::bitset< SymbolKindMax+1 > SymbolKindBitset
std::string message
The diagnostic's code.
std::string triggerCharacter
The trigger character (a single character) that has trigger code complete.
TextDocumentIdentifier textDocument
The text document.
std::string label
The label of this completion item.
friend bool operator==(const DocumentHighlight &LHS, const DocumentHighlight &RHS)
DocumentHighlightKind kind
The highlight kind, default is DocumentHighlightKind.Text.
SymbolKind adjustKindToCapability(SymbolKind Kind, SymbolKindBitset &SupportedSymbolKinds)
static const llvm::StringLiteral QUICKFIX_KIND
bool contains(Range Rng) const
A URI describes the location of a source file.
std::vector< Diagnostic > diagnostics
An array of diagnostics.
bool deprecated
Indicates if this symbol is deprecated.
llvm::Optional< Command > command
A command this code action executes.
The parameters of a Workspace Symbol Request.
std::string workingDirectory
std::string text
The content of the opened text document.
Clangd extension: indicates the current state of the file in clangd, sent from server via the textDoc...
llvm::Optional< std::vector< Diagnostic > > diagnostics
The diagnostics that this code action resolves.
Position position
The position at which this request was sent.
URIForFile uri
The text document's URI.
friend bool operator!=(const Location &LHS, const Location &RHS)
Range range
The range at which the message applies.
friend bool operator<(const URIForFile &LHS, const URIForFile &RHS)
Position end
The range's end position.
llvm::Optional< WorkspaceEdit > workspaceEdit
llvm::raw_ostream & operator<<(llvm::raw_ostream &OS, const CodeCompletion &C)
Completion was re-triggered as the current completion list is incomplete.
std::string toString() const
Returns a string URI with all components percent-encoded.
Clangd extension that's used in the 'compilationDatabaseChanges' in workspace/didChangeConfiguration ...
friend bool operator==(const Position &LHS, const Position &RHS)
void log(llvm::raw_ostream &OS) const override
friend bool operator==(const Range &LHS, const Range &RHS)
Represents information about identifier.
constexpr auto SymbolKindMax
llvm::Optional< TraceLevel > trace
The initial trace setting. If omitted trace is disabled ('off').
llvm::StringRef file() const
Retrieves absolute path to the file.