Commit f6f0c810 authored by Roberto Raggi's avatar Roberto Raggi
Browse files

Improved CppCodeCompletion::completeScope(). Added simple support for typedefs.

parent 702e078a
...@@ -515,7 +515,7 @@ int CppCodeCompletion::startCompletion(TextEditor::ITextEditable *editor) ...@@ -515,7 +515,7 @@ int CppCodeCompletion::startCompletion(TextEditor::ITextEditable *editor)
} if ((m_completionOperator == T_DOT || m_completionOperator == T_ARROW) && } if ((m_completionOperator == T_DOT || m_completionOperator == T_ARROW) &&
completeMember(exprTy, resolvedTypes, context)) { completeMember(exprTy, resolvedTypes, context)) {
return m_startPosition; return m_startPosition;
} else if (m_completionOperator == T_COLON_COLON && completeScope(exprTy, resolvedTypes, context)) { } else if (m_completionOperator == T_COLON_COLON && completeScope(resolvedTypes, context)) {
return m_startPosition; return m_startPosition;
} else if (m_completionOperator == T_SIGNAL && completeSignal(exprTy, resolvedTypes, context)) { } else if (m_completionOperator == T_SIGNAL && completeSignal(exprTy, resolvedTypes, context)) {
return m_startPosition; return m_startPosition;
...@@ -682,32 +682,45 @@ bool CppCodeCompletion::completeMember(FullySpecifiedType, ...@@ -682,32 +682,45 @@ bool CppCodeCompletion::completeMember(FullySpecifiedType,
return false; return false;
} }
bool CppCodeCompletion::completeScope(FullySpecifiedType exprTy, bool CppCodeCompletion::completeScope(const QList<TypeOfExpression::Result> &results,
const QList<TypeOfExpression::Result> &resolvedTypes,
const LookupContext &context) const LookupContext &context)
{ {
if (results.isEmpty())
return false; // nothing to do.
// Search for a class or a namespace. // Search for a class or a namespace.
foreach (TypeOfExpression::Result p, resolvedTypes) { TypeOfExpression::Result result(FullySpecifiedType(), 0);
if (p.first->isClass() || p.first->isNamespace()) { foreach (result, results) {
exprTy = p.first; FullySpecifiedType ty = result.first;
if (ty->isClass() || ty->isNamespace())
break; break;
}
} }
if (exprTy->asNamespace()) { FullySpecifiedType exprTy = result.first;
if (! exprTy) {
return false;
} else if (exprTy->asNamespace()) {
QList<Symbol *> candidates; QList<Symbol *> candidates;
foreach (TypeOfExpression::Result p, resolvedTypes) { foreach (TypeOfExpression::Result p, results) {
if (Namespace *ns = p.first->asNamespace()) if (Namespace *ns = p.first->asNamespace())
candidates.append(ns); candidates.append(ns);
} }
completeNamespace(candidates, context); completeNamespace(candidates, context);
} else if (exprTy->isClass()) { } else if (exprTy->isClass()) {
QList<Symbol *> candidates; QList<Symbol *> candidates;
foreach (TypeOfExpression::Result p, resolvedTypes) { foreach (TypeOfExpression::Result p, results) {
if (Class *k = p.first->asClass()) if (Class *k = p.first->asClass())
candidates.append(k); candidates.append(k);
} }
completeClass(candidates, context); completeClass(candidates, context);
} else if (Symbol *symbol = result.second) {
if (symbol->isTypedef()) {
SymbolsForDotAccess symbolsForDotAccess;
const QList<Symbol *> candidates = symbolsForDotAccess(result,
context);
completeClass(candidates, context);
}
} }
return ! m_completions.isEmpty(); return ! m_completions.isEmpty();
......
...@@ -100,8 +100,7 @@ private: ...@@ -100,8 +100,7 @@ private:
const QList<CPlusPlus::TypeOfExpression::Result> &, const QList<CPlusPlus::TypeOfExpression::Result> &,
const CPlusPlus::LookupContext &context); const CPlusPlus::LookupContext &context);
bool completeScope(CPlusPlus::FullySpecifiedType exprTy, bool completeScope(const QList<CPlusPlus::TypeOfExpression::Result> &,
const QList<CPlusPlus::TypeOfExpression::Result> &,
const CPlusPlus::LookupContext &context); const CPlusPlus::LookupContext &context);
void completeNamespace(const QList<CPlusPlus::Symbol *> &candidates, void completeNamespace(const QList<CPlusPlus::Symbol *> &candidates,
......
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