diff --git a/RedPandaIDE/parser/cppparser.cpp b/RedPandaIDE/parser/cppparser.cpp index 6a87ea78..951e6df0 100644 --- a/RedPandaIDE/parser/cppparser.cpp +++ b/RedPandaIDE/parser/cppparser.cpp @@ -1613,6 +1613,8 @@ void CppParser::setInheritance(int index, const PStatement& classStatement, bool inheritanceInfo->handled = false; mClassInheritances.append(inheritanceInfo); + + handleInheritance(classStatement, inheritanceInfo); } } @@ -4373,6 +4375,29 @@ void CppParser::handleVar(const QString& typePrefix,bool isExtern,bool isStatic) mIndex++; } +void CppParser::handleInheritance(PStatement derivedStatement, PClassInheritanceInfo inheritanceInfo) +{ + if (inheritanceInfo->handled) + return; + PStatement statement = doFindStatementOf( + inheritanceInfo->file, + inheritanceInfo->parentClassName, + inheritanceInfo->isGlobal?PStatement():derivedStatement->parentScope.lock()); + + if (statement && statement->kind == StatementKind::skClass) { + inheritClassStatement(derivedStatement, + inheritanceInfo->isStruct, + statement, + inheritanceInfo->visibility); +// inheritanceInfo->parentClassFilename = statement->fileName; + inheritanceInfo->handled = true; + PFileIncludes fileIncludes = mPreprocessor.findFileIncludes(statement->fileName); + Q_ASSERT(fileIncludes!=nullptr); + fileIncludes->handledInheritances.append(inheritanceInfo); + } + +} + void CppParser::handleInheritances() { for (int i=mClassInheritances.length()-1;i>=0;i--) { @@ -4387,21 +4412,7 @@ void CppParser::handleInheritances() } continue; } - if (inheritanceInfo->handled) - continue; - PStatement statement = doFindStatementOf( - inheritanceInfo->file, - inheritanceInfo->parentClassName, - inheritanceInfo->isGlobal?PStatement():derivedStatement->parentScope.lock()); - - if (statement && statement->kind == StatementKind::skClass) { - inheritClassStatement(derivedStatement, - inheritanceInfo->isStruct, - statement, - inheritanceInfo->visibility); - inheritanceInfo->parentClassFilename = statement->fileName; - inheritanceInfo->handled = true; - } + handleInheritance(derivedStatement, inheritanceInfo); } //mClassInheritances.clear(); } @@ -5982,6 +5993,15 @@ void CppParser::internalInvalidateFile(const QString &fileName) } } p->statements.clear(); + + //invalidate all handledInheritances + for (std::weak_ptr &pWeakInfo: p->handledInheritances) { + PClassInheritanceInfo info = pWeakInfo.lock(); + if (info) { + info->handled = false; + } + } + p->handledInheritances.clear(); } //remove all statements from namespace cache @@ -6000,10 +6020,10 @@ void CppParser::internalInvalidateFile(const QString &fileName) } // class inheritance // invalid class inheritance infos (derived class is not valid) whould be auto removed in handleInheritances() - foreach (const PClassInheritanceInfo& info, mClassInheritances) { - if (info->handled && info->parentClassFilename == fileName) - info->handled = false; - } + // foreach (const PClassInheritanceInfo& info, mClassInheritances) { + // if (info->handled && info->parentClassFilename == fileName) + // info->handled = false; + // } // delete it from scannedfiles mPreprocessor.removeScannedFile(fileName); } diff --git a/RedPandaIDE/parser/cppparser.h b/RedPandaIDE/parser/cppparser.h index e4497ee1..ca05ced4 100644 --- a/RedPandaIDE/parser/cppparser.h +++ b/RedPandaIDE/parser/cppparser.h @@ -516,6 +516,7 @@ private: void handleStructs(bool isTypedef = false); void handleUsing(); void handleVar(const QString& typePrefix,bool isExtern,bool isStatic); + void handleInheritance(PStatement derivedClass, PClassInheritanceInfo pInfo); void handleInheritances(); void skipRequires(); void internalParse(const QString& fileName); diff --git a/RedPandaIDE/parser/parserutils.h b/RedPandaIDE/parser/parserutils.h index 8aaac9fc..dab04edf 100644 --- a/RedPandaIDE/parser/parserutils.h +++ b/RedPandaIDE/parser/parserutils.h @@ -295,6 +295,7 @@ private: QVector mScopes; }; +struct ClassInheritanceInfo; struct FileIncludes { QString baseFile; QMap includeFiles; // true means the file is directly included, false means included indirectly @@ -304,6 +305,7 @@ struct FileIncludes { StatementMap declaredStatements; // statements declared in this file (full name as key) CppScopes scopes; // int is start line of the statement scope QMap branches; + QList> handledInheritances; bool isLineVisible(int line); }; using PFileIncludes = std::shared_ptr; diff --git a/RedPandaIDE/parser/statementmodel.h b/RedPandaIDE/parser/statementmodel.h index aa18710c..b1b63309 100644 --- a/RedPandaIDE/parser/statementmodel.h +++ b/RedPandaIDE/parser/statementmodel.h @@ -60,7 +60,7 @@ struct ClassInheritanceInfo { bool isGlobal; bool isStruct; StatementAccessibility visibility; - QString parentClassFilename; +// QString parentClassFilename; bool handled; }; diff --git a/libs/qsynedit/qsynedit/painter.cpp b/libs/qsynedit/qsynedit/painter.cpp index 63231a7c..cd1f17b4 100644 --- a/libs/qsynedit/qsynedit/painter.cpp +++ b/libs/qsynedit/qsynedit/painter.cpp @@ -22,29 +22,6 @@ namespace QSynedit { -QSet QSynEditPainter::OperatorGlyphs { - "-", - "+", - "*", - "/", - "\\", - "~", - "!", - "@", - "#", - "$", - "%", - "^", - "&", - "|", - "=", - "<", - ">", - "?", - ":", -}; - - QSynEditPainter::QSynEditPainter(QSynEdit *edit, QPainter *painter, int firstRow, int lastRow, int left, int right): mEdit{edit}, mPainter{painter}, diff --git a/libs/qsynedit/qsynedit/painter.h b/libs/qsynedit/qsynedit/painter.h index decc7ced..10637543 100644 --- a/libs/qsynedit/qsynedit/painter.h +++ b/libs/qsynedit/qsynedit/painter.h @@ -109,8 +109,6 @@ private: QRect mClip; int mFirstRow, mLastRow, mLeft, mRight; SynTokenAccu mTokenAccu; - - static QSet OperatorGlyphs; }; }