diff --git a/uppsrc/ide/Assist.cpp b/uppsrc/ide/Assist.cpp index e097892e6..d79cb0db2 100644 --- a/uppsrc/ide/Assist.cpp +++ b/uppsrc/ide/Assist.cpp @@ -470,12 +470,10 @@ void AssistEditor::Assist() } else { GatherItems(parser.current_scope, false, in_types, true); - Vector usings = Split(parser.context.namespace_using, ';'); - for(int i = 0; i < usings.GetCount(); i++) - if(parser.current_scope != usings[i]) // Do not scan namespace already scanned - GatherItems(usings[i], false, in_types, true); - if(parser.current_scope.GetCount()) // Do not scan global namespace twice - GatherItems("", false, in_types, true); + Vector ns = GetNamespaces(parser); + for(int i = 0; i < ns.GetCount(); i++) + if(parser.current_scope != ns[i]) // Do not scan namespace already scanned + GatherItems(ns[i], false, in_types, true); } } LTIMING("Assist3"); diff --git a/uppsrc/ide/Assist.h b/uppsrc/ide/Assist.h index 4e9f0e04c..7828af6e6 100644 --- a/uppsrc/ide/Assist.h +++ b/uppsrc/ide/Assist.h @@ -1,3 +1,5 @@ +Vector GetNamespaces(const Parser& parser); + struct Navigator { virtual int GetCurrentLine() = 0; diff --git a/uppsrc/ide/ContextGoto.cpp b/uppsrc/ide/ContextGoto.cpp index 33fd8bd5f..9aee77be9 100644 --- a/uppsrc/ide/ContextGoto.cpp +++ b/uppsrc/ide/ContextGoto.cpp @@ -230,6 +230,8 @@ void Ide::ContextGoto0(int pos) } } } + + Vector ns = GetNamespaces(parser); if(qual.GetCount()) { // Ctrl::MOUSELEFT, Vector::Iterator Vector todo; @@ -275,9 +277,12 @@ void Ide::ContextGoto0(int pos) } // Can be unqualified type name like 'String' String t = RemoveTemplateParams(Qualify(CodeBase(), parser.current_scope, id, parser.context.namespace_using)); - if(CodeBase().Find(t) >= 0) { - scope.Add(t); - istype.Add(true); + for(int i = 0; i < ns.GetCount(); i++) { + String tt = Merge("::", ns[i], t); + if(CodeBase().Find(tt) >= 0) { + scope.Add(tt); + istype.Add(true); + } } } @@ -285,16 +290,14 @@ void Ide::ContextGoto0(int pos) usings.Add(""); // Add global namespace too Index done; - for(int i = 0; i < usings.GetCount(); i++) { + for(int i = 0; i < ns.GetCount(); i++) { String r; - if(GetIdScope(r, usings[i], id, done)) { + if(GetIdScope(r, ns[i], id, done)) { scope.Add(r); istype.Add(false); } } -DDUMP(scope); -DDUMP(id); for(int j = 0; j < scope.GetCount(); j++) { q = CodeBase().Find(scope[j]); if(q >= 0) { @@ -302,10 +305,6 @@ DDUMP(id); for(int anyfile = 0; anyfile < 2; anyfile++) for(int pass = 0; pass < 2; pass++) for(int i = 0; i < n.GetCount(); i++) { - DDUMP(i); - DDUMP(n[i].name); - DDUMP(n[i].file); - DDUMP(n[i].line); if(n[i].name == id && (pass || !istype[j] || n[i].IsType()) && (anyfile || findarg(n[i].filetype, FILE_CPP, FILE_C) >= 0)) { diff --git a/uppsrc/ide/Cpp.cpp b/uppsrc/ide/Cpp.cpp index a57cf2789..6afe96b0b 100644 --- a/uppsrc/ide/Cpp.cpp +++ b/uppsrc/ide/Cpp.cpp @@ -148,6 +148,20 @@ void AssistEditor::Context(Parser& parser, int pos) #endif } + +Vector GetNamespaces(const Parser& parser) +{ + Vector ns; + Vector h = Split(parser.current_scope, ':'); + while(h.GetCount()) { + ns.Add(Join(h, "::")); + h.Drop(); + } + ns.Append(Split(parser.context.namespace_using, ';')); + ns.Add(""); // Add global namespace too + return ns; +} + String Qualify(const String& scope, const String& type, const String& usings) { return Qualify(CodeBase(), scope, type, usings); @@ -255,10 +269,9 @@ Index AssistEditor::ExpressionType(const Parser& parser, const Vector usings = Split(parser.context.namespace_using, ';'); - for(int i = 0; i < usings.GetCount(); i++) - ExpressionType(usings[i], parser.context.namespace_using, xp, 0, typeset, false, 0); - ExpressionType("", parser.context.namespace_using, xp, 0, typeset, false, 0); + Vector ns = GetNamespaces(parser); + for(int i = 0; i < ns.GetCount(); i++) + ExpressionType(ns[i], parser.context.namespace_using, xp, 0, typeset, false, 0); return typeset; }