From 60055107ca74bd3c8359064f5dc5497bcdc4ee69 Mon Sep 17 00:00:00 2001 From: Roy Qu Date: Fri, 10 Mar 2023 16:02:47 +0800 Subject: [PATCH] fix: '::' is not correctly handled when skip to : in the parser --- RedPandaIDE/parser/cppparser.cpp | 17 +++++++++++------ .../settingsdialog/projectgeneralwidget.cpp | 2 +- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/RedPandaIDE/parser/cppparser.cpp b/RedPandaIDE/parser/cppparser.cpp index 49a86673..f38605a2 100644 --- a/RedPandaIDE/parser/cppparser.cpp +++ b/RedPandaIDE/parser/cppparser.cpp @@ -3817,7 +3817,7 @@ void CppParser::internalParse(const QString &fileName) QStringList preprocessResult = mPreprocessor.result(); #ifdef QT_DEBUG -// stringsToFile(mPreprocessor.result(),QString("r:\\preprocess-%1.txt").arg(extractFileName(fileName))); + stringsToFile(mPreprocessor.result(),QString("r:\\preprocess-%1.txt").arg(extractFileName(fileName))); // mPreprocessor.dumpDefinesTo("r:\\defines.txt"); // mPreprocessor.dumpIncludesListTo("r:\\includes.txt"); #endif @@ -3831,7 +3831,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; @@ -3842,8 +3842,8 @@ void CppParser::internalParse(const QString &fileName) break; } #ifdef QT_DEBUG -// mStatementList.dumpAll(QString("r:\\all-stats-%1.txt").arg(extractFileName(fileName))); -// mStatementList.dump(QString("r:\\stats-%1.txt").arg(extractFileName(fileName))); + mStatementList.dumpAll(QString("r:\\all-stats-%1.txt").arg(extractFileName(fileName))); + mStatementList.dump(QString("r:\\stats-%1.txt").arg(extractFileName(fileName))); #endif //reduce memory usage internalClear(); @@ -5441,9 +5441,14 @@ int CppParser::indexOfNextSemicolonOrLeftBrace(int index) int CppParser::indexOfNextColon(int index) { while (indextext[0].unicode()) { + QString s =mTokenizer[index]->text; + switch(s[0].unicode()) { case ':': - return index; + if (s.length()==1) + return index; + else + index++; + break; case '(': index = mTokenizer[index]->matchIndex+1; break; diff --git a/RedPandaIDE/settingsdialog/projectgeneralwidget.cpp b/RedPandaIDE/settingsdialog/projectgeneralwidget.cpp index a565045a..8a8b4986 100644 --- a/RedPandaIDE/settingsdialog/projectgeneralwidget.cpp +++ b/RedPandaIDE/settingsdialog/projectgeneralwidget.cpp @@ -188,7 +188,7 @@ void ProjectGeneralWidget::on_btnRemove_clicked() setSettingsChanged(); } -void ProjectGeneralWidget::on_cbEncoding_currentTextChanged(const QString &arg1) +void ProjectGeneralWidget::on_cbEncoding_currentTextChanged(const QString &/*arg1*/) { QString userData = ui->cbEncoding->currentData().toString(); if (userData == ENCODING_AUTO_DETECT