From f111433ac5a08de5269de35fa20733842ddda417 Mon Sep 17 00:00:00 2001 From: Roy Qu Date: Tue, 8 Aug 2023 10:40:59 +0800 Subject: [PATCH] - fix: Can't parse virtual inherit. --- NEWS.md | 3 ++- RedPandaIDE/parser/cppparser.cpp | 21 ++++++++++++--------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/NEWS.md b/NEWS.md index ae14f213..61f8985d 100644 --- a/NEWS.md +++ b/NEWS.md @@ -15,7 +15,8 @@ Red Panda C++ Version 2.24 - enhancement: Support optional enum type. - enhancement: Support simple const expression evaluation for enum values. - fix: Accessibilty for inherited members are not correct calculated in multiple inheritance. - - fix: Can't handle full class name when handle inheritance. + - fix: Can't parse full class name when handle inheritance. + - fix: Can't parse virtual inherit. Red Panda C++ Version 2.23 diff --git a/RedPandaIDE/parser/cppparser.cpp b/RedPandaIDE/parser/cppparser.cpp index 5d7361b4..843d6a8e 100644 --- a/RedPandaIDE/parser/cppparser.cpp +++ b/RedPandaIDE/parser/cppparser.cpp @@ -1520,16 +1520,19 @@ void CppParser::setInheritance(int index, const PStatement& classStatement, bool StatementAccessibility lastInheritScopeType = StatementAccessibility::None; // Assemble a list of statements in text form we inherit from while (true) { - StatementAccessibility inheritScopeType = getClassMemberAccessibility(mTokenizer[index]->text); QString currentText = mTokenizer[index]->text; if (currentText=='(') { //skip to matching ')' index=mTokenizer[index]->matchIndex; - } else if (inheritScopeType == StatementAccessibility::None) { - if (currentText=="::" - || isIdentChar(currentText[0])) { - - + } else if (currentText=="::" + || (isIdentChar(currentText[0]))) { + KeywordType keywordType = mCppKeywords.value(currentText, KeywordType::None); + if (keywordType!=KeywordType::None) { + StatementAccessibility inheritScopeType = getClassMemberAccessibility(mTokenizer[index]->text); + if (inheritScopeType != StatementAccessibility::None) { + lastInheritScopeType = inheritScopeType; + } + } else { QString basename = currentText; bool isGlobal = false; index++; @@ -1565,13 +1568,13 @@ void CppParser::setInheritance(int index, const PStatement& classStatement, bool // Find the corresponding PStatement PStatement statement = doFindStatementOf(mCurrentFile,basename, isGlobal?PStatement():classStatement->parentScope.lock()); + if (statement && statement->kind == StatementKind::skClass) { inheritClassStatement(classStatement,isStruct,statement,lastInheritScopeType); } } - } else { - lastInheritScopeType = inheritScopeType; } + index++; if (index >= tokenCount) break; @@ -1924,6 +1927,7 @@ bool CppParser::checkForKeyword(KeywordType& keywordType) case KeywordType::For: case KeywordType::Public: case KeywordType::Private: + case KeywordType::Protected: case KeywordType::Struct: case KeywordType::Enum: case KeywordType::Inline: @@ -1931,7 +1935,6 @@ bool CppParser::checkForKeyword(KeywordType& keywordType) case KeywordType::Typedef: case KeywordType::Using: case KeywordType::Friend: - case KeywordType::Protected: case KeywordType::None: case KeywordType::NotKeyword: case KeywordType::DeclType: