IndexDataConsumer.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //===--- IndexDataConsumer.h - Abstract index data consumer -----*- C++ -*-===//
  7. //
  8. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  9. // See https://llvm.org/LICENSE.txt for license information.
  10. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  11. //
  12. //===----------------------------------------------------------------------===//
  13. #ifndef LLVM_CLANG_INDEX_INDEXDATACONSUMER_H
  14. #define LLVM_CLANG_INDEX_INDEXDATACONSUMER_H
  15. #include "clang/Index/IndexSymbol.h"
  16. #include "clang/Lex/Preprocessor.h"
  17. namespace clang {
  18. class ASTContext;
  19. class DeclContext;
  20. class Expr;
  21. class FileID;
  22. class IdentifierInfo;
  23. class ImportDecl;
  24. class MacroInfo;
  25. namespace index {
  26. class IndexDataConsumer {
  27. public:
  28. struct ASTNodeInfo {
  29. const Expr *OrigE;
  30. const Decl *OrigD;
  31. const Decl *Parent;
  32. const DeclContext *ContainerDC;
  33. };
  34. virtual ~IndexDataConsumer() = default;
  35. virtual void initialize(ASTContext &Ctx) {}
  36. virtual void setPreprocessor(std::shared_ptr<Preprocessor> PP) {}
  37. /// \returns true to continue indexing, or false to abort.
  38. virtual bool handleDeclOccurrence(const Decl *D, SymbolRoleSet Roles,
  39. ArrayRef<SymbolRelation> Relations,
  40. SourceLocation Loc, ASTNodeInfo ASTNode) {
  41. return true;
  42. }
  43. /// \returns true to continue indexing, or false to abort.
  44. virtual bool handleMacroOccurrence(const IdentifierInfo *Name,
  45. const MacroInfo *MI, SymbolRoleSet Roles,
  46. SourceLocation Loc) {
  47. return true;
  48. }
  49. /// \returns true to continue indexing, or false to abort.
  50. ///
  51. /// This will be called for each module reference in an import decl.
  52. /// For "@import MyMod.SubMod", there will be a call for 'MyMod' with the
  53. /// 'reference' role, and a call for 'SubMod' with the 'declaration' role.
  54. virtual bool handleModuleOccurrence(const ImportDecl *ImportD,
  55. const Module *Mod, SymbolRoleSet Roles,
  56. SourceLocation Loc) {
  57. return true;
  58. }
  59. virtual void finish() {}
  60. };
  61. } // namespace index
  62. } // namespace clang
  63. #endif
  64. #ifdef __GNUC__
  65. #pragma GCC diagnostic pop
  66. #endif