diff --git a/RedPandaIDE/parser/cppparser.cpp b/RedPandaIDE/parser/cppparser.cpp index cdad7f89..813fcc69 100644 --- a/RedPandaIDE/parser/cppparser.cpp +++ b/RedPandaIDE/parser/cppparser.cpp @@ -976,7 +976,7 @@ void CppParser::resetParser() mInlineNamespaces.clear(); mPreprocessor.clear(); - mTokenizer.reset(); + mTokenizer.clear(); } } @@ -3260,8 +3260,7 @@ void CppParser::internalParse(const QString &fileName) // Preprocess the file... { auto action = finally([this]{ - mPreprocessor.reset(); - mTokenizer.reset(); + mTokenizer.clear(); }); // Let the preprocessor augment the include records // mPreprocessor.setIncludesList(mIncludesList); @@ -3273,7 +3272,7 @@ void CppParser::internalParse(const QString &fileName) QStringList preprocessResult = mPreprocessor.result(); //reduce memory usage - mPreprocessor.clearResult(); + mPreprocessor.clearTempResults(); #ifdef QT_DEBUG // stringsToFile(mPreprocessor.result(),"r:\\preprocess.txt"); // mPreprocessor.dumpDefinesTo("r:\\defines.txt"); @@ -3301,7 +3300,7 @@ void CppParser::internalParse(const QString &fileName) // mStatementList.dumpAll("r:\\all-stats.txt"); #endif //reduce memory usage - mTokenizer.reset(); + mTokenizer.clear(); } } diff --git a/RedPandaIDE/parser/cpppreprocessor.cpp b/RedPandaIDE/parser/cpppreprocessor.cpp index a08d2bdb..59f36d9b 100644 --- a/RedPandaIDE/parser/cpppreprocessor.cpp +++ b/RedPandaIDE/parser/cpppreprocessor.cpp @@ -29,7 +29,7 @@ CppPreprocessor::CppPreprocessor() void CppPreprocessor::clear() { //don't use reset(), it will reset(add) defines. - clearResult(); + clearTempResults(); //Result across processings. //used by parser even preprocess finished @@ -48,7 +48,7 @@ void CppPreprocessor::clear() mIncludePaths.clear(); } -void CppPreprocessor::clearResult() +void CppPreprocessor::clearTempResults() { //temporary data when preprocessing single file mFileName=""; @@ -159,13 +159,6 @@ PDefine CppPreprocessor::getHardDefine(const QString &name) return mHardDefines.value(name,PDefine()); } -void CppPreprocessor::reset() -{ - clearResult(); - // Clear extracted data - resetDefines(); // do not throw away hardcoded -} - void CppPreprocessor::resetDefines() { mDefines = mHardDefines; @@ -182,8 +175,9 @@ void CppPreprocessor::setScanOptions(bool parseSystem, bool parseLocal) void CppPreprocessor::preprocess(const QString &fileName, QStringList buffer) { + clearTempResults(); mFileName = fileName; - reset(); + mDefines = mHardDefines; openInclude(fileName, buffer); // StringsToFile(mBuffer,"f:\\buffer.txt"); preprocessBuffer(); @@ -340,14 +334,11 @@ void CppPreprocessor::clearProjectIncludePaths() mProjectIncludePathList.clear(); } -void CppPreprocessor::clearScannedFiles() +void CppPreprocessor::removeScannedFile(const QString &filename) { - mScannedFiles.clear(); -} - -void CppPreprocessor::clearIncludeList() -{ - mIncludesList.clear(); + mScannedFiles.remove(filename); + mIncludesList.remove(filename); + mFileDefines.remove(filename); } QString CppPreprocessor::getNextPreprocessor() diff --git a/RedPandaIDE/parser/cpppreprocessor.h b/RedPandaIDE/parser/cpppreprocessor.h index 21dd3e36..46ec5e81 100644 --- a/RedPandaIDE/parser/cpppreprocessor.h +++ b/RedPandaIDE/parser/cpppreprocessor.h @@ -62,10 +62,10 @@ public: explicit CppPreprocessor(); void clear(); - void clearResult(); + + void clearTempResults(); void getDefineParts(const QString& input, QString &name, QString &args, QString &value); void addHardDefineByLine(const QString& line); - void reset(); //reset but don't clear generated defines void setScanOptions(bool parseSystem, bool parseLocal); void preprocess(const QString& fileName, QStringList buffer = QStringList()); @@ -75,8 +75,7 @@ public: void addProjectIncludePath(const QString& fileName); void clearIncludePaths(); void clearProjectIncludePaths(); - void clearScannedFiles(); - void clearIncludeList(); + QStringList result() const; QHash &includesList(); diff --git a/RedPandaIDE/parser/cpptokenizer.cpp b/RedPandaIDE/parser/cpptokenizer.cpp index 5830c663..39c6262a 100644 --- a/RedPandaIDE/parser/cpptokenizer.cpp +++ b/RedPandaIDE/parser/cpptokenizer.cpp @@ -24,7 +24,7 @@ CppTokenizer::CppTokenizer() } -void CppTokenizer::reset() +void CppTokenizer::clear() { mTokenList.clear(); mBuffer.clear(); @@ -34,7 +34,7 @@ void CppTokenizer::reset() void CppTokenizer::tokenize(const QStringList &buffer) { - reset(); + clear(); mBuffer = buffer; if (mBuffer.isEmpty()) diff --git a/RedPandaIDE/parser/cpptokenizer.h b/RedPandaIDE/parser/cpptokenizer.h index ec8a0426..56080034 100644 --- a/RedPandaIDE/parser/cpptokenizer.h +++ b/RedPandaIDE/parser/cpptokenizer.h @@ -31,7 +31,7 @@ public: using TokenList = QVector; explicit CppTokenizer(); - void reset(); + void clear(); void tokenize(const QStringList& buffer); void dumpTokens(const QString& fileName); const TokenList& tokens(); diff --git a/RedPandaIDE/project.cpp b/RedPandaIDE/project.cpp index baa5913a..1aa2226a 100644 --- a/RedPandaIDE/project.cpp +++ b/RedPandaIDE/project.cpp @@ -585,7 +585,7 @@ void Project::resetParserProjectFiles() mParser->clearProjectFiles(); mParser->clearProjectIncludePaths(); foreach (const PProjectUnit& unit, mUnits) { - mParser->addFileToScan(unit->fileName()); + mParser->addFileToScan(unit->fileName(),true); } foreach (const QString& s, mOptions.includeDirs) { mParser->addProjectIncludePath(s);