diff --git a/src/source_clang.cc b/src/source_clang.cc index d4ed42e..8e0a9e2 100644 --- a/src/source_clang.cc +++ b/src/source_clang.cc @@ -555,15 +555,10 @@ void Source::ClangViewAutocomplete::autocomplete_dialog_setup() { } } //Fixes for the most commonly used stream manipulators - //TODO: feel free to add more - if(row=="endl(basic_ostream<_CharT, _Traits> &__os)") - row="endl"; - else if(row=="flush(basic_ostream<_CharT, _Traits> &__os)") - row="flush"; - else if(row=="hex(std::ios_base &__str)" || row=="hex(std::ios_base &__base)") - row="hex"; - else if(row=="dec(std::ios_base &__str)" || row=="dec(std::ios_base &__base)") - row="dec"; + static auto manipulators_map=autocomplete_manipulators_map(); + auto it=manipulators_map.find(row); + if(it!=manipulators_map.end()) + row=it->second; get_buffer()->insert(autocomplete_dialog->start_mark->get_iter(), row); //if selection is finalized, select text inside template arguments or function parameters if(hide_window) { @@ -787,6 +782,18 @@ std::vector Source::ClangViewAu return suggestions; } +std::unordered_map Source::ClangViewAutocomplete::autocomplete_manipulators_map() { + std::unordered_map map; + //TODO: feel free to add more + map["endl(basic_ostream<_CharT, _Traits> &__os)"]="endl"; + map["flush(basic_ostream<_CharT, _Traits> &__os)"]="flush"; + map["hex(std::ios_base &__str)"]="hex"; //clang++ headers + map["hex(std::ios_base &__base)"]="hex"; //g++ headers + map["dec(std::ios_base &__str)"]="dec"; + map["dec(std::ios_base &__base)"]="dec"; + return map; +} + void Source::ClangViewAutocomplete::async_delete() { parsing_in_progress->cancel("canceled, freeing resources in the background"); parse_state=ParseState::STOP; diff --git a/src/source_clang.h b/src/source_clang.h index ac7b7e8..a108aae 100644 --- a/src/source_clang.h +++ b/src/source_clang.h @@ -89,6 +89,7 @@ namespace Source { Tooltips autocomplete_tooltips; std::string prefix; std::mutex prefix_mutex; + static std::unordered_map autocomplete_manipulators_map(); Glib::Dispatcher do_delete_object; std::thread delete_thread;