mirror of https://gitlab.com/cppit/libclangmm
28 changed files with 243 additions and 139 deletions
@ -1,16 +1,12 @@ |
|||||||
#ifndef INDEX_H_ |
#ifndef INDEX_H_ |
||||||
#define INDEX_H_ |
#define INDEX_H_ |
||||||
|
|
||||||
#include <clang-c/Index.h> |
#include <clang-c/Index.h> |
||||||
|
|
||||||
namespace clang { |
namespace clang { |
||||||
class TranslationUnit; |
|
||||||
class Index { |
class Index { |
||||||
public: |
public: |
||||||
Index(int excludeDeclarationsFromPCH, int displayDiagnostics); |
Index(int excludeDeclarationsFromPCH, int displayDiagnostics); |
||||||
private: |
|
||||||
CXIndex index_; |
CXIndex index_; |
||||||
friend TranslationUnit; |
|
||||||
}; |
}; |
||||||
} // namespace clang
|
} // namespace clang
|
||||||
#endif // INDEX_H_
|
#endif // INDEX_H_
|
||||||
|
|||||||
@ -1,23 +1,32 @@ |
|||||||
#ifndef SOURCERANGE_H_ |
#ifndef SOURCERANGE_H_ |
||||||
#define SOURCERANGE_H_ |
#define SOURCERANGE_H_ |
||||||
#include "TranslationUnit.h" |
#include <clang-c/Index.h> |
||||||
#include "Token.h" |
#include "Token.h" |
||||||
#include "Cursor.h" |
#include "Cursor.h" |
||||||
|
#include "SourceLocation.h" |
||||||
|
#include <string> |
||||||
|
|
||||||
namespace clang { |
namespace clang { |
||||||
|
class Token; |
||||||
|
class SourceLocation; |
||||||
|
class Cursor; |
||||||
|
|
||||||
|
class RangeData { |
||||||
|
public: |
||||||
|
std::string path; |
||||||
|
unsigned start_offset, end_offset; |
||||||
|
}; |
||||||
|
|
||||||
class SourceRange { |
class SourceRange { |
||||||
public: |
public: |
||||||
SourceRange() {} |
SourceRange() {} |
||||||
SourceRange(TranslationUnit *tu, Token *token); |
SourceRange(Token *token); |
||||||
SourceRange(SourceLocation *start, |
SourceRange(SourceLocation *start, |
||||||
SourceLocation *end); |
SourceLocation *end); |
||||||
explicit SourceRange(Cursor *cursor); |
explicit SourceRange(Cursor *cursor); |
||||||
|
static RangeData get_range_data(SourceLocation &start, SourceLocation &end); |
||||||
private: |
RangeData get_range_data(); |
||||||
CXSourceRange range_; |
CXSourceRange range_; |
||||||
friend Tokens; |
|
||||||
friend SourceLocation; |
|
||||||
friend Diagnostic; |
|
||||||
}; |
}; |
||||||
} // namespace clang
|
} // namespace clang
|
||||||
#endif // SOURCERANGE_H_
|
#endif // SOURCERANGE_H_
|
||||||
|
|||||||
@ -1,21 +1,29 @@ |
|||||||
#ifndef TOKENS_H_ |
#ifndef TOKENS_H_ |
||||||
#define TOKENS_H_ |
#define TOKENS_H_ |
||||||
#include "TranslationUnit.h" |
#include <clang-c/Index.h> |
||||||
#include "SourceRange.h" |
#include "SourceRange.h" |
||||||
#include "Token.h" |
#include "Token.h" |
||||||
|
#include <unordered_map> |
||||||
|
#include <vector> |
||||||
|
|
||||||
namespace clang { |
namespace clang { |
||||||
class Tokens : public std::vector<clang::Token> { |
class Tokens : public std::vector<clang::Token> { |
||||||
public: |
public: |
||||||
Tokens(TranslationUnit *tu, SourceRange *range); |
Tokens(CXTranslationUnit &tu, SourceRange *range); |
||||||
~Tokens(); |
~Tokens(); |
||||||
void update_types(clang::TranslationUnit *tu); |
void update_types(); |
||||||
std::string get_brief_comments(size_t cursor_id); |
std::string get_brief_comments(size_t cursor_id); |
||||||
|
CXCursor find_referenced(); |
||||||
|
bool equalCursors(CXCursor a, CXCursor b); |
||||||
|
void rename(CXCursor &referenced, std::unordered_map<std::string, std::unordered_multimap<unsigned, unsigned> > &ranges); |
||||||
|
|
||||||
private: |
private: |
||||||
CXToken *tokens_; |
CXToken *tokens_; |
||||||
unsigned num_tokens_; |
unsigned num_tokens_; |
||||||
std::vector<CXCursor> clang_cursors; |
std::vector<CXCursor> clang_cursors; |
||||||
TranslationUnit& tu; |
CXTranslationUnit& tu; |
||||||
|
|
||||||
|
static CXChildVisitResult clang_visitor(CXCursor cursor, CXCursor parent, CXClientData clientData); |
||||||
}; |
}; |
||||||
} // namespace clang
|
} // namespace clang
|
||||||
#endif // TOKENS_H_
|
#endif // TOKENS_H_
|
||||||
|
|||||||
Loading…
Reference in new issue