summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clangd/Protocol.h
diff options
context:
space:
mode:
Diffstat (limited to 'clang-tools-extra/clangd/Protocol.h')
-rw-r--r--clang-tools-extra/clangd/Protocol.h20
1 files changed, 19 insertions, 1 deletions
diff --git a/clang-tools-extra/clangd/Protocol.h b/clang-tools-extra/clangd/Protocol.h
index 692f206edfa..76dcf52a87e 100644
--- a/clang-tools-extra/clangd/Protocol.h
+++ b/clang-tools-extra/clangd/Protocol.h
@@ -67,9 +67,25 @@ public:
}
};
+// URI in "file" scheme for a file.
struct URIForFile {
URIForFile() = default;
- explicit URIForFile(std::string AbsPath);
+
+ /// Canonicalizes \p AbsPath via URI.
+ ///
+ /// File paths in URIForFile can come from index or local AST. Path from
+ /// index goes through URI transformation, and the final path is resolved by
+ /// URI scheme and could potentially be different from the original path.
+ /// Hence, we do the same transformation for all paths.
+ ///
+ /// Files can be referred to by several paths (e.g. in the presence of links).
+ /// Which one we prefer may depend on where we're coming from. \p TUPath is a
+ /// hint, and should usually be the main entrypoint file we're processing.
+ static URIForFile canonicalize(llvm::StringRef AbsPath,
+ llvm::StringRef TUPath);
+
+ static llvm::Expected<URIForFile> fromURI(const URI &U,
+ llvm::StringRef HintPath);
/// Retrieves absolute path to the file.
llvm::StringRef file() const { return File; }
@@ -90,6 +106,8 @@ struct URIForFile {
}
private:
+ explicit URIForFile(std::string &&File) : File(std::move(File)) {}
+
std::string File;
};
OpenPOWER on IntegriCloud