clang-tools
9.0.0
|
A URI describes the location of a source file. More...
#include <URI.h>
Public Member Functions | |
URI (llvm::StringRef Scheme, llvm::StringRef Authority, llvm::StringRef Body) | |
llvm::StringRef | scheme () const |
Returns decoded scheme e.g. "https". More... | |
llvm::StringRef | authority () const |
Returns decoded authority e.g. "reviews.lvm.org". More... | |
llvm::StringRef | body () const |
Returns decoded body e.g. "/D41946". More... | |
std::string | toString () const |
Returns a string URI with all components percent-encoded. More... | |
Static Public Member Functions | |
static llvm::Expected< URI > | create (llvm::StringRef AbsolutePath, llvm::StringRef Scheme) |
Creates a URI for a file in the given scheme. More... | |
static URI | create (llvm::StringRef AbsolutePath) |
static URI | createFile (llvm::StringRef AbsolutePath) |
This creates a file:// URI for AbsolutePath . The path must be absolute. More... | |
static llvm::Expected< URI > | parse (llvm::StringRef Uri) |
Parse a URI string "<scheme>:[//<authority>/]<path>". More... | |
static llvm::Expected< std::string > | resolve (const URI &U, llvm::StringRef HintPath="") |
Resolves the absolute path of U . More... | |
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 to get th canonical path. More... | |
static llvm::Expected< std::string > | includeSpelling (const URI &U) |
Gets the preferred spelling of this file for #include, if there is one, e.g. More... | |
Friends | |
bool | operator== (const URI &LHS, const URI &RHS) |
bool | operator< (const URI &LHS, const URI &RHS) |
A URI describes the location of a source file.
In the simplest case, this is a "file" URI that directly encodes the absolute path to a file. More abstract cases are possible: a shared index service might expose repo:// URIs that are relative to the source control root.
Clangd handles URIs of the form <scheme>:[//<authority>]<body>. It doesn't further split the authority or body into constituent parts (e.g. query strings is included in the body).
clang::clangd::URI::URI | ( | llvm::StringRef | Scheme, |
llvm::StringRef | Authority, | ||
llvm::StringRef | Body | ||
) |
|
inline |
|
inline |
Returns decoded body e.g. "/D41946".
Definition at line 37 of file URI.h.
References create(), createFile(), parse(), resolve(), and toString().
|
static |
|
static |
Definition at line 196 of file URI.cpp.
References createFile().
|
static |
This creates a file:// URI for AbsolutePath
. The path must be absolute.
Definition at line 215 of file URI.cpp.
References clang::tidy::cppcoreguidelines::toString().
Referenced by body(), create(), and clang::clangd::URIForFile::uri().
|
static |
Gets the preferred spelling of this file for #include, if there is one, e.g.
<system_header.h>, "path/to/x.h".
This allows URI schemas to provide their customized include paths.
Returns an empty string if normal include-shortening based on the absolute path should be used. Fails if the URI is not valid in the schema.
|
static |
Parse a URI string "<scheme>:[//<authority>/]<path>".
Percent-encoded characters in the URI will be decoded.
Definition at line 164 of file URI.cpp.
Referenced by body(), clang::clangd::URIDistance::distance(), and clang::clangd::dex::generateProximityURIs().
|
static |
Resolves the absolute path of U
.
If there is no matching scheme, or the URI is invalid in the scheme, this returns an error.
HintPath
A related path, such as the current file or working directory, which can help disambiguate when the same file exists in many workspaces.
Definition at line 222 of file URI.cpp.
Referenced by body().
|
static |
Resolves AbsPath
into a canonical path of its URI, by converting AbsPath
to URI and resolving the URI to get th canonical path.
This ensures that paths with the same URI are resolved into consistent file path.
Definition at line 230 of file URI.cpp.
Referenced by clang::clangd::URIForFile::canonicalize().
|
inline |
std::string clang::clangd::URI::toString | ( | ) | const |