[CodeCompletion] Make sure callback is always called from performOperation

We had some situations left that neither returned an error, nor called the callback with results in `performOperation`. Return an error in these and adjust the tests to correctly match the error.
This commit is contained in:
Alex Hoppen
2021-10-07 19:04:56 +02:00
parent 2fcb24e716
commit b6e03e3d98
8 changed files with 89 additions and 36 deletions

View File

@@ -190,8 +190,15 @@ static void swiftCodeCompleteImpl(
ide::makeCodeCompletionCallbacksFactory(CompletionContext,
Consumer));
auto *SF = CI.getCodeCompletionFile();
performCodeCompletionSecondPass(*SF, *callbacksFactory);
if (!Result->DidFindCodeCompletionToken) {
Callback(ResultType::success(
{/*HasResults=*/false, &CI.getASTContext(), &CI.getInvocation(),
&CompletionContext, /*RequestedModules=*/{}, /*DC=*/nullptr}));
return;
}
performCodeCompletionSecondPass(*CI.getCodeCompletionFile(),
*callbacksFactory);
if (!Consumer.HandleResultWasCalled) {
// If we didn't receive a handleResult call from the second pass,
// we didn't receive any results. To make sure Callback gets called