diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2009-07-29 23:38:21 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2009-07-29 23:38:21 +0000 |
commit | b17dc46c795d5eceeceb1424b96d63739d12a522 (patch) | |
tree | d41ccd8f87a22fa6ff2efea2375c96c088b1a640 /include/clang | |
parent | 8e9e9ef5348bce1a8f0741a5684fac3de9701c28 (diff) |
-Make IndexProvider an abstract interface for getting indexing information.
-Introduce Indexer as an IndexProvider implementation.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@77524 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang')
-rw-r--r-- | include/clang/Index/Handlers.h (renamed from include/clang/Index/EntityHandler.h) | 18 | ||||
-rw-r--r-- | include/clang/Index/IndexProvider.h | 35 | ||||
-rw-r--r-- | include/clang/Index/Indexer.h | 59 |
3 files changed, 79 insertions, 33 deletions
diff --git a/include/clang/Index/EntityHandler.h b/include/clang/Index/Handlers.h index 4cde3e7f90..631e5bb340 100644 --- a/include/clang/Index/EntityHandler.h +++ b/include/clang/Index/Handlers.h @@ -1,4 +1,4 @@ -//===--- EntityHandler.h - Interface for receiving entities -----*- C++ -*-===// +//===--- Handlers.h - Interfaces for receiving information ------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -7,23 +7,31 @@ // //===----------------------------------------------------------------------===// // -// Abstract interface for receiving Entities. +// Abstract interfaces for receiving information. // //===----------------------------------------------------------------------===// -#ifndef LLVM_CLANG_INDEX_ENTITYHANDLER_H -#define LLVM_CLANG_INDEX_ENTITYHANDLER_H +#ifndef LLVM_CLANG_INDEX_HANDLERS_H +#define LLVM_CLANG_INDEX_HANDLERS_H namespace clang { namespace idx { class Entity; + class TranslationUnit; /// \brief Abstract interface for receiving Entities. class EntityHandler { public: virtual ~EntityHandler(); - virtual void HandleEntity(Entity Ent); + virtual void HandleEntity(Entity Ent) = 0; +}; + +/// \brief Abstract interface for receiving TranslationUnits. +class TranslationUnitHandler { +public: + virtual ~TranslationUnitHandler(); + virtual void Handle(TranslationUnit *TU) = 0; }; } // namespace idx diff --git a/include/clang/Index/IndexProvider.h b/include/clang/Index/IndexProvider.h index ab86474f9a..bf776eee4f 100644 --- a/include/clang/Index/IndexProvider.h +++ b/include/clang/Index/IndexProvider.h @@ -1,4 +1,4 @@ -//===--- IndexProvider.h - Map of entities to translation units -*- C++ -*-===// +//===--- IndexProvider.h - Maps information to translation units -*- C++ -*-==// // // The LLVM Compiler Infrastructure // @@ -7,46 +7,25 @@ // //===----------------------------------------------------------------------===// // -// Maps Entities to TranslationUnits +// Maps information to TranslationUnits. // //===----------------------------------------------------------------------===// #ifndef LLVM_CLANG_INDEX_INDEXPROVIDER_H #define LLVM_CLANG_INDEX_INDEXPROVIDER_H -#include "llvm/ADT/SmallPtrSet.h" -#include <map> - namespace clang { namespace idx { - class Program; class Entity; - class TranslationUnit; + class TranslationUnitHandler; -/// \brief Maps Entities to TranslationUnits. +/// \brief Maps information to TranslationUnits. class IndexProvider { public: - typedef llvm::SmallPtrSet<TranslationUnit *, 4> TUSetTy; - typedef std::map<Entity, TUSetTy> MapTy; - class Indexer; - - explicit IndexProvider(Program &prog) : Prog(prog) { } - - Program &getProgram() const { return Prog; } - - /// \brief Find all Entities and map them to the given translation unit. - void IndexAST(TranslationUnit *TU); - - typedef TUSetTy::iterator translation_unit_iterator; - - translation_unit_iterator translation_units_begin(Entity Ent) const; - translation_unit_iterator translation_units_end(Entity Ent) const; - bool translation_units_empty(Entity Ent) const; - -private: - Program &Prog; - mutable MapTy Map; + virtual ~IndexProvider(); + virtual void GetTranslationUnitsFor(Entity Ent, + TranslationUnitHandler *Handler) = 0; }; } // namespace idx diff --git a/include/clang/Index/Indexer.h b/include/clang/Index/Indexer.h new file mode 100644 index 0000000000..a7c29581a0 --- /dev/null +++ b/include/clang/Index/Indexer.h @@ -0,0 +1,59 @@ +//===--- Indexer.h - IndexProvider implementation ---------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// IndexProvider implementation. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_CLANG_INDEX_INDEXER_H +#define LLVM_CLANG_INDEX_INDEXER_H + +#include "clang/Index/IndexProvider.h" +#include "llvm/ADT/SmallPtrSet.h" +#include <map> + +namespace clang { + +namespace idx { + class Program; + class TranslationUnit; + +/// \brief Maps information to TranslationUnits. +class Indexer : public IndexProvider { +public: + typedef llvm::SmallPtrSet<TranslationUnit *, 4> TUSetTy; + typedef std::map<Entity, TUSetTy> MapTy; + + explicit Indexer(Program &prog) : Prog(prog) { } + + Program &getProgram() const { return Prog; } + + /// \brief Find all Entities and map them to the given translation unit. + void IndexAST(TranslationUnit *TU); + + virtual void GetTranslationUnitsFor(Entity Ent, + TranslationUnitHandler *Handler); + + typedef TUSetTy::iterator translation_unit_iterator; + + translation_unit_iterator translation_units_begin(Entity Ent) const; + translation_unit_iterator translation_units_end(Entity Ent) const; + bool translation_units_empty(Entity Ent) const; + +private: + Program &Prog; + MapTy Map; + CtxTUMapTy CtxTUMap; +}; + +} // namespace idx + +} // namespace clang + +#endif |