[SourceKit/CodeCompletion] Use callback function to run the second pass

To controls the lifetime of CompilerInstance within CompletionIntance.

- Prevent from using the same CompilerInstance from multiple completion
  requests
- Separate the stacktrace between "fast" and "normal" completions
- Further code consolidation between various completion-like requests
This commit is contained in:
Rintaro Ishizaki
2019-12-18 14:07:36 -08:00
parent fcb50d6354
commit 044477e7a3
9 changed files with 257 additions and 280 deletions

View File

@@ -436,6 +436,16 @@ public:
/// returns the original path;
static std::string resolvePathSymlinks(StringRef FilePath);
/// Perform a completion like operation. It initializes a \c CompilerInstance,
/// the calls \p Callback with it. \p Callback must perform the second pass
/// using that instance.
bool performCompletionLikeOperation(
llvm::MemoryBuffer *UnresolvedInputFile, unsigned Offset,
ArrayRef<const char *> Args,
llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> FileSystem,
std::string &Error,
llvm::function_ref<void(swift::CompilerInstance &)> Callback);
//==========================================================================//
// LangSupport Interface
//==========================================================================//