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) {
108 Result.push_back(*
I);
148 std::string Uri = Scheme.
str() +
":";
149 if (Authority.
empty() && Body.empty())
167 "File scheme: expect body to be an absolute path starting "
171 if (!Authority.
empty()) {
173 (
"//" + Authority).toVector(Path);
180 return std::string(Path);
187 size_t Pos = Uri.
find(
':');
190 "Scheme must be provided in URI: " +
196 "Invalid scheme: " + SchemeStr +
197 " (decoded: " + UriScheme +
")");
198 Uri = Uri.
substr(Pos + 1);
201 std::string UriAuthority;
214 "unsupported URI scheme `" + UriScheme +
215 "' for workspace files");
244 if (std::optional<StringRef> Str =
Value.getAsString()) {
247 Path.report(
"unresolvable URI");
251 Result = std::move(*ExpectedUri);
262 return Os <<
Value.uri();
273 Path.report(
"expected object");
278 TextDocument->getObject(
"documentSymbol")) {
279 if (std::optional<bool> HierarchicalSupport =
281 Result.hierarchicalDocumentSymbol = *HierarchicalSupport;
283 if (
auto *
CodeAction = TextDocument->getObject(
"codeAction")) {
284 if (
CodeAction->getObject(
"codeActionLiteralSupport"))
285 Result.codeActionStructure =
true;
288 if (
auto *Window = O->getObject(
"window")) {
289 if (std::optional<bool> WorkDoneProgressSupport =
290 Window->getBoolean(
"workDoneProgress"))
291 Result.workDoneProgress = *WorkDoneProgressSupport;
303 if (!O || !O.map(
"name", Result.name))
307 O.map(
"version", Result.version);
317 if (std::optional<StringRef> Str =
Value.getAsString()) {
322 if (*Str ==
"messages") {
326 if (*Str ==
"verbose") {
340 O.map(
"capabilities", Result.capabilities);
341 O.map(
"trace", Result.trace);
354 return O && O.map(
"uri", Result.uri) &&
355 O.map(
"languageId", Result.languageId) && O.map(
"text", Result.text) &&
356 O.map(
"version", Result.version);
371 return O && O.map(
"uri", Result.uri);
382 {
"version",
Value.version},
390 return O && O.map(
"uri", Result.uri) && O.map(
"version", Result.version);
400 return O && O.map(
"line", Result.line) &&
401 O.map(
"character", Result.character);
406 {
"line",
Value.line},
407 {
"character",
Value.character},
412 return Os <<
Value.line <<
':' <<
Value.character;
422 return O && O.map(
"start", Result.start) && O.map(
"end", Result.end);
427 {
"start",
Value.start},
443 return O && O.map(
"uri", Result.uri) && O.map(
"range", Result.range);
449 {
"range",
Value.range},
465 return O && O.map(
"textDocument", Result.textDocument) &&
466 O.map(
"position", Result.position);
476 return O && O.mapOptional(
"includeDeclaration", Result.includeDeclaration);
484 O.mapOptional(
"context", Result.context);
495 return O && O.map(
"textDocument", Result.textDocument);
506 return O && O.map(
"textDocument", Result.textDocument);
537 for (
const auto &Change : Changes)
538 if (
failed(Change.applyTo(Contents)))
547 return O && O.map(
"range", Result.range) &&
548 O.map(
"rangeLength", Result.rangeLength) && O.map(
"text", Result.text);
555 return O && O.map(
"textDocument", Result.textDocument) &&
556 O.map(
"contentChanges", Result.contentChanges);
578 if (Mc.
value.empty())
595 return std::move(Result);
604 {
"kind",
static_cast<int>(Symbol.kind)},
605 {
"range", Symbol.range},
606 {
"selectionRange", Symbol.selectionRange}};
608 if (!Symbol.detail.empty())
609 Result[
"detail"] = Symbol.detail;
610 if (!Symbol.children.empty())
611 Result[
"children"] = Symbol.children;
612 return std::move(Result);
622 return O && O.map(
"textDocument", Result.textDocument);
633 return O && O.map(
"location", Result.location) &&
634 O.map(
"message", Result.message);
639 {
"location", Info.location},
640 {
"message", Info.message},
649 return static_cast<int>(
Tag);
654 if (std::optional<int64_t>
I =
Value.getAsInteger()) {
664 {
"range", Diag.
range},
669 Result[
"category"] = *Diag.
category;
671 Result[
"source"] = Diag.
source;
674 if (!Diag.
tags.empty())
675 Result[
"tags"] = Diag.
tags;
676 return std::move(Result);
689 return O.map(
"range", Result.range) && O.map(
"message", Result.message) &&
716 return O && O.map(
"range", Result.range) && O.map(
"newText", Result.newText);
721 {
"range",
Value.range},
722 {
"newText",
Value.newText},
727 Os <<
Value.range <<
" => \"";
738 if (std::optional<int64_t> IntValue =
Value.getAsInteger()) {
751 size_t KindVal =
static_cast<size_t>(Kind);
753 KindVal <= SupportedCompletionItemKinds.size() &&
754 SupportedCompletionItemKinds[KindVal])
774 for (
size_t I = 0, E = ArrayValue->size();
I < E; ++
I) {
776 if (
fromJSON((*ArrayValue)[
I], KindOut, Path.index(
I)))
777 Result.set(
size_t(KindOut));
789 assert(!
Value.label.empty() &&
"completion item label is required");
792 Result[
"kind"] =
static_cast<int>(
Value.kind);
793 if (!
Value.detail.empty())
794 Result[
"detail"] =
Value.detail;
795 if (
Value.documentation)
796 Result[
"documentation"] =
Value.documentation;
797 if (!
Value.sortText.empty())
798 Result[
"sortText"] =
Value.sortText;
799 if (!
Value.filterText.empty())
800 Result[
"filterText"] =
Value.filterText;
801 if (!
Value.insertText.empty())
802 Result[
"insertText"] =
Value.insertText;
804 Result[
"insertTextFormat"] =
static_cast<int>(
Value.insertTextFormat);
806 Result[
"textEdit"] = *
Value.textEdit;
807 if (!
Value.additionalTextEdits.empty()) {
808 Result[
"additionalTextEdits"] =
811 if (
Value.deprecated)
812 Result[
"deprecated"] =
Value.deprecated;
813 return std::move(Result);
833 {
"isIncomplete",
Value.isIncomplete},
846 if (!O || !O.map(
"triggerKind", TriggerKind) ||
862 return fromJSON(*Context, Result.context, Path.field(
"context"));
872 "parameter information label is required");
874 if (
Value.labelOffsets)
876 {
Value.labelOffsets->first,
Value.labelOffsets->second});
878 Result[
"label"] =
Value.labelString;
879 if (!
Value.documentation.empty())
880 Result[
"documentation"] =
Value.documentation;
881 return std::move(Result);
889 assert(!
Value.label.empty() &&
"signature information label is required");
891 {
"label",
Value.label},
894 if (!
Value.documentation.empty())
895 Result[
"documentation"] =
Value.documentation;
896 return std::move(Result);
910 "Unexpected negative value for number of active signatures.");
912 "Unexpected negative value for active parameter index");
914 {
"activeSignature",
Value.activeSignature},
915 {
"activeParameter",
Value.activeParameter},
927 return O && O.map(
"textDocument", Result.textDocument);
936 {
"range",
Value.range},
937 {
"target",
Value.target},
948 return O && O.map(
"textDocument", Result.textDocument) &&
949 O.map(
"range", Result.range);
958 {
"kind", (int)
Value.kind},
959 {
"label",
Value.label},
960 {
"paddingLeft",
Value.paddingLeft},
961 {
"paddingRight",
Value.paddingRight}};
976 return Os <<
"parameter";
990 if (!O || !O.map(
"diagnostics", Result.diagnostics))
992 O.map(
"only", Result.only);
1003 return O && O.map(
"textDocument", Result.textDocument) &&
1004 O.map(
"range", Result.range) && O.map(
"context", Result.context);
1014 return O && O.map(
"changes", Result.changes);
1019 for (
auto &Change :
Value.changes)
1036 if (
Value.diagnostics)
1038 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.