Go to the documentation of this file.
23 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_PROTOCOL_H
24 #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_PROTOCOL_H
28 #include "clang/Index/IndexSymbol.h"
29 #include "llvm/ADT/Optional.h"
30 #include "llvm/Support/JSON.h"
31 #include "llvm/Support/raw_ostream.h"
56 class LSPError :
public llvm::ErrorInfo<LSPError> {
65 void log(llvm::raw_ostream &
OS)
const override {
69 return llvm::inconvertibleErrorCode();
88 llvm::StringRef TUPath);
90 static llvm::Expected<URIForFile>
fromURI(
const URI &U,
91 llvm::StringRef HintPath);
94 llvm::StringRef
file()
const {
return File; }
96 explicit operator bool()
const {
return !File.empty(); }
100 return LHS.File == RHS.File;
104 return !(LHS == RHS);
108 return LHS.File < RHS.File;
112 explicit URIForFile(std::string &&File) : File(std::move(File)) {}
118 llvm::json::Value
toJSON(
const URIForFile &U);
119 bool fromJSON(
const llvm::json::Value &, URIForFile &);
158 return !(LHS == RHS);
169 bool fromJSON(
const llvm::json::Value &, Position &);
170 llvm::json::Value
toJSON(
const Position &);
171 llvm::raw_ostream &
operator<<(llvm::raw_ostream &,
const Position &);
184 return !(LHS == RHS);
209 return !(LHS == RHS);
231 bool fromJSON(
const llvm::json::Value &, TextEdit &);
232 llvm::json::Value
toJSON(
const TextEdit &);
233 llvm::raw_ostream &
operator<<(llvm::raw_ostream &,
const TextEdit &);
558 return llvm::json::Object{{
"token", P.
token}, {
"value", P.
value}};
862 llvm::Optional<std::map<std::string, std::vector<TextEdit>>>
changes;
911 llvm::json::Value
toJSON(
const Command &C);
924 llvm::Optional<std::string>
kind;
933 llvm::Optional<WorkspaceEdit>
edit;
1006 llvm::Optional<SymbolID>
ID;
1206 llvm::raw_ostream &
operator<<(llvm::raw_ostream &,
1257 int LHSKind = static_cast<int>(LHS.
kind);
1258 int RHSKind = static_cast<int>(RHS.
kind);
1259 return std::tie(LHS.
range, LHSKind) < std::tie(RHS.
range, RHSKind);
1267 llvm::json::Value
toJSON(
const DocumentHighlight &DH);
1268 llvm::raw_ostream &
operator<<(llvm::raw_ostream &,
const DocumentHighlight &);
1316 llvm::Optional<std::vector<TypeHierarchyItem>>
parents;
1321 llvm::Optional<std::vector<TypeHierarchyItem>>
children;
1425 llvm::Optional<std::vector<SemanticTokensEdit>>
edits;
1427 llvm::Optional<std::vector<SemanticToken>>
tokens;
1454 std::vector<TheiaSemanticHighlightingInformation>
Lines;
1508 return !(LHS == RHS);
1511 llvm::json::Value
toJSON(
const DocumentLink &DocumentLink);
1534 template <>
struct format_provider<
clang::clangd::Position> {
1537 assert(Style.empty() &&
"style modifiers for this type are not supported");
A document highlight is a range inside a text document which deserves special attention.
llvm::Optional< std::map< std::string, std::vector< TextEdit > > > changes
Holds changes to existing resources.
CharSourceRange Range
SourceRange for the file name.
Range selectionRange
The range that should be selected and revealed when this type hierarchy item is being picked,...
bool isIncomplete
The list is not complete.
Range range
The range enclosing this symbol not including leading/trailing whitespace but everything else like co...
constexpr auto SymbolKindMax
TextDocumentItem textDocument
The document that was opened.
std::string source
A human-readable string describing the source of this diagnostic, e.g.
Some operations such as code completion produce a set of candidates.
std::error_code convertToErrorCode() const override
constexpr auto SymbolKindMin
URIForFile uri
The text document's URI.
Clangd extension that's used in the 'compilationDatabaseChanges' in workspace/didChangeConfiguration ...
const static llvm::StringLiteral CLANGD_APPLY_TWEAK
std::string workingDirectory
bool DiagnosticFixes
Whether the client accepts diagnostics with codeActions attached inline.
LSPError(std::string Message, ErrorCode Code)
llvm::Optional< bool > wantDiagnostics
Forces diagnostics to be generated, or to not be generated, for this version of the file.
std::string previousResultId
The previous result id.
unsigned tokenModifiers
each set bit will be looked up in SemanticTokensLegend.tokenModifiers
Body of textDocument/semanticTokens/full request.
URIForFile uri
The text document's URI.
std::vector< Diagnostic > diagnostics
An array of diagnostic information items.
URIForFile uri
The file's URI.
bool DiagnosticCategory
Whether the client accepts diagnostics with category attached to it using the "category" extension.
Completion was re-triggered as the current completion list is incomplete.
MessageType type
The message type.
int resolve
The hierarchy levels to resolve. 0 indicates no level.
TextDocumentIdentifier textDocument
The text document.
A code action represents a change that can be performed in code, e.g.
llvm::Optional< std::string > category
The diagnostic's category.
Body of textDocument/semanticTokens/full/delta request.
llvm::Optional< CompletionItemKindBitset > CompletionItemKinds
The supported set of CompletionItemKinds for textDocument/completion.
friend bool operator==(const DocumentHighlight &LHS, const DocumentHighlight &RHS)
bool deprecated
Indicates if this item is deprecated.
T value
The progress data.
llvm::Optional< std::string > message
Optional, a final message indicating to for example indicate the outcome of the operation.
llvm::Optional< int > processId
The process Id of the parent process that started the server.
Represents a collection of completion items to be presented in the editor.
bool CompletionFixes
Client supports completions with additionalTextEdit near the cursor.
The primary text to be inserted is treated as a plain string.
Describes a a replacement of a contiguous range of semanticTokens.
This models LSP SemanticTokensDelta | SemanticTokens, which is the result of textDocument/semanticTok...
llvm::Optional< SymbolKindBitset > WorkspaceSymbolKinds
The supported set of SymbolKinds for workspace/symbol.
llvm::Optional< std::string > kind
std::vector< Position > positions
The positions inside the text document.
friend bool operator<(const Location &LHS, const Location &RHS)
ConfigurationSettings settings
std::string label
The label of this completion item.
bool HierarchicalDocumentSymbol
Client supports hierarchical document symbols.
friend bool operator<(const Range &LHS, const Range &RHS)
Position start
The range's start position.
llvm::Optional< std::string > compilationDatabasePath
bool forceRebuild
Force a complete rebuild of the file, ignoring all cached state.
MarkupKind CompletionDocumentationFormat
The documentation format that should be used for textDocument/completion.
TextDocumentSyncKind
Defines how the host (editor) should sync document changes to the language server.
SymbolKind kind
The kind of the hierarchy item. For instance, class or interface.
A range in a text document that links to an internal or external resource, like another text document...
bool CompletionSnippets
Client supports snippets as insert text.
float score
This is Clangd extension.
Documents should not be synced at all.
unsigned deltaLine
token line number, relative to the previous token
Range range
The range this highlight applies to.
static llvm::Expected< URIForFile > fromURI(const URI &U, llvm::StringRef HintPath)
Position argListStart
Position of the start of the argument list, including opening paren.
std::string tweakID
ID of the tweak that should be executed. Corresponds to Tweak::id().
friend bool operator<=(const Position &LHS, const Position &RHS)
TextDocumentIdentifier textDocument
The document in which the command was invoked.
CodeActionContext context
Context carrying additional information.
bool contains(Range Rng) const
llvm::Optional< std::string > failureReason
friend bool operator<(const URIForFile &LHS, const URIForFile &RHS)
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)
std::vector< DocumentSymbol > children
Children of this symbol, e.g. properties of a class.
std::bitset< SymbolKindMax+1 > SymbolKindBitset
void log(llvm::raw_ostream &OS) const override
std::string containerName
Range range
The range enclosing this type hierarchy item not including leading/trailing whitespace but everything...
llvm::Optional< TextEdit > textEdit
An edit which is applied to a document when selecting this completion.
llvm::Optional< int64_t > version
The version number of this document (it will strictly increase after each change, including undo/redo...
bool cancellable
Controls if a cancel button should show to allow the user to cancel the long-running operation.
Position position
The position at which this request was sent.
Range range
The range at which the message applies.
llvm::Optional< bool > cancellable
Controls enablement state of a cancel button.
llvm::Optional< TweakArgs > tweakArgs
std::bitset< CompletionItemKindMax+1 > CompletionItemKindBitset
int line
Line position in a document (zero-based).
llvm::Optional< std::string > kind
The kind of the code action.
To start progress reporting a $/progress notification with the following payload must be sent.
std::string title
A short, human-readable, title for this code action.
DocumentHighlightKind kind
The highlight kind, default is DocumentHighlightKind.Text.
URIForFile uri
The text document's URI.
Signals the end of progress reporting.
llvm::Optional< std::vector< OffsetEncoding > > offsetEncoding
Supported encodings for LSP character offsets. (clangd extension).
bool OffsetsInSignatureHelp
Client supports processing label offsets instead of a simple label string.
std::string triggerCharacter
The trigger character (a single character) that has trigger code complete.
llvm::Optional< WorkspaceEdit > edit
The workspace edit this code action performs.
ClientCapabilities capabilities
The capabilities provided by the client (editor or tool)
std::string title
Mandatory title of the progress operation.
DiagnosticCallback Diagnostic
std::vector< SemanticToken > tokens
The actual tokens.
ConfigurationSettings ConfigSettings
std::string state
The human-readable string presents the current state of the file, can be shown in the UI (e....
bool RenamePrepareSupport
The client supports testing for validity of rename operations before execution.
MarkupKind HoverContentFormat
The content format that should be used for Hover requests.
Arguments for the 'applyTweak' command.
Specifies a single semantic token in the document.
friend bool operator==(const Range &LHS, const Range &RHS)
std::string insertText
A string that should be inserted to a document when selecting this completion.
llvm::Optional< std::vector< SemanticTokensEdit > > edits
Set if we computed edits relative to a previous set of tokens.
std::vector< SignatureInformation > signatures
The resulting signatures.
Parameters for the semantic highlighting (server-side) push notification.
TextDocumentIdentifier textDocument
std::vector< TheiaSemanticHighlightingInformation > Lines
The lines of highlightings that should be sent.
URIForFile uri
The URI for which diagnostic information is reported.
llvm::json::Value toJSON(const FuzzyFindRequest &Request)
std::vector< CompletionItem > items
The completion items.
llvm::Optional< std::string > message
Optional, more detailed associated progress message.
llvm::Optional< Range > range
An optional range is a range inside a text document that is used to visualize a hover,...
friend bool operator!=(const Location &LHS, const Location &RHS)
unsigned deltaStart
token start character, relative to the previous token (relative to 0 or the previous token's start if...
CompletionItemKind kind
The kind of this completion item.
std::string name
The human readable name of the hierarchy item.
unsigned tokenType
will be looked up in SemanticTokensLegend.tokenTypes
std::string detail
More detail for this symbol, e.g the signature of a function.
llvm::json::Value token
The token to be used to report progress.
URIForFile file
A file provided by the client on a textDocument/codeAction request.
friend bool operator==(const Location &LHS, const Location &RHS)
URIForFile uri
The text document's URI.
std::string command
The command identifier, e.g. CLANGD_APPLY_FIX_COMMAND.
TextDocumentIdentifier textDocument
SymbolKind indexSymbolKindToSymbolKind(index::SymbolKind Kind)
Range selectionRange
The range that should be selected and revealed when this symbol is being picked, e....
SymbolKind
The SymbolInfo Type.
std::string languageId
The text document's language identifier.
std::string sortText
A string that should be used when comparing this item with other items.
int character
Character offset on a line in a document (zero-based).
CompletionTriggerKind triggerKind
How the completion was triggered.
Completion was triggered by typing an identifier (24x7 code complete), manual invocation (e....
bool fromJSON(const llvm::json::Value &Parameters, FuzzyFindRequest &Request)
Position position
The position inside the text document.
Position end
The range's end position.
std::vector< std::string > fallbackFlags
Values in a Context are indexed by typed keys.
constexpr auto CompletionItemKindMax
Represents programming constructs like variables, classes, interfaces etc.
llvm::Optional< std::vector< SemanticToken > > tokens
Set if we computed a fresh set of tokens.
unsigned length
the length of the token. A token cannot be multiline
std::vector< FileEvent > changes
The actual file events.
llvm::Optional< std::vector< TypeHierarchyItem > > children
If this type hierarchy item is resolved, it contains the direct children of the current item.
llvm::raw_ostream & operator<<(llvm::raw_ostream &OS, const CodeCompletion &C)
llvm::Optional< Command > command
A command this code action executes.
CompletionItemKind
The kind of a completion entry.
friend bool operator==(const URIForFile &LHS, const URIForFile &RHS)
URIForFile uri
The URI of the text document where this type hierarchy item belongs to.
Represents information about identifier.
Clangd extension: parameters configurable at any time, via the workspace/didChangeConfiguration notif...
Parameters for the document link request.
std::string USR
Unified Symbol Resolution identifier This is an opaque string uniquely identifying a symbol.
Documents are synced by sending the full content on open.
Documents are synced by always sending the full content of the document.
Exact commands are not specified in the protocol so we define the ones supported by Clangd here.
clang::find_all_symbols::SymbolInfo::SymbolKind SymbolKind
int activeSignature
The active signature.
std::string text
The content of the opened text document.
InitializationOptions initializationOptions
User-provided initialization options.
bool operator()(const Diagnostic &LHS, const Diagnostic &RHS) const
int resolve
The hierarchy levels to resolve. 0 indicates no level.
std::vector< Diagnostic > diagnostics
An array of diagnostics.
TextDocumentIdentifier textDocument
The text document.
Reporting progress is done using the following payload.
InsertTextFormat insertTextFormat
The format of the insert text.
bool WorkDoneProgress
The client supports progress notifications.
llvm::Optional< std::vector< Diagnostic > > diagnostics
The diagnostics that this code action resolves.
std::vector< TextEdit > additionalTextEdits
An optional array of additional text edits that are applied when selecting this completion.
The type hierarchy params is an extension of the TextDocumentPositionsParams with optional properties...
friend bool operator<(const DocumentHighlight &LHS, const DocumentHighlight &RHS)
MarkupContent contents
The hover's content.
std::string toString() const
Returns a string URI with all components percent-encoded.
std::map< std::string, ClangdCompileCommand > compilationDatabaseChanges
llvm::Optional< std::string > detail
Optional detail for the hierarchy item.
bool deprecated
true if the hierarchy item is deprecated. Otherwise, false.
bool CodeActionStructure
Client supports CodeAction return value for textDocument/codeAction.
SymbolKind kind
The kind of this symbol.
Range range
The range of this selection range.
llvm::Optional< double > percentage
Optional progress percentage to display (value 100 is considered 100%).
bool percentage
Optional progress percentage to display (value 100 is considered 100%).
std::vector< TextDocumentContentChangeEvent > contentChanges
The actual content changes.
VersionedTextDocumentIdentifier textDocument
The document that did change.
TypeHierarchyDirection direction
The direction of the hierarchy levels to resolve.
TextDocumentIdentifier textDocument
The text document.
friend bool operator<(const Position &LHS, const Position &RHS)
TextDocumentIdentifier textDocument
The document that was saved.
The parameters of a Workspace Symbol Request.
std::vector< SemanticToken > tokens
std::vector< std::string > compilationCommand
std::string detail
A human-readable string with additional information about this item, like type or symbol information.
VersionedTextDocumentIdentifier TextDocument
The textdocument these highlightings belong to.
FileChangeType type
The change type.
Represents the signature of a callable.
A versioned set of tokens.
llvm::Optional< std::int64_t > version
The version number of this document.
friend bool operator!=(const URIForFile &LHS, const URIForFile &RHS)
std::string message
The actual message.
std::string message
The diagnostic's message.
friend bool operator!=(const Range &LHS, const Range &RHS)
std::unique_ptr< SelectionRange > parent
The parent selection range containing this range.
static URIForFile canonicalize(llvm::StringRef AbsPath, llvm::StringRef TUPath)
Canonicalizes AbsPath via URI.
int severity
The diagnostic's severity.
llvm::json::Value token
The progress token provided by the client or server.
llvm::Optional< TraceLevel > trace
The initial trace setting. If omitted trace is disabled ('off').
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
llvm::Optional< int64_t > version
The version number of the document the diagnostics are published for.
llvm::Optional< std::vector< CodeAction > > codeActions
Clangd extension: code actions related to this diagnostic.
llvm::raw_string_ostream OS
Stores information about a region of code that can be folded.
const static llvm::StringLiteral REFACTOR_KIND
llvm::Optional< std::vector< TypeHierarchyItem > > parents
If this type hierarchy item is resolved, it contains the direct parents.
friend bool operator==(const DocumentLink &LHS, const DocumentLink &RHS)
llvm::Optional< Range > range
The range of the document that changed.
Range range
The range this link applies to.
Clangd extension: indicates the current state of the file in clangd, sent from server via the textDoc...
std::string query
A non-empty query string.
bool deprecated
Indicates if this symbol is deprecated.
bool TheiaSemanticHighlighting
Client supports Theia semantic highlighting extension.
bool operator<(const Ref &L, const Ref &R)
llvm::Optional< std::string > rootPath
The rootPath of the workspace.
Clangd extension: parameters configurable at initialize time.
TextDocumentIdentifier textDocument
The document that was closed.
std::string code
The diagnostic's code. Can be omitted.
TextDocumentIdentifier textDocument
The document that was opened.
int activeParameter
The active parameter of the active signature.
bool contains(Position Pos) const
llvm::StringRef file() const
Retrieves absolute path to the file.
const static llvm::StringLiteral CLANGD_APPLY_FIX_COMMAND
bool operator==(const Inclusion &LHS, const Inclusion &RHS)
bool ImplicitProgressCreation
The client supports implicit $/progress work-done progress streams, without a preceding window/workDo...
std::string name
The name of this symbol.
Range selection
A selection provided by the client on a textDocument/codeAction request.
CompletionContext context
InsertTextFormat
Defines whether the insert text in a completion item should be interpreted as plain text or a snippet...
llvm::Optional< WorkspaceEdit > workspaceEdit
llvm::Optional< SymbolID > ID
llvm::Optional< std::vector< DiagnosticRelatedInformation > > relatedInformation
An array of related diagnostic information, e.g.
Completion was triggered by a trigger character specified by the triggerCharacters properties of the ...
TextDocumentIdentifier textDocument
The document to provide document links for.
std::string newText
The string to be inserted.
A LSP-specific comparator used to find diagnostic in a container like std:map.
static URI createFile(llvm::StringRef AbsolutePath)
This creates a file:// URI for AbsolutePath. The path must be absolute.
CompiledFragmentImpl & Out
TextDocumentIdentifier textDocument
The text document.
llvm::Optional< URIForFile > rootUri
The rootUri of the workspace.
TypeHierarchyDirection direction
The direction of the hierarchy levels to resolve.
URIForFile target
The uri this link points to. If missing a resolve request is sent later.
std::string text
The new text of the range/document.
constexpr auto CompletionItemKindMin
TypeHierarchyItem item
The item to resolve.
Range range
The range of the text document to be manipulated.
The show message notification is sent from a server to a client to ask the client to display a partic...
const static llvm::StringLiteral INFO_KIND
A URI describes the location of a source file.
bool HasSignatureHelp
Client supports signature help.
std::string title
Mandatory title of the progress operation.
Range range
The range for which the command was invoked.
The primary text to be inserted is treated as a snippet.
friend bool operator!=(const DocumentLink &LHS, const DocumentLink &RHS)
friend bool operator!=(const Position &LHS, const Position &RHS)
llvm::Optional< std::string > data
An optional 'data' filed, which can be used to identify a type hierarchy item in a resolve request.
std::string newName
The new name of the symbol.
SymbolKind adjustKindToCapability(SymbolKind Kind, SymbolKindBitset &SupportedSymbolKinds)
llvm::Optional< int > rangeLength
The length of the range that got replaced.
const static llvm::StringLiteral QUICKFIX_KIND
Parameters for the typeHierarchy/resolve request.
An Event<T> allows events of type T to be broadcast to listeners.
llvm::Optional< MarkupContent > documentation
A human-readable string that represents a doc-comment.