fix: '::' is not correctly handled when skip to : in the parser

This commit is contained in:
Roy Qu 2023-03-10 16:02:47 +08:00
parent f0f9741220
commit 60055107ca
2 changed files with 12 additions and 7 deletions

View File

@ -3817,7 +3817,7 @@ void CppParser::internalParse(const QString &fileName)
QStringList preprocessResult = mPreprocessor.result(); QStringList preprocessResult = mPreprocessor.result();
#ifdef QT_DEBUG #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.dumpDefinesTo("r:\\defines.txt");
// mPreprocessor.dumpIncludesListTo("r:\\includes.txt"); // mPreprocessor.dumpIncludesListTo("r:\\includes.txt");
#endif #endif
@ -3831,7 +3831,7 @@ void CppParser::internalParse(const QString &fileName)
if (mTokenizer.tokenCount() == 0) if (mTokenizer.tokenCount() == 0)
return; return;
#ifdef QT_DEBUG #ifdef QT_DEBUG
// mTokenizer.dumpTokens(QString("r:\\tokens-%1.txt").arg(extractFileName(fileName))); mTokenizer.dumpTokens(QString("r:\\tokens-%1.txt").arg(extractFileName(fileName)));
#endif #endif
#ifdef QT_DEBUG #ifdef QT_DEBUG
mLastIndex = -1; mLastIndex = -1;
@ -3842,8 +3842,8 @@ void CppParser::internalParse(const QString &fileName)
break; break;
} }
#ifdef QT_DEBUG #ifdef QT_DEBUG
// mStatementList.dumpAll(QString("r:\\all-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))); mStatementList.dump(QString("r:\\stats-%1.txt").arg(extractFileName(fileName)));
#endif #endif
//reduce memory usage //reduce memory usage
internalClear(); internalClear();
@ -5441,9 +5441,14 @@ int CppParser::indexOfNextSemicolonOrLeftBrace(int index)
int CppParser::indexOfNextColon(int index) int CppParser::indexOfNextColon(int index)
{ {
while (index<mTokenizer.tokenCount()) { while (index<mTokenizer.tokenCount()) {
switch(mTokenizer[index]->text[0].unicode()) { QString s =mTokenizer[index]->text;
switch(s[0].unicode()) {
case ':': case ':':
return index; if (s.length()==1)
return index;
else
index++;
break;
case '(': case '(':
index = mTokenizer[index]->matchIndex+1; index = mTokenizer[index]->matchIndex+1;
break; break;

View File

@ -188,7 +188,7 @@ void ProjectGeneralWidget::on_btnRemove_clicked()
setSettingsChanged(); setSettingsChanged();
} }
void ProjectGeneralWidget::on_cbEncoding_currentTextChanged(const QString &arg1) void ProjectGeneralWidget::on_cbEncoding_currentTextChanged(const QString &/*arg1*/)
{ {
QString userData = ui->cbEncoding->currentData().toString(); QString userData = ui->cbEncoding->currentData().toString();
if (userData == ENCODING_AUTO_DETECT if (userData == ENCODING_AUTO_DETECT