forked from qt-creator/qt-creator
Fix C++ type hierarchy
Dynamic casts between library boundaries tend to fail. Add an "explicit cast" to CppClass via virtual functions as a quickfix. This is a recurring issue, e.g.d2769f3003,3f11ef9216and2ffd0e2d0dto name just a few... This was introduced in5e861d2be6Task-number: QTCREATORBUG-20001 Change-Id: Ie5a89a028d587e4e9d1ecec920a7c7d17497dbde Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
This commit is contained in:
@@ -63,6 +63,11 @@ CppElement::CppElement() : helpCategory(TextEditor::HelpItem::Unknown)
|
||||
CppElement::~CppElement()
|
||||
{}
|
||||
|
||||
CppClass *CppElement::toCppClass()
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
class Unknown : public CppElement
|
||||
{
|
||||
public:
|
||||
@@ -156,6 +161,11 @@ bool CppClass::operator==(const CppClass &other)
|
||||
return this->declaration == other.declaration;
|
||||
}
|
||||
|
||||
CppClass *CppClass::toCppClass()
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
void CppClass::lookupBases(Symbol *declaration, const LookupContext &context)
|
||||
{
|
||||
typedef QPair<ClassOrNamespace *, CppClass *> Data;
|
||||
|
||||
@@ -81,6 +81,8 @@ private:
|
||||
QString m_diagnosis;
|
||||
};
|
||||
|
||||
class CppClass;
|
||||
|
||||
class CPPTOOLS_EXPORT CppElement
|
||||
{
|
||||
protected:
|
||||
@@ -89,6 +91,8 @@ protected:
|
||||
public:
|
||||
virtual ~CppElement();
|
||||
|
||||
virtual CppClass *toCppClass();
|
||||
|
||||
TextEditor::HelpItem::Category helpCategory;
|
||||
QStringList helpIdCandidates;
|
||||
QString helpMark;
|
||||
@@ -96,7 +100,7 @@ public:
|
||||
QString tooltip;
|
||||
};
|
||||
|
||||
class CppDeclarableElement : public CppElement
|
||||
class CPPTOOLS_EXPORT CppDeclarableElement : public CppElement
|
||||
{
|
||||
public:
|
||||
explicit CppDeclarableElement(CPlusPlus::Symbol *declaration);
|
||||
@@ -109,7 +113,7 @@ public:
|
||||
QIcon icon;
|
||||
};
|
||||
|
||||
class CppClass : public CppDeclarableElement
|
||||
class CPPTOOLS_EXPORT CppClass : public CppDeclarableElement
|
||||
{
|
||||
public:
|
||||
CppClass();
|
||||
@@ -117,6 +121,8 @@ public:
|
||||
|
||||
bool operator==(const CppClass &other);
|
||||
|
||||
CppClass *toCppClass() final;
|
||||
|
||||
void lookupBases(CPlusPlus::Symbol *declaration, const CPlusPlus::LookupContext &context);
|
||||
void lookupDerived(CPlusPlus::Symbol *declaration, const CPlusPlus::Snapshot &snapshot);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user