[clangd] Improve diagnostics in dexp interface

When running dexp in remote mode without --project-root it shuts down
with an assertion. This is not the desired behaviour: instruct user on
how to run it properly when the configuration is incorrect.
This commit is contained in:
Kirill Bobyrev 2020-08-11 09:48:54 +02:00
parent 0057532e3f
commit c6d2078a35
1 changed files with 12 additions and 6 deletions

View File

@ -30,10 +30,12 @@ llvm::cl::opt<std::string> IndexLocation(
llvm::cl::Positional);
llvm::cl::opt<std::string>
ExecCommand("c", llvm::cl::desc("Command to execute and then exit"));
ExecCommand("c", llvm::cl::desc("Command to execute and then exit."));
llvm::cl::opt<std::string> ProjectRoot("project-root",
llvm::cl::desc("Path to the project"));
llvm::cl::opt<std::string> ProjectRoot(
"project-root",
llvm::cl::desc(
"Path to the project. Required when connecting using remote index."));
static constexpr char Overview[] = R"(
This is an **experimental** interactive tool to process user-provided search
@ -373,10 +375,14 @@ int main(int argc, const char *argv[]) {
llvm::cl::ResetCommandLineParser(); // We reuse it for REPL commands.
llvm::sys::PrintStackTraceOnErrorSignal(argv[0]);
bool RemoteMode = llvm::StringRef(IndexLocation).startswith("remote:");
if (RemoteMode && ProjectRoot.empty()) {
llvm::errs() << "--project-root is required in remote mode\n";
return -1;
}
std::unique_ptr<SymbolIndex> Index;
reportTime(llvm::StringRef(IndexLocation).startswith("remote:")
? "Remote index client creation"
: "Dex build",
reportTime(RemoteMode ? "Remote index client creation" : "Dex build",
[&]() { Index = openIndex(IndexLocation); });
if (!Index) {