Commit 12ee869e authored by Roberto Raggi's avatar Roberto Raggi
Browse files

Simple typedef support for T_ARROW member access.

parent f6f0c810
...@@ -513,7 +513,7 @@ int CppCodeCompletion::startCompletion(TextEditor::ITextEditable *editor) ...@@ -513,7 +513,7 @@ int CppCodeCompletion::startCompletion(TextEditor::ITextEditable *editor)
if (m_completionOperator == T_LPAREN && completeFunction(exprTy, resolvedTypes, context)) { if (m_completionOperator == T_LPAREN && completeFunction(exprTy, resolvedTypes, context)) {
return m_startPosition; return m_startPosition;
} if ((m_completionOperator == T_DOT || m_completionOperator == T_ARROW) && } if ((m_completionOperator == T_DOT || m_completionOperator == T_ARROW) &&
completeMember(exprTy, resolvedTypes, context)) { completeMember(resolvedTypes, context)) {
return m_startPosition; return m_startPosition;
} else if (m_completionOperator == T_COLON_COLON && completeScope(resolvedTypes, context)) { } else if (m_completionOperator == T_COLON_COLON && completeScope(resolvedTypes, context)) {
return m_startPosition; return m_startPosition;
...@@ -575,8 +575,7 @@ bool CppCodeCompletion::completeFunction(FullySpecifiedType exprTy, ...@@ -575,8 +575,7 @@ bool CppCodeCompletion::completeFunction(FullySpecifiedType exprTy,
return ! m_completions.isEmpty(); return ! m_completions.isEmpty();
} }
bool CppCodeCompletion::completeMember(FullySpecifiedType, bool CppCodeCompletion::completeMember(const QList<TypeOfExpression::Result> &results,
const QList<TypeOfExpression::Result> &results,
const LookupContext &context) const LookupContext &context)
{ {
if (results.isEmpty()) if (results.isEmpty())
...@@ -593,10 +592,10 @@ bool CppCodeCompletion::completeMember(FullySpecifiedType, ...@@ -593,10 +592,10 @@ bool CppCodeCompletion::completeMember(FullySpecifiedType,
if (NamedType *namedTy = ty->asNamedType()) { if (NamedType *namedTy = ty->asNamedType()) {
ResolveExpression resolveExpression(context); ResolveExpression resolveExpression(context);
SymbolsForDotAccess symbolsForDotAccess;
Name *className = namedTy->name(); const QList<Symbol *> candidates = symbolsForDotAccess(namedTy, p,
const QList<Symbol *> candidates = context);
context.resolveClass(className, context.visibleScopes(p));
foreach (Symbol *classObject, candidates) { foreach (Symbol *classObject, candidates) {
const QList<TypeOfExpression::Result> overloads = const QList<TypeOfExpression::Result> overloads =
...@@ -617,8 +616,7 @@ bool CppCodeCompletion::completeMember(FullySpecifiedType, ...@@ -617,8 +616,7 @@ bool CppCodeCompletion::completeMember(FullySpecifiedType,
if (PointerType *ptrTy = ty->asPointerType()) { if (PointerType *ptrTy = ty->asPointerType()) {
if (NamedType *namedTy = ptrTy->elementType()->asNamedType()) { if (NamedType *namedTy = ptrTy->elementType()->asNamedType()) {
const QList<Symbol *> classes = const QList<Symbol *> classes =
context.resolveClass(namedTy->name(), symbolsForDotAccess(namedTy, p, context);
context.visibleScopes(p));
foreach (Symbol *c, classes) { foreach (Symbol *c, classes) {
if (! classObjectCandidates.contains(c)) if (! classObjectCandidates.contains(c))
...@@ -630,9 +628,10 @@ bool CppCodeCompletion::completeMember(FullySpecifiedType, ...@@ -630,9 +628,10 @@ bool CppCodeCompletion::completeMember(FullySpecifiedType,
} }
} else if (PointerType *ptrTy = ty->asPointerType()) { } else if (PointerType *ptrTy = ty->asPointerType()) {
if (NamedType *namedTy = ptrTy->elementType()->asNamedType()) { if (NamedType *namedTy = ptrTy->elementType()->asNamedType()) {
const QList<Symbol *> classes = SymbolsForDotAccess symbolsForDotAccess;
context.resolveClass(namedTy->name(),
context.visibleScopes(p)); const QList<Symbol *> classes = symbolsForDotAccess(namedTy, p,
context);
foreach (Symbol *c, classes) { foreach (Symbol *c, classes) {
if (! classObjectCandidates.contains(c)) if (! classObjectCandidates.contains(c))
...@@ -652,7 +651,7 @@ bool CppCodeCompletion::completeMember(FullySpecifiedType, ...@@ -652,7 +651,7 @@ bool CppCodeCompletion::completeMember(FullySpecifiedType,
int length = m_editor->position() - m_startPosition + 1; int length = m_editor->position() - m_startPosition + 1;
m_editor->setCurPos(m_startPosition - 1); m_editor->setCurPos(m_startPosition - 1);
m_editor->replace(length, QLatin1String("->")); m_editor->replace(length, QLatin1String("->"));
m_startPosition++; ++m_startPosition;
namedTy = ptrTy->elementType()->asNamedType(); namedTy = ptrTy->elementType()->asNamedType();
} else { } else {
namedTy = ty->asNamedType(); namedTy = ty->asNamedType();
......
...@@ -96,8 +96,7 @@ private: ...@@ -96,8 +96,7 @@ private:
const QList<CPlusPlus::TypeOfExpression::Result> &, const QList<CPlusPlus::TypeOfExpression::Result> &,
const CPlusPlus::LookupContext &context); const CPlusPlus::LookupContext &context);
bool completeMember(CPlusPlus::FullySpecifiedType exprTy, bool completeMember(const QList<CPlusPlus::TypeOfExpression::Result> &,
const QList<CPlusPlus::TypeOfExpression::Result> &,
const CPlusPlus::LookupContext &context); const CPlusPlus::LookupContext &context);
bool completeScope(const QList<CPlusPlus::TypeOfExpression::Result> &, bool completeScope(const QList<CPlusPlus::TypeOfExpression::Result> &,
......
Markdown is supported
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