- fix: Macros that defined by the compiler are not correctly syntax-colored and tooltiped.

This commit is contained in:
Roy Qu 2023-10-25 00:34:29 +08:00
parent 0bc361e1f9
commit b287464b98
3 changed files with 11 additions and 8 deletions

View File

@ -16,6 +16,7 @@ Red Panda C++ Version 2.26
- change: Set mouse cursor to hand pointing when it's on gutter. - change: Set mouse cursor to hand pointing when it's on gutter.
- enhancement: Basic support for parsing variadic macros(macros that use __VA_ARGS__). - enhancement: Basic support for parsing variadic macros(macros that use __VA_ARGS__).
- enhancement: Better support for expanding macros with complex parameters. - enhancement: Better support for expanding macros with complex parameters.
- fix: Macros that defined by the compiler are not correctly syntax-colored and tooltiped.
Red Panda C++ Version 2.25 Red Panda C++ Version 2.25

View File

@ -734,7 +734,7 @@ void MainWindow::updateCompileActions(const Editor *e)
switch(fileType) { switch(fileType) {
case FileType::CSource: case FileType::CSource:
canCompile = set->canCompileC(); canCompile = set->canCompileC();
qDebug()<<(int)set->compilerType(); //qDebug()<<(int)set->compilerType();
#ifdef ENABLE_SDCC #ifdef ENABLE_SDCC
if (set->compilerType()!=CompilerType::SDCC) if (set->compilerType()!=CompilerType::SDCC)
#endif #endif
@ -742,7 +742,7 @@ void MainWindow::updateCompileActions(const Editor *e)
canGenerateAssembly = canCompile; canGenerateAssembly = canCompile;
canRun = canCompile ; canRun = canCompile ;
} }
qDebug()<<canCompile<<canRun; //qDebug()<<canCompile<<canRun;
canDebug = set->canDebug(); canDebug = set->canDebug();
break; break;
case FileType::CppSource: case FileType::CppSource:

View File

@ -4397,8 +4397,8 @@ 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
//qDebug()<<"preprocess"<<timer.elapsed(); //qDebug()<<"preprocess"<<timer.elapsed();
@ -4416,7 +4416,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;
@ -4429,8 +4429,8 @@ void CppParser::internalParse(const QString &fileName)
} }
// qDebug()<<"parse"<<timer.elapsed(); // qDebug()<<"parse"<<timer.elapsed();
#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();
@ -4580,7 +4580,9 @@ PStatement CppParser::findMemberOfStatement(const QString& filename,
QList<PStatement> stats = statementMap.values(s); QList<PStatement> stats = statementMap.values(s);
PFileIncludes fileIncludes = mPreprocessor.includesList().value(filename,PFileIncludes()); PFileIncludes fileIncludes = mPreprocessor.includesList().value(filename,PFileIncludes());
foreach(const PStatement &s,stats) { foreach(const PStatement &s,stats) {
if (s->fileName == filename || s->definitionFileName==filename) { if (s->line==-1) {
return s; // hard defines
} if (s->fileName == filename || s->definitionFileName==filename) {
return s; return s;
} else if (fileIncludes && (fileIncludes->includeFiles.contains(s->fileName) } else if (fileIncludes && (fileIncludes->includeFiles.contains(s->fileName)
|| fileIncludes->includeFiles.contains(s->definitionFileName))) { || fileIncludes->includeFiles.contains(s->definitionFileName))) {