[CodeCompletion] Avoid typechecking all toplevel decls in the current file

- Use `performParseAndResolveImportsOnly()` to invoke the frontend
- Do `bindExtensions()` in `ide::typeCheckContextUntil()`
- Typecheck preceding `TopLevelCodeDecl`s only if the compleiton is in
  a `TopLevelCodeDecl`
- Other related tweaks

rdar://problem/56636747
This commit is contained in:
Rintaro Ishizaki
2019-10-30 17:13:16 -07:00
parent 9203080c0e
commit 2564a6e494
13 changed files with 109 additions and 39 deletions

View File

@@ -845,8 +845,13 @@ void CompilerInstance::parseAndCheckTypesUpTo(
// If the limiting AST stage is name binding, we're done.
if (limitStage <= SourceFile::NameBound) {
if (Invocation.isCodeCompletion()) {
performCodeCompletionSecondPass(*PersistentState.get(),
*Invocation.getCodeCompletionFactory());
}
return;
}
assert(!Invocation.isCodeCompletion());
const auto &options = Invocation.getFrontendOptions();
forEachFileToTypeCheck([&](SourceFile &SF) {
@@ -870,10 +875,6 @@ void CompilerInstance::parseAndCheckTypesUpTo(
}
});
if (Invocation.isCodeCompletion()) {
performCodeCompletionSecondPass(*PersistentState.get(),
*Invocation.getCodeCompletionFactory());
}
finishTypeChecking(TypeCheckOptions);
}