Go to the documentation of this file.
16 #include "clang/Basic/LLVM.h"
17 #include "clang/Index/IndexSymbol.h"
18 #include "llvm/ADT/Hashing.h"
19 #include "llvm/ADT/SmallString.h"
20 #include "llvm/ADT/StringSwitch.h"
21 #include "llvm/Support/ErrorHandling.h"
22 #include "llvm/Support/Format.h"
23 #include "llvm/Support/FormatVariadic.h"
24 #include "llvm/Support/JSON.h"
25 #include "llvm/Support/Path.h"
26 #include "llvm/Support/raw_ostream.h"
34 llvm::StringRef TUPath) {
35 assert(llvm::sys::path::is_absolute(AbsPath) &&
"the path is relative");
38 elog(
"URIForFile: failed to resolve path {0} with TU path {1}: "
39 "{2}.\nUsing unresolved path.",
40 AbsPath, TUPath, Resolved.takeError());
47 llvm::StringRef HintPath) {
50 return Resolved.takeError();
55 if (
auto S =
E.getAsString()) {
58 elog(
"Failed to parse URI {0}: {1}", *S, Parsed.takeError());
61 if (Parsed->scheme() !=
"file" && Parsed->scheme() !=
"test") {
62 elog(
"Clangd only supports 'file' URI scheme for workspace files: {0}",
69 elog(
"{0}", U.takeError());
85 return llvm::json::Object{{
"uri", R.
uri}};
89 llvm::json::ObjectMapper O(Params);
90 return O && O.map(
"uri", R.
uri);
94 auto Result =
toJSON(static_cast<const TextDocumentIdentifier &>(R));
95 Result.getAsObject()->try_emplace(
"version", R.
version);
101 llvm::json::ObjectMapper O(Params);
102 return fromJSON(Params, static_cast<TextDocumentIdentifier &>(R)) && O &&
107 llvm::json::ObjectMapper O(Params);
108 return O && O.map(
"line", R.
line) && O.map(
"character", R.
character);
112 return llvm::json::Object{
123 llvm::json::ObjectMapper O(Params);
124 return O && O.map(
"start", R.
start) && O.map(
"end", R.
end);
128 return llvm::json::Object{
139 return llvm::json::Object{
150 llvm::json::ObjectMapper O(Params);
151 return O && O.map(
"uri", R.
uri) && O.map(
"languageId", R.
languageId) &&
152 O.map(
"version", R.
version) && O.map(
"text", R.
text);
156 llvm::json::ObjectMapper O(Params);
157 return O && O.map(
"range", R.
range) && O.map(
"newText", R.
newText);
161 return llvm::json::Object{
169 llvm::printEscapedString(TE.
newText,
OS);
174 if (
auto S =
E.getAsString()) {
178 }
else if (*S ==
"messages") {
181 }
else if (*S ==
"verbose") {
190 if (
auto T =
E.getAsInteger()) {
194 Out = static_cast<SymbolKind>(*T);
201 if (
auto *A =
E.getAsArray()) {
202 for (
size_t I = 0; I < A->size(); ++I) {
205 Out.set(
size_t(KindOut));
214 auto KindVal = static_cast<size_t>(
Kind);
215 if (KindVal >=
SymbolKindMin && KindVal <= SupportedSymbolKinds.size() &&
216 SupportedSymbolKinds[KindVal])
232 case index::SymbolKind::Unknown:
234 case index::SymbolKind::Module:
236 case index::SymbolKind::Namespace:
238 case index::SymbolKind::NamespaceAlias:
240 case index::SymbolKind::Macro:
242 case index::SymbolKind::Enum:
244 case index::SymbolKind::Struct:
246 case index::SymbolKind::Class:
248 case index::SymbolKind::Protocol:
250 case index::SymbolKind::Extension:
252 case index::SymbolKind::Union:
254 case index::SymbolKind::TypeAlias:
256 case index::SymbolKind::Function:
258 case index::SymbolKind::Variable:
260 case index::SymbolKind::Field:
262 case index::SymbolKind::EnumConstant:
264 case index::SymbolKind::InstanceMethod:
265 case index::SymbolKind::ClassMethod:
266 case index::SymbolKind::StaticMethod:
268 case index::SymbolKind::InstanceProperty:
269 case index::SymbolKind::ClassProperty:
270 case index::SymbolKind::StaticProperty:
272 case index::SymbolKind::Constructor:
273 case index::SymbolKind::Destructor:
275 case index::SymbolKind::ConversionFunction:
277 case index::SymbolKind::Parameter:
278 case index::SymbolKind::NonTypeTemplateParm:
280 case index::SymbolKind::Using:
282 case index::SymbolKind::TemplateTemplateParm:
283 case index::SymbolKind::TemplateTypeParm:
286 llvm_unreachable(
"invalid symbol kind");
290 const llvm::json::Object *O = Params.getAsObject();
293 if (
auto *TextDocument = O->getObject(
"textDocument")) {
294 if (
auto *SemanticHighlighting =
295 TextDocument->getObject(
"semanticHighlightingCapabilities")) {
296 if (
auto SemanticHighlightingSupport =
297 SemanticHighlighting->getBoolean(
"semanticHighlighting"))
300 if (TextDocument->getObject(
"semanticTokens"))
302 if (
auto *Diagnostics = TextDocument->getObject(
"publishDiagnostics")) {
303 if (
auto CategorySupport = Diagnostics->getBoolean(
"categorySupport"))
305 if (
auto CodeActions = Diagnostics->getBoolean(
"codeActionsInline"))
307 if (
auto RelatedInfo = Diagnostics->getBoolean(
"relatedInformation"))
310 if (
auto *Completion = TextDocument->getObject(
"completion")) {
311 if (
auto *Item = Completion->getObject(
"completionItem")) {
312 if (
auto SnippetSupport = Item->getBoolean(
"snippetSupport"))
314 if (
auto DocumentationFormat = Item->getArray(
"documentationFormat")) {
315 for (
const auto &Format : *DocumentationFormat) {
321 if (
auto *ItemKind = Completion->getObject(
"completionItemKind")) {
322 if (
auto *ValueSet = ItemKind->get(
"valueSet")) {
328 if (
auto EditsNearCursor = Completion->getBoolean(
"editsNearCursor"))
331 if (
auto *
CodeAction = TextDocument->getObject(
"codeAction")) {
332 if (
CodeAction->getObject(
"codeActionLiteralSupport"))
335 if (
auto *
DocumentSymbol = TextDocument->getObject(
"documentSymbol")) {
336 if (
auto HierarchicalSupport =
340 if (
auto *
Hover = TextDocument->getObject(
"hover")) {
341 if (
auto *ContentFormat =
Hover->getArray(
"contentFormat")) {
342 for (
const auto &Format : *ContentFormat) {
348 if (
auto *Help = TextDocument->getObject(
"signatureHelp")) {
350 if (
auto *
Info = Help->getObject(
"signatureInformation")) {
351 if (
auto *
Parameter =
Info->getObject(
"parameterInformation")) {
352 if (
auto OffsetSupport =
Parameter->getBoolean(
"labelOffsetSupport"))
357 if (
auto *Rename = TextDocument->getObject(
"rename")) {
358 if (
auto RenameSupport = Rename->getBoolean(
"prepareSupport"))
362 if (
auto *Workspace = O->getObject(
"workspace")) {
363 if (
auto *
Symbol = Workspace->getObject(
"symbol")) {
365 if (
auto *ValueSet =
SymbolKind->get(
"valueSet")) {
373 if (
auto *Window = O->getObject(
"window")) {
374 if (
auto WorkDoneProgress = Window->getBoolean(
"workDoneProgress"))
376 if (
auto Implicit = Window->getBoolean(
"implicitWorkDoneProgressCreate"))
388 llvm::json::ObjectMapper O(Params);
397 O.map(
"trace", R.
trace);
403 return llvm::json::Object{{
"token", P.
token}};
407 llvm::json::Object Result{
412 Result[
"cancellable"] =
true;
414 Result[
"percentage"] = 0;
417 return std::move(Result);
421 llvm::json::Object Result{{
"kind",
"report"}};
425 Result[
"message"] = *P.
message;
429 return std::move(Result);
433 llvm::json::Object Result{{
"kind",
"end"}};
435 Result[
"message"] = *P.
message;
437 return std::move(Result);
441 return static_cast<int64_t>(R);
445 return llvm::json::Object{{
"type", R.
type}, {
"message", R.
message}};
449 llvm::json::ObjectMapper O(Params);
454 llvm::json::ObjectMapper O(Params);
459 llvm::json::ObjectMapper O(Params);
464 llvm::json::ObjectMapper O(Params);
474 if (
auto T =
E.getAsInteger()) {
478 Out = static_cast<FileChangeType>(*T);
485 llvm::json::ObjectMapper O(Params);
486 return O && O.map(
"uri", R.
uri) && O.map(
"type", R.
type);
490 llvm::json::ObjectMapper O(Params);
491 return O && O.map(
"changes", R.
changes);
496 llvm::json::ObjectMapper O(Params);
497 return O && O.map(
"range", R.
range) && O.map(
"rangeLength", R.
rangeLength) &&
498 O.map(
"text", R.
text);
503 llvm::json::ObjectMapper O(Params);
509 llvm::json::ObjectMapper O(Params);
511 O.map(
"position", R.
position) && O.map(
"ch", R.
ch);
515 llvm::json::ObjectMapper O(Params);
520 llvm::json::ObjectMapper O(Params);
525 return llvm::json::Object{
532 llvm::json::Object
Diag{
548 return std::move(
Diag);
552 llvm::json::ObjectMapper O(Params);
553 if (!O || !O.map(
"range", R.
range) || !O.map(
"message", R.
message))
557 O.map(
"code", R.
code);
558 O.map(
"source", R.
source);
563 llvm::json::Object Result{
568 Result[
"version"] = PDP.
version;
569 return std::move(Result);
573 llvm::json::ObjectMapper O(Params);
600 llvm::json::ObjectMapper O(Params);
606 llvm::json::ObjectMapper O(Params);
607 return O && O.map(
"changes", R.
changes);
616 llvm::json::ObjectMapper O(Params);
617 if (!O || !O.map(
"command", R.
command))
620 auto Args = Params.getAsObject()->getArray(
"arguments");
622 return Args && Args->size() == 1 &&
631 return llvm::json::Object{
633 {
"kind", static_cast<int>(P.
kind)},
651 llvm::json::Object Result{{
"name", llvm::json::Value(
nullptr)},
652 {
"containerName", llvm::json::Value(
nullptr)},
653 {
"usr", llvm::json::Value(
nullptr)},
654 {
"id", llvm::json::Value(
nullptr)}};
657 Result[
"name"] = P.
name;
663 Result[
"usr"] = P.
USR;
666 Result[
"id"] = P.
ID.getValue().str();
669 return std::move(Result);
675 llvm::StringRef ContNameRef;
676 if (!ContNameRef.endswith(
"::")) {
685 llvm::json::ObjectMapper O(Params);
686 return O && O.map(
"query", R.
query);
689 llvm::json::Value
toJSON(
const Command &C) {
690 auto Cmd = llvm::json::Object{{
"title", C.title}, {
"command", C.command}};
692 Cmd[
"arguments"] = {*C.workspaceEdit};
694 Cmd[
"arguments"] = {*C.tweakArgs};
695 return std::move(Cmd);
720 llvm::json::Object Result{{
"name", S.
name},
721 {
"kind", static_cast<int>(S.
kind)},
726 Result[
"detail"] = S.
detail;
730 Result[
"deprecated"] =
true;
732 return std::move(Result);
737 return llvm::json::Object{};
738 llvm::json::Object FileChanges;
739 for (
auto &Change : *WE.
changes)
740 FileChanges[Change.first] = llvm::json::Array(Change.second);
741 return llvm::json::Object{{
"changes", std::move(FileChanges)}};
745 llvm::json::ObjectMapper O(Params);
746 return O && O.map(
"file", A.
file) && O.map(
"selection", A.
selection) &&
751 return llvm::json::Object{
756 return llvm::json::Object{{
"edit", Params.
edit}};
761 llvm::json::ObjectMapper O(Response);
762 if (!O || !O.map(
"applied", R.
applied))
769 llvm::json::ObjectMapper O(Params);
775 llvm::json::ObjectMapper O(Params);
780 if (!O.map(
"triggerKind", TriggerKind))
782 R.
triggerKind = static_cast<CompletionTriggerKind>(TriggerKind);
784 if (
auto *TC = Params.getAsObject()->get(
"triggerCharacter"))
790 if (!
fromJSON(Params, static_cast<TextDocumentPositionParams &>(R)))
792 if (
auto *
Context = Params.getAsObject()->
get(
"context"))
804 llvm_unreachable(
"Invalid MarkupKind");
808 auto Str = V.getAsString();
810 elog(
"Failed to parse markup kind: expected a string");
813 if (*Str ==
"plaintext")
815 else if (*Str ==
"markdown")
818 elog(
"Unknown markup kind: {0}", *Str);
829 if (MC.
value.empty())
832 return llvm::json::Object{
839 llvm::json::Object Result{{
"contents",
toJSON(H.contents)}};
841 if (H.range.hasValue())
842 Result[
"range"] =
toJSON(*H.range);
844 return std::move(Result);
848 if (
auto T =
E.getAsInteger()) {
852 Out = static_cast<CompletionItemKind>(*T);
861 auto KindVal = static_cast<size_t>(
Kind);
863 KindVal <= SupportedCompletionItemKinds.size() &&
864 SupportedCompletionItemKinds[KindVal])
881 if (
auto *A =
E.getAsArray()) {
882 for (
size_t I = 0; I < A->size(); ++I) {
885 Out.set(
size_t(KindOut));
893 assert(!
CI.label.empty() &&
"completion item label is required");
894 llvm::json::Object Result{{
"label",
CI.label}};
896 Result[
"kind"] = static_cast<int>(
CI.kind);
897 if (!
CI.detail.empty())
898 Result[
"detail"] =
CI.detail;
899 if (
CI.documentation)
900 Result[
"documentation"] =
CI.documentation;
901 if (!
CI.sortText.empty())
902 Result[
"sortText"] =
CI.sortText;
903 if (!
CI.filterText.empty())
904 Result[
"filterText"] =
CI.filterText;
905 if (!
CI.insertText.empty())
906 Result[
"insertText"] =
CI.insertText;
908 Result[
"insertTextFormat"] = static_cast<int>(
CI.insertTextFormat);
910 Result[
"textEdit"] = *
CI.textEdit;
911 if (!
CI.additionalTextEdits.empty())
912 Result[
"additionalTextEdits"] = llvm::json::Array(
CI.additionalTextEdits);
914 Result[
"deprecated"] =
CI.deprecated;
915 Result[
"score"] =
CI.score;
916 return std::move(Result);
930 return llvm::json::Object{
932 {
"items", llvm::json::Array(L.
items)},
938 "parameter information label is required");
939 llvm::json::Object Result;
947 return std::move(Result);
951 assert(!SI.
label.empty() &&
"signature information label is required");
952 llvm::json::Object Result{
954 {
"parameters", llvm::json::Array(SI.
parameters)},
958 return std::move(Result);
969 "Unexpected negative value for number of active signatures.");
971 "Unexpected negative value for active parameter index");
972 return llvm::json::Object{
975 {
"signatures", llvm::json::Array(SH.
signatures)},
980 llvm::json::ObjectMapper O(Params);
986 return llvm::json::Object{
988 {
"kind", static_cast<int>(DH.
kind)},
993 return llvm::json::Object{
994 {
"uri", FStatus.
uri},
995 {
"state", FStatus.
state},
1000 static llvm::json::Value
encodeTokens(llvm::ArrayRef<SemanticToken> Toks) {
1001 llvm::json::Array Result;
1002 for (
const auto &Tok : Toks) {
1003 Result.push_back(Tok.deltaLine);
1004 Result.push_back(Tok.deltaStart);
1005 Result.push_back(Tok.length);
1006 Result.push_back(Tok.tokenType);
1007 Result.push_back(Tok.tokenModifiers);
1010 return std::move(Result);
1021 return llvm::json::Object{{
"resultId", Tokens.resultId},
1026 return llvm::json::Object{
1033 llvm::json::Object Result{{
"resultId", TE.
resultId}};
1035 Result[
"edits"] = *TE.
edits;
1038 return std::move(Result);
1042 llvm::json::ObjectMapper O(Params);
1047 llvm::json::ObjectMapper O(Params);
1064 llvm::json::ObjectMapper O(Params);
1065 return O && O.map(
"settings", CCP.
settings);
1070 llvm::json::ObjectMapper O(Params);
1076 llvm::json::ObjectMapper O(Params);
1084 llvm::json::ObjectMapper O(Params);
1088 fromJSON(Params, Opts.ConfigSettings);
1089 O.map(
"compilationDatabasePath", Opts.compilationDatabasePath);
1090 O.map(
"fallbackFlags", Opts.fallbackFlags);
1091 O.map(
"clangdFileStatus", Opts.FileStatus);
1096 auto T =
E.getAsInteger();
1102 Out = static_cast<TypeHierarchyDirection>(*T);
1107 llvm::json::ObjectMapper O(Params);
1119 llvm::json::Object Result{{
"name", I.
name},
1120 {
"kind", static_cast<int>(I.
kind)},
1126 Result[
"detail"] = I.
detail;
1130 Result[
"parents"] = I.
parents;
1134 Result[
"data"] = I.
data;
1135 return std::move(Result);
1139 llvm::json::ObjectMapper O(Params);
1142 if (!(O && O.map(
"name", I.
name) && O.map(
"kind", I.
kind) &&
1143 O.map(
"uri", I.
uri) && O.map(
"range", I.
range) &&
1149 O.map(
"detail", I.
detail);
1153 O.map(
"data", I.
data);
1160 llvm::json::ObjectMapper O(Params);
1161 return O && O.map(
"item", P.
item) && O.map(
"resolve", P.
resolve) &&
1181 llvm_unreachable(
"Unknown clang.clangd.OffsetEncoding");
1185 auto Str = V.getAsString();
1188 OE = llvm::StringSwitch<OffsetEncoding>(*Str)
1206 return llvm::json::Object{{
"line", Highlighting.
Line},
1207 {
"tokens", Highlighting.
Tokens},
1212 return llvm::json::Object{
1214 {
"lines", std::move(Highlighting.
Lines)},
1219 llvm::json::ObjectMapper O(Params);
1226 return llvm::json::Object{{
"range",
Out.range},
1229 return llvm::json::Object{{
"range",
Out.range}};
1233 llvm::json::ObjectMapper O(Params);
1238 return llvm::json::Object{
1245 llvm::json::ObjectMapper O(Params);
1250 llvm::json::Object Result{
1251 {
"startLine",
Range.startLine},
1252 {
"endLine",
Range.endLine},
1254 if (
Range.startCharacter)
1255 Result[
"startCharacter"] =
Range.startCharacter;
1256 if (
Range.endCharacter)
1257 Result[
"endCharacter"] =
Range.endCharacter;
1259 Result[
"kind"] = *
Range.kind;
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.
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...
TextDocumentItem textDocument
The document that was opened.
std::unique_ptr< GlobalCompilationDatabase > Base
std::string source
A human-readable string describing the source of this diagnostic, e.g.
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.
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
A set of edits generated for a single file.
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.
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.
constexpr unsigned SemanticTokenEncodingSize
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.
const Type * get(const Key< Type > &Key) const
Get data stored for a typed Key.
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.
std::vector< Position > positions
The positions inside the text document.
std::unique_ptr< CompilerInvocation > CI
ConfigurationSettings settings
std::string label
The label of this completion item.
bool HierarchicalDocumentSymbol
Client supports hierarchical document symbols.
Position start
The range's start position.
static llvm::Expected< std::string > resolvePath(llvm::StringRef AbsPath, llvm::StringRef HintPath="")
Resolves AbsPath into a canonical path of its URI, by converting AbsPath to URI and resolving the URI...
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.
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.
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)
std::string tweakID
ID of the tweak that should be executed. Corresponds to Tweak::id().
TextDocumentIdentifier textDocument
The document in which the command was invoked.
CodeActionContext context
Context carrying additional information.
llvm::Optional< std::string > failureReason
static llvm::Expected< URI > parse(llvm::StringRef Uri)
Parse a URI string "<scheme>:[//<authority>/]<path>".
std::vector< DocumentSymbol > children
Children of this symbol, e.g. properties of a class.
std::bitset< SymbolKindMax+1 > SymbolKindBitset
std::string containerName
Range range
The range enclosing this type hierarchy item not including leading/trailing whitespace but everything...
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.
static llvm::StringRef toTextKind(MarkupKind Kind)
static llvm::Expected< std::string > resolve(const URI &U, llvm::StringRef HintPath="")
Resolves the absolute path of U.
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 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.
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.
A top-level diagnostic that may have Notes and Fixes.
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.
unsigned deltaStart
token start character, relative to the previous token (relative to 0 or the previous token's start if...
std::string name
The human readable name of the hierarchy item.
The class presents a C++ symbol, e.g.
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.
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....
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.
static const char * toString(OffsetEncoding OE)
int character
Character offset on a line in a document (zero-based).
CompletionTriggerKind triggerKind
How the completion was triggered.
bool fromJSON(const llvm::json::Value &Parameters, FuzzyFindRequest &Request)
Position position
The position inside the text document.
Position end
The range's end position.
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.
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.
bool DiagnosticRelatedInformation
Whether the client accepts diagnostics with related locations.
std::string USR
Unified Symbol Resolution identifier This is an opaque string uniquely identifying a symbol.
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.
static llvm::json::Value encodeTokens(llvm::ArrayRef< SemanticToken > Toks)
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.
bool WorkDoneProgress
The client supports progress notifications.
llvm::Optional< std::vector< Diagnostic > > diagnostics
The diagnostics that this code action resolves.
The type hierarchy params is an extension of the TextDocumentPositionsParams with optional properties...
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.
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.
TextDocumentIdentifier textDocument
The document that was saved.
The parameters of a Workspace Symbol Request.
std::vector< std::string > compilationCommand
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.
std::string message
The actual message.
std::string message
The diagnostic's message.
static URIForFile canonicalize(llvm::StringRef AbsPath, llvm::StringRef TUPath)
Canonicalizes AbsPath via URI.
int severity
The diagnostic's severity.
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.
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.
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
bool SemanticTokens
Client advertises support for the semanticTokens feature.
llvm::Optional< WorkspaceEdit > workspaceEdit
llvm::Optional< SymbolID > ID
llvm::Optional< std::vector< DiagnosticRelatedInformation > > relatedInformation
An array of related diagnostic information, e.g.
TextDocumentIdentifier textDocument
The document to provide document links for.
std::string newText
The string to be inserted.
CompiledFragmentImpl & Out
TextDocumentIdentifier textDocument
The text document.
void elog(const char *Fmt, Ts &&... Vals)
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.
A context is an immutable container for per-request data that must be propagated through layers that ...
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.
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.