mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
fix SourceKit injected VFS with .swiftinterface files
Use `.setFileSystem()` instead of new `setup` method.
This commit is contained in:
@@ -518,12 +518,6 @@ public:
|
||||
/// Returns true if there was an error during setup.
|
||||
bool setup(const CompilerInvocation &Invocation);
|
||||
|
||||
/// Returns true if there was an error during setup.
|
||||
/// \param BaseFS Use this, instead of the real filesystem, as the vase
|
||||
/// filesystem.
|
||||
bool setup(const CompilerInvocation &Invocation,
|
||||
llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> BaseFS);
|
||||
|
||||
private:
|
||||
/// Set up the file system by loading and validating all VFS overlay YAML
|
||||
/// files. If the process of validating VFS files failed, or the overlay
|
||||
|
||||
@@ -196,17 +196,8 @@ bool CompilerInstance::setUpASTContextIfNeeded() {
|
||||
}
|
||||
|
||||
bool CompilerInstance::setup(const CompilerInvocation &Invok) {
|
||||
return setup(Invok, llvm::vfs::getRealFileSystem());
|
||||
}
|
||||
|
||||
bool CompilerInstance::setup(
|
||||
const CompilerInvocation &Invok,
|
||||
llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> BaseFS) {
|
||||
assert(BaseFS);
|
||||
Invocation = Invok;
|
||||
|
||||
SourceMgr.setFileSystem(BaseFS);
|
||||
|
||||
// If initializing the overlay file system fails there's no sense in
|
||||
// continuing because the compiler will read the wrong files.
|
||||
if (setUpVirtualFileSystemOverlays())
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
import SwiftModule
|
||||
|
||||
func foo(
|
||||
_ structDefinedInSwiftModule: StructDefinedInSwiftModule
|
||||
) {
|
||||
structDefinedInSwiftModule.
|
||||
}
|
||||
|
||||
// CHECK: key.name: "methodDefinedInSwiftModule()"
|
||||
|
||||
// RUN: %empty-directory(%t)
|
||||
// RUN: %target-swift-frontend -emit-parseable-module-interface-path %t/SwiftModule.swiftinterface -module-name SwiftModule -emit-module -o /dev/null %S/../Inputs/vfs/SwiftModule/SwiftModule.swift
|
||||
// RUN: %sourcekitd-test -req=complete -pos=6:31 -vfs-files=/target_file1.swift=%s,/SwiftModule/SwiftModule.swiftinterface=%t/SwiftModule.swiftinterface /target_file1.swift -- /target_file1.swift -I /SwiftModule | %FileCheck %s
|
||||
@@ -936,7 +936,8 @@ ASTUnitRef ASTProducer::createASTUnit(SwiftASTManager::Implementation &MgrImpl,
|
||||
|
||||
Invocation.getLangOptions().CollectParsedToken = true;
|
||||
|
||||
if (CompIns.setup(Invocation, InvokRef->Impl.Opts.FileSystem)) {
|
||||
CompIns.getSourceMgr().setFileSystem(InvokRef->Impl.Opts.FileSystem);
|
||||
if (CompIns.setup(Invocation)) {
|
||||
// FIXME: Report the diagnostic.
|
||||
LOG_WARN_FUNC("Compilation setup failed!!!");
|
||||
Error = "compilation setup failed";
|
||||
|
||||
@@ -197,7 +197,8 @@ static bool swiftCodeCompleteImpl(
|
||||
// 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, FileSystem)) {
|
||||
CI.getSourceMgr().setFileSystem(FileSystem);
|
||||
if (CI.setup(Invocation)) {
|
||||
// FIXME: error?
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user