clang-tools  16.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 an enum constant symbol.
31 Symbol enmConstant(llvm::StringRef Name);
32 // Creates a variable symbol.
33 Symbol var(llvm::StringRef Name);
34 // Creates a namespace symbol.
35 Symbol ns(llvm::StringRef Name);
36 // Create a C++20 concept symbol.
37 Symbol conceptSym(llvm::StringRef Name);
38 
39 // Create an Objective-C symbol.
40 Symbol objcSym(llvm::StringRef Name, index::SymbolKind Kind,
41  llvm::StringRef USRPrefix);
42 // Create an @interface or @implementation.
43 Symbol objcClass(llvm::StringRef Name);
44 // Create an @interface or @implementation category.
45 Symbol objcCategory(llvm::StringRef Name, llvm::StringRef CategoryName);
46 // Create an @protocol.
47 Symbol objcProtocol(llvm::StringRef Name);
48 
49 // Create a slab of symbols with the given qualified names as IDs and names.
50 SymbolSlab generateSymbols(std::vector<std::string> QualifiedNames);
51 
52 // Create a slab of symbols with IDs and names [Begin, End].
53 SymbolSlab generateNumSymbols(int Begin, int End);
54 
55 // Returns fully-qualified name out of given symbol.
56 std::string getQualifiedName(const Symbol &Sym);
57 
58 // Performs fuzzy matching-based symbol lookup given a query and an index.
59 // Incomplete is set true if more items than requested can be retrieved, false
60 // otherwise.
61 std::vector<std::string> match(const SymbolIndex &I,
62  const FuzzyFindRequest &Req,
63  bool *Incomplete = nullptr);
64 
65 // Returns qualified names of symbols with any of IDs in the index.
66 std::vector<std::string> lookup(const SymbolIndex &I,
67  llvm::ArrayRef<SymbolID> IDs);
68 
69 } // namespace clangd
70 } // namespace clang
71 
72 #endif
Index.h
clang::clangd::var
Symbol var(llvm::StringRef Name)
Definition: TestIndex.cpp:76
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:80
clang::clangd::generateNumSymbols
SymbolSlab generateNumSymbols(int Begin, int End)
Definition: TestIndex.cpp:122
clang::clangd::match
std::vector< std::string > match(const SymbolIndex &I, const FuzzyFindRequest &Req, bool *Incomplete)
Definition: TestIndex.cpp:133
clang::clangd::generateSymbols
SymbolSlab generateSymbols(std::vector< std::string > QualifiedNames)
Definition: TestIndex.cpp:115
clang::clangd::objcCategory
Symbol objcCategory(llvm::StringRef Name, llvm::StringRef CategoryName)
Definition: TestIndex.cpp:106
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:84
clang::clangd::getQualifiedName
std::string getQualifiedName(const Symbol &Sym)
Definition: TestIndex.cpp:129
clang::clangd::lookup
std::vector< std::string > lookup(const SymbolIndex &I, llvm::ArrayRef< SymbolID > IDs)
Definition: TestIndex.cpp:145
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::clangd::objcProtocol
Symbol objcProtocol(llvm::StringRef Name)
Definition: TestIndex.cpp:111
clang
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
Definition: ApplyReplacements.h:27
clang::clangd::objcClass
Symbol objcClass(llvm::StringRef Name)
Definition: TestIndex.cpp:102
clang::clangd::symbol
Symbol symbol(llvm::StringRef QName)
Definition: TestIndex.cpp:16
clang::clangd::enmConstant
Symbol enmConstant(llvm::StringRef Name)
Definition: TestIndex.cpp:72
clang::clangd::objcSym
Symbol objcSym(llvm::StringRef Name, index::SymbolKind Kind, llvm::StringRef USRPrefix)
Definition: TestIndex.cpp:88