10 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_PATHURI_H 11 #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_PATHURI_H 13 #include "llvm/ADT/StringRef.h" 14 #include "llvm/Support/Error.h" 15 #include "llvm/Support/Registry.h" 31 URI(llvm::StringRef Scheme, llvm::StringRef Authority, llvm::StringRef Body);
34 llvm::StringRef
scheme()
const {
return Scheme; }
36 llvm::StringRef
authority()
const {
return Authority; }
38 llvm::StringRef
body()
const {
return Body; }
45 static llvm::Expected<URI>
create(llvm::StringRef AbsolutePath,
46 llvm::StringRef Scheme);
53 static llvm::Expected<URI>
parse(llvm::StringRef Uri);
60 static llvm::Expected<std::string>
resolve(
const URI &U,
61 llvm::StringRef HintPath =
"");
74 return std::tie(LHS.Scheme, LHS.Authority, LHS.Body) ==
75 std::tie(RHS.Scheme, RHS.Authority, RHS.Body);
79 return std::tie(LHS.Scheme, LHS.Authority, LHS.Body) <
80 std::tie(RHS.Scheme, RHS.Authority, RHS.Body);
87 std::string Authority;
101 virtual llvm::Expected<std::string>
102 getAbsolutePath(llvm::StringRef Authority, llvm::StringRef Body,
103 llvm::StringRef HintPath)
const = 0;
105 virtual llvm::Expected<URI>
106 uriFromAbsolutePath(llvm::StringRef AbsolutePath)
const = 0;
122 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANGD_PATHURI_H friend bool operator==(const URI &LHS, const URI &RHS)
URIScheme is an extension point for teaching clangd to recognize a custom URI scheme.
virtual llvm::Expected< std::string > getIncludeSpelling(const URI &U) const
Returns the include path of the file (e.g.
llvm::StringRef authority() const
Returns decoded authority e.g. "reviews.lvm.org".
static URI createFile(llvm::StringRef AbsolutePath)
This creates a file:// URI for AbsolutePath. The path must be absolute.
llvm::Registry< URIScheme > URISchemeRegistry
By default, a "file" scheme is supported where URI paths are always absolute in the file system...
llvm::StringRef scheme() const
Returns decoded scheme e.g. "https".
llvm::StringRef body() const
Returns decoded body e.g. "/D41946".
static llvm::Expected< URI > create(llvm::StringRef AbsolutePath, llvm::StringRef Scheme)
Creates a URI for a file in the given scheme.
friend bool operator<(const URI &LHS, const URI &RHS)
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
A URI describes the location of a source file.
static llvm::Expected< std::string > resolve(const URI &U, llvm::StringRef HintPath="")
Resolves the absolute path of U.
static llvm::Expected< std::string > includeSpelling(const URI &U)
Gets the preferred spelling of this file for #include, if there is one, e.g.
static llvm::Expected< URI > parse(llvm::StringRef Uri)
Parse a URI string "<scheme>:[//<authority>/]<path>".
std::string toString() const
Returns a string URI with all components percent-encoded.