173
|
1 //===--- FSProvider.h - VFS provider for ClangdServer ------------*- C++-*-===//
|
|
2 //
|
|
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
4 // See https://llvm.org/LICENSE.txt for license information.
|
|
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
6 //
|
|
7 //===----------------------------------------------------------------------===//
|
|
8
|
|
9 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_SUPPORT_FSPROVIDER_H
|
|
10 #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_SUPPORT_FSPROVIDER_H
|
|
11
|
|
12 #include "llvm/ADT/IntrusiveRefCntPtr.h"
|
|
13 #include "llvm/Support/VirtualFileSystem.h"
|
|
14
|
|
15 namespace clang {
|
|
16 namespace clangd {
|
|
17
|
|
18 // Wrapper for vfs::FileSystem for use in multithreaded programs like clangd.
|
|
19 // As FileSystem is not threadsafe, concurrent threads must each obtain one.
|
|
20 class FileSystemProvider {
|
|
21 public:
|
|
22 virtual ~FileSystemProvider() = default;
|
|
23 /// Called by ClangdServer to obtain a vfs::FileSystem to be used for parsing.
|
|
24 /// Context::current() will be the context passed to the clang entrypoint,
|
|
25 /// such as addDocument(), and will also be propagated to result callbacks.
|
|
26 /// Embedders may use this to isolate filesystem accesses.
|
|
27 virtual llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>
|
|
28 getFileSystem() const = 0;
|
|
29 };
|
|
30
|
|
31 class RealFileSystemProvider : public FileSystemProvider {
|
|
32 public:
|
|
33 llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>
|
|
34 getFileSystem() const override;
|
|
35 };
|
|
36
|
|
37 } // namespace clangd
|
|
38 } // namespace clang
|
|
39
|
|
40 #endif
|