| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_XREFS_H |
| 14 |
#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_XREFS_H |
| 15 |
|
| 16 |
#include "Protocol.h" |
| 17 |
#include "SourceCode.h" |
| 18 |
#include "index/Index.h" |
| 19 |
#include "index/SymbolID.h" |
| 20 |
#include "support/Path.h" |
| 21 |
#include "clang/AST/ASTTypeTraits.h" |
| 22 |
#include "llvm/ADT/StringRef.h" |
| 23 |
#include "llvm/Support/raw_ostream.h" |
| 24 |
#include <optional> |
| 25 |
#include <vector> |
| 26 |
|
| 27 |
namespace clang { |
| 28 |
namespace syntax { |
| 29 |
class Token; |
| 30 |
class TokenBuffer; |
| 31 |
} |
| 32 |
namespace clangd { |
| 33 |
class ParsedAST; |
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
struct LocatedSymbol { |
| 42 |
|
| 43 |
std::string Name; |
| 44 |
|
| 45 |
Location PreferredDeclaration; |
| 46 |
|
| 47 |
std::optional<Location> Definition; |
| 48 |
|
| 49 |
SymbolID ID; |
| 50 |
}; |
| 51 |
llvm::raw_ostream &operator<<(llvm::raw_ostream &, const LocatedSymbol &); |
| 52 |
|
| 53 |
|
| 54 |
std::vector<LocatedSymbol> locateSymbolAt(ParsedAST &AST, Position Pos, |
| 55 |
const SymbolIndex *Index = nullptr); |
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
std::vector<LocatedSymbol> locateSymbolTextually(const SpelledWord &Word, |
| 64 |
ParsedAST &AST, |
| 65 |
const SymbolIndex *Index, |
| 66 |
llvm::StringRef MainFilePath, |
| 67 |
ASTNodeKind NodeKind); |
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
const syntax::Token *findNearbyIdentifier(const SpelledWord &Word, |
| 73 |
const syntax::TokenBuffer &TB); |
| 74 |
|
| 75 |
|
| 76 |
std::vector<DocumentLink> getDocumentLinks(ParsedAST &AST); |
| 77 |
|
| 78 |
|
| 79 |
std::vector<DocumentHighlight> findDocumentHighlights(ParsedAST &AST, |
| 80 |
Position Pos); |
| 81 |
|
| 82 |
struct ReferencesResult { |
| 83 |
|
| 84 |
enum ReferenceAttributes : unsigned { |
| 85 |
Declaration = 1 << 0, |
| 86 |
Definition = 1 << 1, |
| 87 |
|
| 88 |
Override = 1 << 2, |
| 89 |
}; |
| 90 |
struct Reference { |
| 91 |
ReferenceLocation Loc; |
| 92 |
unsigned Attributes = 0; |
| 93 |
}; |
| 94 |
std::vector<Reference> References; |
| 95 |
bool HasMore = false; |
| 96 |
}; |
| 97 |
llvm::raw_ostream &operator<<(llvm::raw_ostream &, |
| 98 |
const ReferencesResult::Reference &); |
| 99 |
|
| 100 |
|
| 101 |
|
| 102 |
|
| 103 |
std::vector<LocatedSymbol> findImplementations(ParsedAST &AST, Position Pos, |
| 104 |
const SymbolIndex *Index); |
| 105 |
|
| 106 |
|
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
std::vector<LocatedSymbol> findType(ParsedAST &AST, Position Pos); |
| 111 |
|
| 112 |
|
| 113 |
|
| 114 |
ReferencesResult findReferences(ParsedAST &AST, Position Pos, uint32_t Limit, |
| 115 |
const SymbolIndex *Index = nullptr, |
| 116 |
bool AddContext = false); |
| 117 |
|
| 118 |
|
| 119 |
std::vector<SymbolDetails> getSymbolInfo(ParsedAST &AST, Position Pos); |
| 120 |
|
| 121 |
|
| 122 |
std::vector<const CXXRecordDecl *> findRecordTypeAt(ParsedAST &AST, |
| 123 |
Position Pos); |
| 124 |
|
| 125 |
|
| 126 |
std::vector<const CXXRecordDecl *> typeParents(const CXXRecordDecl *CXXRD); |
| 127 |
|
| 128 |
|
| 129 |
std::vector<TypeHierarchyItem> getTypeHierarchy( |
| 130 |
ParsedAST &AST, Position Pos, int Resolve, TypeHierarchyDirection Direction, |
| 131 |
const SymbolIndex *Index = nullptr, PathRef TUPath = PathRef{}); |
| 132 |
|
| 133 |
|
| 134 |
|
| 135 |
std::optional<std::vector<TypeHierarchyItem>> |
| 136 |
superTypes(const TypeHierarchyItem &Item, const SymbolIndex *Index); |
| 137 |
|
| 138 |
std::vector<TypeHierarchyItem> subTypes(const TypeHierarchyItem &Item, |
| 139 |
const SymbolIndex *Index); |
| 140 |
|
| 141 |
void resolveTypeHierarchy(TypeHierarchyItem &Item, int ResolveLevels, |
| 142 |
TypeHierarchyDirection Direction, |
| 143 |
const SymbolIndex *Index); |
| 144 |
|
| 145 |
|
| 146 |
std::vector<CallHierarchyItem> |
| 147 |
prepareCallHierarchy(ParsedAST &AST, Position Pos, PathRef TUPath); |
| 148 |
|
| 149 |
std::vector<CallHierarchyIncomingCall> |
| 150 |
incomingCalls(const CallHierarchyItem &Item, const SymbolIndex *Index); |
| 151 |
|
| 152 |
|
| 153 |
llvm::DenseSet<const Decl *> getNonLocalDeclRefs(ParsedAST &AST, |
| 154 |
const FunctionDecl *FD); |
| 155 |
} |
| 156 |
} |
| 157 |
|
| 158 |
#endif |