From b287464b982b8e383a6d253f019544af4724eb97 Mon Sep 17 00:00:00 2001 From: Roy Qu Date: Wed, 25 Oct 2023 00:34:29 +0800 Subject: [PATCH] - fix: Macros that defined by the compiler are not correctly syntax-colored and tooltiped. --- NEWS.md | 1 + RedPandaIDE/mainwindow.cpp | 4 ++-- RedPandaIDE/parser/cppparser.cpp | 14 ++++++++------ 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/NEWS.md b/NEWS.md index 57f7b0bf..00475adb 100644 --- a/NEWS.md +++ b/NEWS.md @@ -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 diff --git a/RedPandaIDE/mainwindow.cpp b/RedPandaIDE/mainwindow.cpp index d08655a0..fb2c66a5 100644 --- a/RedPandaIDE/mainwindow.cpp +++ b/RedPandaIDE/mainwindow.cpp @@ -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()<canDebug(); break; case FileType::CppSource: diff --git a/RedPandaIDE/parser/cppparser.cpp b/RedPandaIDE/parser/cppparser.cpp index 5d09f19f..32acda4e 100644 --- a/RedPandaIDE/parser/cppparser.cpp +++ b/RedPandaIDE/parser/cppparser.cpp @@ -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"< 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))) {