Skip to content

Commit 76f2dbe

Browse files
committed
[swift-ide-test] Use dedicated method for code completion on CompletionInstance instead of generic performOperation
1 parent 974829e commit 76f2dbe

File tree

3 files changed

+123
-207
lines changed

3 files changed

+123
-207
lines changed

include/swift/IDE/CodeCompletion.h

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1094,32 +1094,6 @@ struct SimpleCachingCodeCompletionConsumer : public CodeCompletionConsumer {
10941094
virtual void handleResults(CodeCompletionContext &context) = 0;
10951095
};
10961096

1097-
/// A code completion result consumer that prints the results to a
1098-
/// \c raw_ostream.
1099-
class PrintingCodeCompletionConsumer
1100-
: public SimpleCachingCodeCompletionConsumer {
1101-
llvm::raw_ostream &OS;
1102-
bool IncludeKeywords;
1103-
bool IncludeComments;
1104-
bool IncludeSourceText;
1105-
bool PrintAnnotatedDescription;
1106-
1107-
public:
1108-
PrintingCodeCompletionConsumer(llvm::raw_ostream &OS,
1109-
bool IncludeKeywords = true,
1110-
bool IncludeComments = true,
1111-
bool IncludeSourceText = false,
1112-
bool PrintAnnotatedDescription = false)
1113-
: OS(OS),
1114-
IncludeKeywords(IncludeKeywords),
1115-
IncludeComments(IncludeComments),
1116-
IncludeSourceText(IncludeSourceText),
1117-
PrintAnnotatedDescription(PrintAnnotatedDescription) {}
1118-
1119-
void handleResults(CodeCompletionContext &context) override;
1120-
void handleResults(MutableArrayRef<CodeCompletionResult *> Results);
1121-
};
1122-
11231097
/// Create a factory for code completion callbacks.
11241098
CodeCompletionCallbacksFactory *
11251099
makeCodeCompletionCallbacksFactory(CodeCompletionContext &CompletionContext,

lib/IDE/CodeCompletion.cpp

Lines changed: 0 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -7406,81 +7406,6 @@ void CodeCompletionCallbacksImpl::doneParsing() {
74067406
deliverCompletionResults(CompletionContext, Lookup, CurDeclContext, Consumer);
74077407
}
74087408

7409-
void PrintingCodeCompletionConsumer::handleResults(
7410-
CodeCompletionContext &context) {
7411-
auto results = context.takeResults();
7412-
handleResults(results);
7413-
}
7414-
7415-
void PrintingCodeCompletionConsumer::handleResults(
7416-
MutableArrayRef<CodeCompletionResult *> Results) {
7417-
unsigned NumResults = 0;
7418-
for (auto Result : Results) {
7419-
if (!IncludeKeywords && Result->getKind() == CodeCompletionResult::Keyword)
7420-
continue;
7421-
++NumResults;
7422-
}
7423-
if (NumResults == 0)
7424-
return;
7425-
7426-
OS << "Begin completions, " << NumResults << " items\n";
7427-
for (auto Result : Results) {
7428-
if (!IncludeKeywords && Result->getKind() == CodeCompletionResult::Keyword)
7429-
continue;
7430-
Result->printPrefix(OS);
7431-
if (PrintAnnotatedDescription) {
7432-
printCodeCompletionResultDescriptionAnnotated(*Result, OS, /*leadingPunctuation=*/false);
7433-
OS << "; typename=";
7434-
printCodeCompletionResultTypeNameAnnotated(*Result, OS);
7435-
} else {
7436-
Result->getCompletionString()->print(OS);
7437-
}
7438-
7439-
OS << "; name=";
7440-
printCodeCompletionResultFilterName(*Result, OS);
7441-
7442-
if (IncludeSourceText) {
7443-
OS << "; sourcetext=";
7444-
SmallString<64> buf;
7445-
{
7446-
llvm::raw_svector_ostream bufOS(buf);
7447-
printCodeCompletionResultSourceText(*Result, bufOS);
7448-
}
7449-
OS.write_escaped(buf);
7450-
}
7451-
7452-
StringRef comment = Result->getBriefDocComment();
7453-
if (IncludeComments && !comment.empty()) {
7454-
OS << "; comment=" << comment;
7455-
}
7456-
7457-
if (Result->getDiagnosticSeverity() !=
7458-
CodeCompletionDiagnosticSeverity::None) {
7459-
OS << "; diagnostics=" << comment;
7460-
switch (Result->getDiagnosticSeverity()) {
7461-
case CodeCompletionDiagnosticSeverity::Error:
7462-
OS << "error";
7463-
break;
7464-
case CodeCompletionDiagnosticSeverity::Warning:
7465-
OS << "warning";
7466-
break;
7467-
case CodeCompletionDiagnosticSeverity::Remark:
7468-
OS << "remark";
7469-
break;
7470-
case CodeCompletionDiagnosticSeverity::Note:
7471-
OS << "note";
7472-
break;
7473-
case CodeCompletionDiagnosticSeverity::None:
7474-
llvm_unreachable("none");
7475-
}
7476-
OS << ":" << Result->getDiagnosticMessage();
7477-
}
7478-
7479-
OS << "\n";
7480-
}
7481-
OS << "End completions\n";
7482-
}
7483-
74847409
namespace {
74857410
class CodeCompletionCallbacksFactoryImpl
74867411
: public CodeCompletionCallbacksFactory {

0 commit comments

Comments
 (0)