aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChristian Stenger <christian.stenger@qt.io>2024-04-24 11:25:00 +0200
committerChristian Stenger <christian.stenger@qt.io>2024-04-30 04:45:01 +0000
commitcaf31c4fe95acd48c3e497a29e1bbce985b0c080 (patch)
treef87798fce7413f0f6382539dffbba7242b9557f8 /src
parent87193a0311730c0c1db52cbfdd1f5aa90d794117 (diff)
CPlusPlus: Support completion of list iterators
Fixes: QTCREATORBUG-30608 Change-Id: I169efe675e13540ecc5fbbd6b15dd13d8522db7d Reviewed-by: Christian Stenger <christian.stenger@qt.io> Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/libs/cplusplus/ResolveExpression.cpp8
-rw-r--r--src/plugins/cppeditor/cppcompletion_test.cpp10
2 files changed, 18 insertions, 0 deletions
diff --git a/src/libs/cplusplus/ResolveExpression.cpp b/src/libs/cplusplus/ResolveExpression.cpp
index 4fc1cd2d56..e779c447bf 100644
--- a/src/libs/cplusplus/ResolveExpression.cpp
+++ b/src/libs/cplusplus/ResolveExpression.cpp
@@ -1062,6 +1062,8 @@ ClassOrNamespace *ResolveExpression::baseExpression(const QList<LookupItem> &bas
}
typedefsResolver.resolve(&ty, &scope, r.binding());
+ if (auto ref = ty->asReferenceType()) // deref if needed
+ ty = ref->elementType();
if (Q_UNLIKELY(debug))
qDebug() << "- after typedef resolving:" << oo.prettyType(ty);
@@ -1082,6 +1084,9 @@ ClassOrNamespace *ResolveExpression::baseExpression(const QList<LookupItem> &bas
if (ClassOrNamespace *binding = findClass(type, scope))
return binding;
+ if (ClassOrNamespace *binding = findClass(type, r.scope())) // local classes and structs
+ return binding;
+
} else {
ClassOrNamespace *binding
= findClassForTemplateParameterInExpressionScope(r.binding(),
@@ -1176,6 +1181,9 @@ ClassOrNamespace *ResolveExpression::baseExpression(const QList<LookupItem> &bas
if (ClassOrNamespace *binding = findClass(ty, scope, enclosingBinding))
return binding;
+
+ if (ClassOrNamespace *binding = findClass(ty, r.scope())) // local classes and structs
+ return binding;
}
}
diff --git a/src/plugins/cppeditor/cppcompletion_test.cpp b/src/plugins/cppeditor/cppcompletion_test.cpp
index fdc30e16be..6f152c65a6 100644
--- a/src/plugins/cppeditor/cppcompletion_test.cpp
+++ b/src/plugins/cppeditor/cppcompletion_test.cpp
@@ -2889,6 +2889,16 @@ void CompletionTest::testCompletionMemberAccessOperator_data()
) << _("p->") << QStringList({"S", "m"})
<< false
<< false;
+ QTest::newRow("dot to arrow: template + reference + double typedef")
+ << _("template <typename T> struct C {\n"
+ " using ref = T &;\n"
+ " ref operator[](int i);\n"
+ "};\n"
+ "struct S { int m; };\n"
+ "template<typename T> using CS = C<T>;\n"
+ "CS<S *> v;\n"
+ "@\n")
+ << _("v[0].") << QStringList({"S", "m"}) << false << true;
}
} // namespace CppEditor::Internal