Skip to content

Commit 317ec1f

Browse files
committed
[IDE] Give default implementation for completion callbacks
1 parent d631b3b commit 317ec1f

File tree

3 files changed

+32
-112
lines changed

3 files changed

+32
-112
lines changed

include/swift/Parse/CodeCompletionCallbacks.h

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -117,114 +117,114 @@ class CodeCompletionCallbacks {
117117

118118
/// Complete the whole expression. This is a fallback that should
119119
/// produce results when more specific completion methods failed.
120-
virtual void completeExpr() = 0;
120+
virtual void completeExpr() {};
121121

122122
/// Complete expr-dot after we have consumed the dot.
123-
virtual void completeDotExpr(Expr *E, SourceLoc DotLoc) = 0;
123+
virtual void completeDotExpr(Expr *E, SourceLoc DotLoc) {};
124124

125125
/// Complete the beginning of a statement or expression.
126-
virtual void completeStmtOrExpr() = 0;
126+
virtual void completeStmtOrExpr() {};
127127

128128
/// Complete the beginning of expr-postfix -- no tokens provided
129129
/// by user.
130-
virtual void completePostfixExprBeginning(CodeCompletionExpr *E) = 0;
130+
virtual void completePostfixExprBeginning(CodeCompletionExpr *E) {};
131131

132132
/// Complete the beginning of expr-postfix in a for-each loop sequqence
133133
/// -- no tokens provided by user.
134-
virtual void completeForEachSequenceBeginning(CodeCompletionExpr *E) = 0;
134+
virtual void completeForEachSequenceBeginning(CodeCompletionExpr *E) {};
135135

136136
/// Complete a given expr-postfix.
137-
virtual void completePostfixExpr(Expr *E, bool hasSpace) = 0;
137+
virtual void completePostfixExpr(Expr *E, bool hasSpace) {};
138138

139139
/// Complete a given expr-postfix, given that there is a following
140140
/// left parenthesis.
141-
virtual void completePostfixExprParen(Expr *E, Expr *CodeCompletionE) = 0;
141+
virtual void completePostfixExprParen(Expr *E, Expr *CodeCompletionE) {};
142142

143143
/// Complete expr-super after we have consumed the 'super' keyword.
144-
virtual void completeExprSuper(SuperRefExpr *SRE) = 0;
144+
virtual void completeExprSuper(SuperRefExpr *SRE) {};
145145

146146
/// Complete expr-super after we have consumed the 'super' keyword and
147147
/// a dot.
148-
virtual void completeExprSuperDot(SuperRefExpr *SRE) = 0;
148+
virtual void completeExprSuperDot(SuperRefExpr *SRE) {};
149149

150150
/// Complete the argument to an Objective-C #keyPath
151151
/// expression.
152152
///
153153
/// \param KPE A partial #keyPath expression that can be used to
154154
/// provide context. This will be \c NULL if no components of the
155155
/// #keyPath argument have been parsed yet.
156-
virtual void completeExprKeyPath(KeyPathExpr *KPE, SourceLoc DotLoc) = 0;
156+
virtual void completeExprKeyPath(KeyPathExpr *KPE, SourceLoc DotLoc) {};
157157

158158
/// Complete the beginning of type-simple -- no tokens provided
159159
/// by user.
160-
virtual void completeTypeSimpleBeginning() = 0;
160+
virtual void completeTypeSimpleBeginning() {};
161161

162162
/// Complete a given type-identifier after we have consumed the dot.
163-
virtual void completeTypeIdentifierWithDot(IdentTypeRepr *ITR) = 0;
163+
virtual void completeTypeIdentifierWithDot(IdentTypeRepr *ITR) {};
164164

165165
/// Complete a given type-identifier when there is no trailing dot.
166-
virtual void completeTypeIdentifierWithoutDot(IdentTypeRepr *ITR) = 0;
166+
virtual void completeTypeIdentifierWithoutDot(IdentTypeRepr *ITR) {};
167167

168168
/// Complete at the beginning of a case stmt pattern.
169-
virtual void completeCaseStmtBeginning() = 0;
169+
virtual void completeCaseStmtBeginning() {};
170170

171171
/// Complete a case stmt pattern that starts with a dot.
172-
virtual void completeCaseStmtDotPrefix() = 0;
172+
virtual void completeCaseStmtDotPrefix() {};
173173

174174
/// Complete at the beginning of member of a nominal decl member -- no tokens
175175
/// provided by user.
176176
virtual void completeNominalMemberBeginning(
177-
SmallVectorImpl<StringRef> &Keywords) = 0;
177+
SmallVectorImpl<StringRef> &Keywords) {};
178178

179179
/// Complete at the beginning of accessor in a accessor block.
180-
virtual void completeAccessorBeginning() = 0;
180+
virtual void completeAccessorBeginning() {};
181181

182182
/// Complete the keyword in attribute, for instance, @available.
183-
virtual void completeDeclAttrKeyword(Decl *D, bool Sil, bool Param) = 0;
183+
virtual void completeDeclAttrKeyword(Decl *D, bool Sil, bool Param) {};
184184

185185
/// Complete the parameters in attribute, for instance, version specifier for
186186
/// @available.
187-
virtual void completeDeclAttrParam(DeclAttrKind DK, int Index) = 0;
187+
virtual void completeDeclAttrParam(DeclAttrKind DK, int Index) {};
188188

189189
/// Complete within a precedence group decl or after a colon in an
190190
/// operator decl.
191-
virtual void completeInPrecedenceGroup(SyntaxKind SK) = 0;
191+
virtual void completeInPrecedenceGroup(SyntaxKind SK) {};
192192

193193
/// Complete the platform names inside #available statements.
194-
virtual void completePoundAvailablePlatform() = 0;
194+
virtual void completePoundAvailablePlatform() {};
195195

196196
/// Complete the import decl with importable modules.
197197
virtual void
198-
completeImportDecl(std::vector<std::pair<Identifier, SourceLoc>> &Path) = 0;
198+
completeImportDecl(std::vector<std::pair<Identifier, SourceLoc>> &Path) {};
199199

200200
/// Complete unresolved members after dot.
201201
virtual void completeUnresolvedMember(CodeCompletionExpr *E,
202-
SourceLoc DotLoc) = 0;
202+
SourceLoc DotLoc) {};
203203

204-
virtual void completeAssignmentRHS(AssignExpr *E) = 0;
204+
virtual void completeAssignmentRHS(AssignExpr *E) {};
205205

206-
virtual void completeCallArg(CodeCompletionExpr *E) = 0;
206+
virtual void completeCallArg(CodeCompletionExpr *E) {};
207207

208-
virtual void completeReturnStmt(CodeCompletionExpr *E) = 0;
208+
virtual void completeReturnStmt(CodeCompletionExpr *E) {};
209209

210210
/// Complete a yield statement. A missing yield index means that the
211211
/// completion immediately follows the 'yield' keyword; it may be either
212212
/// an expresion or a parenthesized expression list. A present yield
213213
/// index means that the completion is within the parentheses and is
214214
/// for a specific yield value.
215215
virtual void completeYieldStmt(CodeCompletionExpr *E,
216-
Optional<unsigned> yieldIndex) = 0;
216+
Optional<unsigned> yieldIndex) {};
217217

218218
virtual void completeAfterPoundExpr(CodeCompletionExpr *E,
219-
Optional<StmtKind> ParentKind) = 0;
219+
Optional<StmtKind> ParentKind) {};
220220

221-
virtual void completeAfterPoundDirective() = 0;
221+
virtual void completeAfterPoundDirective() {};
222222

223-
virtual void completePlatformCondition() = 0;
223+
virtual void completePlatformCondition() {};
224224

225-
virtual void completeAfterIfStmt(bool hasElse) = 0;
225+
virtual void completeAfterIfStmt(bool hasElse) {};
226226

227-
virtual void completeGenericParams(TypeLoc TL) = 0;
227+
virtual void completeGenericParams(TypeLoc TL) {};
228228

229229
/// Signals that the AST for the all the delayed-parsed code was
230230
/// constructed. No \c complete*() callbacks will be done after this.

lib/IDE/ConformingMethodList.cpp

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -50,49 +50,6 @@ class ConformingMethodListCallbacks : public CodeCompletionCallbacks {
5050
void completePostfixExpr(Expr *E, bool hasSpace) override;
5151
// }
5252

53-
// Ignore other callbacks.
54-
// {
55-
void completeExpr() override{};
56-
void completeExprSuper(SuperRefExpr *SRE) override{};
57-
void completeExprSuperDot(SuperRefExpr *SRE) override{};
58-
void completeInPrecedenceGroup(SyntaxKind SK) override{};
59-
void completePoundAvailablePlatform() override{};
60-
void completeExprKeyPath(KeyPathExpr *KPE, SourceLoc DotLoc) override {}
61-
void completeTypeSimpleBeginning() override {}
62-
void completeTypeIdentifierWithDot(IdentTypeRepr *ITR) override {}
63-
void completeTypeIdentifierWithoutDot(IdentTypeRepr *ITR) override {}
64-
void completeDeclAttrKeyword(Decl *D, bool Sil, bool Param) override {}
65-
void completeDeclAttrParam(DeclAttrKind DK, int Index) override {}
66-
void completeNominalMemberBeginning(
67-
SmallVectorImpl<StringRef> &Keywords) override {}
68-
void completeImportDecl(
69-
std::vector<std::pair<Identifier, SourceLoc>> &Path) override {}
70-
void completeAfterPoundExpr(CodeCompletionExpr *E,
71-
Optional<StmtKind> ParentKind) override {}
72-
void completeAfterPoundDirective() override {}
73-
void completePlatformCondition() override {}
74-
void completeGenericParams(TypeLoc TL) override {}
75-
void completeAfterIfStmt(bool hasElse) override {}
76-
void completeAccessorBeginning() override{};
77-
78-
void completeStmtOrExpr() override{};
79-
void completePostfixExprBeginning(CodeCompletionExpr *E) override {}
80-
void completeForEachSequenceBeginning(CodeCompletionExpr *E) override{};
81-
void completeCaseStmtBeginning() override{};
82-
83-
void completeAssignmentRHS(AssignExpr *E) override{};
84-
void completeCallArg(CodeCompletionExpr *E) override{};
85-
void completeReturnStmt(CodeCompletionExpr *E) override{};
86-
void completeYieldStmt(CodeCompletionExpr *E,
87-
Optional<unsigned> yieldIndex) override{};
88-
89-
void completeUnresolvedMember(CodeCompletionExpr *E,
90-
SourceLoc DotLoc) override{};
91-
void completeCaseStmtDotPrefix() override{};
92-
93-
void completePostfixExprParen(Expr *E, Expr *CodeCompletionE) override{};
94-
// }
95-
9653
void doneParsing() override;
9754
};
9855

lib/IDE/TypeContextInfo.cpp

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -35,45 +35,10 @@ class ContextInfoCallbacks : public CodeCompletionCallbacks {
3535
ContextInfoCallbacks(Parser &P, TypeContextInfoConsumer &Consumer)
3636
: CodeCompletionCallbacks(P), Consumer(Consumer) {}
3737

38-
void completeExpr() override{};
39-
40-
// Ignore callbacks for suffix completions
41-
// {
42-
void completeDotExpr(Expr *E, SourceLoc DotLoc) override {};
43-
void completePostfixExpr(Expr *E, bool hasSpace) override {};
44-
void completeExprSuper(SuperRefExpr *SRE) override {};
45-
void completeExprSuperDot(SuperRefExpr *SRE) override {};
46-
// }
47-
48-
// Ignore non-expression callbacks.
49-
// {
50-
void completeInPrecedenceGroup(SyntaxKind SK) override {};
51-
void completePoundAvailablePlatform() override {};
52-
void completeExprKeyPath(KeyPathExpr *KPE, SourceLoc DotLoc) override {}
53-
void completeTypeSimpleBeginning() override {}
54-
void completeTypeIdentifierWithDot(IdentTypeRepr *ITR) override {}
55-
void completeTypeIdentifierWithoutDot(IdentTypeRepr *ITR) override {}
56-
void completeDeclAttrKeyword(Decl *D, bool Sil, bool Param) override {}
57-
void completeDeclAttrParam(DeclAttrKind DK, int Index) override {}
58-
void completeNominalMemberBeginning(
59-
SmallVectorImpl<StringRef> &Keywords) override {}
60-
void completeImportDecl(
61-
std::vector<std::pair<Identifier, SourceLoc>> &Path) override {}
62-
void completeAfterPoundExpr(CodeCompletionExpr *E,
63-
Optional<StmtKind> ParentKind) override {}
64-
void completeAfterPoundDirective() override {}
65-
void completePlatformCondition() override {}
66-
void completeGenericParams(TypeLoc TL) override {}
67-
void completeAfterIfStmt(bool hasElse) override {}
68-
void completeAccessorBeginning() override {};
69-
// }
70-
71-
void completeStmtOrExpr() override {};
7238
void completePostfixExprBeginning(CodeCompletionExpr *E) override;
7339
void completeForEachSequenceBeginning(CodeCompletionExpr *E) override;
7440
void completeCaseStmtBeginning() override;
7541

76-
void completeAssignmentRHS(AssignExpr *E) override {};
7742
void completeCallArg(CodeCompletionExpr *E) override;
7843
void completeReturnStmt(CodeCompletionExpr *E) override;
7944
void completeYieldStmt(CodeCompletionExpr *E,
@@ -83,8 +48,6 @@ class ContextInfoCallbacks : public CodeCompletionCallbacks {
8348
SourceLoc DotLoc) override;
8449
void completeCaseStmtDotPrefix() override;
8550

86-
void completePostfixExprParen(Expr *E, Expr *CodeCompletionE) override{};
87-
8851
void doneParsing() override;
8952
};
9053

0 commit comments

Comments
 (0)