[CodeCompletion] Replace main module instead of file

Rather than replacing the code completion file
on the `CompilerInstance` whenever we do a cached
top-level completion, let's set a new main module
instead.

This allows us to properly update the
`LoadedModules` map, and allows the retrieval of
the code completion file to be turned into a
request.
This commit is contained in:
Hamish Knight
2020-06-02 14:25:28 -07:00
parent 1bc028ece3
commit d26f4148a9
11 changed files with 75 additions and 43 deletions

View File

@@ -142,8 +142,8 @@ static bool swiftCodeCompleteImpl(
SwiftConsumer.setContext(&CI.getASTContext(), &CI.getInvocation(),
&CompletionContext);
auto SF = CI.getCodeCompletionFile();
performCodeCompletionSecondPass(*SF.get(), *callbacksFactory);
auto *SF = CI.getCodeCompletionFile();
performCodeCompletionSecondPass(*SF, *callbacksFactory);
SwiftConsumer.clearContext();
});
}