fixes #315 : foreach not correcly handled.

This commit is contained in:
Roy Qu 2024-03-24 17:07:53 +08:00
parent 27e28e4388
commit 741b814e1d
2 changed files with 14 additions and 11 deletions

View File

@ -4004,7 +4004,8 @@ void CppParser::handleVar(const QString& typePrefix,bool isExtern,bool isStatic,
&& !(addedVar->properties & StatementProperty::spFunctionPointer)
&& AutoTypes.contains(addedVar->type)) {
//handle e.g.: for(auto x:vec)
int endIndex = indexOfNextRightParenthesis(mIndex+1, maxIndex);
// for(auto x:vec ) is replaced by "for { auto x: vec ;" in handleForAndCatch();
int endIndex = indexOfNextSemicolon(mIndex+1, maxIndex);
QString expressionText;
for (int i=mIndex+1;i<endIndex;i++) {
expressionText+=mTokenizer[i]->text;
@ -4336,9 +4337,9 @@ void CppParser::internalParse(const QString &fileName)
QStringList preprocessResult = mPreprocessor.result();
#ifdef QT_DEBUG
// stringsToFile(mPreprocessor.result(),QString("r:\\preprocess-%1.txt").arg(extractFileName(fileName)));
// mPreprocessor.dumpDefinesTo("r:\\defines.txt");
// mPreprocessor.dumpIncludesListTo("r:\\includes.txt");
// stringsToFile(mPreprocessor.result(),QString("z:\\preprocess-%1.txt").arg(extractFileName(fileName)));
// mPreprocessor.dumpDefinesTo("z:\\defines.txt");
// mPreprocessor.dumpIncludesListTo("z:\\includes.txt");
#endif
//qDebug()<<"preprocess"<<timer.elapsed();
//reduce memory usage
@ -4355,7 +4356,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("z:\\tokens-%1.txt").arg(extractFileName(fileName)));
#endif
#ifdef QT_DEBUG
mLastIndex = -1;
@ -4367,12 +4368,14 @@ void CppParser::internalParse(const QString &fileName)
if (!handleStatement(endIndex))
break;
}
#ifdef QT_DEBUG
// mTokenizer.dumpTokens(QString("z:\\tokens-after-%1.txt").arg(extractFileName(fileName)));
#endif
handleInheritances();
// qDebug()<<"parse"<<timer.elapsed();
#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("z:\\all-stats-%1.txt").arg(extractFileName(fileName)));
// mStatementList.dump(QString("z:\\stats-%1.txt").arg(extractFileName(fileName)));
#endif
//reduce memory usage
internalClear();

View File

@ -925,7 +925,7 @@ void QSynEdit::invalidateLines(int firstLine, int lastLine)
{
if (!isVisible())
return;
qDebug()<<"invalidate lines:"<<firstLine<<lastLine;
// qDebug()<<"invalidate lines:"<<firstLine<<lastLine;
if (firstLine == -1 && lastLine == -1) {
QRect rcInval = clientRect();
rcInval.setLeft(rcInval.left()+mGutterWidth);
@ -951,7 +951,7 @@ void QSynEdit::invalidateLines(int firstLine, int lastLine)
int firstLineTop = std::max((firstLine-1)*mTextHeight, mTopPos);
int lastLineBottom = std::min(lastLine*mTextHeight, mTopPos+clientHeight());
qDebug()<<firstLineTop<<lastLineBottom<<firstLine<<lastLine;
// qDebug()<<firstLineTop<<lastLineBottom<<firstLine<<lastLine;
// any line visible?
if (lastLineBottom >= firstLineTop) {
QRect rcInval = {
@ -960,7 +960,7 @@ void QSynEdit::invalidateLines(int firstLine, int lastLine)
clientWidth(), lastLineBottom - firstLineTop
};
invalidateRect(rcInval);
qDebug()<<rcInval;
// qDebug()<<rcInval;
}
}
}