Commit 0ef213df authored by Roberto Raggi's avatar Roberto Raggi
Browse files

Nicer implementation of ::completeScope()

parent c72c84d8
...@@ -775,43 +775,24 @@ bool CppCodeCompletion::completeMember(const QList<TypeOfExpression::Result> &re ...@@ -775,43 +775,24 @@ bool CppCodeCompletion::completeMember(const QList<TypeOfExpression::Result> &re
bool CppCodeCompletion::completeScope(const QList<TypeOfExpression::Result> &results, bool CppCodeCompletion::completeScope(const QList<TypeOfExpression::Result> &results,
const LookupContext &context) const LookupContext &context)
{ {
if (results.isEmpty()) QList<Symbol *> classes, namespaces;
return false; // nothing to do.
// Search for a class or a namespace. foreach (TypeOfExpression::Result result, results) {
TypeOfExpression::Result result;
foreach (result, results) {
FullySpecifiedType ty = result.first; FullySpecifiedType ty = result.first;
if (ty->isClassType() || ty->isNamespaceType()) if (Class *classTy = ty->asClassType())
break; classes.append(classTy);
}
FullySpecifiedType exprTy = result.first; else if (Namespace *namespaceTy = ty->asNamespaceType())
if (! exprTy) { namespaces.append(namespaceTy);
return false;
} else if (exprTy->isNamespaceType()) {
QList<Symbol *> candidates;
foreach (TypeOfExpression::Result p, results) {
if (Namespace *ns = p.first->asNamespaceType())
candidates.append(ns);
}
completeNamespace(candidates, context);
} else if (exprTy->isClassType()) {
QList<Symbol *> candidates;
foreach (TypeOfExpression::Result p, results) {
if (Class *k = p.first->asClassType())
candidates.append(k);
}
completeClass(candidates, context);
} else if (Symbol *symbol = result.second) {
if (symbol->isTypedef()) {
ResolveClass resolveClass;
const QList<Symbol *> candidates = resolveClass(result, context);
completeClass(candidates, context);
}
} }
if (! classes.isEmpty())
completeClass(classes, context);
else if (! namespaces.isEmpty() && m_completions.isEmpty())
completeNamespace(namespaces, context);
return ! m_completions.isEmpty(); return ! m_completions.isEmpty();
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment