forked from qt-creator/qt-creator
CppEditor: Support decl/def switch for conversion operators
Fixes: QTCREATORBUG-21168 Change-Id: I515fe146a679e007c96fa8d23f1457dadf07db3c Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
9
src/libs/3rdparty/cplusplus/Control.cpp
vendored
9
src/libs/3rdparty/cplusplus/Control.cpp
vendored
@@ -579,6 +579,15 @@ const OperatorNameId *Control::findOperatorNameId(OperatorNameId::Kind operatorI
|
||||
return &*i;
|
||||
}
|
||||
|
||||
const ConversionNameId *Control::findConversionNameId(const FullySpecifiedType &type) const
|
||||
{
|
||||
for (const ConversionNameId &id : d->conversionNameIds) {
|
||||
if (type.match(id.type()))
|
||||
return &id;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const Identifier *Control::findIdentifier(const char *chars, int size) const
|
||||
{ return d->identifiers.findLiteral(chars, size); }
|
||||
|
||||
|
||||
1
src/libs/3rdparty/cplusplus/Control.h
vendored
1
src/libs/3rdparty/cplusplus/Control.h
vendored
@@ -186,6 +186,7 @@ public:
|
||||
const Identifier *cpp11Final() const;
|
||||
|
||||
const OperatorNameId *findOperatorNameId(OperatorNameId::Kind operatorId) const;
|
||||
const ConversionNameId *findConversionNameId(const FullySpecifiedType &type) const;
|
||||
|
||||
const Identifier *findIdentifier(const char *chars, int size) const;
|
||||
const Identifier *identifier(const char *chars, int size);
|
||||
|
||||
21
src/libs/3rdparty/cplusplus/Scope.cpp
vendored
21
src/libs/3rdparty/cplusplus/Scope.cpp
vendored
@@ -71,6 +71,7 @@ public:
|
||||
|
||||
Symbol *lookat(const Identifier *id) const;
|
||||
Symbol *lookat(OperatorNameId::Kind operatorId) const;
|
||||
Symbol *lookat(const ConversionNameId *convId) const;
|
||||
|
||||
private:
|
||||
/// Returns the hash value for the given Symbol.
|
||||
@@ -181,6 +182,23 @@ Symbol *SymbolTable::lookat(OperatorNameId::Kind operatorId) const
|
||||
return symbol;
|
||||
}
|
||||
|
||||
Symbol *SymbolTable::lookat(const ConversionNameId *convId) const
|
||||
{
|
||||
if (!_hash)
|
||||
return nullptr;
|
||||
|
||||
Symbol *symbol = _hash[0]; // See Symbol::HashCode
|
||||
for (; symbol; symbol = symbol->_next) {
|
||||
if (const Name *identity = symbol->unqualifiedName()) {
|
||||
if (const ConversionNameId * const id = identity->asConversionNameId()) {
|
||||
if (id->type().match(convId->type()))
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return symbol;
|
||||
}
|
||||
|
||||
void SymbolTable::rehash()
|
||||
{
|
||||
_hashSize <<= 1;
|
||||
@@ -281,6 +299,9 @@ Symbol *Scope::find(const Identifier *id) const
|
||||
Symbol *Scope::find(OperatorNameId::Kind operatorId) const
|
||||
{ return _members ? _members->lookat(operatorId) : nullptr; }
|
||||
|
||||
Symbol *Scope::find(const ConversionNameId *conv) const
|
||||
{ return _members ? _members->lookat(conv) : nullptr; }
|
||||
|
||||
/// Set the start offset of the scope
|
||||
int Scope::startOffset() const
|
||||
{ return _startOffset; }
|
||||
|
||||
1
src/libs/3rdparty/cplusplus/Scope.h
vendored
1
src/libs/3rdparty/cplusplus/Scope.h
vendored
@@ -55,6 +55,7 @@ public:
|
||||
|
||||
Symbol *find(const Identifier *id) const;
|
||||
Symbol *find(OperatorNameId::Kind operatorId) const;
|
||||
Symbol *find(const ConversionNameId *conv) const;
|
||||
|
||||
/// Set the start offset of the scope
|
||||
int startOffset() const;
|
||||
|
||||
Reference in New Issue
Block a user