Skip to content

Commit f641a58

Browse files
author
marcrasi
authored
hook for custom VFS in SourceKit (#24708)
1 parent 65d14d0 commit f641a58

File tree

33 files changed

+689
-213
lines changed

33 files changed

+689
-213
lines changed

include/swift/Frontend/Frontend.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,12 @@ class CompilerInstance {
518518
/// Returns true if there was an error during setup.
519519
bool setup(const CompilerInvocation &Invocation);
520520

521+
/// Returns true if there was an error during setup.
522+
/// \param BaseFS Use this, instead of the real filesystem, as the vase
523+
/// filesystem.
524+
bool setup(const CompilerInvocation &Invocation,
525+
llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> BaseFS);
526+
521527
private:
522528
/// Set up the file system by loading and validating all VFS overlay YAML
523529
/// files. If the process of validating VFS files failed, or the overlay

lib/ClangImporter/ClangImporter.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1024,10 +1024,10 @@ ClangImporter::create(ASTContext &ctx,
10241024

10251025
// Set up the file manager.
10261026
{
1027-
if (!ctx.SearchPathOpts.VFSOverlayFiles.empty()) {
1027+
if (ctx.SourceMgr.getFileSystem() != llvm::vfs::getRealFileSystem()) {
10281028
// If the clang instance has overlays it means the user has provided
1029-
// -ivfsoverlay options and swift -vfsoverlay options. We're going to
1030-
// clobber their file system with our own, so warn about it.
1029+
// -ivfsoverlay options. We're going to clobber their file system with
1030+
// the Swift file system, so warn about it.
10311031
if (!instance.getHeaderSearchOpts().VFSOverlayFiles.empty()) {
10321032
ctx.Diags.diagnose(SourceLoc(), diag::clang_vfs_overlay_is_ignored);
10331033
}

lib/Frontend/Frontend.cpp

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,17 @@ void CompilerInstance::recordPrimarySourceFile(SourceFile *SF) {
176176
}
177177

178178
bool CompilerInstance::setup(const CompilerInvocation &Invok) {
179+
return setup(Invok, llvm::vfs::getRealFileSystem());
180+
}
181+
182+
bool CompilerInstance::setup(
183+
const CompilerInvocation &Invok,
184+
llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> BaseFS) {
185+
assert(BaseFS);
179186
Invocation = Invok;
180187

188+
SourceMgr.setFileSystem(BaseFS);
189+
181190
// If initializing the overlay file system fails there's no sense in
182191
// continuing because the compiler will read the wrong files.
183192
if (setUpVirtualFileSystemOverlays())
@@ -238,19 +247,20 @@ static bool loadAndValidateVFSOverlay(
238247
}
239248

240249
bool CompilerInstance::setUpVirtualFileSystemOverlays() {
241-
auto BaseFS = llvm::vfs::getRealFileSystem();
250+
auto BaseFS = SourceMgr.getFileSystem();
242251
auto OverlayFS = llvm::IntrusiveRefCntPtr<llvm::vfs::OverlayFileSystem>(
243252
new llvm::vfs::OverlayFileSystem(BaseFS));
244253
bool hadAnyFailure = false;
254+
bool hasOverlays = false;
245255
for (const auto &File : Invocation.getSearchPathOptions().VFSOverlayFiles) {
256+
hasOverlays = true;
246257
hadAnyFailure |=
247258
loadAndValidateVFSOverlay(File, BaseFS, OverlayFS, Diagnostics);
248259
}
249260

250261
// If we successfully loaded all the overlays, let the source manager and
251262
// diagnostic engine take advantage of the overlay file system.
252-
if (!hadAnyFailure &&
253-
(OverlayFS->overlays_begin() != OverlayFS->overlays_end())) {
263+
if (!hadAnyFailure && hasOverlays) {
254264
SourceMgr.setFileSystem(OverlayFS);
255265
}
256266

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import CModule
2+
import SwiftModule
3+
4+
func foo(
5+
_ structDefinedInCModule: StructDefinedInCModule,
6+
_ structDefinedInSwiftModule: StructDefinedInSwiftModule,
7+
_ structDefinedInSameTarget: StructDefinedInSameTarget
8+
) {
9+
structDefinedInCModule.
10+
structDefinedInSwiftModule.
11+
structDefinedInSameTarget.
12+
}
13+
14+
// CHECK-CMODULE: key.name: "intFieldDefinedInCModule"
15+
16+
// CHECK-SWIFTMODULE: key.name: "methodDefinedInSwiftModule()"
17+
18+
// CHECK-SAMETARGET: key.name: "methodDefinedInSameTarget()"
19+
20+
// RUN: %empty-directory(%t)
21+
// RUN: %swift -emit-module -o %t/SwiftModule.swiftmodule -module-name SwiftModule %S/../Inputs/vfs/SwiftModule/SwiftModule.swift
22+
// RUN: %sourcekitd-test -req=complete -pos=9:27 -vfs-files=/target_file1.swift=%s,/target_file2.swift=%S/../Inputs/vfs/other_file_in_target.swift,/CModule/module.modulemap=%S/../Inputs/vfs/CModule/module.modulemap,/CModule/CModule.h=%S/../Inputs/vfs/CModule/CModule.h,/SwiftModule/SwiftModule.swiftmodule=%t/SwiftModule.swiftmodule /target_file1.swift -- /target_file1.swift /target_file2.swift -I /CModule -I /SwiftModule | %FileCheck --check-prefix=CHECK-CMODULE %s
23+
// RUN: %sourcekitd-test -req=complete -pos=10:31 -vfs-files=/target_file1.swift=%s,/target_file2.swift=%S/../Inputs/vfs/other_file_in_target.swift,/CModule/module.modulemap=%S/../Inputs/vfs/CModule/module.modulemap,/CModule/CModule.h=%S/../Inputs/vfs/CModule/CModule.h,/SwiftModule/SwiftModule.swiftmodule=%t/SwiftModule.swiftmodule /target_file1.swift -- /target_file1.swift /target_file2.swift -I /CModule -I /SwiftModule | %FileCheck --check-prefix=CHECK-SWIFTMODULE %s
24+
// RUN: %sourcekitd-test -req=complete -pos=11:30 -vfs-files=/target_file1.swift=%s,/target_file2.swift=%S/../Inputs/vfs/other_file_in_target.swift,/CModule/module.modulemap=%S/../Inputs/vfs/CModule/module.modulemap,/CModule/CModule.h=%S/../Inputs/vfs/CModule/CModule.h,/SwiftModule/SwiftModule.swiftmodule=%t/SwiftModule.swiftmodule /target_file1.swift -- /target_file1.swift /target_file2.swift -I /CModule -I /SwiftModule | %FileCheck --check-prefix=CHECK-SAMETARGET %s
25+
26+
// REQUIRES: sourcekit_use_inproc_library
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import CModule
2+
import SwiftModule
3+
4+
func foo(
5+
_ structDefinedInCModule: StructDefinedInCModule,
6+
_ structDefinedInSwiftModule: StructDefinedInSwiftModule,
7+
_ structDefinedInSameTarget: StructDefinedInSameTarget
8+
) {
9+
}
10+
11+
// CHECK-CMODULE: <Declaration>struct StructDefinedInCModule</Declaration>
12+
13+
// CHECK-SWIFTMODULE: <Declaration>struct StructDefinedInSwiftModule</Declaration>
14+
15+
// CHECK-SAMETARGET: <Declaration>struct StructDefinedInSameTarget</Declaration>
16+
17+
// RUN: %empty-directory(%t)
18+
// RUN: %swift -emit-module -o %t/SwiftModule.swiftmodule -module-name SwiftModule %S/../Inputs/vfs/SwiftModule/SwiftModule.swift
19+
// RUN: %sourcekitd-test -req=cursor -pos=5:43 -vfs-files=/target_file1.swift=%s,/target_file2.swift=%S/../Inputs/vfs/other_file_in_target.swift,/CModule/module.modulemap=%S/../Inputs/vfs/CModule/module.modulemap,/CModule/CModule.h=%S/../Inputs/vfs/CModule/CModule.h,/SwiftModule/SwiftModule.swiftmodule=%t/SwiftModule.swiftmodule /target_file1.swift -- /target_file1.swift /target_file2.swift -I /CModule -I /SwiftModule | %FileCheck --check-prefix=CHECK-CMODULE %s
20+
// USR test intentionally omitted for CModule, because SourceKit does not support clang USRs.
21+
// RUN: %sourcekitd-test -req=cursor -pos=6:43 -vfs-files=/target_file1.swift=%s,/target_file2.swift=%S/../Inputs/vfs/other_file_in_target.swift,/CModule/module.modulemap=%S/../Inputs/vfs/CModule/module.modulemap,/CModule/CModule.h=%S/../Inputs/vfs/CModule/CModule.h,/SwiftModule/SwiftModule.swiftmodule=%t/SwiftModule.swiftmodule /target_file1.swift -- /target_file1.swift /target_file2.swift -I /CModule -I /SwiftModule | %FileCheck --check-prefix=CHECK-SWIFTMODULE %s
22+
// RUN: %sourcekitd-test -req=cursor -usr "s:11SwiftModule015StructDefinedInaB0V" -vfs-files=/target_file1.swift=%s,/target_file2.swift=%S/../Inputs/vfs/other_file_in_target.swift,/CModule/module.modulemap=%S/../Inputs/vfs/CModule/module.modulemap,/CModule/CModule.h=%S/../Inputs/vfs/CModule/CModule.h,/SwiftModule/SwiftModule.swiftmodule=%t/SwiftModule.swiftmodule /target_file1.swift -- /target_file1.swift /target_file2.swift -I /CModule -I /SwiftModule | %FileCheck --check-prefix=CHECK-SWIFTMODULE %s
23+
// RUN: %sourcekitd-test -req=cursor -pos=7:43 -vfs-files=/target_file1.swift=%s,/target_file2.swift=%S/../Inputs/vfs/other_file_in_target.swift,/CModule/module.modulemap=%S/../Inputs/vfs/CModule/module.modulemap,/CModule/CModule.h=%S/../Inputs/vfs/CModule/CModule.h,/SwiftModule/SwiftModule.swiftmodule=%t/SwiftModule.swiftmodule /target_file1.swift -- /target_file1.swift /target_file2.swift -I /CModule -I /SwiftModule | %FileCheck --check-prefix=CHECK-SAMETARGET %s
24+
// RUN: %sourcekitd-test -req=cursor -usr "s:4main25StructDefinedInSameTargetV" -vfs-files=/target_file1.swift=%s,/target_file2.swift=%S/../Inputs/vfs/other_file_in_target.swift,/CModule/module.modulemap=%S/../Inputs/vfs/CModule/module.modulemap,/CModule/CModule.h=%S/../Inputs/vfs/CModule/CModule.h,/SwiftModule/SwiftModule.swiftmodule=%t/SwiftModule.swiftmodule /target_file1.swift -- /target_file1.swift /target_file2.swift -I /CModule -I /SwiftModule | %FileCheck --check-prefix=CHECK-SAMETARGET %s
25+
26+
// REQUIRES: sourcekit_use_inproc_library
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
struct StructDefinedInCModule {
2+
int intFieldDefinedInCModule;
3+
};
4+
5+
void functionDefinedInCModule();
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module CModule {
2+
header "CModule.h"
3+
export *
4+
}

test/SourceKit/Inputs/vfs/README

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Some example source files and modules for populating a VFS, for testing VFS
2+
injection.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
public struct StructDefinedInSwiftModule {
2+
public func methodDefinedInSwiftModule() {}
3+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
struct StructDefinedInSameTarget {
2+
func methodDefinedInSameTarget() {}
3+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import CModule
2+
import SwiftModule
3+
4+
func foo(
5+
_ structDefinedInSwiftModule: StructDefinedInSwiftModule,
6+
_ structDefinedInSameTarget: StructDefinedInSameTarget
7+
) {
8+
let a: String = functionDefinedInCModule()
9+
// CHECK: cannot convert value of type 'Void' to specified type 'String'
10+
11+
let b: Float = structDefinedInSwiftModule.methodDefinedInSwiftModule()
12+
// CHECK: cannot convert value of type '()' to specified type 'Float'
13+
14+
let c: Double = structDefinedInSameTarget.methodDefinedInSameTarget()
15+
// CHECK: cannot convert value of type '()' to specified type 'Double'
16+
}
17+
18+
// RUN: %empty-directory(%t)
19+
// RUN: %swift -emit-module -o %t/SwiftModule.swiftmodule -module-name SwiftModule %S/../Inputs/vfs/SwiftModule/SwiftModule.swift
20+
// RUN: %sourcekitd-test -req=open -vfs-files=/target_file1.swift=%s,/target_file2.swift=%S/../Inputs/vfs/other_file_in_target.swift,/CModule/module.modulemap=%S/../Inputs/vfs/CModule/module.modulemap,/CModule/CModule.h=%S/../Inputs/vfs/CModule/CModule.h,/SwiftModule/SwiftModule.swiftmodule=%t/SwiftModule.swiftmodule /target_file1.swift -- /target_file1.swift /target_file2.swift -I /CModule -I /SwiftModule == \
21+
// RUN: -req=print-diags -vfs-files=/target_file1.swift=%s,/target_file2.swift=%S/../Inputs/vfs/other_file_in_target.swift,/CModule/module.modulemap=%S/../Inputs/vfs/CModule/module.modulemap,/CModule/CModule.h=%S/../Inputs/vfs/CModule/CModule.h,/SwiftModule/SwiftModule.swiftmodule=%t/SwiftModule.swiftmodule /target_file1.swift | %FileCheck %s
22+
23+
// REQUIRES: sourcekit_use_inproc_library

test/lit.site.cfg.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,9 @@ else:
108108
# even if SWIFT_ENABLE_GOLD_LINKER isn't set, we cannot use BFD for Android
109109
config.android_linker_name = "gold"
110110

111+
if "@SWIFT_SOURCEKIT_USE_INPROC_LIBRARY@" == "TRUE":
112+
config.available_features.add('sourcekit_use_inproc_library')
113+
111114
# Let the main config do the real work.
112115
if config.test_exec_root is None:
113116
config.test_exec_root = os.path.dirname(os.path.realpath(__file__))

tools/SourceKit/cmake/modules/AddSwiftSourceKit.cmake

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ macro(add_sourcekit_executable name)
228228
cmake_parse_arguments(SOURCEKITEXE
229229
"EXCLUDE_FROM_ALL"
230230
""
231-
"LINK_LIBS;LLVM_COMPONENT_DEPENDS"
231+
"C_COMPILE_FLAGS;LINK_LIBS;LLVM_COMPONENT_DEPENDS"
232232
${ARGN})
233233

234234
if (${SOURCEKITEXE_EXCLUDE_FROM_ALL})
@@ -263,6 +263,8 @@ macro(add_sourcekit_executable name)
263263
endif()
264264
endif()
265265
add_sourcekit_default_compiler_flags("${name}")
266+
set_property(TARGET "${name}" APPEND_STRING PROPERTY
267+
COMPILE_FLAGS " ${SOURCEKITEXE_C_COMPILE_FLAGS}")
266268
endmacro()
267269

268270
# Add a new SourceKit framework.

tools/SourceKit/include/SourceKit/Core/Context.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include "SourceKit/Core/LLVM.h"
1717
#include "llvm/ADT/StringRef.h"
1818
#include "llvm/ADT/STLExtras.h"
19+
#include "llvm/ADT/StringMap.h"
1920
#include <memory>
2021
#include <string>
2122

@@ -24,6 +25,7 @@ namespace llvm {
2425
}
2526

2627
namespace SourceKit {
28+
class FileSystemProvider;
2729
class LangSupport;
2830
class NotificationCenter;
2931

@@ -32,6 +34,8 @@ class Context {
3234
std::unique_ptr<LangSupport> SwiftLang;
3335
std::shared_ptr<NotificationCenter> NotificationCtr;
3436

37+
llvm::StringMap<FileSystemProvider *> FileSystemProviders;
38+
3539
public:
3640
Context(StringRef RuntimeLibPath,
3741
llvm::function_ref<
@@ -44,6 +48,17 @@ class Context {
4448
LangSupport &getSwiftLangSupport() { return *SwiftLang; }
4549

4650
std::shared_ptr<NotificationCenter> getNotificationCenter() { return NotificationCtr; }
51+
52+
/// Returns the FileSystemProvider registered under Name, or nullptr if not
53+
/// found.
54+
FileSystemProvider *getFileSystemProvider(StringRef Name);
55+
56+
/// Registers the given FileSystemProvider under Name. The caller is
57+
/// responsible for keeping FileSystemProvider alive at least as long as
58+
/// this Context.
59+
/// \param FileSystemProvider must be non-null
60+
void setFileSystemProvider(StringRef Name,
61+
FileSystemProvider *FileSystemProvider);
4762
};
4863

4964
} // namespace SourceKit

tools/SourceKit/include/SourceKit/Core/LangSupport.h

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,11 @@
1717
#include "SourceKit/Support/UIdent.h"
1818
#include "llvm/Support/VersionTuple.h"
1919
#include "llvm/ADT/ArrayRef.h"
20+
#include "llvm/ADT/IntrusiveRefCntPtr.h"
2021
#include "llvm/ADT/Optional.h"
2122
#include "llvm/ADT/SmallString.h"
2223
#include "swift/AST/Type.h"
24+
#include "llvm/Support/VirtualFileSystem.h"
2325
#include <functional>
2426
#include <memory>
2527
#include <unordered_set>
@@ -585,9 +587,10 @@ class LangSupport {
585587
ArrayRef<const char *> Args,
586588
StringRef Hash) = 0;
587589

588-
virtual void codeComplete(llvm::MemoryBuffer *InputBuf, unsigned Offset,
589-
CodeCompletionConsumer &Consumer,
590-
ArrayRef<const char *> Args) = 0;
590+
virtual void
591+
codeComplete(llvm::MemoryBuffer *InputBuf, unsigned Offset,
592+
CodeCompletionConsumer &Consumer, ArrayRef<const char *> Args,
593+
llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> FileSystem) = 0;
591594

592595
virtual void codeCompleteOpen(StringRef name, llvm::MemoryBuffer *inputBuf,
593596
unsigned offset, OptionsDictionary *options,
@@ -611,9 +614,10 @@ class LangSupport {
611614
virtual void
612615
codeCompleteSetCustom(ArrayRef<CustomCompletionInfo> completions) = 0;
613616

614-
virtual void editorOpen(StringRef Name, llvm::MemoryBuffer *Buf,
615-
EditorConsumer &Consumer,
616-
ArrayRef<const char *> Args) = 0;
617+
virtual void
618+
editorOpen(StringRef Name, llvm::MemoryBuffer *Buf, EditorConsumer &Consumer,
619+
ArrayRef<const char *> Args,
620+
llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> FileSystem) = 0;
617621

618622
virtual void editorOpenInterface(EditorConsumer &Consumer,
619623
StringRef Name,
@@ -662,12 +666,12 @@ class LangSupport {
662666
unsigned Length,
663667
EditorConsumer &Consumer) = 0;
664668

665-
virtual void getCursorInfo(StringRef Filename, unsigned Offset,
666-
unsigned Length, bool Actionables,
667-
bool CancelOnSubsequentRequest,
668-
ArrayRef<const char *> Args,
669-
std::function<void(const CursorInfoData &)> Receiver) = 0;
670-
669+
virtual void
670+
getCursorInfo(StringRef Filename, unsigned Offset, unsigned Length,
671+
bool Actionables, bool CancelOnSubsequentRequest,
672+
ArrayRef<const char *> Args,
673+
llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> FileSystem,
674+
std::function<void(const CursorInfoData &)> Receiver) = 0;
671675

672676
virtual void getNameInfo(StringRef Filename, unsigned Offset,
673677
NameTranslatingInfo &Input,
@@ -679,11 +683,11 @@ class LangSupport {
679683
ArrayRef<const char *> Args,
680684
std::function<void(const RangeInfo&)> Receiver) = 0;
681685

682-
virtual void
683-
getCursorInfoFromUSR(StringRef Filename, StringRef USR,
684-
bool CancelOnSubsequentRequest,
685-
ArrayRef<const char *> Args,
686-
std::function<void(const CursorInfoData &)> Receiver) = 0;
686+
virtual void getCursorInfoFromUSR(
687+
StringRef Filename, StringRef USR, bool CancelOnSubsequentRequest,
688+
ArrayRef<const char *> Args,
689+
llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> FileSystem,
690+
std::function<void(const CursorInfoData &)> Receiver) = 0;
687691

688692
virtual void findRelatedIdentifiersInFile(StringRef Filename,
689693
unsigned Offset,
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
//===--- FileSystemProvider.h - ---------------------------------*- C++ -*-===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See https://swift.org/LICENSE.txt for license information
9+
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
#ifndef LLVM_SOURCEKIT_SUPPORT_FILESYSTEMPROVIDER_H
14+
#define LLVM_SOURCEKIT_SUPPORT_FILESYSTEMPROVIDER_H
15+
16+
#include "llvm/ADT/IntrusiveRefCntPtr.h"
17+
#include "llvm/ADT/SmallVector.h"
18+
#include "llvm/ADT/StringMap.h"
19+
#include "llvm/Support/VirtualFileSystem.h"
20+
21+
namespace SourceKit {
22+
23+
/// Allows clients of SourceKit to specify custom llvm::vfs::FileSystems to be
24+
/// used while serving a request.
25+
///
26+
/// Requests to SourceKit select FileSystemProviders by specifying
27+
/// 'key.vfs.name', and pass arguments to the FileSystemProviders by
28+
/// specifying 'key.vfs.args'. SourceKit then passes the given arguments to the
29+
/// selected FileSystemProvider, and uses the resulting llvm::vfs::FileSystem
30+
/// while serving the request.
31+
///
32+
/// The following requests currently support custom FileSystemProviders (other
33+
/// requests respond with an invalid request error if you try):
34+
/// - source.request.editor.open: Associates the given custom filesystem with
35+
/// this editor file, so that all subsequent
36+
/// operations on this editor file use it. Sending
37+
/// another 'source.request.editor.open' with
38+
/// 'key.vfs.name' replaces the filesystem.
39+
/// Sending another 'source.request.editor.open'
40+
/// without 'key.vfs.name' resets it to the default
41+
/// filesystem.
42+
/// - source.request.codecomplete: Uses the given custom filesystem to process.
43+
/// - source.request.cursorinfo: Uses the given custom filesystem to process.
44+
class FileSystemProvider {
45+
public:
46+
virtual ~FileSystemProvider() = default;
47+
48+
/// Returns a llvm::vfs::FileSystem to be used while serving a request, or
49+
/// nullptr on failure.
50+
/// \param Args arguments passed into the request under 'key.vfs.args'.
51+
/// \param [out] ErrBuf filled with an error message on failure.
52+
virtual llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>
53+
getFileSystem(const llvm::SmallVectorImpl<const char *> &Args,
54+
llvm::SmallVectorImpl<char> &ErrBuf) = 0;
55+
};
56+
57+
} // namespace SourceKit
58+
59+
#endif

0 commit comments

Comments
 (0)