Go to the documentation of this file.
9 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_PATHURI_H
10 #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_PATHURI_H
12 #include "llvm/ADT/StringRef.h"
13 #include "llvm/Support/Error.h"
14 #include "llvm/Support/Registry.h"
30 URI(llvm::StringRef Scheme, llvm::StringRef Authority, llvm::StringRef Body);
33 llvm::StringRef
scheme()
const {
return Scheme; }
35 llvm::StringRef
authority()
const {
return Authority; }
37 llvm::StringRef
body()
const {
return Body; }
44 static llvm::Expected<URI>
create(llvm::StringRef AbsolutePath,
45 llvm::StringRef Scheme);
49 static URI create(llvm::StringRef AbsolutePath);
56 static llvm::Expected<URI>
parse(llvm::StringRef Uri);
63 static llvm::Expected<std::string>
resolve(
const URI &U,
64 llvm::StringRef HintPath =
"");
67 static llvm::Expected<std::string>
resolve(llvm::StringRef FileURI,
68 llvm::StringRef HintPath =
"");
74 static llvm::Expected<std::string>
resolvePath(llvm::StringRef AbsPath,
75 llvm::StringRef HintPath =
"");
88 return std::tie(LHS.Scheme, LHS.Authority, LHS.Body) ==
89 std::tie(RHS.Scheme, RHS.Authority, RHS.Body);
93 return std::tie(LHS.Scheme, LHS.Authority, LHS.Body) <
94 std::tie(RHS.Scheme, RHS.Authority, RHS.Body);
101 std::string Authority;
115 virtual llvm::Expected<std::string>
117 llvm::StringRef HintPath)
const = 0;
119 virtual llvm::Expected<URI>
136 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANGD_PATHURI_H
virtual ~URIScheme()=default
llvm::StringRef body() const
Returns decoded body e.g. "/D41946".
friend bool operator<(const URI &LHS, const URI &RHS)
static llvm::Expected< URI > create(llvm::StringRef AbsolutePath, llvm::StringRef Scheme)
Creates a URI for a file in the given scheme.
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...
URIScheme is an extension point for teaching clangd to recognize a custom URI scheme.
llvm::Registry< URIScheme > URISchemeRegistry
By default, a "file" scheme is supported where URI paths are always absolute in the file system.
static llvm::Expected< URI > parse(llvm::StringRef Uri)
Parse a URI string "<scheme>:[//<authority>/]<path>".
virtual llvm::Expected< std::string > getIncludeSpelling(const URI &U) const
Returns the include path of the file (e.g.
static llvm::Expected< std::string > resolve(const URI &U, llvm::StringRef HintPath="")
Resolves the absolute path of U.
virtual llvm::Expected< URI > uriFromAbsolutePath(llvm::StringRef AbsolutePath) const =0
static llvm::Expected< std::string > includeSpelling(const URI &U)
Gets the preferred spelling of this file for #include, if there is one, e.g.
friend bool operator==(const URI &LHS, const URI &RHS)
virtual llvm::Expected< std::string > getAbsolutePath(llvm::StringRef Authority, llvm::StringRef Body, llvm::StringRef HintPath) const =0
Returns the absolute path of the file corresponding to the URI authority+body in the file system.
std::string toString() const
Returns a string URI with all components percent-encoded.
llvm::StringRef authority() const
Returns decoded authority e.g. "reviews.lvm.org".
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
llvm::StringRef scheme() const
Returns decoded scheme e.g. "https".
static URI createFile(llvm::StringRef AbsolutePath)
This creates a file:// URI for AbsolutePath. The path must be absolute.
A URI describes the location of a source file.