From 43dbbf798af85c9dcae23ec69de0005da9413dd3 Mon Sep 17 00:00:00 2001 From: Roy Qu Date: Sat, 28 Oct 2023 09:20:01 +0800 Subject: [PATCH] optimize --- RedPandaIDE/parser/cppparser.cpp | 6 ++++++ RedPandaIDE/parser/cpppreprocessor.cpp | 12 ++++++++++-- RedPandaIDE/parser/cpppreprocessor.h | 2 +- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/RedPandaIDE/parser/cppparser.cpp b/RedPandaIDE/parser/cppparser.cpp index ca8bc905..9cb96d5f 100644 --- a/RedPandaIDE/parser/cppparser.cpp +++ b/RedPandaIDE/parser/cppparser.cpp @@ -3454,6 +3454,12 @@ void CppParser::handlePreprocessor() if (delimPos>=0) { // qDebug()<line<baseFile; + } else { + mCurrentFile.squeeze(); + } mIsSystemHeader = isSystemHeaderFile(mCurrentFile) || isProjectHeaderFile(mCurrentFile); mIsProjectFile = mProjectFiles.contains(mCurrentFile); mIsHeader = isHFile(mCurrentFile); diff --git a/RedPandaIDE/parser/cpppreprocessor.cpp b/RedPandaIDE/parser/cpppreprocessor.cpp index 341cc6aa..2e1749e7 100644 --- a/RedPandaIDE/parser/cpppreprocessor.cpp +++ b/RedPandaIDE/parser/cpppreprocessor.cpp @@ -778,8 +778,17 @@ void CppPreprocessor::removeGCCAttribute(const QString &line, QString &newLine, } } -void CppPreprocessor::openInclude(const QString &fileName) +void CppPreprocessor::openInclude(QString fileName) { + fileName.squeeze(); + + PFileIncludes fileIncludes = getFileIncludesEntry(fileName); + if (fileIncludes) { + fileName = fileIncludes->baseFile; + } else { + fileName.squeeze(); + } + if (mIncludes.size()>0) { PParsedFile topFile = mIncludes.front(); if (topFile->fileIncludes->includeFiles.contains(fileName)) { @@ -826,7 +835,6 @@ void CppPreprocessor::openInclude(const QString &fileName) mCurrentIncludes->baseFile = fileName; mIncludesList.insert(fileName,mCurrentIncludes); } - parsedFile->fileIncludes = mCurrentIncludes; // Don't parse stuff we have already parsed diff --git a/RedPandaIDE/parser/cpppreprocessor.h b/RedPandaIDE/parser/cpppreprocessor.h index 165c76e1..37a9f31d 100644 --- a/RedPandaIDE/parser/cpppreprocessor.h +++ b/RedPandaIDE/parser/cpppreprocessor.h @@ -134,7 +134,7 @@ private: PParsedFile getInclude(int index) const { return mIncludes[index]; } - void openInclude(const QString& fileName); + void openInclude(QString fileName); void closeInclude(); // branch stuff