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

FullySpecifiedType::simplified() strips references from the type.

parent 7a5b1bdd
...@@ -988,10 +988,7 @@ bool CppCodeCompletion::completeMember(const QList<TypeOfExpression::Result> &re ...@@ -988,10 +988,7 @@ bool CppCodeCompletion::completeMember(const QList<TypeOfExpression::Result> &re
QList<Symbol *> classObjectCandidates; QList<Symbol *> classObjectCandidates;
if (m_completionOperator == T_ARROW) { if (m_completionOperator == T_ARROW) {
FullySpecifiedType ty = result.first; FullySpecifiedType ty = result.first.simplified();
if (ReferenceType *refTy = ty->asReferenceType())
ty = refTy->elementType();
if (Class *classTy = ty->asClassType()) { if (Class *classTy = ty->asClassType()) {
Symbol *symbol = result.second; Symbol *symbol = result.second;
...@@ -1026,10 +1023,7 @@ bool CppCodeCompletion::completeMember(const QList<TypeOfExpression::Result> &re ...@@ -1026,10 +1023,7 @@ bool CppCodeCompletion::completeMember(const QList<TypeOfExpression::Result> &re
if (! funTy) if (! funTy)
continue; continue;
ty = funTy->returnType(); ty = funTy->returnType().simplified();
if (ReferenceType *refTy = ty->asReferenceType())
ty = refTy->elementType();
if (PointerType *ptrTy = ty->asPointerType()) { if (PointerType *ptrTy = ty->asPointerType()) {
if (NamedType *namedTy = ptrTy->elementType()->asNamedType()) { if (NamedType *namedTy = ptrTy->elementType()->asNamedType()) {
...@@ -1063,19 +1057,13 @@ bool CppCodeCompletion::completeMember(const QList<TypeOfExpression::Result> &re ...@@ -1063,19 +1057,13 @@ bool CppCodeCompletion::completeMember(const QList<TypeOfExpression::Result> &re
} }
} }
} else if (m_completionOperator == T_DOT) { } else if (m_completionOperator == T_DOT) {
FullySpecifiedType ty = result.first; FullySpecifiedType ty = result.first.simplified();
if (ReferenceType *refTy = ty->asReferenceType())
ty = refTy->elementType();
NamedType *namedTy = 0; NamedType *namedTy = 0;
if (ArrayType *arrayTy = ty->asArrayType()) { if (ArrayType *arrayTy = ty->asArrayType()) {
// Replace . with [0]. when `ty' is an array type. // Replace . with [0]. when `ty' is an array type.
FullySpecifiedType elementTy = arrayTy->elementType(); FullySpecifiedType elementTy = arrayTy->elementType().simplified();
if (ReferenceType *refTy = elementTy->asReferenceType())
elementTy = refTy->elementType();
if (elementTy->isNamedType() || elementTy->isPointerType()) { if (elementTy->isNamedType() || elementTy->isPointerType()) {
ty = elementTy; ty = elementTy;
...@@ -1322,9 +1310,8 @@ bool CppCodeCompletion::completeQtMethod(const QList<TypeOfExpression::Result> & ...@@ -1322,9 +1310,8 @@ bool CppCodeCompletion::completeQtMethod(const QList<TypeOfExpression::Result> &
QSet<QString> signatures; QSet<QString> signatures;
foreach (const TypeOfExpression::Result &p, results) { foreach (const TypeOfExpression::Result &p, results) {
FullySpecifiedType ty = p.first; FullySpecifiedType ty = p.first.simplified();
if (ReferenceType *refTy = ty->asReferenceType())
ty = refTy->elementType();
if (PointerType *ptrTy = ty->asPointerType()) if (PointerType *ptrTy = ty->asPointerType())
ty = ptrTy->elementType(); ty = ptrTy->elementType();
else else
......
...@@ -201,4 +201,12 @@ bool FullySpecifiedType::operator < (const FullySpecifiedType &other) const ...@@ -201,4 +201,12 @@ bool FullySpecifiedType::operator < (const FullySpecifiedType &other) const
return _type < other._type; return _type < other._type;
} }
FullySpecifiedType FullySpecifiedType::simplified() const
{
if (const ReferenceType *refTy = type()->asReferenceType())
return refTy->elementType().simplified();
return *this;
}
CPLUSPLUS_END_NAMESPACE CPLUSPLUS_END_NAMESPACE
...@@ -119,6 +119,8 @@ public: ...@@ -119,6 +119,8 @@ public:
bool operator != (const FullySpecifiedType &other) const; bool operator != (const FullySpecifiedType &other) const;
bool operator < (const FullySpecifiedType &other) const; bool operator < (const FullySpecifiedType &other) const;
FullySpecifiedType simplified() const;
private: private:
Type *_type; Type *_type;
struct Flags { struct Flags {
......
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