34 auto *V = O->get(Prop);
35 if (!V || V->getAsNull())
37 return fromJSON(*V, Out, Path.field(Prop));
51 return Path.size() > 1 &&
llvm::isAlpha(Path[0]) && Path[1] ==
':';
55 return Path.size() > 2 && Path[0] == Path[1] &&
61 if ((
C >=
'a' &&
C <=
'z') || (
C >=
'A' &&
C <=
'Z') ||
62 (
C >=
'0' &&
C <=
'9'))
84 for (
unsigned char C : Content) {
98 for (
auto I = Content.
begin(),
E = Content.
end();
I !=
E; ++
I) {
104 Result.push_back(*
I);
144 std::string Uri = Scheme.
str() +
":";
145 if (Authority.
empty() && Body.empty())
163 "File scheme: expect body to be an absolute path starting "
167 if (!Authority.
empty()) {
169 (
"//" + Authority).toVector(Path);
176 return std::string(Path);
183 size_t Pos = Uri.
find(
':');
186 "Scheme must be provided in URI: " +
192 "Invalid scheme: " + SchemeStr +
193 " (decoded: " + UriScheme +
")");
194 Uri = Uri.
substr(Pos + 1);
197 std::string UriAuthority;
210 "unsupported URI scheme `" + UriScheme +
211 "' for workspace files");
240 if (std::optional<StringRef> Str =
Value.getAsString()) {
243 Path.report(
"unresolvable URI");
247 Result = std::move(*ExpectedUri);
258 return Os <<
Value.uri();
269 Path.report(
"expected object");
274 TextDocument->getObject(
"documentSymbol")) {
275 if (std::optional<bool> HierarchicalSupport =
277 Result.hierarchicalDocumentSymbol = *HierarchicalSupport;
279 if (
auto *
CodeAction = TextDocument->getObject(
"codeAction")) {
280 if (
CodeAction->getObject(
"codeActionLiteralSupport"))
281 Result.codeActionStructure =
true;
284 if (
auto *Window = O->getObject(
"window")) {
285 if (std::optional<bool> WorkDoneProgressSupport =
286 Window->getBoolean(
"workDoneProgress"))
287 Result.workDoneProgress = *WorkDoneProgressSupport;
299 if (!O || !O.map(
"name", Result.name))
303 O.map(
"version", Result.version);
313 if (std::optional<StringRef> Str =
Value.getAsString()) {
318 if (*Str ==
"messages") {
322 if (*Str ==
"verbose") {
336 O.map(
"capabilities", Result.capabilities);
337 O.map(
"trace", Result.trace);
350 return O && O.map(
"uri", Result.uri) &&
351 O.map(
"languageId", Result.languageId) && O.map(
"text", Result.text) &&
352 O.map(
"version", Result.version);
367 return O && O.map(
"uri", Result.uri);
378 {
"version",
Value.version},
386 return O && O.map(
"uri", Result.uri) && O.map(
"version", Result.version);
396 return O && O.map(
"line", Result.line) &&
397 O.map(
"character", Result.character);
402 {
"line",
Value.line},
403 {
"character",
Value.character},
408 return Os <<
Value.line <<
':' <<
Value.character;
418 return O && O.map(
"start", Result.start) && O.map(
"end", Result.end);
423 {
"start",
Value.start},
439 return O && O.map(
"uri", Result.uri) && O.map(
"range", Result.range);
445 {
"range",
Value.range},
461 return O && O.map(
"textDocument", Result.textDocument) &&
462 O.map(
"position", Result.position);
472 return O && O.mapOptional(
"includeDeclaration", Result.includeDeclaration);
480 O.mapOptional(
"context", Result.context);
491 return O && O.map(
"textDocument", Result.textDocument);
502 return O && O.map(
"textDocument", Result.textDocument);
512 return O && O.map(
"textDocument", R.textDocument);
543 for (
const auto &Change : Changes)
544 if (
failed(Change.applyTo(Contents)))
553 return O && O.map(
"range", Result.range) &&
554 O.map(
"rangeLength", Result.rangeLength) && O.map(
"text", Result.text);
561 return O && O.map(
"textDocument", Result.textDocument) &&
562 O.map(
"contentChanges", Result.contentChanges);
584 if (Mc.
value.empty())
601 return std::move(Result);
610 {
"kind",
static_cast<int>(Symbol.kind)},
611 {
"range", Symbol.range},
612 {
"selectionRange", Symbol.selectionRange}};
614 if (!Symbol.detail.empty())
615 Result[
"detail"] = Symbol.detail;
616 if (!Symbol.children.empty())
617 Result[
"children"] = Symbol.children;
618 return std::move(Result);
628 return O && O.map(
"textDocument", Result.textDocument);
639 return O && O.map(
"location", Result.location) &&
640 O.map(
"message", Result.message);
645 {
"location",
Info.location},
646 {
"message",
Info.message},
655 return static_cast<int>(
Tag);
660 if (std::optional<int64_t>
I =
Value.getAsInteger()) {
670 {
"range", Diag.
range},
675 Result[
"category"] = *Diag.
category;
677 Result[
"source"] = Diag.
source;
680 if (!Diag.
tags.empty())
681 Result[
"tags"] = Diag.
tags;
682 return std::move(Result);
695 return O.map(
"range", Result.range) && O.map(
"message", Result.message) &&
722 return O && O.map(
"range", Result.range) && O.map(
"newText", Result.newText);
727 {
"range",
Value.range},
728 {
"newText",
Value.newText},
733 Os <<
Value.range <<
" => \"";
744 if (std::optional<int64_t> IntValue =
Value.getAsInteger()) {
757 size_t KindVal =
static_cast<size_t>(Kind);
759 KindVal <= SupportedCompletionItemKinds.size() &&
760 SupportedCompletionItemKinds[KindVal])
780 for (
size_t I = 0, E = ArrayValue->size();
I < E; ++
I) {
782 if (
fromJSON((*ArrayValue)[
I], KindOut, Path.index(
I)))
783 Result.set(
size_t(KindOut));
795 assert(!
Value.label.empty() &&
"completion item label is required");
798 Result[
"kind"] =
static_cast<int>(
Value.kind);
799 if (!
Value.detail.empty())
800 Result[
"detail"] =
Value.detail;
801 if (
Value.documentation)
802 Result[
"documentation"] =
Value.documentation;
803 if (!
Value.sortText.empty())
804 Result[
"sortText"] =
Value.sortText;
805 if (!
Value.filterText.empty())
806 Result[
"filterText"] =
Value.filterText;
807 if (!
Value.insertText.empty())
808 Result[
"insertText"] =
Value.insertText;
810 Result[
"insertTextFormat"] =
static_cast<int>(
Value.insertTextFormat);
812 Result[
"textEdit"] = *
Value.textEdit;
813 if (!
Value.additionalTextEdits.empty()) {
814 Result[
"additionalTextEdits"] =
817 if (
Value.deprecated)
818 Result[
"deprecated"] =
Value.deprecated;
819 return std::move(Result);
839 {
"isIncomplete",
Value.isIncomplete},
852 if (!O || !O.map(
"triggerKind", TriggerKind) ||
868 return fromJSON(*Context, Result.context, Path.field(
"context"));
878 "parameter information label is required");
880 if (
Value.labelOffsets)
882 {
Value.labelOffsets->first,
Value.labelOffsets->second});
884 Result[
"label"] =
Value.labelString;
885 if (!
Value.documentation.empty())
886 Result[
"documentation"] =
Value.documentation;
887 return std::move(Result);
895 assert(!
Value.label.empty() &&
"signature information label is required");
897 {
"label",
Value.label},
900 if (!
Value.documentation.empty())
901 Result[
"documentation"] =
Value.documentation;
902 return std::move(Result);
916 "Unexpected negative value for number of active signatures.");
918 "Unexpected negative value for active parameter index");
920 {
"activeSignature",
Value.activeSignature},
921 {
"activeParameter",
Value.activeParameter},
933 return O && O.map(
"textDocument", Result.textDocument);
942 {
"range",
Value.range},
943 {
"target",
Value.target},
954 return O && O.map(
"textDocument", Result.textDocument) &&
955 O.map(
"range", Result.range);
964 {
"kind", (int)
Value.kind},
965 {
"label",
Value.label},
966 {
"paddingLeft",
Value.paddingLeft},
967 {
"paddingRight",
Value.paddingRight}};
982 return Os <<
"parameter";
996 if (!O || !O.map(
"diagnostics", Result.diagnostics))
998 O.map(
"only", Result.only);
1009 return O && O.map(
"textDocument", Result.textDocument) &&
1010 O.map(
"range", Result.range) && O.map(
"context", Result.context);
1020 return O && O.map(
"changes", Result.changes);
1025 for (
auto &Change :
Value.changes)
1042 if (
Value.diagnostics)
1044 if (
Value.isPreferred)
1057 {
"type",
static_cast<int>(Params.
type)},
1061 Out[
"actions"] = *Params.
actions;
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
This file supports working with JSON data.
static bool isWindowsPath(StringRef Path)
static void percentEncode(StringRef Content, std::string &Out)
Encodes a string according to percent-encoding.
static std::string percentDecode(StringRef Content)
Decodes a string according to percent-encoding.
static bool isNetworkPath(StringRef Path)
static llvm::Expected< std::string > parseFilePathFromURI(StringRef OrigUri)
static bool isStructurallyValidScheme(StringRef Scheme)
Returns true if the given scheme is structurally valid, i.e.
static bool shouldEscapeInURI(unsigned char C)
static llvm::Expected< std::string > uriFromAbsolutePath(StringRef AbsolutePath, StringRef Scheme)
static StringSet & getSupportedSchemes()
Return the set containing the supported URI schemes.
static bool mapOptOrNull(const llvm::json::Value &Params, llvm::StringLiteral Prop, T &Out, llvm::json::Path Path)
static llvm::Expected< std::string > getAbsolutePath(StringRef Authority, StringRef Body)
static llvm::StringRef toTextKind(MarkupKind Kind)
static bool contains(SmallPtrSetImpl< ConstantExpr * > &Cache, ConstantExpr *Expr, Constant *C)
StringSet - A set-like wrapper for the StringMap.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Tagged union holding either a T or a Error.
Error takeError()
Take ownership of the stored error.
static std::unique_ptr< MemoryBuffer > getMemBuffer(StringRef InputData, StringRef BufferName="", bool RequiresNullTerminator=true)
Open the specified memory range as a MemoryBuffer.
Represents a location in source code.
constexpr const char * getPointer() const
Represents a range in source code.
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
This owns the files read by a parser, handles include stacks, and handles diagnostic wrangling.
unsigned AddNewSourceBuffer(std::unique_ptr< MemoryBuffer > F, SMLoc IncludeLoc)
Add a new source buffer to this source manager.
A wrapper around a string literal that serves as a proxy for constructing global tables of StringRefs...
StringRef - Represent a constant reference to a string, i.e.
std::pair< StringRef, StringRef > split(char Separator) const
Split into two substrings around the first occurrence of a separator character.
static constexpr size_t npos
std::string str() const
str - Get the contents as an std::string.
constexpr StringRef substr(size_t Start, size_t N=npos) const
Return a reference to the substring from [Start, Start + N).
bool starts_with(StringRef Prefix) const
Check if this string starts with the given Prefix.
constexpr bool empty() const
empty - Check if the string is empty.
StringRef drop_front(size_t N=1) const
Return a StringRef equal to 'this' but with the first N elements dropped.
size_t find(char C, size_t From=0) const
Search for the first character C in the string.
bool consume_front(char Prefix)
Returns true if this StringRef has the given prefix and removes that prefix.
StringSet - A wrapper for StringMap that provides set-like functionality.
std::pair< typename Base::iterator, bool > insert(StringRef key)
An Array is a JSON array, which contains heterogeneous JSON values.
Helper for mapping JSON objects onto protocol structs.
An Object is a JSON object, which maps strings to heterogenous JSON values.
A "cursor" marking a position within a Value.
A Value is an JSON value of unknown type.
const json::Object * getAsObject() const
static LLVM_ABI_FOR_TEST char ID
URI in "file" scheme for a file.
static void registerSupportedScheme(StringRef scheme)
Register a supported URI scheme.
static llvm::Expected< URIForFile > fromFile(StringRef absoluteFilepath, StringRef scheme="file")
Try to build a URIForFile from the given absolute file path and optional scheme.
static llvm::Expected< URIForFile > fromURI(StringRef uri)
Try to build a URIForFile from the given URI string.
StringRef scheme() const
Return the scheme of the uri.
StringRef uri() const
Returns the original uri of the file.
This class implements an extremely fast bulk output stream that can only output to a stream.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
@ C
The default llvm calling convention, compatible with C.
constexpr auto kCompletionItemKindMin
MarkupKind
Describes the content type that a client supports in various result literals like Hover.
LLVM_ABI_FOR_TEST llvm::json::Value toJSON(const URIForFile &value)
Add support for JSON serialization.
bool operator<(const CompletionItem &lhs, const CompletionItem &rhs)
bool operator==(const TextEdit &lhs, const TextEdit &rhs)
raw_ostream & operator<<(raw_ostream &os, const URIForFile &value)
CompletionItemKind adjustKindToCapability(CompletionItemKind kind, CompletionItemKindBitset &supportedCompletionItemKinds)
InlayHintKind
Inlay hint kinds.
@ Parameter
An inlay hint that is for a parameter.
@ Type
An inlay hint that for a type annotation.
std::bitset< kCompletionItemKindMax+1 > CompletionItemKindBitset
CompletionItemKind
The kind of a completion entry.
LLVM_ABI_FOR_TEST bool fromJSON(const llvm::json::Value &value, URIForFile &result, llvm::json::Path path)
LLVM_ABI std::string convert_to_slash(StringRef path, Style style=Style::native)
Replaces backslashes with slashes if Windows.
LLVM_ABI StringRef root_name(StringRef path LLVM_LIFETIME_BOUND, Style style=Style::native)
Get root name.
LLVM_ABI bool is_separator(char value, Style style=Style::native)
Check whether the given char is a path separator on the host OS.
This is an optimization pass for GlobalISel generic memory operations.
auto drop_begin(T &&RangeOrContainer, size_t N=1)
Return a range covering RangeOrContainer with the first N elements excluded.
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly.
bool failed(LogicalResult Result)
Utility function that returns true if the provided LogicalResult corresponds to a failure value.
LLVM_ABI std::error_code inconvertibleErrorCode()
The value returned by this function can be returned from convertToErrorCode for Error values where no...
LogicalResult failure(bool IsFailure=true)
Utility function to generate a LogicalResult.
LLVM_ABI void printEscapedString(StringRef Name, raw_ostream &Out)
Print each character of the specified string, escaping it if it is not printable or if it is an escap...
Error createStringError(std::error_code EC, char const *Fmt, const Ts &... Vals)
Create formatted StringError object.
bool isAlpha(char C)
Checks if character C is a valid letter as classified by "C" locale.
uint8_t hexFromNibbles(char MSB, char LSB)
Return the binary representation of the two provided values, MSB and LSB, that make up the nibbles of...
char hexdigit(unsigned X, bool LowerCase=false)
hexdigit - Return the hexadecimal character for the given number X (which should be less than 16).
bool isAlnum(char C)
Checks whether character C is either a decimal digit or an uppercase or lowercase letter as classifie...
bool isHexDigit(char C)
Checks if character C is a hexadecimal numeric character.
void consumeError(Error Err)
Consume a Error without doing anything.
This class represents an efficient way to signal success or failure.
A code action represents a change that can be performed in code, e.g.
static const llvm::StringLiteral kRefactor
static const llvm::StringLiteral kInfo
static const llvm::StringLiteral kQuickFix
std::string label
The label of this completion item.
std::string sortText
A string that should be used when comparing this item with other items.
Represents a collection of completion items to be presented in the editor.
std::vector< DiagnosticTag > tags
Additional metadata about the diagnostic.
std::string message
The diagnostic's message.
Range range
The source range where the message applies.
std::optional< std::vector< DiagnosticRelatedInformation > > relatedInformation
An array of related diagnostic information, e.g.
std::string source
A human-readable string describing the source of this diagnostic, e.g.
DiagnosticSeverity severity
The diagnostic's severity.
std::optional< std::string > category
The diagnostic's category.
Parameters for the document link request.
A range in a text document that links to an internal or external resource, like another text document...
Represents programming constructs like variables, classes, interfaces etc.
std::optional< Range > range
An optional range is a range inside a text document that is used to visualize a hover,...
MarkupContent contents
The hover's content.
InlayHintKind kind
The kind of this hint.
std::string label
The label of this hint.
Position position
The position of this hint.
A parameter literal used in inlay hint requests.
std::string title
A short title like 'Retry', 'Open Log' etc.
URIForFile uri
The URI for which diagnostic information is reported.
int64_t version
The version number of the document the diagnostics are published for.
std::vector< Diagnostic > diagnostics
The list of reported diagnostics.
std::string message
The actual message.
std::optional< std::vector< MessageActionItem > > actions
The message action items to present.
Represents the signature of a callable.
std::optional< Range > range
The range of the document that changed.
LogicalResult applyTo(std::string &contents) const
Try to apply this change to the given contents string.
std::string text
The new text of the range/document.