summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clangd/SourceCode.h
diff options
context:
space:
mode:
authorKadir Cetinkaya <kadircet@google.com>2019-09-25 11:35:38 +0200
committerKadir Cetinkaya <kadircet@google.com>2019-10-25 12:13:30 +0200
commitd62e3ed3f4b9e1c7492194d0c9997147bdfe6aa6 (patch)
tree7de97e41a61541e38b43ed5aef25b8b1252686fb /clang-tools-extra/clangd/SourceCode.h
parentd581f68519da8810b6817ec095e2a415b203feba (diff)
downloadbcm5719-llvm-d62e3ed3f4b9e1c7492194d0c9997147bdfe6aa6.tar.gz
bcm5719-llvm-d62e3ed3f4b9e1c7492194d0c9997147bdfe6aa6.zip
[clangd] Implement GetEligiblePoints
Summary: This is an helper for incoming move definition out-of-line action to figure out possible insertion locations for definition of a qualified name. Reviewers: hokein, ilya-biryukov Subscribers: MaskRay, jkorous, arphaman, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D68024
Diffstat (limited to 'clang-tools-extra/clangd/SourceCode.h')
-rw-r--r--clang-tools-extra/clangd/SourceCode.h21
1 files changed, 21 insertions, 0 deletions
diff --git a/clang-tools-extra/clangd/SourceCode.h b/clang-tools-extra/clangd/SourceCode.h
index 3017746c17e..a05d8adf923 100644
--- a/clang-tools-extra/clangd/SourceCode.h
+++ b/clang-tools-extra/clangd/SourceCode.h
@@ -262,6 +262,27 @@ llvm::StringSet<> collectWords(llvm::StringRef Content);
std::vector<std::string> visibleNamespaces(llvm::StringRef Code,
const format::FormatStyle &Style);
+/// Represents locations that can accept a definition.
+struct EligibleRegion {
+ /// Namespace that owns all of the EligiblePoints, e.g.
+ /// namespace a{ namespace b {^ void foo();^} }
+ /// It will be “a::b” for both carrot locations.
+ std::string EnclosingNamespace;
+ /// Offsets into the code marking eligible points to insert a function
+ /// definition.
+ std::vector<Position> EligiblePoints;
+};
+
+/// Returns most eligible region to insert a definition for \p
+/// FullyQualifiedName in the \p Code.
+/// Pseudo parses \pCode under the hood to determine namespace decls and
+/// possible insertion points. Choses the region that matches the longest prefix
+/// of \p FullyQualifiedName. Returns EOF if there are no shared namespaces.
+/// \p FullyQualifiedName should not contain anonymous namespaces.
+EligibleRegion getEligiblePoints(llvm::StringRef Code,
+ llvm::StringRef FullyQualifiedName,
+ const format::FormatStyle &Style);
+
struct DefinedMacro {
llvm::StringRef Name;
const MacroInfo *Info;
OpenPOWER on IntegriCloud