forked from qt-creator/qt-creator
CppEditor: Store typedefed name for anonymous structs
... and use it as the struct display name in some places. Fixes: QTCREATORBUG-26611 Change-Id: I1b127f5705307a0fabd2441ff871162c882927a5 Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
4
src/libs/3rdparty/cplusplus/Bind.cpp
vendored
4
src/libs/3rdparty/cplusplus/Bind.cpp
vendored
@@ -2022,6 +2022,10 @@ bool Bind::visit(SimpleDeclarationAST *ast)
|
||||
for (const auto &nameAndLoc : qAsConst(namesAndLocations)) {
|
||||
const int sourceLocation = nameAndLoc.second;
|
||||
Declaration *decl = control()->newDeclaration(sourceLocation, nameAndLoc.first);
|
||||
if (const Type * const t = declTy.type(); t && declTy.isTypedef() && t->asClassType()
|
||||
&& t->asClassType()->name() && t->asClassType()->name()->asAnonymousNameId()) {
|
||||
declTy.type()->asClassType()->setCanonicalTypedefName(decl->name());
|
||||
}
|
||||
decl->setType(declTy);
|
||||
setDeclSpecifiers(decl, type);
|
||||
|
||||
|
||||
5
src/libs/3rdparty/cplusplus/Symbols.cpp
vendored
5
src/libs/3rdparty/cplusplus/Symbols.cpp
vendored
@@ -635,6 +635,11 @@ void Class::addBaseClass(BaseClass *baseClass)
|
||||
FullySpecifiedType Class::type() const
|
||||
{ return FullySpecifiedType(const_cast<Class *>(this)); }
|
||||
|
||||
const Name *Class::prettyName() const
|
||||
{
|
||||
return _canonicalTypedefName ? _canonicalTypedefName : name();
|
||||
}
|
||||
|
||||
void Class::visitSymbol0(SymbolVisitor *visitor)
|
||||
{
|
||||
if (visitor->visit(this)) {
|
||||
|
||||
4
src/libs/3rdparty/cplusplus/Symbols.h
vendored
4
src/libs/3rdparty/cplusplus/Symbols.h
vendored
@@ -495,6 +495,9 @@ public:
|
||||
const Class *asClassType() const override { return this; }
|
||||
Class *asClassType() override { return this; }
|
||||
|
||||
void setCanonicalTypedefName(const Name *n) { _canonicalTypedefName = n; }
|
||||
const Name *prettyName() const;
|
||||
|
||||
protected:
|
||||
void visitSymbol0(SymbolVisitor *visitor) override;
|
||||
void accept0(TypeVisitor *visitor) override;
|
||||
@@ -503,6 +506,7 @@ protected:
|
||||
private:
|
||||
Key _key;
|
||||
std::vector<BaseClass *> _baseClasses;
|
||||
const Name *_canonicalTypedefName = nullptr;
|
||||
};
|
||||
|
||||
class CPLUSPLUS_EXPORT QtPropertyDeclaration final : public Symbol
|
||||
|
||||
@@ -53,6 +53,9 @@ static void path_helper(Symbol *symbol,
|
||||
if (ns && ns->isInline())
|
||||
return;
|
||||
}
|
||||
if (symbol->asClass())
|
||||
addNames(symbol->asClass()->prettyName(), names);
|
||||
else
|
||||
addNames(symbol->name(), names);
|
||||
|
||||
} else if (symbol->asObjCClass() || symbol->asObjCBaseClass() || symbol->asObjCProtocol()
|
||||
|
||||
@@ -166,7 +166,7 @@ void TypePrettyPrinter::visit(Template *type)
|
||||
|
||||
void TypePrettyPrinter::visit(Class *classTy)
|
||||
{
|
||||
_text.prepend(overview()->prettyName(classTy->name()));
|
||||
_text.prepend(overview()->prettyName(classTy->prettyName()));
|
||||
prependCv(_fullySpecifiedType);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user