diff options
| author | Sam McCall <sam.mccall@gmail.com> | 2018-10-19 15:42:23 +0000 |
|---|---|---|
| committer | Sam McCall <sam.mccall@gmail.com> | 2018-10-19 15:42:23 +0000 |
| commit | 0d9b40f583f49cfb7deb4bd734f9c3e3160413c5 (patch) | |
| tree | f2880bb1570126533c7a2d75d37a7d6299e03a4a /clang-tools-extra/clangd/ClangdServer.cpp | |
| parent | 57e6706e56d0467a808693b2192a587638eb047c (diff) | |
| download | bcm5719-llvm-0d9b40f583f49cfb7deb4bd734f9c3e3160413c5.tar.gz bcm5719-llvm-0d9b40f583f49cfb7deb4bd734f9c3e3160413c5.zip | |
[clangd] Set workspace root when initializing ClangdServer, disallow mutation.
Summary:
Rename instance variable to WorkspaceRoot to match what we call it internally.
Add fixme to set it automatically. Don't do it yet, clients have assumptions
that the constructor won't access the FS.
Don't second-guess the provided root.
Reviewers: ioeric
Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits
Differential Revision: https://reviews.llvm.org/D53404
llvm-svn: 344787
Diffstat (limited to 'clang-tools-extra/clangd/ClangdServer.cpp')
| -rw-r--r-- | clang-tools-extra/clangd/ClangdServer.cpp | 15 |
1 files changed, 2 insertions, 13 deletions
diff --git a/clang-tools-extra/clangd/ClangdServer.cpp b/clang-tools-extra/clangd/ClangdServer.cpp index 577222c20b6..b0b1af1bbe4 100644 --- a/clang-tools-extra/clangd/ClangdServer.cpp +++ b/clang-tools-extra/clangd/ClangdServer.cpp @@ -109,6 +109,7 @@ ClangdServer::ClangdServer(const GlobalCompilationDatabase &CDB, ? new FileIndex(Opts.URISchemes, Opts.HeavyweightDynamicSymbolIndex) : nullptr), + WorkspaceRoot(Opts.WorkspaceRoot), PCHs(std::make_shared<PCHContainerOperations>()), // Pass a callback into `WorkScheduler` to extract symbols from a newly // parsed file and rebuild the file index synchronously each time an AST @@ -131,18 +132,6 @@ ClangdServer::ClangdServer(const GlobalCompilationDatabase &CDB, Index = nullptr; } -void ClangdServer::setRootPath(PathRef RootPath) { - auto FS = FSProvider.getFileSystem(); - auto Status = FS->status(RootPath); - if (!Status) - elog("Failed to get status for RootPath {0}: {1}", RootPath, - Status.getError().message()); - else if (Status->isDirectory()) - this->RootPath = RootPath; - else - elog("The provided RootPath {0} is not a directory.", RootPath); -} - void ClangdServer::addDocument(PathRef File, StringRef Contents, WantDiagnostics WantDiags) { DocVersion Version = ++InternalVersion[File]; @@ -495,7 +484,7 @@ void ClangdServer::onFileEvent(const DidChangeWatchedFilesParams &Params) { void ClangdServer::workspaceSymbols( StringRef Query, int Limit, Callback<std::vector<SymbolInformation>> CB) { CB(clangd::getWorkspaceSymbols(Query, Limit, Index, - RootPath ? *RootPath : "")); + WorkspaceRoot.getValueOr(""))); } void ClangdServer::documentSymbols( |

