diff --git a/uppsrc/ide/Assist.cpp b/uppsrc/ide/Assist.cpp index 2d04788c2..0b06a1074 100644 --- a/uppsrc/ide/Assist.cpp +++ b/uppsrc/ide/Assist.cpp @@ -278,12 +278,30 @@ void AssistEditor::SyncAssist() assist_item_ndx.Clear(); int typei = type.GetCursor() - 1; Buffer found(assist_item.GetCount(), false); + VectorMap found_name; // to accelerate resolving duplicities + Index cpp; for(int pass = 0; pass < 2; pass++) { for(int i = 0; i < assist_item.GetCount(); i++) { const AssistItem& m = assist_item[i]; if(!found[i] && (typei < 0 || m.typei == typei) && ((pass ? m.uname.StartsWith(uname) : m.name.StartsWith(name)) || m.kind == KIND_ERROR)) { + int q = found_name.Find(m.name); + if(q >= 0) { // resolve duplicities + int& ii = found_name[q]; + if(ii >= 0) { // lazy call to CppText + const AssistItem& mm = assist_item[ii]; + cpp.FindAdd(CppText(mm.name, mm.pretty)); + ii = -1; + } + String g = CppText(m.name, m.pretty); + if(cpp.Find(g) >= 0) + continue; + else + cpp.Add(g); + } + else + found_name.Add(m.name, i); found[i] = true; assist_item_ndx.Add(i); } diff --git a/uppsrc/ide/AssistDisplay.cpp b/uppsrc/ide/AssistDisplay.cpp index 23e1b9544..6bf1a92aa 100644 --- a/uppsrc/ide/AssistDisplay.cpp +++ b/uppsrc/ide/AssistDisplay.cpp @@ -117,6 +117,35 @@ int PaintCpp(Draw& w, const Rect& r, int kind, const String& name, const String& return x; } +String CppText(const String& name, const String& pretty) +{ // converts pretty to text that is unique wrt PaintCpp - to avoid duplicities in autocomplete + String g; + Vector n = ParsePretty(name, pretty); + for(int i = 0; i < n.GetCount(); i++) + if(findarg(n[i].type, ITEM_NAME, ITEM_OPERATOR) >= 0 || pretty[n[i].pos] == '(') { + for(int j = i; j < n.GetCount(); j++) + g << pretty.Mid(n[j].pos, n[j].len); + while(i) { + const ItemTextPart& p = n[i - 1]; + if(p.len == 1 && pretty[p.pos] == ' ') + i--; + else + break; + } + g << '@'; + if(i > 2) { // autocomplete sometimes fully qualifies the the name, looks ugly, remove XXX:: from the end + ItemTextPart& p = n[i - 1]; + if(p.type == ITEM_CPP && p.len == 2 && pretty[p.pos] == ':' && pretty[p.pos + 1] == ':' && + n[i - 2].type == ITEM_TEXT) + i -= 2; + } + for(int j = 0; j < i; j++) + g << pretty.Mid(n[j].pos, n[j].len); + break; + } + return TrimBoth(g); +} + void AssistEditor::AssistDisplay::Paint(Draw& w, const Rect& r, const Value& q, Color ink, Color paper, dword style) const { int ii = q; diff --git a/uppsrc/ide/clang/clang.h b/uppsrc/ide/clang/clang.h index 7fdfabbd3..c383f1a01 100644 --- a/uppsrc/ide/clang/clang.h +++ b/uppsrc/ide/clang/clang.h @@ -92,6 +92,7 @@ enum AdditionalKinds { Image CxxIcon(int kind); // TODO: Move here int PaintCpp(Draw& w, const Rect& r, int kind, const String& name, const String& pretty, Color ink, bool focuscursor, bool retval_last = false); String SignatureQtf(const String& name, const String& pretty, int pari = INT_MAX); +String CppText(const String& name, const String& pretty); bool IsStruct(int kind); bool IsTemplate(int kind);