@@ -25,22 +25,6 @@ class SyntacticElementTarget;
25
25
}
26
26
27
27
class CompletionContextFinder : public ASTWalker {
28
- enum class ContextKind {
29
- FallbackExpression,
30
- StringInterpolation,
31
- SingleStmtClosure,
32
- MultiStmtClosure,
33
- ErrorExpression
34
- };
35
-
36
- struct Context {
37
- ContextKind Kind;
38
- Expr *E;
39
- };
40
-
41
- // / Stack of all "interesting" contexts up to code completion expression.
42
- llvm::SmallVector<Context, 4 > Contexts;
43
-
44
28
// / If we are completing inside an expression, the \c CodeCompletionExpr that
45
29
// / represents the code completion token.
46
30
@@ -49,44 +33,18 @@ class CompletionContextFinder : public ASTWalker {
49
33
// / component.
50
34
llvm::PointerUnion<CodeCompletionExpr *, const KeyPathExpr *> CompletionNode;
51
35
52
- Expr *InitialExpr = nullptr ;
53
- DeclContext *InitialDC;
54
-
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
-
67
36
public:
68
37
MacroWalking getMacroWalkingBehavior () const override {
69
38
return MacroWalking::Arguments;
70
39
}
71
40
72
41
// / Finder for completion contexts within the provided SyntacticElementTarget.
73
- CompletionContextFinder (constraints::SyntacticElementTarget target,
74
- DeclContext *DC);
75
-
76
- static CompletionContextFinder forFallback (DeclContext *DC) {
77
- return CompletionContextFinder (DC);
78
- }
42
+ CompletionContextFinder (constraints::SyntacticElementTarget target);
79
43
80
44
PreWalkResult<Expr *> walkToExprPre (Expr *E) override ;
81
45
82
- PostWalkResult<Expr *> walkToExprPost (Expr *E) override ;
83
-
84
46
PreWalkAction walkToDeclPre (Decl *D) override ;
85
47
86
- bool locatedInStringInterpolation () const {
87
- return hasContext (ContextKind::StringInterpolation);
88
- }
89
-
90
48
bool hasCompletionExpr () const {
91
49
return CompletionNode.dyn_cast <CodeCompletionExpr *>() != nullptr ;
92
50
}
@@ -114,28 +72,8 @@ class CompletionContextFinder : public ASTWalker {
114
72
// / If we are completing in a key path, returns the index at which the key
115
73
// / path has the code completion component.
116
74
size_t getKeyPathCompletionComponentIndex () const ;
117
-
118
- struct Fallback {
119
- Expr *E; // /< The fallback expression.
120
- DeclContext *DC; // /< The fallback expression's decl context.
121
- bool SeparatePrecheck; // /< True if the fallback may require prechecking.
122
- };
123
-
124
- // / As a fallback sometimes its useful to not only type-check
125
- // / code completion expression directly but instead add some
126
- // / of the enclosing context e.g. when completion is an argument
127
- // / to a call.
128
- std::optional<Fallback> getFallbackCompletionExpr () const ;
129
-
130
- private:
131
- bool hasContext (ContextKind kind) const {
132
- return llvm::find_if (Contexts, [&kind](const Context &currContext) {
133
- return currContext.Kind == kind;
134
- }) != Contexts.end ();
135
- }
136
75
};
137
76
138
-
139
77
// / Returns \c true if \p range is valid and contains the IDE inspection
140
78
// / target. This performs the underlying check based on \c CharSourceRange
141
79
// / to make sure we correctly return \c true if the ide inspection target
0 commit comments