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
29 #include "clang/Index/IndexSymbol.h"
30 #include "llvm/ADT/Optional.h"
31 #include "llvm/ADT/SmallVector.h"
32 #include "llvm/Support/JSON.h"
33 #include "llvm/Support/raw_ostream.h"
63 class LSPError :
public llvm::ErrorInfo<LSPError> {
72 void log(llvm::raw_ostream &
OS)
const override {
76 return llvm::inconvertibleErrorCode();
95 llvm::StringRef TUPath);
97 static llvm::Expected<URIForFile>
fromURI(
const URI &U,
98 llvm::StringRef HintPath);
101 llvm::StringRef
file()
const {
return File; }
103 explicit operator bool()
const {
return !File.empty(); }
107 return LHS.File == RHS.File;
111 return !(LHS == RHS);
115 return LHS.File < RHS.File;
119 explicit URIForFile(std::string &&File) : File(std::move(File)) {}
167 return !(LHS == RHS);
180 llvm::raw_ostream &
operator<<(llvm::raw_ostream &,
const Position &);
193 return !(LHS == RHS);
218 return !(LHS == RHS);
238 return std::tie(L.newText, L.range) == std::tie(R.
newText, R.
range);
242 llvm::raw_ostream &
operator<<(llvm::raw_ostream &,
const TextEdit &);
588 return llvm::json::Object{{
"token", P.
token}, {
"value", P.
value}};
868 llvm::SmallVector<DiagnosticTag, 1>
tags;
948 std::map<std::string, std::vector<TextEdit>>
changes;
998 llvm::Optional<std::string>
kind;
1014 llvm::Optional<WorkspaceEdit>
edit;
1307 llvm::raw_ostream &
operator<<(llvm::raw_ostream &,
1358 int LHSKind =
static_cast<int>(LHS.
kind);
1359 int RHSKind =
static_cast<int>(RHS.
kind);
1360 return std::tie(LHS.
range, LHSKind) < std::tie(RHS.
range, RHSKind);
1369 llvm::raw_ostream &
operator<<(llvm::raw_ostream &,
const DocumentHighlight &);
1419 llvm::Optional<std::vector<TypeHierarchyItem>>
parents;
1424 llvm::Optional<std::vector<TypeHierarchyItem>>
children;
1698 llvm::Optional<std::vector<SemanticTokensEdit>>
edits;
1700 llvm::Optional<std::vector<SemanticToken>>
tokens;
1756 return !(LHS == RHS);
1844 template <>
struct format_provider<
clang::clangd::Position> {
1847 assert(Style.empty() &&
"style modifiers for this type are not supported");
bool includeDeclaration
Include the declaration of the current symbol.
Range selectionRange
The range that should be selected and revealed when this symbol is being picked, e....
A document highlight is a range inside a text document which deserves special attention.
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 paddingLeft
Render padding before the hint.
bool isIncomplete
The list is not complete.
@ Warning
A warning message.
Range range
The range enclosing this symbol not including leading/trailing whitespace but everything else like co...
@ Designator
A hint before an element of an aggregate braced initializer list, indicating what it is initializing.
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
std::string label
The label of this hint.
constexpr auto SymbolKindMin
URIForFile uri
The text document's URI.
Clangd extension that's used in the 'compilationDatabaseChanges' in workspace/didChangeConfiguration ...
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.
InlayHintKind kind
The kind of this hint.
@ TriggerTriggerForIncompleteCompletions
Completion was re-triggered as the current completion list is incomplete.
URIForFile uri
The resource identifier of this item.
MessageType type
The message type.
int resolve
The hierarchy levels to resolve. 0 indicates no level.
TextDocumentIdentifier textDocument
The text document.
std::string detail
More detaill for this item, e.g. the signature of a function.
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< CodeDescription > codeDescription
An optional property to describe the error code.
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.
std::string detail
Brief additional information, such as "||" for the particular operator.
Represents a collection of completion items to be presented in the editor.
bool CompletionFixes
Client supports completions with additionalTextEdit near the cursor.
@ PlainText
The primary text to be inserted is treated as a plain string.
std::vector< std::string > only
Requested kind of actions to return.
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)
bool isPreferred
Marks this as a preferred action.
CallHierarchyItem to
The item that is called.
ConfigurationSettings settings
std::string label
The label of this completion item.
bool paddingRight
Render padding after the hint.
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.
@ Created
The file got created.
TextDocumentSyncKind
Defines how the host (editor) should sync document changes to the language server.
std::vector< SymbolTag > tags
Tags for this item.
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
The score that clangd calculates to rank the returned completions.
@ None
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 kind
The specific kind of node this is, such as "BinaryOperator".
llvm::Optional< Range > range
The position of the node to be dumped.
Represents an incoming call, e.g. a caller of a method or constructor.
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)
llvm::json::Object rawCapabilities
The same data as capabilities, but not parsed (to expose to modules).
llvm::Optional< int > limit
Max results to return, overriding global default.
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.
The parameter of a textDocument/prepareCallHierarchy request.
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< Range > range
The range of the original source file covered by this node.
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.
std::map< std::string, std::vector< TextEdit > > changes
Holds changes to existing resources.
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
llvm::json::Value argument
llvm::SmallVector< DiagnosticTag, 1 > tags
Additional metadata about the diagnostic.
std::vector< Range > fromRanges
The range at which the calls appear.
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.
MarkupKind SignatureHelpDocumentationFormat
The documentation format that should be used for textDocument/signatureHelp.
Specifies a single semantic token in the document.
A tree that can be used to represent memory usage of nested components while preserving the hierarchy...
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.
TextDocumentIdentifier textDocument
std::string role
The general kind of node, such as "expression" Corresponds to the base AST node type such as Expr.
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
@ Deleted
The file got deleted.
Represents an outgoing call, e.g.
bool fromJSON(const llvm::json::Value &Parameters, FuzzyFindRequest &Request, llvm::json::Path P)
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 data
An optional 'data' field, which can be used to identify a call hierarchy item in an incomingCalls or ...
std::string command
The identifier of the actual command handler.
TextDocumentIdentifier textDocument
SymbolKind indexSymbolKindToSymbolKind(index::SymbolKind Kind)
llvm::json::Object data
A data entry field that is preserved between a textDocument/publishDiagnostics notification and textD...
Range selectionRange
The range that should be selected and revealed when this symbol is being picked, e....
SymbolKind
The SymbolInfo Type.
Structure to capture a description for an error code.
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.
@ Invoked
Completion was triggered by typing an identifier (24x7 code complete), manual invocation (e....
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.
@ Incremental
Documents are synced by sending the full content on open.
@ Full
Documents are synced by always sending the full content of the document.
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
@ Deprecated
Deprecated or obsolete code.
The parameter of a callHierarchy/incomingCalls request.
int resolve
The hierarchy levels to resolve. 0 indicates no level.
std::vector< Diagnostic > diagnostics
An array of diagnostics known on the client side overlapping the range provided to the textDocument/c...
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.
@ Type
An inlay hint that for a type annotation.
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 SemanticTokenRefreshSupport
Whether the client implementation supports a refresh request sent from the server to the client.
bool CodeActionStructure
Client supports CodeAction return value for textDocument/codeAction.
Payload for textDocument/ast request.
SymbolKind kind
The kind of this symbol.
Range range
The range of this selection range.
bool percentage
Optional progress percentage to display (value 100 is considered 100%).
llvm::Optional< Range > range
The visible document range for which inlay hints should be computed.
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.
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.
@ Info
An information message.
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::Optional< unsigned > percentage
Optional progress percentage to display (value 100 is considered 100%).
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)
Range range
The range enclosing this symbol not including leading / trailing whitespace but everything else,...
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 query string to filter symbols by.
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.
Represents programming constructs like functions or constructors in the context of call hierarchy.
std::string code
The diagnostic's code. Can be omitted.
TextDocumentIdentifier textDocument
The document that was opened.
CallHierarchyItem from
The item that makes the call.
int activeParameter
The active parameter of the active signature.
bool contains(Position Pos) const
llvm::Optional< int > limit
Max results to return, overriding global default.
llvm::StringRef file() const
Retrieves absolute path to the file.
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...
InlayHintKind
Inlay hint kinds.
std::string arcana
A one-line dump of detailed information about the node.
llvm::Optional< std::vector< DiagnosticRelatedInformation > > relatedInformation
An array of related diagnostic information, e.g.
@ TriggerCharacter
Completion was triggered by a trigger character specified by the triggerCharacters properties of the ...
TextDocumentIdentifier textDocument
The document to provide document links for.
TextDocumentIdentifier textDocument
The text document.
std::string newText
The string to be inserted.
A LSP-specific comparator used to find diagnostic in a container like std:map.
@ Unnecessary
Unused or unnecessary code.
static URI createFile(llvm::StringRef AbsolutePath)
This creates a file:// URI for AbsolutePath. The path must be absolute.
CompiledFragmentImpl & Out
bool CancelsStaleRequests
Whether the client claims to cancel stale requests.
TextDocumentIdentifier textDocument
The text document.
std::vector< ASTNode > children
Nodes nested within this one, such as the operands of a BinaryOperator.
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.
TextDocumentIdentifier textDocument
The text document.
The parameter of a callHierarchy/outgoingCalls request.
Simplified description of a clang AST node.
constexpr auto CompletionItemKindMin
TypeHierarchyItem item
The item to resolve.
std::vector< Range > fromRanges
The range at which this item is called.
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.
@ Changed
The file got changed.
@ Snippet
The primary text to be inserted is treated as a snippet.
Position position
The position of this hint.
Range range
The range of source code to which the hint applies.
friend bool operator!=(const DocumentLink &LHS, const DocumentLink &RHS)
static constexpr bool Value
friend bool operator!=(const Position &LHS, const Position &RHS)
std::string name
The name of this item.
std::string href
An URI to open with more information about the diagnostic error.
llvm::Optional< std::string > data
An optional 'data' field, which can be used to identify a type hierarchy item in a resolve request.
std::string newName
The new name of the symbol.
std::vector< HeaderHandle > Path
A parameter literal used in inlay hint requests.
SymbolKind adjustKindToCapability(SymbolKind Kind, SymbolKindBitset &SupportedSymbolKinds)
llvm::Optional< int > rangeLength
The length of the range that got replaced.
SymbolKind kind
The kind of this item.
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.
@ Parameter
An inlay hint that is for a parameter.