|
|
|
|
@ -17,16 +17,11 @@ clang::Tokens::~Tokens() {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void clang::Tokens::update_types(clang::TranslationUnit *tu) { |
|
|
|
|
std::vector<CXCursor> clang_cursors(size()); |
|
|
|
|
clang_cursors.clear(); |
|
|
|
|
clang_cursors.reserve(size()); |
|
|
|
|
clang_annotateTokens(tu->tu_, tokens_, size(), clang_cursors.data()); |
|
|
|
|
|
|
|
|
|
std::vector<clang::Cursor> cursors; |
|
|
|
|
for(auto clang_cursor: clang_cursors) { |
|
|
|
|
cursors.emplace_back(); |
|
|
|
|
cursors.back().cursor_=clang_cursor; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
for(int c=0;c<size();c++) { |
|
|
|
|
for(size_t c=0;c<size();c++) { |
|
|
|
|
auto referenced=clang_getCursorReferenced(clang_cursors[c]); |
|
|
|
|
if(!clang_Cursor_isNull(referenced)) { |
|
|
|
|
auto type=clang_getCursorType(referenced); |
|
|
|
|
@ -44,6 +39,7 @@ void clang::Tokens::update_types(clang::TranslationUnit *tu) {
|
|
|
|
|
if(spelling.find(" ")==std::string::npos) |
|
|
|
|
spelling+=auto_end; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
(*this)[c].type=spelling; |
|
|
|
|
//std::cout << clang_getCString(clang_getTypeSpelling(type)) << ": " << type.kind << endl;
|
|
|
|
|
////auto cursor=clang_getTypeDeclaration(type);
|
|
|
|
|
@ -83,4 +79,58 @@ void clang::Tokens::update_types(clang::TranslationUnit *tu) {
|
|
|
|
|
} |
|
|
|
|
}*/ |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
std::string clang::Tokens::get_brief_comment(size_t cursor_id) { |
|
|
|
|
std::string comment_string; |
|
|
|
|
auto referenced=clang_getCursorReferenced(clang_cursors[cursor_id]); |
|
|
|
|
auto comment=clang_Cursor_getParsedComment(referenced); |
|
|
|
|
if(clang_Comment_getKind(comment)==CXComment_FullComment) { |
|
|
|
|
size_t para_c=0; |
|
|
|
|
for(unsigned c=0;c<clang_Comment_getNumChildren(comment);c++) { |
|
|
|
|
auto child_comment=clang_Comment_getChild(comment, c); |
|
|
|
|
if(clang_Comment_getKind(child_comment)==CXComment_Paragraph) { |
|
|
|
|
para_c++; |
|
|
|
|
if(para_c>=2) |
|
|
|
|
break; |
|
|
|
|
for(unsigned c=0;c<clang_Comment_getNumChildren(child_comment);c++) { |
|
|
|
|
auto grandchild_comment=clang_Comment_getChild(child_comment, c); |
|
|
|
|
if(clang_Comment_getKind(grandchild_comment)==CXComment_Text) { |
|
|
|
|
auto cxstr=clang_TextComment_getText(grandchild_comment); |
|
|
|
|
comment_string+=clang_getCString(cxstr); |
|
|
|
|
comment_string+="\n"; |
|
|
|
|
clang_disposeString(cxstr); |
|
|
|
|
size_t dot_position=comment_string.find("."); |
|
|
|
|
if(dot_position!=std::string::npos) |
|
|
|
|
return comment_string.substr(0, dot_position); |
|
|
|
|
} |
|
|
|
|
if(clang_Comment_getKind(grandchild_comment)==CXComment_InlineCommand) { |
|
|
|
|
auto cxstr=clang_InlineCommandComment_getCommandName(grandchild_comment); |
|
|
|
|
if(comment_string.size()>0) |
|
|
|
|
comment_string.pop_back(); |
|
|
|
|
if(clang_InlineCommandComment_getNumArgs(grandchild_comment)==0) |
|
|
|
|
comment_string+=clang_getCString(cxstr); |
|
|
|
|
clang_disposeString(cxstr); |
|
|
|
|
for(unsigned arg_c=0;arg_c<clang_InlineCommandComment_getNumArgs(grandchild_comment);arg_c++) { |
|
|
|
|
auto cxstr=clang_InlineCommandComment_getArgText(grandchild_comment, arg_c); |
|
|
|
|
if(cxstr.data!=NULL) { |
|
|
|
|
if(arg_c>0) |
|
|
|
|
comment_string+=" "; |
|
|
|
|
comment_string+=clang_getCString(cxstr); |
|
|
|
|
clang_disposeString(cxstr); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
/*cout << " " << clang_Comment_getKind(child_comment) << ", children: " << clang_Comment_getNumChildren(child_comment) << endl;
|
|
|
|
|
auto cxstr=clang_FullComment_getAsHTML(child_comment); |
|
|
|
|
cout << " " << clang_getCString(cxstr) << endl; |
|
|
|
|
clang_disposeString(cxstr);*/ |
|
|
|
|
} |
|
|
|
|
while(comment_string.size()>0 && (comment_string.back()=='\n' || comment_string.back()==' ')) |
|
|
|
|
comment_string.pop_back(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return comment_string; |
|
|
|
|
} |