xref: /llvm-project/clang-tools-extra/clangd/index/remote/Client.h (revision 319e11daee807981db61dad3da90d9bf36317e03)
1 //===--- Client.h - Connect to a remote index via gRPC -----------*- 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_INDEX_REMOTE_CLIENT_H
10 #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_INDEX_REMOTE_CLIENT_H
11 
12 #include "index/Index.h"
13 #include "llvm/ADT/StringRef.h"
14 
15 #include <memory>
16 
17 namespace clang {
18 namespace clangd {
19 
20 namespace remote {
21 
22 /// Returns an SymbolIndex client that passes requests to remote index located
23 /// at \p Address. The client allows synchronous RPC calls.
24 /// \p IndexRoot is an absolute path on the local machine to the source tree
25 /// described by the remote index. Paths returned by the index will be treated
26 /// as relative to this directory.
27 ///
28 /// This method attempts to resolve the address and establish the connection.
29 ///
30 /// \returns nullptr if the address is not resolved during the function call or
31 /// if the project was compiled without Remote Index support.
32 std::unique_ptr<clangd::SymbolIndex> getClient(llvm::StringRef Address,
33                                                llvm::StringRef IndexRoot);
34 
35 } // namespace remote
36 } // namespace clangd
37 } // namespace clang
38 
39 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANGD_INDEX_REMOTE_CLIENT_H
40