clang-tools  15.0.0git
TestIndex.h
Go to the documentation of this file.
1 //===-- IndexHelpers.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 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_UNITTESTS_TESTINDEX_H
10 #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_UNITTESTS_TESTINDEX_H
11 
12 #include "index/Index.h"
13 
14 namespace clang {
15 namespace clangd {
16 
17 // Creates Symbol instance and sets SymbolID to given QualifiedName.
18 Symbol symbol(llvm::StringRef QName);
19 
20 // Helpers to produce fake index symbols with proper SymbolID.
21 // USRFormat is a regex replacement string for the unqualified part of the USR.
22 Symbol sym(llvm::StringRef QName, index::SymbolKind Kind,
23  llvm::StringRef USRFormat);
24 // Creats a function symbol assuming no function arg.
25 Symbol func(llvm::StringRef Name);
26 // Creates a class symbol.
27 Symbol cls(llvm::StringRef Name);
28 // Creates an enum symbol.
29 Symbol enm(llvm::StringRef Name);
30 // Creates a variable symbol.
31 Symbol var(llvm::StringRef Name);
32 // Creates a namespace symbol.
33 Symbol ns(llvm::StringRef Name);
34 // Create a C++20 concept symbol.
35 Symbol conceptSym(llvm::StringRef Name);
36 
37 // Create a slab of symbols with the given qualified names as IDs and names.
38 SymbolSlab generateSymbols(std::vector<std::string> QualifiedNames);
39 
40 // Create a slab of symbols with IDs and names [Begin, End].
41 SymbolSlab generateNumSymbols(int Begin, int End);
42 
43 // Returns fully-qualified name out of given symbol.
44 std::string getQualifiedName(const Symbol &Sym);
45 
46 // Performs fuzzy matching-based symbol lookup given a query and an index.
47 // Incomplete is set true if more items than requested can be retrieved, false
48 // otherwise.
49 std::vector<std::string> match(const SymbolIndex &I,
50  const FuzzyFindRequest &Req,
51  bool *Incomplete = nullptr);
52 
53 // Returns qualified names of symbols with any of IDs in the index.
54 std::vector<std::string> lookup(const SymbolIndex &I,
55  llvm::ArrayRef<SymbolID> IDs);
56 
57 } // namespace clangd
58 } // namespace clang
59 
60 #endif
Index.h
clang::clangd::var
Symbol var(llvm::StringRef Name)
Definition: TestIndex.cpp:72
Kind
BindArgumentKind Kind
Definition: AvoidBindCheck.cpp:59
clang::clangd::cls
Symbol cls(llvm::StringRef Name)
Definition: TestIndex.cpp:64
clang::clangd::func
Symbol func(llvm::StringRef Name)
Definition: TestIndex.cpp:60
clang::clangd::ns
Symbol ns(llvm::StringRef Name)
Definition: TestIndex.cpp:76
clang::clangd::generateNumSymbols
SymbolSlab generateNumSymbols(int Begin, int End)
Definition: TestIndex.cpp:91
clang::clangd::match
std::vector< std::string > match(const SymbolIndex &I, const FuzzyFindRequest &Req, bool *Incomplete)
Definition: TestIndex.cpp:102
clang::clangd::generateSymbols
SymbolSlab generateSymbols(std::vector< std::string > QualifiedNames)
Definition: TestIndex.cpp:84
Name
Token Name
Definition: MacroToEnumCheck.cpp:89
clang::clangd::enm
Symbol enm(llvm::StringRef Name)
Definition: TestIndex.cpp:68
clang::clangd::conceptSym
Symbol conceptSym(llvm::StringRef Name)
Definition: TestIndex.cpp:80
clang::clangd::getQualifiedName
std::string getQualifiedName(const Symbol &Sym)
Definition: TestIndex.cpp:98
clang::clangd::lookup
std::vector< std::string > lookup(const SymbolIndex &I, llvm::ArrayRef< SymbolID > IDs)
Definition: TestIndex.cpp:114
SymbolKind
clang::find_all_symbols::SymbolInfo::SymbolKind SymbolKind
Definition: SymbolInfo.cpp:19
clang::clangd::sym
Symbol sym(llvm::StringRef QName, index::SymbolKind Kind, llvm::StringRef USRFormat)
Definition: TestIndex.cpp:39
clang
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
Definition: ApplyReplacements.h:27
clang::clangd::symbol
Symbol symbol(llvm::StringRef QName)
Definition: TestIndex.cpp:16