clang-tools  10.0.0
FindSymbols.h
Go to the documentation of this file.
1 //===--- FindSymbols.h --------------------------------------*- 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 // Queries that provide a list of symbols matching a string.
10 //
11 //===----------------------------------------------------------------------===//
12 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_FINDSYMBOLS_H
13 #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_FINDSYMBOLS_H
14 
15 #include "Protocol.h"
16 #include "index/Symbol.h"
17 #include "llvm/ADT/StringRef.h"
18 
19 namespace clang {
20 namespace clangd {
21 class ParsedAST;
22 class SymbolIndex;
23 
24 /// Helper function for deriving an LSP Location for a Symbol.
25 llvm::Expected<Location> symbolToLocation(const Symbol &Sym,
26  llvm::StringRef HintPath);
27 
28 /// Searches for the symbols matching \p Query. The syntax of \p Query can be
29 /// the non-qualified name or fully qualified of a symbol. For example,
30 /// "vector" will match the symbol std::vector and "std::vector" would also
31 /// match it. Direct children of scopes (namepaces, etc) can be listed with a
32 /// trailing
33 /// "::". For example, "std::" will list all children of the std namespace and
34 /// "::" alone will list all children of the global namespace.
35 /// \p Limit limits the number of results returned (0 means no limit).
36 /// \p HintPath This is used when resolving URIs. If empty, URI resolution can
37 /// fail if a hint path is required for the scheme of a specific URI.
38 llvm::Expected<std::vector<SymbolInformation>>
39 getWorkspaceSymbols(llvm::StringRef Query, int Limit,
40  const SymbolIndex *const Index, llvm::StringRef HintPath);
41 
42 /// Retrieves the symbols contained in the "main file" section of an AST in the
43 /// same order that they appear.
44 llvm::Expected<std::vector<DocumentSymbol>> getDocumentSymbols(ParsedAST &AST);
45 
46 } // namespace clangd
47 } // namespace clang
48 
49 #endif
llvm::Optional< ParsedAST > AST
int Limit
llvm::Expected< std::vector< SymbolInformation > > getWorkspaceSymbols(llvm::StringRef Query, int Limit, const SymbolIndex *const Index, llvm::StringRef HintPath)
Searches for the symbols matching Query.
Definition: FindSymbols.cpp:67
llvm::Expected< Location > symbolToLocation(const Symbol &Sym, llvm::StringRef HintPath)
Helper function for deriving an LSP Location for a Symbol.
Definition: FindSymbols.cpp:42
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
llvm::Expected< std::vector< DocumentSymbol > > getDocumentSymbols(ParsedAST &AST)
Retrieves the symbols contained in the "main file" section of an AST in the same order that they appe...
const SymbolIndex * Index
Definition: Dexp.cpp:84