From d8e4c4d76b1f0a0c45628e01d721843b5ed3cd1a Mon Sep 17 00:00:00 2001 From: Roy Qu Date: Tue, 20 Feb 2024 12:34:02 +0800 Subject: [PATCH] - Fix: Expression that starts with full scoped variables might be treated as var definition. --- NEWS.md | 1 + RedPandaIDE/parser/cppparser.cpp | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/NEWS.md b/NEWS.md index 907a508d..5e3b35d1 100644 --- a/NEWS.md +++ b/NEWS.md @@ -43,6 +43,7 @@ Red Panda C++ Version 2.26 - Enhancement: add Windows arm64 package. - Fix: Force to use debug server when debugging with lldb-mi to fix input/output on Windows. - Fix: Can't goto definition/declaration into files that not saved. + - Fix: Expression that starts with full scoped variables might be treated as var definition. Red Panda C++ Version 2.25 diff --git a/RedPandaIDE/parser/cppparser.cpp b/RedPandaIDE/parser/cppparser.cpp index 14d1c2ce..c933d689 100644 --- a/RedPandaIDE/parser/cppparser.cpp +++ b/RedPandaIDE/parser/cppparser.cpp @@ -2340,6 +2340,10 @@ void CppParser::checkAndHandleMethodOrVar(KeywordType keywordType) mIndex++; } else { QString s = mTokenizer[mIndex]->text; + if (!isWordChar(s.front())) { + mIndex = indexOfNextPeriodOrSemicolon(mIndex); + return; + } if (sName.endsWith("::")) { sName+=s; } else { @@ -4444,7 +4448,7 @@ void CppParser::internalParse(const QString &fileName) if (mTokenizer.tokenCount() == 0) return; #ifdef QT_DEBUG -// mTokenizer.dumpTokens(QString("r:\\tokens-%1.txt").arg(extractFileName(fileName))); + mTokenizer.dumpTokens(QString("r:\\tokens-%1.txt").arg(extractFileName(fileName))); #endif #ifdef QT_DEBUG mLastIndex = -1; @@ -6305,6 +6309,7 @@ int CppParser::indexOfNextPeriodOrSemicolon(int index, int endIndex) case ';': case ',': case '}': + case ')': return index; case '(': index = mTokenizer[index]->matchIndex+1;