- 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.
- enhancement: Basic support for parsing variadic macros(macros that use __VA_ARGS__).
- 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

View File

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

View File

@ -4397,8 +4397,8 @@ 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");
// stringsToFile(mPreprocessor.result(),QString("r:\\preprocess-%1.txt").arg(extractFileName(fileName)));
// mPreprocessor.dumpDefinesTo("r:\\defines.txt");
// mPreprocessor.dumpIncludesListTo("r:\\includes.txt");
#endif
//qDebug()<<"preprocess"<<timer.elapsed();
@ -4416,7 +4416,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;
@ -4429,8 +4429,8 @@ void CppParser::internalParse(const QString &fileName)
}
// 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("r:\\all-stats-%1.txt").arg(extractFileName(fileName)));
// mStatementList.dump(QString("r:\\stats-%1.txt").arg(extractFileName(fileName)));
#endif
//reduce memory usage
internalClear();
@ -4580,7 +4580,9 @@ PStatement CppParser::findMemberOfStatement(const QString& filename,
QList<PStatement> stats = statementMap.values(s);
PFileIncludes fileIncludes = mPreprocessor.includesList().value(filename,PFileIncludes());
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;
} else if (fileIncludes && (fileIncludes->includeFiles.contains(s->fileName)
|| fileIncludes->includeFiles.contains(s->definitionFileName))) {