#include "XRefs.h"
#include "AST.h"
#include "FindSymbols.h"
#include "FindTarget.h"
#include "Headers.h"
#include "HeuristicResolver.h"
#include "IncludeCleaner.h"
#include "ParsedAST.h"
#include "Protocol.h"
#include "Quality.h"
#include "Selection.h"
#include "SourceCode.h"
#include "URI.h"
#include "clang-include-cleaner/Analysis.h"
#include "clang-include-cleaner/Types.h"
#include "index/Index.h"
#include "index/Merge.h"
#include "index/Relation.h"
#include "index/SymbolCollector.h"
#include "index/SymbolID.h"
#include "index/SymbolLocation.h"
#include "support/Logger.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/ASTTypeTraits.h"
#include "clang/AST/Attr.h"
#include "clang/AST/Attrs.inc"
#include "clang/AST/Decl.h"
#include "clang/AST/DeclCXX.h"
#include "clang/AST/DeclObjC.h"
#include "clang/AST/DeclTemplate.h"
#include "clang/AST/DeclVisitor.h"
#include "clang/AST/ExprCXX.h"
#include "clang/AST/RecursiveASTVisitor.h"
#include "clang/AST/Stmt.h"
#include "clang/AST/StmtCXX.h"
#include "clang/AST/StmtVisitor.h"
#include "clang/AST/Type.h"
#include "clang/Basic/LLVM.h"
#include "clang/Basic/LangOptions.h"
#include "clang/Basic/SourceLocation.h"
#include "clang/Basic/SourceManager.h"
#include "clang/Basic/TokenKinds.h"
#include "clang/Index/IndexDataConsumer.h"
#include "clang/Index/IndexSymbol.h"
#include "clang/Index/IndexingAction.h"
#include "clang/Index/IndexingOptions.h"
#include "clang/Index/USRGeneration.h"
#include "clang/Lex/Lexer.h"
#include "clang/Tooling/Syntax/Tokens.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/ScopeExit.h"
#include "llvm/ADT/SmallSet.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/raw_ostream.h"
#include <optional>
#include <string>
#include <vector>
namespace clang {
namespace clangd {
namespace {
const NamedDecl *getDefinition(const NamedDecl *D) { … }
void logIfOverflow(const SymbolLocation &Loc) { … }
std::optional<Location> toLSPLocation(const SymbolLocation &Loc,
llvm::StringRef TUPath) { … }
SymbolLocation toIndexLocation(const Location &Loc, std::string &URIStorage) { … }
SymbolLocation getPreferredLocation(const Location &ASTLoc,
const SymbolLocation &IdxLoc,
std::string &Scratch) { … }
std::vector<std::pair<const NamedDecl *, DeclRelationSet>>
getDeclAtPositionWithRelations(ParsedAST &AST, SourceLocation Pos,
DeclRelationSet Relations,
ASTNodeKind *NodeKind = nullptr) { … }
std::vector<const NamedDecl *>
getDeclAtPosition(ParsedAST &AST, SourceLocation Pos, DeclRelationSet Relations,
ASTNodeKind *NodeKind = nullptr) { … }
std::optional<Location> makeLocation(const ASTContext &AST, SourceLocation Loc,
llvm::StringRef TUPath) { … }
std::optional<LocatedSymbol> locateFileReferent(const Position &Pos,
ParsedAST &AST,
llvm::StringRef MainFilePath) { … }
std::optional<LocatedSymbol>
locateMacroReferent(const syntax::Token &TouchedIdentifier, ParsedAST &AST,
llvm::StringRef MainFilePath) { … }
const NamedDecl *getPreferredDecl(const NamedDecl *D) { … }
std::vector<LocatedSymbol> findImplementors(llvm::DenseSet<SymbolID> IDs,
RelationKind Predicate,
const SymbolIndex *Index,
llvm::StringRef MainFilePath) { … }
void enhanceLocatedSymbolsFromIndex(llvm::MutableArrayRef<LocatedSymbol> Result,
const SymbolIndex *Index,
llvm::StringRef MainFilePath) { … }
std::vector<LocatedSymbol>
locateASTReferent(SourceLocation CurLoc, const syntax::Token *TouchedIdentifier,
ParsedAST &AST, llvm::StringRef MainFilePath,
const SymbolIndex *Index, ASTNodeKind &NodeKind) { … }
std::vector<LocatedSymbol> locateSymbolForType(const ParsedAST &AST,
const QualType &Type,
const SymbolIndex *Index) { … }
bool tokenSpelledAt(SourceLocation SpellingLoc, const syntax::TokenBuffer &TB) { … }
llvm::StringRef sourcePrefix(SourceLocation Loc, const SourceManager &SM) { … }
bool isDependentName(ASTNodeKind NodeKind) { … }
}
std::vector<LocatedSymbol> locateSymbolTextually(const SpelledWord &Word,
ParsedAST &AST,
const SymbolIndex *Index,
llvm::StringRef MainFilePath,
ASTNodeKind NodeKind) { … }
const syntax::Token *findNearbyIdentifier(const SpelledWord &Word,
const syntax::TokenBuffer &TB) { … }
std::vector<LocatedSymbol> locateSymbolAt(ParsedAST &AST, Position Pos,
const SymbolIndex *Index) { … }
std::vector<DocumentLink> getDocumentLinks(ParsedAST &AST) { … }
namespace {
class ReferenceFinder : public index::IndexDataConsumer { … };
std::vector<ReferenceFinder::Reference>
findRefs(const llvm::ArrayRef<const NamedDecl *> TargetDecls, ParsedAST &AST,
bool PerToken) { … }
const Stmt *getFunctionBody(DynTypedNode N) { … }
const Stmt *getLoopBody(DynTypedNode N) { … }
class FindControlFlow : public RecursiveASTVisitor<FindControlFlow> { … };
SourceRange findCaseBounds(const SwitchStmt &Switch, SourceLocation Loc,
const SourceManager &SM) { … }
std::vector<SourceLocation> relatedControlFlow(const SelectionTree::Node &N) { … }
DocumentHighlight toHighlight(const ReferenceFinder::Reference &Ref,
const SourceManager &SM) { … }
std::optional<DocumentHighlight> toHighlight(SourceLocation Loc,
const syntax::TokenBuffer &TB) { … }
}
std::vector<DocumentHighlight> findDocumentHighlights(ParsedAST &AST,
Position Pos) { … }
std::vector<LocatedSymbol> findImplementations(ParsedAST &AST, Position Pos,
const SymbolIndex *Index) { … }
namespace {
void getOverriddenMethods(const CXXMethodDecl *CMD,
llvm::DenseSet<SymbolID> &OverriddenMethods) { … }
std::optional<std::string>
stringifyContainerForMainFileRef(const Decl *Container) { … }
std::optional<ReferencesResult>
maybeFindIncludeReferences(ParsedAST &AST, Position Pos,
URIForFile URIMainFile) { … }
}
ReferencesResult findReferences(ParsedAST &AST, Position Pos, uint32_t Limit,
const SymbolIndex *Index, bool AddContext) { … }
std::vector<SymbolDetails> getSymbolInfo(ParsedAST &AST, Position Pos) { … }
llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const LocatedSymbol &S) { … }
llvm::raw_ostream &operator<<(llvm::raw_ostream &OS,
const ReferencesResult::Reference &R) { … }
template <typename HierarchyItem>
static std::optional<HierarchyItem>
declToHierarchyItem(const NamedDecl &ND, llvm::StringRef TUPath) { … }
static std::optional<TypeHierarchyItem>
declToTypeHierarchyItem(const NamedDecl &ND, llvm::StringRef TUPath) { … }
static std::optional<CallHierarchyItem>
declToCallHierarchyItem(const NamedDecl &ND, llvm::StringRef TUPath) { … }
template <typename HierarchyItem>
static std::optional<HierarchyItem> symbolToHierarchyItem(const Symbol &S,
PathRef TUPath) { … }
static std::optional<TypeHierarchyItem>
symbolToTypeHierarchyItem(const Symbol &S, PathRef TUPath) { … }
static std::optional<CallHierarchyItem>
symbolToCallHierarchyItem(const Symbol &S, PathRef TUPath) { … }
static void fillSubTypes(const SymbolID &ID,
std::vector<TypeHierarchyItem> &SubTypes,
const SymbolIndex *Index, int Levels, PathRef TUPath) { … }
RecursionProtectionSet;
static void fillSuperTypes(const CXXRecordDecl &CXXRD, llvm::StringRef TUPath,
TypeHierarchyItem &Item,
RecursionProtectionSet &RPSet) { … }
std::vector<const CXXRecordDecl *> findRecordTypeAt(ParsedAST &AST,
Position Pos) { … }
static QualType typeForNode(const SelectionTree::Node *N) { … }
static void unwrapFindType(
QualType T, const HeuristicResolver* H, llvm::SmallVector<QualType>& Out) { … }
static llvm::SmallVector<QualType> unwrapFindType(
QualType T, const HeuristicResolver* H) { … }
std::vector<LocatedSymbol> findType(ParsedAST &AST, Position Pos,
const SymbolIndex *Index) { … }
std::vector<const CXXRecordDecl *> typeParents(const CXXRecordDecl *CXXRD) { … }
std::vector<TypeHierarchyItem>
getTypeHierarchy(ParsedAST &AST, Position Pos, int ResolveLevels,
TypeHierarchyDirection Direction, const SymbolIndex *Index,
PathRef TUPath) { … }
std::optional<std::vector<TypeHierarchyItem>>
superTypes(const TypeHierarchyItem &Item, const SymbolIndex *Index) { … }
std::vector<TypeHierarchyItem> subTypes(const TypeHierarchyItem &Item,
const SymbolIndex *Index) { … }
void resolveTypeHierarchy(TypeHierarchyItem &Item, int ResolveLevels,
TypeHierarchyDirection Direction,
const SymbolIndex *Index) { … }
std::vector<CallHierarchyItem>
prepareCallHierarchy(ParsedAST &AST, Position Pos, PathRef TUPath) { … }
std::vector<CallHierarchyIncomingCall>
incomingCalls(const CallHierarchyItem &Item, const SymbolIndex *Index) { … }
llvm::DenseSet<const Decl *> getNonLocalDeclRefs(ParsedAST &AST,
const FunctionDecl *FD) { … }
}
}