diff options
author | Marc-Andre Laperle <marc-andre.laperle@ericsson.com> | 2018-06-05 14:01:40 +0000 |
---|---|---|
committer | Marc-Andre Laperle <marc-andre.laperle@ericsson.com> | 2018-06-05 14:01:40 +0000 |
commit | 945b5a3df03b0b941b99a1003ef168dca5d82c4c (patch) | |
tree | e645a4b8d7c62c2dff3d7ee2d429c870000cd7c6 /clang-tools-extra/clangd/CodeComplete.cpp | |
parent | 1181f94ae43d3f257bf2d7ca3c2178cb8b305b37 (diff) | |
download | bcm5719-llvm-945b5a3df03b0b941b99a1003ef168dca5d82c4c.tar.gz bcm5719-llvm-945b5a3df03b0b941b99a1003ef168dca5d82c4c.zip |
[clangd] Add "member" symbols to the index
Summary:
This adds more symbols to the index:
- member variables and functions
- enum constants in scoped enums
The code completion behavior should remain intact but workspace symbols should
now provide much more useful symbols.
Other symbols should be considered such as the ones in "main files" (files not
being included) but this can be done separately as this introduces its fair
share of problems.
Signed-off-by: Marc-Andre Laperle <marc-andre.laperle@ericsson.com>
Reviewers: ioeric, sammccall
Reviewed By: ioeric, sammccall
Subscribers: hokein, sammccall, jkorous, klimek, ilya-biryukov, jkorous-apple, ioeric, MaskRay, cfe-commits
Differential Revision: https://reviews.llvm.org/D44954
llvm-svn: 334017
Diffstat (limited to 'clang-tools-extra/clangd/CodeComplete.cpp')
-rw-r--r-- | clang-tools-extra/clangd/CodeComplete.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/clang-tools-extra/clangd/CodeComplete.cpp b/clang-tools-extra/clangd/CodeComplete.cpp index 40d9058040f..7de69e344f7 100644 --- a/clang-tools-extra/clangd/CodeComplete.cpp +++ b/clang-tools-extra/clangd/CodeComplete.cpp @@ -25,6 +25,7 @@ #include "Trace.h" #include "URI.h" #include "index/Index.h" +#include "clang/ASTMatchers/ASTMatchFinder.h" #include "clang/Basic/LangOptions.h" #include "clang/Format/Format.h" #include "clang/Frontend/CompilerInstance.h" @@ -949,6 +950,7 @@ private: if (Opts.Limit) Req.MaxCandidateCount = Opts.Limit; Req.Query = Filter->pattern(); + Req.RestrictForCodeCompletion = true; Req.Scopes = getQueryScopes(Recorder->CCContext, Recorder->CCSema->getSourceManager()); log(llvm::formatv("Code complete: fuzzyFind(\"{0}\", scopes=[{1}])", @@ -1089,5 +1091,16 @@ SignatureHelp signatureHelp(PathRef FileName, return Result; } +bool isIndexedForCodeCompletion(const NamedDecl &ND, ASTContext &ASTCtx) { + using namespace clang::ast_matchers; + auto InTopLevelScope = hasDeclContext( + anyOf(namespaceDecl(), translationUnitDecl(), linkageSpecDecl())); + return !match(decl(anyOf(InTopLevelScope, + hasDeclContext( + enumDecl(InTopLevelScope, unless(isScoped()))))), + ND, ASTCtx) + .empty(); +} + } // namespace clangd } // namespace clang |