- fix: Fail to evaluate expressions if macro can't be expanded.

This commit is contained in:
Roy Qu 2024-05-05 16:01:29 +08:00
parent b3ca4f5d38
commit cd65ecd74a
3 changed files with 5 additions and 9 deletions

View File

@ -164,6 +164,7 @@ Red Panda C++ Version 2.27
- enhancement: New compiler option "stack size" in the link subpage.
- change: Set "Ctrl+G" as the shortcut for "Goto page..."
- change: Set "Ctrl+B" as the shortcut for "Toggle Bookmark"
- fix: Fail to evaluate expressions if macro can't be expanded.
Red Panda C++ Version 2.26
- enhancement: Code suggestion for embedded std::vectors.

View File

@ -5507,8 +5507,9 @@ bool CppParser::expandMacro(QStringList &phraseExpression, int pos, PStatement m
phraseExpression.removeAt(pos);
usedMacros.removeAt(pos);
} else {
if (pos+1 >= phraseExpression.length() || phraseExpression[pos+1]!=")")
return false;
//don't expand
if (pos+1 >= phraseExpression.length() || phraseExpression[pos+1]!="(")
return true;
QString args=macro->args.mid(1,macro->args.length()-2).trimmed(); // remove '(' ')'
if(args=="")

View File

@ -761,17 +761,11 @@ void CodeCompletionPopup::getCompletionFor(
PStatement scope = mCurrentScope;//the scope the expression in
PStatement parentTypeStatement;
// QString scopeName = ownerExpression.join("");
// PStatement ownerStatement = mParser->findStatementOf(
// fileName,
// scopeName,
// mCurrentStatement,
// parentTypeStatement);
PEvalStatement ownerStatement = mParser->evalExpression(fileName,
ownerExpression,
scope);
if(!ownerStatement || !ownerStatement->effectiveTypeStatement) {
if(!ownerStatement || !ownerStatement->effectiveTypeStatement) {
return;
}
if (memberOperator == "::") {