|
|
|
@ -1,4 +1,5 @@ |
|
|
|
#include "Token.h" |
|
|
|
#include "Token.h" |
|
|
|
|
|
|
|
#include "Utility.h" |
|
|
|
|
|
|
|
|
|
|
|
// // // // //
|
|
|
|
// // // // //
|
|
|
|
// Token //
|
|
|
|
// Token //
|
|
|
|
@ -16,8 +17,7 @@ clang::SourceRange clang::Token::get_source_range() { |
|
|
|
} |
|
|
|
} |
|
|
|
// returns a string description of this tokens kind
|
|
|
|
// returns a string description of this tokens kind
|
|
|
|
std::string clang::Token::get_spelling() { |
|
|
|
std::string clang::Token::get_spelling() { |
|
|
|
CXString s = clang_getTokenSpelling(cx_tu, cx_token); |
|
|
|
return clang::to_string(clang_getTokenSpelling(cx_tu, cx_token)); |
|
|
|
return std::string(clang_getCString(s)); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const clang::TokenKind clang::Token::get_kind() { |
|
|
|
const clang::TokenKind clang::Token::get_kind() { |
|
|
|
@ -30,9 +30,7 @@ bool clang::Token::has_type() { |
|
|
|
if(clang_Cursor_isNull(referenced)) |
|
|
|
if(clang_Cursor_isNull(referenced)) |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
auto type=clang_getCursorType(referenced); |
|
|
|
auto type=clang_getCursorType(referenced); |
|
|
|
auto cxstr=clang_getTypeSpelling(type); |
|
|
|
auto spelling=clang::to_string(clang_getTypeSpelling(type)); |
|
|
|
std::string spelling=clang_getCString(cxstr); |
|
|
|
|
|
|
|
clang_disposeString(cxstr); |
|
|
|
|
|
|
|
return spelling!=""; |
|
|
|
return spelling!=""; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -41,17 +39,13 @@ std::string clang::Token::get_type() { |
|
|
|
auto referenced=clang_getCursorReferenced(cx_cursor); |
|
|
|
auto referenced=clang_getCursorReferenced(cx_cursor); |
|
|
|
if(!clang_Cursor_isNull(referenced)) { |
|
|
|
if(!clang_Cursor_isNull(referenced)) { |
|
|
|
auto type=clang_getCursorType(referenced); |
|
|
|
auto type=clang_getCursorType(referenced); |
|
|
|
auto cxstr=clang_getTypeSpelling(type); |
|
|
|
spelling=clang::to_string(clang_getTypeSpelling(type)); |
|
|
|
spelling=clang_getCString(cxstr); |
|
|
|
|
|
|
|
clang_disposeString(cxstr); |
|
|
|
|
|
|
|
std::string auto_end=""; |
|
|
|
std::string auto_end=""; |
|
|
|
//TODO fix const auto
|
|
|
|
//TODO fix const auto
|
|
|
|
if((spelling.size()>=4 && spelling.substr(0, 4)=="auto")) { |
|
|
|
if((spelling.size()>=4 && spelling.substr(0, 4)=="auto")) { |
|
|
|
auto_end=spelling.substr(4); |
|
|
|
auto_end=spelling.substr(4); |
|
|
|
auto type=clang_getCanonicalType(clang_getCursorType(cx_cursor)); |
|
|
|
auto type=clang_getCanonicalType(clang_getCursorType(cx_cursor)); |
|
|
|
auto cxstr=clang_getTypeSpelling(type); |
|
|
|
spelling=clang::to_string(clang_getTypeSpelling(type)); |
|
|
|
spelling=clang_getCString(cxstr); |
|
|
|
|
|
|
|
clang_disposeString(cxstr); |
|
|
|
|
|
|
|
if(spelling.find(" ")==std::string::npos) |
|
|
|
if(spelling.find(" ")==std::string::npos) |
|
|
|
spelling+=auto_end; |
|
|
|
spelling+=auto_end; |
|
|
|
} |
|
|
|
} |
|
|
|
@ -63,10 +57,7 @@ std::string clang::Token::get_brief_comments() { |
|
|
|
std::string comment_string; |
|
|
|
std::string comment_string; |
|
|
|
auto referenced=get_cursor().get_referenced(); |
|
|
|
auto referenced=get_cursor().get_referenced(); |
|
|
|
if(referenced) { |
|
|
|
if(referenced) { |
|
|
|
auto cxstr=clang_Cursor_getBriefCommentText(referenced.cx_cursor); |
|
|
|
comment_string=clang::to_string(clang_Cursor_getBriefCommentText(referenced.cx_cursor)); |
|
|
|
if(cxstr.data!=NULL) |
|
|
|
|
|
|
|
comment_string=clang_getCString(cxstr); |
|
|
|
|
|
|
|
clang_disposeString(cxstr); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
return comment_string; |
|
|
|
return comment_string; |
|
|
|
} |
|
|
|
} |
|
|
|
|