11#include <llvm/ADT/SmallVector.h>
12#include <llvm/Support/JSON.h>
13#include <llvm/Support/raw_ostream.h>
38class LSPError :
public llvm::ErrorInfo<LSPError> {
47 void log(llvm::raw_ostream &OS)
const override {
51 return llvm::inconvertibleErrorCode();
70 llvm::StringRef TUPath);
72 static llvm::Expected<URIForFile>
fromURI(
const URI &U,
73 llvm::StringRef HintPath);
76 llvm::StringRef
file()
const {
return File; }
78 explicit operator bool()
const {
return !File.empty(); }
82 return LHS.File == RHS.File;
90 return LHS.File < RHS.File;
94 explicit URIForFile(std::string &&File) : File(std::move(File)) {}
100llvm::json::Value
toJSON(
const URIForFile &U);
101bool fromJSON(
const llvm::json::Value &, URIForFile &, llvm::json::Path);
142 return !(LHS == RHS);
153bool fromJSON(
const llvm::json::Value &, Position &, llvm::json::Path);
154llvm::json::Value
toJSON(
const Position &);
155llvm::raw_ostream &
operator<<(llvm::raw_ostream &,
const Position &);
168 return !(LHS == RHS);
188bool fromJSON(
const llvm::json::Value &, Range &, llvm::json::Path);
189llvm::json::Value
toJSON(
const Range &);
190llvm::raw_ostream &
operator<<(llvm::raw_ostream &,
const Range &);
202 return !(LHS == RHS);
209llvm::json::Value
toJSON(
const Location &);
210bool fromJSON(
const llvm::json::Value &, Location &, llvm::json::Path);
211llvm::raw_ostream &
operator<<(llvm::raw_ostream &,
const Location &);
242bool fromJSON(
const llvm::json::Value &, TextEdit &, llvm::json::Path);
243llvm::json::Value
toJSON(
const TextEdit &);
244llvm::raw_ostream &
operator<<(llvm::raw_ostream &,
const TextEdit &);
633 return llvm::json::Object{{
"token", P.
token}, {
"value", P.
value}};
913 llvm::SmallVector<DiagnosticTag, 1>
tags;
996 std::optional<std::map<std::string, std::vector<TextEdit>>>
changes;
1345llvm::raw_ostream &
operator<<(llvm::raw_ostream &,
1396 int LHSKind =
static_cast<int>(LHS.
kind);
1397 int RHSKind =
static_cast<int>(RHS.
kind);
1398 return std::tie(LHS.
range, LHSKind) < std::tie(RHS.
range, RHSKind);
1406llvm::json::Value
toJSON(
const DocumentHighlight &DH);
1407llvm::raw_ostream &
operator<<(llvm::raw_ostream &,
const DocumentHighlight &);
1452 std::optional<std::vector<ResolveParams>>
parents;
1465 std::optional<std::vector<TypeHierarchyItem>>
parents;
1471 std::optional<std::vector<TypeHierarchyItem>>
children;
1743 std::optional<std::vector<SemanticTokensEdit>>
edits;
1745 std::optional<std::vector<SemanticToken>>
tokens;
1811 return !(LHS == RHS);
1814llvm::json::Value
toJSON(
const DocumentLink &DocumentLink);
1920 assert(Style.empty() &&
"style modifiers for this type are not supported");
An Event<T> allows events of type T to be broadcast to listeners.
LSPError(std::string Message, ErrorCode Code)
void log(llvm::raw_ostream &OS) const override
std::error_code convertToErrorCode() const override
std::string toString() const
Returns a string URI with all components percent-encoded.
static URI createFile(llvm::StringRef AbsolutePath)
This creates a file:// URI for AbsolutePath. The path must be absolute.
Whether current platform treats paths case insensitively.
std::bitset< SymbolKindMax+1 > SymbolKindBitset
@ Created
The file got created.
@ Deleted
The file got deleted.
@ Changed
The file got changed.
@ Warning
A warning message.
@ Info
An information message.
std::string ChangeAnnotationIdentifier
bool fromJSON(const llvm::json::Value &, URIForFile &, llvm::json::Path)
constexpr auto CompletionItemKindMax
@ TriggerTriggerForIncompleteCompletions
Completion was re-triggered as the current completion list is incomplete.
constexpr auto CompletionItemKindMin
std::bitset< CompletionItemKindMax+1 > CompletionItemKindBitset
llvm::json::Value toJSON(const URIForFile &U)
Serialize/deserialize URIForFile to/from a string URI.
@ None
Documents should not be synced at all.
@ Full
Documents are synced by always sending the full content of the document.
llvm::raw_ostream & operator<<(llvm::raw_ostream &, const Position &)
CompletionItemKind
The kind of a completion entry.
CompletionItemKind adjustKindToCapability(CompletionItemKind Kind, CompletionItemKindBitset &SupportedCompletionItemKinds)
bool operator==(const TextEdit &L, const TextEdit &R)
InlayHintKind
Inlay hint kinds.
constexpr auto SymbolKindMin
bool operator<(const CompletionItem &, const CompletionItem &)
constexpr auto SymbolKindMax
std::vector< ASTNode > children
Nodes nested within this one, such as the operands of a BinaryOperator.
std::optional< Range > range
TextDocumentIdentifier textDocument
The text document.
std::optional< Range > range
std::optional< std::string > failureReason
Represents an incoming call, e.g. a caller of a method or constructor.
CallHierarchyItem from
The item that makes the call.
std::vector< Range > fromRanges
The parameter of a callHierarchy/incomingCalls request.
URIForFile uri
The resource identifier of this item.
std::vector< SymbolTag > tags
Tags for this item.
std::string detail
More detaill for this item, e.g. the signature of a function.
SymbolKind kind
The kind of this item.
std::string name
The name of this item.
CallHierarchyItem to
The item that is called.
std::vector< Range > fromRanges
The parameter of a callHierarchy/outgoingCalls request.
The parameter of a textDocument/prepareCallHierarchy request.
std::optional< bool > needsConfirmation
std::string workingDirectory
std::vector< std::string > compilationCommand
MarkupKind SignatureHelpDocumentationFormat
bool WorkspaceConfiguration
bool RenamePrepareSupport
bool DocumentChanges
The client supports versioned document changes for WorkspaceEdit.
std::optional< SymbolKindBitset > WorkspaceSymbolKinds
bool TheiaSemanticHighlighting
std::optional< CompletionItemKindBitset > CompletionItemKinds
bool HierarchicalDocumentSymbol
MarkupKind CompletionDocumentationFormat
bool CancelsStaleRequests
bool OffsetsInSignatureHelp
std::optional< std::vector< OffsetEncoding > > offsetEncoding
Supported encodings for LSP character offsets. (clangd extension).
bool ImplicitProgressCreation
bool SemanticTokenRefreshSupport
MarkupKind HoverContentFormat
std::vector< Diagnostic > diagnostics
std::vector< std::string > only
Range range
The range for which the command was invoked.
TextDocumentIdentifier textDocument
The document in which the command was invoked.
CodeActionContext context
Context carrying additional information.
std::string title
A short, human-readable, title for this code action.
std::optional< std::string > kind
static const llvm::StringLiteral REFACTOR_KIND
std::optional< Command > command
static const llvm::StringLiteral INFO_KIND
std::optional< WorkspaceEdit > edit
The workspace edit this code action performs.
static const llvm::StringLiteral QUICKFIX_KIND
std::optional< std::vector< Diagnostic > > diagnostics
The diagnostics that this code action resolves.
Structure to capture a description for an error code.
std::string href
An URI to open with more information about the diagnostic error.
std::string triggerCharacter
CompletionTriggerKind triggerKind
How the completion was triggered.
bool deprecated
Indicates if this item is deprecated.
std::optional< TextEdit > textEdit
InsertTextFormat insertTextFormat
std::optional< MarkupContent > documentation
A human-readable string that represents a doc-comment.
std::vector< TextEdit > additionalTextEdits
Represents a collection of completion items to be presented in the editor.
std::vector< CompletionItem > items
The completion items.
CompletionContext context
std::optional< int > limit
std::optional< std::string > section
std::optional< URIForFile > scopeUri
std::vector< ConfigurationItem > items
std::map< std::string, ClangdCompileCommand > compilationDatabaseChanges
std::optional< std::string > category
std::optional< std::vector< CodeAction > > codeActions
llvm::SmallVector< DiagnosticTag, 1 > tags
Additional metadata about the diagnostic.
Range range
The range at which the message applies.
std::string message
The diagnostic's message.
std::optional< std::vector< DiagnosticRelatedInformation > > relatedInformation
std::optional< CodeDescription > codeDescription
An optional property to describe the error code.
std::string code
The diagnostic's code. Can be omitted.
ConfigurationSettings settings
std::optional< bool > wantDiagnostics
std::vector< TextDocumentContentChangeEvent > contentChanges
The actual content changes.
VersionedTextDocumentIdentifier textDocument
std::vector< FileEvent > changes
The actual file events.
TextDocumentIdentifier textDocument
The document that was closed.
TextDocumentItem textDocument
The document that was opened.
TextDocumentIdentifier textDocument
The document that was saved.
Range range
The range this highlight applies to.
DocumentHighlightKind kind
The highlight kind, default is DocumentHighlightKind.Text.
friend bool operator<(const DocumentHighlight &LHS, const DocumentHighlight &RHS)
friend bool operator==(const DocumentHighlight &LHS, const DocumentHighlight &RHS)
Parameters for the document link request.
TextDocumentIdentifier textDocument
The document to provide document links for.
Range range
The range this link applies to.
friend bool operator!=(const DocumentLink &LHS, const DocumentLink &RHS)
friend bool operator==(const DocumentLink &LHS, const DocumentLink &RHS)
URIForFile target
The uri this link points to. If missing a resolve request is sent later.
TextDocumentIdentifier textDocument
SymbolKind kind
The kind of this symbol.
std::vector< DocumentSymbol > children
Children of this symbol, e.g. properties of a class.
std::string name
The name of this symbol.
bool deprecated
Indicates if this symbol is deprecated.
std::string detail
More detail for this symbol, e.g the signature of a function.
llvm::json::Value argument
std::string command
The identifier of the actual command handler.
URIForFile uri
The file's URI.
FileChangeType type
The change type.
URIForFile uri
The text document's URI.
TextDocumentIdentifier textDocument
Stores information about a region of code that can be folded.
static const llvm::StringLiteral IMPORT_KIND
static const llvm::StringLiteral COMMENT_KIND
static const llvm::StringLiteral REGION_KIND
std::optional< Range > range
MarkupContent contents
The hover's content.
TextDocumentIdentifier TextDocument
The textdocument these inactive regions belong to.
std::vector< Range > InactiveRegions
The inactive regions that should be sent.
std::vector< std::string > fallbackFlags
ConfigurationSettings ConfigSettings
std::optional< std::string > compilationDatabasePath
std::optional< std::string > rootPath
llvm::json::Object rawCapabilities
The same data as capabilities, but not parsed (to expose to modules).
InitializationOptions initializationOptions
User-provided initialization options.
std::optional< TraceLevel > trace
The initial trace setting. If omitted trace is disabled ('off').
ClientCapabilities capabilities
The capabilities provided by the client (editor or tool)
std::optional< URIForFile > rootUri
std::optional< int > processId
Position position
The position of this hint.
A parameter literal used in inlay hint requests.
TextDocumentIdentifier textDocument
The text document.
std::optional< Range > range
bool operator()(const Diagnostic &LHS, const Diagnostic &RHS) const
friend bool operator==(const Location &LHS, const Location &RHS)
friend bool operator<(const Location &LHS, const Location &RHS)
friend bool operator!=(const Location &LHS, const Location &RHS)
URIForFile uri
The text document's URI.
int64_t line
Line position in a document (zero-based).
friend bool operator==(const Position &LHS, const Position &RHS)
friend bool operator!=(const Position &LHS, const Position &RHS)
friend bool operator<=(const Position &LHS, const Position &RHS)
friend bool operator<(const Position &LHS, const Position &RHS)
T value
The progress data.
llvm::json::Value token
The progress token provided by the client or server.
URIForFile uri
The URI for which diagnostic information is reported.
std::optional< int64_t > version
The version number of the document the diagnostics are published for.
std::vector< Diagnostic > diagnostics
An array of diagnostic information items.
bool contains(Range Rng) const
friend bool operator==(const Range &LHS, const Range &RHS)
bool overlap(const Range &RHS) const
friend bool operator<(const Range &LHS, const Range &RHS)
Position start
The range's start position.
bool contains(Position Pos) const
Range operator/(const Range &RHS) const
Position end
The range's end position.
friend bool operator!=(const Range &LHS, const Range &RHS)
bool includeDeclaration
Include the declaration of the current symbol.
std::optional< std::string > containerName
std::string newName
The new name of the symbol.
Position position
The position at which this request was sent.
TextDocumentIdentifier textDocument
The document that was opened.
Parameters for the typeHierarchy/resolve request.
TypeHierarchyDirection direction
The direction of the hierarchy levels to resolve.
TypeHierarchyItem item
The item to resolve.
int resolve
The hierarchy levels to resolve. 0 indicates no level.
TextDocumentIdentifier textDocument
The text document.
std::vector< Position > positions
The positions inside the text document.
std::unique_ptr< SelectionRange > parent
unsigned length
the length of the token. A token cannot be multiline
unsigned tokenType
will be looked up in SemanticTokensLegend.tokenTypes
unsigned deltaLine
token line number, relative to the previous token
unsigned tokenModifiers
each set bit will be looked up in SemanticTokensLegend.tokenModifiers
std::string previousResultId
The previous result id.
TextDocumentIdentifier textDocument
The text document.
Describes a replacement of a contiguous range of semanticTokens.
std::vector< SemanticToken > tokens
std::optional< std::vector< SemanticTokensEdit > > edits
Set if we computed edits relative to a previous set of tokens.
std::optional< std::vector< SemanticToken > > tokens
Set if we computed a fresh set of tokens.
Body of textDocument/semanticTokens/full request.
TextDocumentIdentifier textDocument
The text document.
A versioned set of tokens.
std::vector< SemanticToken > tokens
The actual tokens.
MessageType type
The message type.
std::string message
The actual message.
Represents the signature of a callable.
int activeSignature
The active signature.
int activeParameter
The active parameter of the active signature.
std::vector< SignatureInformation > signatures
The resulting signatures.
std::string text
The new text of the range/document.
std::optional< Range > range
The range of the document that changed.
std::optional< int > rangeLength
The length of the range that got replaced.
std::vector< TextEdit > edits
VersionedTextDocumentIdentifier textDocument
The text document to change.
URIForFile uri
The text document's URI.
std::string languageId
The text document's language identifier.
std::optional< int64_t > version
std::string text
The content of the opened text document.
URIForFile uri
The text document's URI.
Position position
The position inside the text document.
TextDocumentIdentifier textDocument
The text document.
ChangeAnnotationIdentifier annotationId
std::string tweakID
ID of the tweak that should be executed. Corresponds to Tweak::id().
URIForFile file
A file provided by the client on a textDocument/codeAction request.
Range selection
A selection provided by the client on a textDocument/codeAction request.
Used to resolve a client provided item back.
std::optional< std::vector< ResolveParams > > parents
std::nullopt means parents aren't resolved and empty is no parents.
std::optional< std::vector< TypeHierarchyItem > > children
std::optional< std::string > detail
More detail for this item, e.g. the signature of a function.
SymbolKind kind
The kind of this item.
std::optional< std::vector< TypeHierarchyItem > > parents
This is a clangd exntesion.
URIForFile uri
The resource identifier of this item.
std::string name
The name of this item.
TypeHierarchyDirection direction
friend bool operator<(const URIForFile &LHS, const URIForFile &RHS)
static URIForFile canonicalize(llvm::StringRef AbsPath, llvm::StringRef TUPath)
friend bool operator!=(const URIForFile &LHS, const URIForFile &RHS)
friend bool operator==(const URIForFile &LHS, const URIForFile &RHS)
static llvm::Expected< URIForFile > fromURI(const URI &U, llvm::StringRef HintPath)
llvm::StringRef file() const
Retrieves absolute path to the file.
std::optional< std::int64_t > version
llvm::json::Value token
The token to be used to report progress.
Signals the end of progress reporting.
std::optional< std::string > message
Reporting progress is done using the following payload.
std::optional< bool > cancellable
std::optional< std::string > message
std::optional< unsigned > percentage
std::optional< std::map< std::string, std::vector< TextEdit > > > changes
Holds changes to existing resources.
std::map< std::string, ChangeAnnotation > changeAnnotations
std::optional< std::vector< TextDocumentEdit > > documentChanges
The parameters of a Workspace Symbol Request.
std::optional< int > limit