Clang Project

clang_source_code/include/clang/Index/IndexDataConsumer.h
1//===--- IndexDataConsumer.h - Abstract index data consumer -----*- 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_INDEX_INDEXDATACONSUMER_H
10#define LLVM_CLANG_INDEX_INDEXDATACONSUMER_H
11
12#include "clang/Index/IndexSymbol.h"
13#include "clang/Lex/Preprocessor.h"
14
15namespace clang {
16  class ASTContext;
17  class DeclContext;
18  class Expr;
19  class FileID;
20  class IdentifierInfo;
21  class ImportDecl;
22  class MacroInfo;
23
24namespace index {
25
26class IndexDataConsumer {
27public:
28  struct ASTNodeInfo {
29    const Expr *OrigE;
30    const Decl *OrigD;
31    const Decl *Parent;
32    const DeclContext *ContainerDC;
33  };
34
35  virtual ~IndexDataConsumer() {}
36
37  virtual void initialize(ASTContext &Ctx) {}
38
39  virtual void setPreprocessor(std::shared_ptr<PreprocessorPP) {}
40
41  /// \returns true to continue indexing, or false to abort.
42  virtual bool handleDeclOccurence(const Decl *DSymbolRoleSet Roles,
43                                   ArrayRef<SymbolRelationRelations,
44                                   SourceLocation LocASTNodeInfo ASTNode);
45
46  /// \returns true to continue indexing, or false to abort.
47  virtual bool handleMacroOccurence(const IdentifierInfo *Name,
48                                    const MacroInfo *MISymbolRoleSet Roles,
49                                    SourceLocation Loc);
50
51  /// \returns true to continue indexing, or false to abort.
52  ///
53  /// This will be called for each module reference in an import decl.
54  /// For "@import MyMod.SubMod", there will be a call for 'MyMod' with the
55  /// 'reference' role, and a call for 'SubMod' with the 'declaration' role.
56  virtual bool handleModuleOccurence(const ImportDecl *ImportD,
57                                     const Module *Mod,
58                                     SymbolRoleSet RolesSourceLocation Loc);
59
60  virtual void finish() {}
61};
62
63// namespace index
64// namespace clang
65
66#endif
67
clang::index::IndexDataConsumer::ASTNodeInfo
clang::index::IndexDataConsumer::ASTNodeInfo::OrigE
clang::index::IndexDataConsumer::ASTNodeInfo::OrigD
clang::index::IndexDataConsumer::ASTNodeInfo::Parent
clang::index::IndexDataConsumer::ASTNodeInfo::ContainerDC
clang::index::IndexDataConsumer::initialize
clang::index::IndexDataConsumer::setPreprocessor
clang::index::IndexDataConsumer::handleDeclOccurence
clang::index::IndexDataConsumer::handleMacroOccurence
clang::index::IndexDataConsumer::handleModuleOccurence
clang::index::IndexDataConsumer::finish