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