diff --git a/RedPandaIDE/parser/cppparser.cpp b/RedPandaIDE/parser/cppparser.cpp index de79bc34..e48ecefc 100644 --- a/RedPandaIDE/parser/cppparser.cpp +++ b/RedPandaIDE/parser/cppparser.cpp @@ -200,17 +200,17 @@ PStatement CppParser::findScopeStatement(const QString &filename, int line) PStatement CppParser::doFindScopeStatement(const QString &filename, int line) const { - PFileIncludes fileIncludes = mPreprocessor.findFileIncludes(filename); + PParsedFileInfo fileIncludes = mPreprocessor.findFileIncludes(filename); if (!fileIncludes) return PStatement(); return fileIncludes->scopes.findScopeAtLine(line); } -PFileIncludes CppParser::findFileIncludes(const QString &filename, bool deleteIt) +PParsedFileInfo CppParser::findFileIncludes(const QString &filename, bool deleteIt) { QMutexLocker locker(&mMutex); - PFileIncludes fileIncludes = mPreprocessor.findFileIncludes(filename); + PParsedFileInfo fileIncludes = mPreprocessor.findFileIncludes(filename); if (deleteIt && fileIncludes) mPreprocessor.removeFileIncludes(filename); return fileIncludes; @@ -234,7 +234,7 @@ QString CppParser::findTemplateParamOf(const QString &fileName, const QString &p PStatement CppParser::findFunctionAt(const QString &fileName, int line) { QMutexLocker locker(&mMutex); - PFileIncludes fileIncludes = mPreprocessor.findFileIncludes(fileName); + PParsedFileInfo fileIncludes = mPreprocessor.findFileIncludes(fileName); if (!fileIncludes) return PStatement(); for (PStatement& statement : fileIncludes->statements) { @@ -664,7 +664,7 @@ PStatement CppParser::doFindAliasedStatement(const PStatement &statement, QSettype.mid(0,pos); QString name = statement->type.mid(pos+2); - PFileIncludes fileIncludes = mPreprocessor.findFileIncludes(statement->fileName); + PParsedFileInfo fileIncludes = mPreprocessor.findFileIncludes(statement->fileName); if (!fileIncludes) return PStatement(); foundSet.insert(statement.get()); @@ -838,7 +838,7 @@ QStringList CppParser::getFileDirectIncludes(const QString &filename) return QStringList(); if (filename.isEmpty()) return QStringList(); - PFileIncludes fileIncludes = mPreprocessor.findFileIncludes(filename); + PParsedFileInfo fileIncludes = mPreprocessor.findFileIncludes(filename); if (fileIncludes) { return fileIncludes->directIncludes; @@ -854,7 +854,7 @@ QSet CppParser::internalGetIncludedFiles(const QString &filename) const if (filename.isEmpty()) return list; list.insert(filename); - PFileIncludes fileIncludes = mPreprocessor.findFileIncludes(filename); + PParsedFileInfo fileIncludes = mPreprocessor.findFileIncludes(filename); if (fileIncludes) { foreach (const QString& file, fileIncludes->includeFiles.keys()) { @@ -883,13 +883,13 @@ QSet CppParser::internalGetFileUsings(const QString &filename) const return result; // if (mParsing) // return result; - PFileIncludes fileIncludes= mPreprocessor.findFileIncludes(filename); + PParsedFileInfo fileIncludes= mPreprocessor.findFileIncludes(filename); if (fileIncludes) { foreach (const QString& usingName, fileIncludes->usings) { result.insert(usingName); } foreach (const QString& subFile,fileIncludes->includeFiles.keys()){ - PFileIncludes subIncludes = mPreprocessor.findFileIncludes(subFile); + PParsedFileInfo subIncludes = mPreprocessor.findFileIncludes(subFile); if (subIncludes) { foreach (const QString& usingName, subIncludes->usings) { result.insert(usingName); @@ -939,7 +939,7 @@ bool CppParser::isLineVisible(const QString &fileName, int line) if (mParsing) { return true; } - PFileIncludes fileIncludes = mPreprocessor.findFileIncludes(fileName); + PParsedFileInfo fileIncludes = mPreprocessor.findFileIncludes(fileName); if (!fileIncludes) return true; return fileIncludes->isLineVisible(line); @@ -1436,7 +1436,7 @@ PStatement CppParser::addStatement(const PStatement& parent, if (oldStatement && !oldStatement->hasDefinition()) { oldStatement->setHasDefinition(true); if (oldStatement->fileName!=fileName) { - PFileIncludes fileIncludes=mPreprocessor.findFileIncludes(fileName); + PParsedFileInfo fileIncludes=mPreprocessor.findFileIncludes(fileName); if (fileIncludes) { fileIncludes->statements.insert(oldStatement->fullName, oldStatement); @@ -1497,7 +1497,7 @@ PStatement CppParser::addStatement(const PStatement& parent, } if (result->kind!= StatementKind::Block) { - PFileIncludes fileIncludes = mPreprocessor.findFileIncludes(fileName); + PParsedFileInfo fileIncludes = mPreprocessor.findFileIncludes(fileName); if (fileIncludes) { fileIncludes->statements.insert(result->fullName,result); } @@ -1744,7 +1744,7 @@ void CppParser::addSoloScopeLevel(PStatement& statement, int line, bool shouldRe mCurrentScope.append(statement); - PFileIncludes fileIncludes = mPreprocessor.findFileIncludes(mCurrentFile); + PParsedFileInfo fileIncludes = mPreprocessor.findFileIncludes(mCurrentFile); if (fileIncludes) { fileIncludes->scopes.addScope(line,statement); @@ -1776,7 +1776,7 @@ void CppParser::removeScopeLevel(int line, int maxIndex) // qDebug()<<"--remove scope"<kind == StatementKind::Block) { if (currentScope->children.isEmpty()) { @@ -1841,7 +1841,7 @@ QStringList CppParser::sortFilesByIncludeRelations(const QSet &files) while (!fileSet.isEmpty()) { bool found=false; foreach (const QString& file,fileSet) { - PFileIncludes fileIncludes = mPreprocessor.findFileIncludes(file); + PParsedFileInfo fileIncludes = mPreprocessor.findFileIncludes(file); bool hasInclude=false; if (fileIncludes) { foreach(const QString& inc,fileIncludes->includeFiles.keys()) { @@ -3391,7 +3391,7 @@ void CppParser::handlePreprocessor() if (delimPos>=0) { // qDebug()<line<baseFile; } else { @@ -3974,7 +3974,7 @@ void CppParser::handleUsing(int maxIndex) scopeStatement->usingList.insert(fullName); } } else { - PFileIncludes fileInfo = mPreprocessor.findFileIncludes(mCurrentFile); + PParsedFileInfo fileInfo = mPreprocessor.findFileIncludes(mCurrentFile); if (!fileInfo) return; if (mNamespaces.contains(usingName)) { @@ -4281,7 +4281,7 @@ void CppParser::handleInheritance(PStatement derivedStatement, PClassInheritance inheritanceInfo->visibility); // inheritanceInfo->parentClassFilename = statement->fileName; inheritanceInfo->handled = true; - PFileIncludes fileIncludes = mPreprocessor.findFileIncludes(statement->fileName); + PParsedFileInfo fileIncludes = mPreprocessor.findFileIncludes(statement->fileName); Q_ASSERT(fileIncludes!=nullptr); fileIncludes->handledInheritances.append(inheritanceInfo); } @@ -4479,7 +4479,7 @@ PStatement CppParser::findMacro(const QString &phrase, const QString &fileName) if (statementMap.isEmpty()) return PStatement(); StatementList statements = statementMap.values(phrase); - PFileIncludes includes = mPreprocessor.findFileIncludes(fileName); + PParsedFileInfo includes = mPreprocessor.findFileIncludes(fileName); foreach (const PStatement& s, statements) { if (s->kind == StatementKind::Preprocessor) { if (includes && fileName != s->fileName && !includes->includeFiles.contains(s->fileName)) @@ -4542,7 +4542,7 @@ PStatement CppParser::findMemberOfStatement(const QString& filename, return statementMap.value(s,PStatement()); } else { QList stats = statementMap.values(s); - PFileIncludes fileIncludes = mPreprocessor.findFileIncludes(filename); + PParsedFileInfo fileIncludes = mPreprocessor.findFileIncludes(filename); foreach(const PStatement &s,stats) { if (s->line==-1) { return s; // hard defines @@ -5900,7 +5900,7 @@ void CppParser::internalInvalidateFile(const QString &fileName) return; // remove its include files list - PFileIncludes p = findFileIncludes(fileName, true); + PParsedFileInfo p = findFileIncludes(fileName, true); if (p) { //fPreprocessor.InvalidDefinesInFile(FileName); //we don't need this, since we reset defines after each parse //p->includeFiles.clear(); @@ -5963,7 +5963,7 @@ QSet CppParser::calculateFilesToBeReparsed(const QString &fileName) QSet result; result.insert(fileName); foreach (const QString& file, mProjectFiles) { - PFileIncludes fileIncludes = mPreprocessor.findFileIncludes(file); + PParsedFileInfo fileIncludes = mPreprocessor.findFileIncludes(file); if (fileIncludes && fileIncludes->includeFiles.contains(fileName)) { result.insert(file); } diff --git a/RedPandaIDE/parser/cppparser.h b/RedPandaIDE/parser/cppparser.h index 498e9068..e61b5f48 100644 --- a/RedPandaIDE/parser/cppparser.h +++ b/RedPandaIDE/parser/cppparser.h @@ -48,7 +48,7 @@ public: const QString& phrase, int line); PStatement findScopeStatement(const QString& filename, int line); - PFileIncludes findFileIncludes(const QString &filename, bool deleteIt = false); + PParsedFileInfo findFileIncludes(const QString &filename, bool deleteIt = false); QString findFirstTemplateParamOf(const QString& fileName, const QString& phrase, const PStatement& currentScope); diff --git a/RedPandaIDE/parser/cpppreprocessor.cpp b/RedPandaIDE/parser/cpppreprocessor.cpp index bd8718d8..0fef272c 100644 --- a/RedPandaIDE/parser/cpppreprocessor.cpp +++ b/RedPandaIDE/parser/cpppreprocessor.cpp @@ -224,7 +224,7 @@ void CppPreprocessor::dumpIncludesListTo(const QString &fileName) const QFile file(fileName); if (file.open(QIODevice::WriteOnly|QIODevice::Truncate)) { QTextStream stream(&file); - for (const PFileIncludes& fileIncludes:mIncludesList) { + for (const PParsedFileInfo& fileIncludes:mIncludesList) { stream<baseFile<<" : " #if QT_VERSION >= QT_VERSION_CHECK(5,15,0) <baseFile; } else { @@ -847,7 +847,7 @@ void CppPreprocessor::openInclude(QString fileName) mCurrentIncludes = getFileIncludesEntry(fileName); if (!mCurrentIncludes) { // do NOT create a new item for a file that's already in the list - mCurrentIncludes = std::make_shared(); + mCurrentIncludes = std::make_shared(); mCurrentIncludes->baseFile = fileName; mIncludesList.insert(fileName,mCurrentIncludes); } @@ -872,7 +872,7 @@ void CppPreprocessor::openInclude(QString fileName) } else { //add defines of already parsed including headers; addDefinesInFile(fileName); - PFileIncludes fileIncludes = getFileIncludesEntry(fileName); + PParsedFileInfo fileIncludes = getFileIncludesEntry(fileName); if (fileIncludes) { for (PParsedFile& file:mIncludes) { foreach (const QString& incFile,fileIncludes->includeFiles.keys()) { @@ -959,7 +959,7 @@ void CppPreprocessor::addDefinesInFile(const QString &fileName) } } - PFileIncludes fileIncludes = getFileIncludesEntry(fileName); + PParsedFileInfo fileIncludes = getFileIncludesEntry(fileName); if (fileIncludes) { foreach (const QString& file, fileIncludes->includeFiles.keys()) { addDefinesInFile(file); diff --git a/RedPandaIDE/parser/cpppreprocessor.h b/RedPandaIDE/parser/cpppreprocessor.h index aee839a8..f70fb86a 100644 --- a/RedPandaIDE/parser/cpppreprocessor.h +++ b/RedPandaIDE/parser/cpppreprocessor.h @@ -41,7 +41,7 @@ struct ParsedFile { QString fileName; // Record filename, but not used now QStringList buffer; // do not concat them all int branches; //branch levels; - PFileIncludes fileIncludes; // includes of this file + PParsedFileInfo fileIncludes; // includes of this file }; using PParsedFile = std::shared_ptr; @@ -91,7 +91,7 @@ public: return mResult; }; - PFileIncludes findFileIncludes(const QString& fileName) const { + PParsedFileInfo findFileIncludes(const QString& fileName) const { return mIncludesList.value(fileName); } @@ -183,8 +183,8 @@ private: } } // include stuff - PFileIncludes getFileIncludesEntry(const QString& fileName){ - return mIncludesList.value(fileName,PFileIncludes()); + PParsedFileInfo getFileIncludesEntry(const QString& fileName){ + return mIncludesList.value(fileName,PParsedFileInfo()); } void addDefinesInFile(const QString& fileName); void addDefineByParts(const QString& name, const QString& args, @@ -262,7 +262,7 @@ private: QString mFileName; QStringList mBuffer; QStringList mResult; - PFileIncludes mCurrentIncludes; + PParsedFileInfo mCurrentIncludes; int mPreProcIndex; QList mIncludes; // stack of files we've stepped into. last one is current file, first one is source file QList mBranchResults;// stack of branch results (boolean). last one is current branch, first one is outermost branch @@ -272,7 +272,7 @@ private: //Result across processings. //used by parser even preprocess finished - QHash mIncludesList; + QHash mIncludesList; QHash mFileDefines; //dictionary to save defines for each headerfile; QHash mFileUndefines; //dictionary to save defines for each headerfile; QSet mScannedFiles; diff --git a/RedPandaIDE/parser/parserutils.cpp b/RedPandaIDE/parser/parserutils.cpp index 623ba217..6b995fe3 100644 --- a/RedPandaIDE/parser/parserutils.cpp +++ b/RedPandaIDE/parser/parserutils.cpp @@ -767,7 +767,7 @@ bool isTypeKind(StatementKind kind) } } -bool FileIncludes::isLineVisible(int line) +bool ParsedFileInfo::isLineVisible(int line) { int lastI=-1; foreach(int i,branches.keys()) { diff --git a/RedPandaIDE/parser/parserutils.h b/RedPandaIDE/parser/parserutils.h index 4d516be5..462d42d9 100644 --- a/RedPandaIDE/parser/parserutils.h +++ b/RedPandaIDE/parser/parserutils.h @@ -317,7 +317,7 @@ struct ClassInheritanceInfo { using PClassInheritanceInfo = std::shared_ptr; -struct FileIncludes { +struct ParsedFileInfo { QString baseFile; QMap includeFiles; // true means the file is directly included, false means included indirectly QStringList directIncludes; // @@ -329,7 +329,7 @@ struct FileIncludes { QList> handledInheritances; bool isLineVisible(int line); }; -using PFileIncludes = std::shared_ptr; +using PParsedFileInfo = std::shared_ptr; extern QStringList CppDirectives; extern QStringList JavadocTags; diff --git a/RedPandaIDE/widgets/classbrowser.cpp b/RedPandaIDE/widgets/classbrowser.cpp index 64b58e4b..a181950a 100644 --- a/RedPandaIDE/widgets/classbrowser.cpp +++ b/RedPandaIDE/widgets/classbrowser.cpp @@ -283,7 +283,7 @@ void ClassBrowserModel::addMembers() if (mCurrentFile.isEmpty()) return; // show statements in the file - PFileIncludes p = mParser->findFileIncludes(mCurrentFile); + PParsedFileInfo p = mParser->findFileIncludes(mCurrentFile); if (!p) return; filterChildren(mRoot,p->statements); @@ -291,7 +291,7 @@ void ClassBrowserModel::addMembers() if (mParser->projectFiles().isEmpty()) return; foreach(const QString& file,mParser->projectFiles()) { - PFileIncludes p = mParser->findFileIncludes(file); + PParsedFileInfo p = mParser->findFileIncludes(file); if (!p) return; filterChildren(mRoot,p->statements);