mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-07-11 22:03:01 -06:00
cpp: namespace issues resolved
git-svn-id: svn://ultimatepp.org/upp/trunk@8541 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
b262f847c5
commit
27b15afd7b
4 changed files with 33 additions and 21 deletions
|
|
@ -470,12 +470,10 @@ void AssistEditor::Assist()
|
|||
}
|
||||
else {
|
||||
GatherItems(parser.current_scope, false, in_types, true);
|
||||
Vector<String> 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<String> 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");
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
Vector<String> GetNamespaces(const Parser& parser);
|
||||
|
||||
struct Navigator {
|
||||
virtual int GetCurrentLine() = 0;
|
||||
|
||||
|
|
|
|||
|
|
@ -230,6 +230,8 @@ void Ide::ContextGoto0(int pos)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
Vector<String> ns = GetNamespaces(parser);
|
||||
|
||||
if(qual.GetCount()) { // Ctrl::MOUSELEFT, Vector<String>::Iterator
|
||||
Vector<String> 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<String> 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)) {
|
||||
|
|
|
|||
|
|
@ -148,6 +148,20 @@ void AssistEditor::Context(Parser& parser, int pos)
|
|||
#endif
|
||||
}
|
||||
|
||||
|
||||
Vector<String> GetNamespaces(const Parser& parser)
|
||||
{
|
||||
Vector<String> ns;
|
||||
Vector<String> 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<String> AssistEditor::ExpressionType(const Parser& parser, const Vector<St
|
|||
return typeset;
|
||||
}
|
||||
}
|
||||
Vector<String> 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<String> 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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue