From 8224a1f76e4ca935afda579bcb6420d3b97d0b63 Mon Sep 17 00:00:00 2001 From: eidheim Date: Sat, 19 Sep 2015 12:19:34 +0200 Subject: [PATCH] clang::Cursor and clang::Token cleanup. --- src/source.cc | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/source.cc b/src/source.cc index 1abec3b..b9e91b7 100644 --- a/src/source.cc +++ b/src/source.cc @@ -1446,15 +1446,16 @@ void Source::ClangViewParse::show_type_tooltips(const Gdk::Rectangle &rectangle) type_tooltips.clear(); for(auto &token: *tokens) { - if(token.get_kind()==clang::Token_Identifier && token.has_type()) { + auto cursor=token.get_cursor(); + if(token.get_kind()==clang::Token_Identifier && cursor.has_type()) { if(static_cast(token.get_cursor().get_kind())==103) //These cursors are buggy continue; auto start=get_buffer()->get_iter_at_line_index(token.offsets.first.line-1, token.offsets.first.index-1); auto end=get_buffer()->get_iter_at_line_index(token.offsets.second.line-1, token.offsets.second.index-1); auto create_tooltip_buffer=[this, &token]() { auto tooltip_buffer=Gtk::TextBuffer::create(get_buffer()->get_tag_table()); - tooltip_buffer->insert_with_tag(tooltip_buffer->get_insert()->get_iter(), "Type: "+token.get_type(), "def:note"); - auto brief_comment=token.get_brief_comments(); + tooltip_buffer->insert_with_tag(tooltip_buffer->get_insert()->get_iter(), "Type: "+token.get_cursor().get_type(), "def:note"); + auto brief_comment=token.get_cursor().get_brief_comments(); if(brief_comment!="") tooltip_buffer->insert_with_tag(tooltip_buffer->get_insert()->get_iter(), "\n\n"+brief_comment, "def:note"); return tooltip_buffer; @@ -1949,11 +1950,12 @@ Source::ClangViewAutocomplete(file_path, project_path, language) { auto line=(unsigned)iter.get_line(); auto index=(unsigned)iter.get_line_index(); for(auto &token: *clang_tokens) { - if(token.get_kind()==clang::Token_Identifier && token.has_type()) { + auto cursor=token.get_cursor(); + if(token.get_kind()==clang::Token_Identifier && cursor.has_type()) { if(line==token.offsets.first.line-1 && index>=token.offsets.first.index-1 && index <=token.offsets.second.index-1) { if(static_cast(token.get_cursor().get_kind())==103) //These cursors are buggy continue; - auto referenced=token.get_cursor().get_referenced(); + auto referenced=cursor.get_referenced(); if(referenced) return {referenced.get_usr(), static_cast(referenced.get_kind())}; } @@ -1969,7 +1971,7 @@ Source::ClangViewAutocomplete(file_path, project_path, language) { auto line=(unsigned)iter.get_line(); auto index=(unsigned)iter.get_line_index(); for(auto &token: *clang_tokens) { - if(token.get_kind()==clang::Token_Identifier && token.has_type()) { + if(token.get_kind()==clang::Token_Identifier && token.get_cursor().has_type()) { if(line==token.offsets.first.line-1 && index>=token.offsets.first.index-1 && index <=token.offsets.second.index-1) { return token.get_spelling(); } @@ -2037,9 +2039,10 @@ Source::ClangViewAutocomplete(file_path, project_path, language) { auto line=(unsigned)iter.get_line(); auto index=(unsigned)iter.get_line_index(); for(auto &token: *clang_tokens) { - if(token.get_kind()==clang::Token_Identifier && token.has_type()) { + auto cursor=token.get_cursor(); + if(token.get_kind()==clang::Token_Identifier && cursor.has_type()) { if(line==token.offsets.first.line-1 && index>=token.offsets.first.index-1 && index <=token.offsets.second.index-1) { - auto referenced=token.get_cursor().get_referenced(); + auto referenced=cursor.get_referenced(); if(referenced) { location.first=referenced.get_source_location().get_path(); location.second=referenced.get_source_location().get_offset();