Skip to content

Commit d6eec88

Browse files
benlangmuirrintaro
authored andcommitted
[completion] Update CodeCompletionConsumer::handleResults()
Receive 'CodeCompletionContext' so that consumers can get more information from it.
1 parent c8e2dc1 commit d6eec88

File tree

4 files changed

+14
-6
lines changed

4 files changed

+14
-6
lines changed

include/swift/IDE/CodeCompletion.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -995,8 +995,7 @@ struct SimpleCachingCodeCompletionConsumer : public CodeCompletionConsumer {
995995
DeclContext *DCForModules) override;
996996

997997
/// Clients should override this method to receive \p Results.
998-
virtual void handleResults(
999-
MutableArrayRef<CodeCompletionResult *> Results) = 0;
998+
virtual void handleResults(CodeCompletionContext &context) = 0;
1000999
};
10011000

10021001
/// A code completion result consumer that prints the results to a
@@ -1018,7 +1017,8 @@ class PrintingCodeCompletionConsumer
10181017
IncludeComments(IncludeComments),
10191018
PrintAnnotatedDescription(PrintAnnotatedDescription) {}
10201019

1021-
void handleResults(MutableArrayRef<CodeCompletionResult *> Results) override;
1020+
void handleResults(CodeCompletionContext &context) override;
1021+
void handleResults(MutableArrayRef<CodeCompletionResult *> Results);
10221022
};
10231023

10241024
/// Create a factory for code completion callbacks.

lib/IDE/CodeCompletion.cpp

+7-1
Original file line numberDiff line numberDiff line change
@@ -7376,6 +7376,12 @@ void CodeCompletionCallbacksImpl::doneParsing() {
73767376
deliverCompletionResults(CompletionContext, Lookup, CurDeclContext, Consumer);
73777377
}
73787378

7379+
void PrintingCodeCompletionConsumer::handleResults(
7380+
CodeCompletionContext &context) {
7381+
auto results = context.takeResults();
7382+
handleResults(results);
7383+
}
7384+
73797385
void PrintingCodeCompletionConsumer::handleResults(
73807386
MutableArrayRef<CodeCompletionResult *> Results) {
73817387
unsigned NumResults = 0;
@@ -7545,7 +7551,7 @@ void SimpleCachingCodeCompletionConsumer::handleResultsAndModules(
75457551
&context.getResultSink());
75467552
}
75477553

7548-
handleResults(context.takeResults());
7554+
handleResults(context);
75497555
}
75507556

75517557
//===----------------------------------------------------------------------===//

lib/IDE/REPLCodeCompletion.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,8 @@ class REPLCodeCompletionConsumer : public SimpleCachingCodeCompletionConsumer {
165165
REPLCodeCompletionConsumer(REPLCompletions &Completions)
166166
: Completions(Completions) {}
167167

168-
void handleResults(MutableArrayRef<CodeCompletionResult *> Results) override {
168+
void handleResults(CodeCompletionContext &context) override {
169+
MutableArrayRef<CodeCompletionResult *> Results = context.takeResults();
169170
CodeCompletionContext::sortCompletionResults(Results);
170171
for (auto Result : Results) {
171172
std::string InsertableString = toInsertableString(Result);

tools/SourceKit/lib/SwiftLang/SwiftCompletion.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,8 @@ struct SwiftCodeCompletionConsumer
9797
}
9898
void clearContext() { swiftContext = SwiftCompletionInfo(); }
9999

100-
void handleResults(MutableArrayRef<CodeCompletionResult *> Results) override {
100+
void handleResults(CodeCompletionContext &context) override {
101+
MutableArrayRef<CodeCompletionResult *> Results = context.takeResults();
101102
assert(swiftContext.swiftASTContext);
102103
handleResultsImpl(Results, swiftContext);
103104
}

0 commit comments

Comments
 (0)