@@ -52,6 +52,18 @@ class CompletionContextFinder : public ASTWalker {
5252 Expr *InitialExpr = nullptr ;
5353 DeclContext *InitialDC;
5454
55+ // / Whether we're looking for any viable fallback expression.
56+ bool ForFallback = false ;
57+
58+ // / Finder for fallback completion contexts within the outermost non-closure
59+ // / context of the code completion expression's direct context.
60+ CompletionContextFinder (DeclContext *completionDC)
61+ : InitialDC(completionDC), ForFallback(true ) {
62+ while (auto *ACE = dyn_cast<AbstractClosureExpr>(InitialDC))
63+ InitialDC = ACE->getParent ();
64+ InitialDC->walkContext (*this );
65+ }
66+
5567public:
5668 MacroWalking getMacroWalkingBehavior () const override {
5769 return MacroWalking::Arguments;
@@ -61,18 +73,16 @@ class CompletionContextFinder : public ASTWalker {
6173 CompletionContextFinder (constraints::SyntacticElementTarget target,
6274 DeclContext *DC);
6375
64- // / Finder for completion contexts within the outermost non-closure context of
65- // / the code completion expression's direct context.
66- CompletionContextFinder (DeclContext *completionDC) : InitialDC(completionDC) {
67- while (auto *ACE = dyn_cast<AbstractClosureExpr>(InitialDC))
68- InitialDC = ACE->getParent ();
69- InitialDC->walkContext (*this );
76+ static CompletionContextFinder forFallback (DeclContext *DC) {
77+ return CompletionContextFinder (DC);
7078 }
7179
7280 PreWalkResult<Expr *> walkToExprPre (Expr *E) override ;
7381
7482 PostWalkResult<Expr *> walkToExprPost (Expr *E) override ;
7583
84+ PreWalkAction walkToDeclPre (Decl *D) override ;
85+
7686 bool locatedInStringInterpolation () const {
7787 return hasContext (ContextKind::StringInterpolation);
7888 }
0 commit comments