Skip to content

Commit 44262a3

Browse files
committed
[IDE] Pass SourceFile in doneParsing callback
This will be necessary to make cursor info completion like to inspect the just parsed source file because the callback from parsing the code completion token won’t be called.
1 parent 54360ad commit 44262a3

File tree

5 files changed

+8
-8
lines changed

5 files changed

+8
-8
lines changed

include/swift/Parse/CodeCompletionCallbacks.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ class CodeCompletionCallbacks {
254254

255255
/// Signals that the AST for the all the delayed-parsed code was
256256
/// constructed. No \c complete*() callbacks will be done after this.
257-
virtual void doneParsing() = 0;
257+
virtual void doneParsing(SourceFile *SrcFile) = 0;
258258
};
259259

260260
/// A factory to create instances of \c CodeCompletionCallbacks.

lib/IDE/CodeCompletion.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ class CodeCompletionCallbacksImpl : public CodeCompletionCallbacks {
287287
void completeTypeAttrBeginning() override;
288288
void completeOptionalBinding() override;
289289

290-
void doneParsing() override;
290+
void doneParsing(SourceFile *SrcFile) override;
291291

292292
private:
293293
void addKeywords(CodeCompletionResultSink &Sink, bool MaybeFuncBody);
@@ -1552,7 +1552,7 @@ static void undoSingleExpressionReturn(DeclContext *DC) {
15521552
}
15531553
}
15541554

1555-
void CodeCompletionCallbacksImpl::doneParsing() {
1555+
void CodeCompletionCallbacksImpl::doneParsing(SourceFile *SrcFile) {
15561556
CompletionContext.CodeCompletionKind = Kind;
15571557

15581558
if (Kind == CompletionKind::None) {

lib/IDE/ConformingMethodList.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class ConformingMethodListCallbacks : public CodeCompletionCallbacks {
4949
void completePostfixExpr(Expr *E, bool hasSpace) override;
5050
// }
5151

52-
void doneParsing() override;
52+
void doneParsing(SourceFile *SrcFile) override;
5353
};
5454

5555
void ConformingMethodListCallbacks::completeDotExpr(CodeCompletionExpr *E,
@@ -64,7 +64,7 @@ void ConformingMethodListCallbacks::completePostfixExpr(Expr *E,
6464
ParsedExpr = E;
6565
}
6666

67-
void ConformingMethodListCallbacks::doneParsing() {
67+
void ConformingMethodListCallbacks::doneParsing(SourceFile *SrcFile) {
6868
if (!ParsedExpr)
6969
return;
7070

lib/IDE/TypeContextInfo.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class ContextInfoCallbacks : public CodeCompletionCallbacks {
4848
void completeUnresolvedMember(CodeCompletionExpr *E,
4949
SourceLoc DotLoc) override;
5050

51-
void doneParsing() override;
51+
void doneParsing(SourceFile *SrcFile) override;
5252
};
5353

5454
void ContextInfoCallbacks::completePostfixExprBeginning(CodeCompletionExpr *E) {
@@ -85,7 +85,7 @@ void ContextInfoCallbacks::completeCaseStmtBeginning(CodeCompletionExpr *E) {
8585
// TODO: Implement?
8686
}
8787

88-
void ContextInfoCallbacks::doneParsing() {
88+
void ContextInfoCallbacks::doneParsing(SourceFile *SrcFile) {
8989
if (!ParsedExpr)
9090
return;
9191

lib/Parse/Parser.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ void Parser::performCodeCompletionSecondPassImpl(
195195
assert(!State->hasCodeCompletionDelayedDeclState() &&
196196
"Second pass should not set any code completion info");
197197

198-
CodeCompletion->doneParsing();
198+
CodeCompletion->doneParsing(DC->getParentSourceFile());
199199

200200
State->restoreCodeCompletionDelayedDeclState(info);
201201
}

0 commit comments

Comments
 (0)