diff --git a/src/source_clang.cpp b/src/source_clang.cpp index 7ee0d72..78d46c9 100644 --- a/src/source_clang.cpp +++ b/src/source_clang.cpp @@ -270,8 +270,8 @@ void Source::ClangViewParse::update_syntax() { for(size_t c = 0; c < clang_tokens->size(); ++c) { auto &token = (*clang_tokens)[c]; auto &token_offsets = clang_tokens_offsets[c]; - //if(token.get_kind()==clangmm::Token::Kind::Token_Punctuation) - //ranges.emplace_back(token_offset, static_cast(token.get_cursor().get_kind())); + // if(token.get_kind()==clangmm::Token::Kind::Token_Punctuation) + // ranges.emplace_back(token_offset, static_cast(token.get_cursor().get_kind())); auto token_kind = token.get_kind(); if(token_kind == clangmm::Token::Kind::Keyword) apply_tag(token_offsets, 702); @@ -420,8 +420,9 @@ void Source::ClangViewParse::update_diagnostics() { } } if(diagnostic.severity >= clangmm::Diagnostic::Severity::Error && - starts_with(diagnostic.spelling, "variable has incomplete type '")) { - size_t start = 30; + (starts_with(diagnostic.spelling, "variable has incomplete type '") || + starts_with(diagnostic.spelling, "member access into incomplete type '"))) { + auto start = diagnostic.spelling.find('\'') + 1; auto end = diagnostic.spelling.find('\'', start); if(end != std::string::npos) { auto type = diagnostic.spelling.substr(start, end - start); @@ -1110,9 +1111,9 @@ Source::ClangViewAutocomplete::ClangViewAutocomplete(const boost::filesystem::pa row = text.substr(0, pos); else row = text; - //erase existing variable or function before insert iter + // Erase existing variable or function before insert iter get_buffer()->erase(CompletionDialog::get()->start_mark->get_iter(), get_buffer()->get_insert()->get_iter()); - //do not insert template argument or function parameters if they already exist + // Do not insert template argument or function parameters if they already exist auto iter = get_buffer()->get_insert()->get_iter(); if(*iter == '<' || *iter == '(') { auto bracket_pos = row.find(*iter); @@ -1120,12 +1121,12 @@ Source::ClangViewAutocomplete::ClangViewAutocomplete(const boost::filesystem::pa row = row.substr(0, bracket_pos); } } - //Fixes for the most commonly used stream manipulators + // Fixes for the most commonly used stream manipulators auto manipulators_map = autocomplete_manipulators_map(); auto it = manipulators_map.find(row); if(it != manipulators_map.end()) row = it->second; - //Do not insert template argument, function parameters or ':' unless hide_window is true + // Do not insert template argument, function parameters or ':' unless hide_window is true if(!hide_window) { for(size_t c = 0; c < row.size(); ++c) { if(row[c] == '<' || row[c] == '(' || row[c] == ':') { @@ -1139,7 +1140,7 @@ Source::ClangViewAutocomplete::ClangViewAutocomplete(const boost::filesystem::pa row.pop_back(); get_buffer()->insert(CompletionDialog::get()->start_mark->get_iter(), row); - //if selection is finalized, select text inside template arguments or function parameters + // If selection is finalized, select text inside template arguments or function parameters if(hide_window) { size_t start_pos = std::string::npos; size_t end_pos = std::string::npos; @@ -1185,7 +1186,7 @@ Source::ClangViewAutocomplete::ClangViewAutocomplete(const boost::filesystem::pa get_buffer()->select_range(get_buffer()->get_iter_at_offset(start_offset), get_buffer()->get_iter_at_offset(end_offset)); } else { - //new autocomplete after for instance when selecting "std::" + // New autocomplete after for instance when selecting "std::" auto iter = get_buffer()->get_insert()->get_iter(); if(iter.backward_char() && *iter == ':') { autocomplete.run(); @@ -1206,12 +1207,12 @@ Source::ClangViewAutocomplete::ClangViewAutocomplete(const boost::filesystem::pa } const std::unordered_map &Source::ClangViewAutocomplete::autocomplete_manipulators_map() { - //TODO: feel free to add more + // TODO: feel free to add more static std::unordered_map map = { {"endl(basic_ostream<_CharT, _Traits> &__os)", "endl"}, {"flush(basic_ostream<_CharT, _Traits> &__os)", "flush"}, - {"hex(std::ios_base &__str)", "hex"}, //clang++ headers - {"hex(std::ios_base &__base)", "hex"}, //g++ headers + {"hex(std::ios_base &__str)", "hex"}, // clang++ headers + {"hex(std::ios_base &__base)", "hex"}, // g++ headers {"dec(std::ios_base &__str)", "dec"}, {"dec(std::ios_base &__base)", "dec"}}; return map; @@ -1694,7 +1695,7 @@ Source::ClangViewRefactor::ClangViewRefactor(const boost::filesystem::path &file return usages; auto embolden_token = [](std::string &line, unsigned token_start_pos, unsigned token_end_pos) { - //markup token as bold + // Markup token as bold size_t pos = 0; while((pos = line.find('&', pos)) != std::string::npos) { size_t pos2 = line.find(';', pos + 2);