clang-tools 19.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
14namespace clang {
15namespace clangd {
16
17// Creates Symbol instance and sets SymbolID to given QualifiedName.
18Symbol 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.
22Symbol sym(llvm::StringRef QName, index::SymbolKind Kind,
23 llvm::StringRef USRFormat, llvm::StringRef Signature = {});
24// Creats a function symbol assuming no function arg.
25Symbol func(llvm::StringRef Name);
26// Creates a class symbol.
27Symbol cls(llvm::StringRef Name);
28// Creates an enum symbol.
29Symbol enm(llvm::StringRef Name);
30// Creates an enum constant symbol.
31Symbol enmConstant(llvm::StringRef Name);
32// Creates a variable symbol.
33Symbol var(llvm::StringRef Name);
34// Creates a namespace symbol.
35Symbol ns(llvm::StringRef Name);
36// Create a C++20 concept symbol.
37Symbol conceptSym(llvm::StringRef Name);
38// Create a macro symbol.
39Symbol macro(llvm::StringRef Name, llvm::StringRef ArgList = {});
40
41// Create an Objective-C symbol.
42Symbol objcSym(llvm::StringRef Name, index::SymbolKind Kind,
43 llvm::StringRef USRPrefix);
44// Create an @interface or @implementation.
45Symbol objcClass(llvm::StringRef Name);
46// Create an @interface or @implementation category.
47Symbol objcCategory(llvm::StringRef Name, llvm::StringRef CategoryName);
48// Create an @protocol.
49Symbol objcProtocol(llvm::StringRef Name);
50
51// Create a slab of symbols with the given qualified names as IDs and names.
52SymbolSlab generateSymbols(std::vector<std::string> QualifiedNames);
53
54// Create a slab of symbols with IDs and names [Begin, End].
55SymbolSlab generateNumSymbols(int Begin, int End);
56
57// Returns fully-qualified name out of given symbol.
58std::string getQualifiedName(const Symbol &Sym);
59
60// Performs fuzzy matching-based symbol lookup given a query and an index.
61// Incomplete is set true if more items than requested can be retrieved, false
62// otherwise.
63std::vector<std::string> match(const SymbolIndex &I,
64 const FuzzyFindRequest &Req,
65 bool *Incomplete = nullptr);
66
67// Returns qualified names of symbols with any of IDs in the index.
68std::vector<std::string> lookup(const SymbolIndex &I,
69 llvm::ArrayRef<SymbolID> IDs);
70
71} // namespace clangd
72} // namespace clang
73
74#endif
BindArgumentKind Kind
llvm::SmallString< 256U > Name
std::string Signature
Symbol objcProtocol(llvm::StringRef Name)
Definition: TestIndex.cpp:117
Symbol objcClass(llvm::StringRef Name)
Definition: TestIndex.cpp:108
Symbol func(llvm::StringRef Name)
Definition: TestIndex.cpp:62
Symbol cls(llvm::StringRef Name)
Definition: TestIndex.cpp:66
Symbol objcCategory(llvm::StringRef Name, llvm::StringRef CategoryName)
Definition: TestIndex.cpp:112
Symbol conceptSym(llvm::StringRef Name)
Definition: TestIndex.cpp:86
Symbol sym(llvm::StringRef QName, index::SymbolKind Kind, llvm::StringRef USRFormat, llvm::StringRef Signature)
Definition: TestIndex.cpp:40
Symbol ns(llvm::StringRef Name)
Definition: TestIndex.cpp:82
Symbol objcSym(llvm::StringRef Name, index::SymbolKind Kind, llvm::StringRef USRPrefix)
Definition: TestIndex.cpp:94
std::vector< std::string > match(const SymbolIndex &I, const FuzzyFindRequest &Req, bool *Incomplete)
Definition: TestIndex.cpp:139
Symbol symbol(llvm::StringRef QName)
Definition: TestIndex.cpp:17
Symbol enm(llvm::StringRef Name)
Definition: TestIndex.cpp:70
Symbol macro(llvm::StringRef Name, llvm::StringRef ArgList)
Definition: TestIndex.cpp:90
SymbolSlab generateSymbols(std::vector< std::string > QualifiedNames)
Definition: TestIndex.cpp:121
std::string getQualifiedName(const Symbol &Sym)
Definition: TestIndex.cpp:135
std::vector< std::string > lookup(const SymbolIndex &I, llvm::ArrayRef< SymbolID > IDs)
Definition: TestIndex.cpp:151
Symbol enmConstant(llvm::StringRef Name)
Definition: TestIndex.cpp:74
SymbolSlab generateNumSymbols(int Begin, int End)
Definition: TestIndex.cpp:128
Symbol var(llvm::StringRef Name)
Definition: TestIndex.cpp:78
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//