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);
533 for (
const auto &Change : Changes)
534 if (
failed(Change.applyTo(Contents)))
543 return O && O.map(
"range", Result.range) &&
544 O.map(
"rangeLength", Result.rangeLength) && O.map(
"text", Result.text);
551 return O && O.map(
"textDocument", Result.textDocument) &&
552 O.map(
"contentChanges", Result.contentChanges);
574 if (Mc.
value.empty())
591 return std::move(Result);
600 {
"kind",
static_cast<int>(Symbol.kind)},
601 {
"range", Symbol.range},
602 {
"selectionRange", Symbol.selectionRange}};
604 if (!Symbol.detail.empty())
605 Result[
"detail"] = Symbol.detail;
606 if (!Symbol.children.empty())
607 Result[
"children"] = Symbol.children;
608 return std::move(Result);
618 return O && O.map(
"textDocument", Result.textDocument);
629 return O && O.map(
"location", Result.location) &&
630 O.map(
"message", Result.message);
635 {
"location", Info.location},
636 {
"message", Info.message},
645 return static_cast<int>(
Tag);
650 if (std::optional<int64_t>
I =
Value.getAsInteger()) {
660 {
"range", Diag.
range},
665 Result[
"category"] = *Diag.
category;
667 Result[
"source"] = Diag.
source;
670 if (!Diag.
tags.empty())
671 Result[
"tags"] = Diag.
tags;
672 return std::move(Result);
685 return O.map(
"range", Result.range) && O.map(
"message", Result.message) &&
712 return O && O.map(
"range", Result.range) && O.map(
"newText", Result.newText);
717 {
"range",
Value.range},
718 {
"newText",
Value.newText},
723 Os <<
Value.range <<
" => \"";
734 if (std::optional<int64_t> IntValue =
Value.getAsInteger()) {
747 size_t KindVal =
static_cast<size_t>(Kind);
749 KindVal <= SupportedCompletionItemKinds.size() &&
750 SupportedCompletionItemKinds[KindVal])
770 for (
size_t I = 0, E = ArrayValue->size();
I < E; ++
I) {
772 if (
fromJSON((*ArrayValue)[
I], KindOut, Path.index(
I)))
773 Result.set(
size_t(KindOut));
785 assert(!
Value.label.empty() &&
"completion item label is required");
788 Result[
"kind"] =
static_cast<int>(
Value.kind);
789 if (!
Value.detail.empty())
790 Result[
"detail"] =
Value.detail;
791 if (
Value.documentation)
792 Result[
"documentation"] =
Value.documentation;
793 if (!
Value.sortText.empty())
794 Result[
"sortText"] =
Value.sortText;
795 if (!
Value.filterText.empty())
796 Result[
"filterText"] =
Value.filterText;
797 if (!
Value.insertText.empty())
798 Result[
"insertText"] =
Value.insertText;
800 Result[
"insertTextFormat"] =
static_cast<int>(
Value.insertTextFormat);
802 Result[
"textEdit"] = *
Value.textEdit;
803 if (!
Value.additionalTextEdits.empty()) {
804 Result[
"additionalTextEdits"] =
807 if (
Value.deprecated)
808 Result[
"deprecated"] =
Value.deprecated;
809 return std::move(Result);
829 {
"isIncomplete",
Value.isIncomplete},
842 if (!O || !O.map(
"triggerKind", TriggerKind) ||
858 return fromJSON(*Context, Result.context, Path.field(
"context"));
868 "parameter information label is required");
870 if (
Value.labelOffsets)
872 {
Value.labelOffsets->first,
Value.labelOffsets->second});
874 Result[
"label"] =
Value.labelString;
875 if (!
Value.documentation.empty())
876 Result[
"documentation"] =
Value.documentation;
877 return std::move(Result);
885 assert(!
Value.label.empty() &&
"signature information label is required");
887 {
"label",
Value.label},
890 if (!
Value.documentation.empty())
891 Result[
"documentation"] =
Value.documentation;
892 return std::move(Result);
906 "Unexpected negative value for number of active signatures.");
908 "Unexpected negative value for active parameter index");
910 {
"activeSignature",
Value.activeSignature},
911 {
"activeParameter",
Value.activeParameter},
923 return O && O.map(
"textDocument", Result.textDocument);
932 {
"range",
Value.range},
933 {
"target",
Value.target},
944 return O && O.map(
"textDocument", Result.textDocument) &&
945 O.map(
"range", Result.range);
954 {
"kind", (int)
Value.kind},
955 {
"label",
Value.label},
956 {
"paddingLeft",
Value.paddingLeft},
957 {
"paddingRight",
Value.paddingRight}};
972 return Os <<
"parameter";
986 if (!O || !O.map(
"diagnostics", Result.diagnostics))
988 O.map(
"only", Result.only);
999 return O && O.map(
"textDocument", Result.textDocument) &&
1000 O.map(
"range", Result.range) && O.map(
"context", Result.context);
1010 return O && O.map(
"changes", Result.changes);
1015 for (
auto &Change :
Value.changes)
1032 if (
Value.diagnostics)
1034 if (
Value.isPreferred)
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.
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.
bool consume_front(StringRef Prefix)
Returns true if this StringRef has the given prefix and removes that prefix.
size_t find(char C, size_t From=0) const
Search for the first character C in the string.
static constexpr size_t npos
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
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::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.
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.
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.
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.