diff options
author | Haojian Wu <hokein@google.com> | 2018-01-17 14:29:25 +0000 |
---|---|---|
committer | Haojian Wu <hokein@google.com> | 2018-01-17 14:29:25 +0000 |
commit | 10d95c53af3d30cd362ab798c51cdaaaac325c89 (patch) | |
tree | e376e5d85c2edd7578fcd2ab15318f0ee69002b2 /clang/lib/Sema/SemaCodeComplete.cpp | |
parent | 178deccb63c30a0919064922fcec597fbe1039cd (diff) | |
download | bcm5719-llvm-10d95c53af3d30cd362ab798c51cdaaaac325c89.tar.gz bcm5719-llvm-10d95c53af3d30cd362ab798c51cdaaaac325c89.zip |
[Sema] Add visited contexts to CodeCompleteContext
Summary:
This would allow code completion clients to know which context is visited during Sema code completion.
Also some changes:
* add `EnteredContext` callback in VisibleDeclConsumer.
* add a simple unittest for sema code completion (only for visited contexts at the moment).
Reviewers: ilya-biryukov
Reviewed By: ilya-biryukov
Subscribers: mgorny, bkramer, cfe-commits
Differential Revision: https://reviews.llvm.org/D42071
llvm-svn: 322661
Diffstat (limited to 'clang/lib/Sema/SemaCodeComplete.cpp')
-rw-r--r-- | clang/lib/Sema/SemaCodeComplete.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaCodeComplete.cpp b/clang/lib/Sema/SemaCodeComplete.cpp index f7adaf4dcd0..ac318a65fce 100644 --- a/clang/lib/Sema/SemaCodeComplete.cpp +++ b/clang/lib/Sema/SemaCodeComplete.cpp @@ -318,6 +318,11 @@ namespace { /// \brief Ignore this declaration, if it is seen again. void Ignore(const Decl *D) { AllDeclsFound.insert(D->getCanonicalDecl()); } + /// \brief Add a visited context. + void addVisitedContext(DeclContext *Ctx) { + CompletionContext.addVisitedContext(Ctx); + } + /// \name Name lookup predicates /// /// These predicates can be passed to the name lookup functions to filter the @@ -1280,7 +1285,7 @@ namespace { class CodeCompletionDeclConsumer : public VisibleDeclConsumer { ResultBuilder &Results; DeclContext *CurContext; - + public: CodeCompletionDeclConsumer(ResultBuilder &Results, DeclContext *CurContext) : Results(Results), CurContext(CurContext) { } @@ -1295,6 +1300,10 @@ namespace { false, Accessible); Results.AddResult(Result, CurContext, Hiding, InBaseClass); } + + void EnteredContext(DeclContext* Ctx) override { + Results.addVisitedContext(Ctx); + } }; } |