2017-02-16 09:35:30 +00:00
|
|
|
#ifndef CURSOR_H_
|
|
|
|
#define CURSOR_H_
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
2017-02-17 09:57:44 +00:00
|
|
|
#include <type_traits>
|
2017-02-16 09:35:30 +00:00
|
|
|
|
2017-02-17 09:57:44 +00:00
|
|
|
#include <clang-c/Index.h>
|
2017-02-16 09:35:30 +00:00
|
|
|
#include "SourceLocation.h"
|
|
|
|
#include "SourceRange.h"
|
|
|
|
|
|
|
|
|
|
|
|
namespace clang {
|
2017-02-17 09:57:44 +00:00
|
|
|
|
|
|
|
class Type {
|
|
|
|
public:
|
2017-02-18 19:37:24 +00:00
|
|
|
Type();
|
|
|
|
Type(const CXType& other);
|
2017-02-17 09:57:44 +00:00
|
|
|
|
|
|
|
bool operator==(const Type& rhs) const;
|
|
|
|
|
2017-02-19 02:03:13 +00:00
|
|
|
// Returns true if this is a fundamental type like int.
|
|
|
|
bool is_fundamental() const;
|
|
|
|
|
2017-02-18 19:37:24 +00:00
|
|
|
std::string get_usr() const;
|
2017-02-17 09:57:44 +00:00
|
|
|
std::string get_spelling() const;
|
2017-02-19 00:53:31 +00:00
|
|
|
|
|
|
|
// Try to resolve this type and remove qualifies, ie, Foo* will become Foo
|
|
|
|
Type strip_qualifiers() const;
|
|
|
|
|
2017-02-18 19:37:24 +00:00
|
|
|
Type get_return_type() const;
|
|
|
|
std::vector<Type> get_arguments() const;
|
2017-02-17 09:57:44 +00:00
|
|
|
|
|
|
|
CXType cx_type;
|
|
|
|
};
|
|
|
|
|
|
|
|
enum class VisiterResult {
|
|
|
|
Break,
|
|
|
|
Continue,
|
|
|
|
Recurse
|
|
|
|
};
|
|
|
|
|
|
|
|
class Cursor {
|
|
|
|
public:
|
|
|
|
Cursor();
|
|
|
|
explicit Cursor(const CXCursor& other);
|
|
|
|
|
|
|
|
operator bool() const;
|
|
|
|
bool operator==(const Cursor& rhs) const;
|
|
|
|
|
|
|
|
CXCursorKind get_kind() const;
|
|
|
|
Type get_type() const;
|
|
|
|
SourceLocation get_source_location() const;
|
2017-02-18 19:37:24 +00:00
|
|
|
//SourceRange get_source_range() const;
|
2017-02-17 09:57:44 +00:00
|
|
|
std::string get_spelling() const;
|
|
|
|
std::string get_display_name() const;
|
|
|
|
std::string get_usr() const;
|
|
|
|
|
|
|
|
bool is_definition() const;
|
|
|
|
|
|
|
|
Cursor get_referenced() const;
|
|
|
|
Cursor get_canonical() const;
|
|
|
|
Cursor get_definition() const;
|
|
|
|
Cursor get_semantic_parent() const;
|
|
|
|
std::vector<Cursor> get_arguments() const;
|
|
|
|
bool is_valid_kind() const;
|
2017-02-18 23:58:40 +00:00
|
|
|
|
|
|
|
std::string evaluate() const;
|
|
|
|
|
2017-02-17 09:57:44 +00:00
|
|
|
std::string get_type_description() const;
|
|
|
|
std::string get_comments() const;
|
|
|
|
|
2017-02-18 19:37:24 +00:00
|
|
|
std::string ToString() const;
|
|
|
|
|
2017-02-17 09:57:44 +00:00
|
|
|
template<typename TClientData>
|
|
|
|
using Visitor = VisiterResult(*)(Cursor cursor, Cursor parent, TClientData* client_data);
|
|
|
|
|
|
|
|
enum class VisitResult {
|
|
|
|
Completed, EndedEarly
|
2017-02-16 09:35:30 +00:00
|
|
|
};
|
2017-02-17 09:57:44 +00:00
|
|
|
|
|
|
|
template<typename TClientData>
|
|
|
|
VisitResult VisitChildren(Visitor<TClientData> visitor, TClientData* client_data) const {
|
|
|
|
if (clang_visitChildren(cx_cursor, reinterpret_cast<CXCursorVisitor>(visitor), client_data) == 0)
|
|
|
|
return VisitResult::Completed;
|
|
|
|
return VisitResult::EndedEarly;
|
|
|
|
}
|
|
|
|
|
|
|
|
CXCursor cx_cursor;
|
|
|
|
};
|
2017-02-16 09:35:30 +00:00
|
|
|
} // namespace clang
|
2017-02-17 09:57:44 +00:00
|
|
|
|
2017-02-16 09:35:30 +00:00
|
|
|
#endif // CURSOR_H_
|