thread a vfs through the completion handler

This commit is contained in:
Marc Rasi
2019-04-30 20:39:04 -07:00
parent 419e97d7db
commit a6e0210b6d
23 changed files with 247 additions and 109 deletions

View File

@@ -117,12 +117,11 @@ static UIdent getUIDForCodeCompletionKindToReport(CompletionKind kind) {
}
}
static bool swiftCodeCompleteImpl(SwiftLangSupport &Lang,
llvm::MemoryBuffer *UnresolvedInputFile,
unsigned Offset,
SwiftCodeCompletionConsumer &SwiftConsumer,
ArrayRef<const char *> Args,
std::string &Error) {
static bool swiftCodeCompleteImpl(
SwiftLangSupport &Lang, llvm::MemoryBuffer *UnresolvedInputFile,
unsigned Offset, SwiftCodeCompletionConsumer &SwiftConsumer,
ArrayRef<const char *> Args, std::string &Error,
llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> FileSystem = nullptr) {
// Resolve symlinks for the input file; we resolve them for the input files
// in the arguments as well.
@@ -160,7 +159,8 @@ static bool swiftCodeCompleteImpl(SwiftLangSupport &Lang,
CompilerInvocation Invocation;
bool Failed = Lang.getASTManager()->initCompilerInvocation(
Invocation, Args, CI.getDiags(), InputFile->getBufferIdentifier(), Error);
Invocation, Args, CI.getDiags(), InputFile->getBufferIdentifier(), Error,
FileSystem);
if (Failed) {
return false;
}
@@ -195,7 +195,7 @@ static bool swiftCodeCompleteImpl(SwiftLangSupport &Lang,
// FIXME: We need to be passing the buffers from the open documents.
// It is not a huge problem in practice because Xcode auto-saves constantly.
if (CI.setup(Invocation)) {
if (CI.setup(Invocation, FileSystem)) {
// FIXME: error?
return true;
}
@@ -210,10 +210,10 @@ static bool swiftCodeCompleteImpl(SwiftLangSupport &Lang,
return true;
}
void SwiftLangSupport::codeComplete(llvm::MemoryBuffer *UnresolvedInputFile,
unsigned Offset,
SourceKit::CodeCompletionConsumer &SKConsumer,
ArrayRef<const char *> Args) {
void SwiftLangSupport::codeComplete(
llvm::MemoryBuffer *UnresolvedInputFile, unsigned Offset,
SourceKit::CodeCompletionConsumer &SKConsumer, ArrayRef<const char *> Args,
llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> FileSystem) {
SwiftCodeCompletionConsumer SwiftConsumer([&](
MutableArrayRef<CodeCompletionResult *> Results,
SwiftCompletionInfo &info) {
@@ -251,7 +251,7 @@ void SwiftLangSupport::codeComplete(llvm::MemoryBuffer *UnresolvedInputFile,
std::string Error;
if (!swiftCodeCompleteImpl(*this, UnresolvedInputFile, Offset, SwiftConsumer,
Args, Error)) {
Args, Error, FileSystem)) {
SKConsumer.failed(Error);
}
}