- fix: Crash if #include a non-exist header file in the source.
This commit is contained in:
parent
ce9398c2a4
commit
aa12dcc4d1
1
NEWS.md
1
NEWS.md
|
@ -25,6 +25,7 @@ Red Panda C++ Version 2.26
|
||||||
- enhancement: Slightly reduce memory usage.
|
- enhancement: Slightly reduce memory usage.
|
||||||
- change: In Options -> Language -> Generate Assembly, option "Don't generate SEH directives" default to True.
|
- change: In Options -> Language -> Generate Assembly, option "Don't generate SEH directives" default to True.
|
||||||
- change: In Options —> Editor -> Code Suggestion, option "Hide symbols starting with underscore" default to True.
|
- change: In Options —> Editor -> Code Suggestion, option "Hide symbols starting with underscore" default to True.
|
||||||
|
- fix: Crash if include a non-exist header file in the source.
|
||||||
|
|
||||||
Red Panda C++ Version 2.25
|
Red Panda C++ Version 2.25
|
||||||
|
|
||||||
|
|
|
@ -358,8 +358,8 @@ void ProjectCompiler::writeMakeObjFilesRules(QFile &file)
|
||||||
writeln(file);
|
writeln(file);
|
||||||
QString objStr=genMakePath2(shortFileName);
|
QString objStr=genMakePath2(shortFileName);
|
||||||
// if we have scanned it, use scanned info
|
// if we have scanned it, use scanned info
|
||||||
if (parser && parser->scannedFiles().contains(unit->fileName())) {
|
if (parser && parser->fileScanned(unit->fileName())) {
|
||||||
QSet<QString> fileIncludes = parser->getFileIncludes(unit->fileName());
|
QSet<QString> fileIncludes = parser->getIncludedFiles(unit->fileName());
|
||||||
foreach(const PProjectUnit &unit2, projectUnits) {
|
foreach(const PProjectUnit &unit2, projectUnits) {
|
||||||
if (unit2==unit)
|
if (unit2==unit)
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -235,8 +235,8 @@ void SDCCProjectCompiler::writeMakeObjFilesRules(QFile &file)
|
||||||
writeln(file);
|
writeln(file);
|
||||||
QString objStr=genMakePath2(shortFileName);
|
QString objStr=genMakePath2(shortFileName);
|
||||||
// if we have scanned it, use scanned info
|
// if we have scanned it, use scanned info
|
||||||
if (parser && parser->scannedFiles().contains(unit->fileName())) {
|
if (parser && parser->fileScanned(unit->fileName())) {
|
||||||
QSet<QString> fileIncludes = parser->getFileIncludes(unit->fileName());
|
QSet<QString> fileIncludes = parser->getIncludedFiles(unit->fileName());
|
||||||
foreach(const PProjectUnit &unit2, projectUnits) {
|
foreach(const PProjectUnit &unit2, projectUnits) {
|
||||||
if (unit2==unit)
|
if (unit2==unit)
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -187,7 +187,7 @@ PStatement CppParser::findScopeStatement(const QString &filename, int line)
|
||||||
|
|
||||||
PStatement CppParser::doFindScopeStatement(const QString &filename, int line) const
|
PStatement CppParser::doFindScopeStatement(const QString &filename, int line) const
|
||||||
{
|
{
|
||||||
PFileIncludes fileIncludes = mPreprocessor.includesList().value(filename);
|
PFileIncludes fileIncludes = mPreprocessor.findFileIncludes(filename);
|
||||||
if (!fileIncludes)
|
if (!fileIncludes)
|
||||||
return PStatement();
|
return PStatement();
|
||||||
|
|
||||||
|
@ -197,9 +197,9 @@ PStatement CppParser::doFindScopeStatement(const QString &filename, int line) co
|
||||||
PFileIncludes CppParser::findFileIncludes(const QString &filename, bool deleteIt)
|
PFileIncludes CppParser::findFileIncludes(const QString &filename, bool deleteIt)
|
||||||
{
|
{
|
||||||
QMutexLocker locker(&mMutex);
|
QMutexLocker locker(&mMutex);
|
||||||
PFileIncludes fileIncludes = mPreprocessor.includesList().value(filename,PFileIncludes());
|
PFileIncludes fileIncludes = mPreprocessor.findFileIncludes(filename);
|
||||||
if (deleteIt && fileIncludes)
|
if (deleteIt && fileIncludes)
|
||||||
mPreprocessor.includesList().remove(filename);
|
mPreprocessor.removeFileIncludes(filename);
|
||||||
return fileIncludes;
|
return fileIncludes;
|
||||||
}
|
}
|
||||||
QString CppParser::findFirstTemplateParamOf(const QString &fileName, const QString &phrase, const PStatement& currentScope)
|
QString CppParser::findFirstTemplateParamOf(const QString &fileName, const QString &phrase, const PStatement& currentScope)
|
||||||
|
@ -221,7 +221,7 @@ QString CppParser::findTemplateParamOf(const QString &fileName, const QString &p
|
||||||
PStatement CppParser::findFunctionAt(const QString &fileName, int line)
|
PStatement CppParser::findFunctionAt(const QString &fileName, int line)
|
||||||
{
|
{
|
||||||
QMutexLocker locker(&mMutex);
|
QMutexLocker locker(&mMutex);
|
||||||
PFileIncludes fileIncludes = mPreprocessor.includesList().value(fileName);
|
PFileIncludes fileIncludes = mPreprocessor.findFileIncludes(fileName);
|
||||||
if (!fileIncludes)
|
if (!fileIncludes)
|
||||||
return PStatement();
|
return PStatement();
|
||||||
for (PStatement& statement : fileIncludes->statements) {
|
for (PStatement& statement : fileIncludes->statements) {
|
||||||
|
@ -775,7 +775,7 @@ QStringList CppParser::getFileDirectIncludes(const QString &filename)
|
||||||
return QStringList();
|
return QStringList();
|
||||||
if (filename.isEmpty())
|
if (filename.isEmpty())
|
||||||
return QStringList();
|
return QStringList();
|
||||||
PFileIncludes fileIncludes = mPreprocessor.includesList().value(filename,PFileIncludes());
|
PFileIncludes fileIncludes = mPreprocessor.findFileIncludes(filename);
|
||||||
|
|
||||||
if (fileIncludes) {
|
if (fileIncludes) {
|
||||||
return fileIncludes->directIncludes;
|
return fileIncludes->directIncludes;
|
||||||
|
@ -784,7 +784,7 @@ QStringList CppParser::getFileDirectIncludes(const QString &filename)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QSet<QString> CppParser::getFileIncludes(const QString &filename)
|
QSet<QString> CppParser::getIncludedFiles(const QString &filename)
|
||||||
{
|
{
|
||||||
QMutexLocker locker(&mMutex);
|
QMutexLocker locker(&mMutex);
|
||||||
QSet<QString> list;
|
QSet<QString> list;
|
||||||
|
@ -793,7 +793,7 @@ QSet<QString> CppParser::getFileIncludes(const QString &filename)
|
||||||
if (filename.isEmpty())
|
if (filename.isEmpty())
|
||||||
return list;
|
return list;
|
||||||
list.insert(filename);
|
list.insert(filename);
|
||||||
PFileIncludes fileIncludes = mPreprocessor.includesList().value(filename,PFileIncludes());
|
PFileIncludes fileIncludes = mPreprocessor.findFileIncludes(filename);
|
||||||
|
|
||||||
if (fileIncludes) {
|
if (fileIncludes) {
|
||||||
foreach (const QString& file, fileIncludes->includeFiles.keys()) {
|
foreach (const QString& file, fileIncludes->includeFiles.keys()) {
|
||||||
|
@ -816,13 +816,13 @@ QSet<QString> CppParser::internalGetFileUsings(const QString &filename) const
|
||||||
return result;
|
return result;
|
||||||
// if (mParsing)
|
// if (mParsing)
|
||||||
// return result;
|
// return result;
|
||||||
PFileIncludes fileIncludes= mPreprocessor.includesList().value(filename,PFileIncludes());
|
PFileIncludes fileIncludes= mPreprocessor.findFileIncludes(filename);
|
||||||
if (fileIncludes) {
|
if (fileIncludes) {
|
||||||
foreach (const QString& usingName, fileIncludes->usings) {
|
foreach (const QString& usingName, fileIncludes->usings) {
|
||||||
result.insert(usingName);
|
result.insert(usingName);
|
||||||
}
|
}
|
||||||
foreach (const QString& subFile,fileIncludes->includeFiles.keys()){
|
foreach (const QString& subFile,fileIncludes->includeFiles.keys()){
|
||||||
PFileIncludes subIncludes = mPreprocessor.includesList().value(subFile,PFileIncludes());
|
PFileIncludes subIncludes = mPreprocessor.findFileIncludes(subFile);
|
||||||
if (subIncludes) {
|
if (subIncludes) {
|
||||||
foreach (const QString& usingName, subIncludes->usings) {
|
foreach (const QString& usingName, subIncludes->usings) {
|
||||||
result.insert(usingName);
|
result.insert(usingName);
|
||||||
|
@ -872,7 +872,7 @@ bool CppParser::isLineVisible(const QString &fileName, int line)
|
||||||
if (mParsing) {
|
if (mParsing) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
PFileIncludes fileIncludes = mPreprocessor.includesList().value(fileName);
|
PFileIncludes fileIncludes = mPreprocessor.findFileIncludes(fileName);
|
||||||
if (!fileIncludes)
|
if (!fileIncludes)
|
||||||
return true;
|
return true;
|
||||||
return fileIncludes->isLineVisible(line);
|
return fileIncludes->isLineVisible(line);
|
||||||
|
@ -952,7 +952,7 @@ void CppParser::parseFile(const QString &fileName, bool inProject, bool onlyIfNo
|
||||||
emit onEndParsing(mFilesScannedCount,0);
|
emit onEndParsing(mFilesScannedCount,0);
|
||||||
});
|
});
|
||||||
QString fName = fileName;
|
QString fName = fileName;
|
||||||
if (onlyIfNotParsed && mPreprocessor.scannedFiles().contains(fName))
|
if (onlyIfNotParsed && mPreprocessor.fileScanned(fName))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (inProject) {
|
if (inProject) {
|
||||||
|
@ -966,7 +966,7 @@ void CppParser::parseFile(const QString &fileName, bool inProject, bool onlyIfNo
|
||||||
foreach (const QString& file,files) {
|
foreach (const QString& file,files) {
|
||||||
mFilesScannedCount++;
|
mFilesScannedCount++;
|
||||||
emit onProgress(file,mFilesToScanCount,mFilesScannedCount);
|
emit onProgress(file,mFilesToScanCount,mFilesScannedCount);
|
||||||
if (!mPreprocessor.scannedFiles().contains(file)) {
|
if (!mPreprocessor.fileScanned(file)) {
|
||||||
internalParse(file);
|
internalParse(file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1022,7 +1022,7 @@ void CppParser::parseFileList(bool updateView)
|
||||||
foreach (const QString& file, files) {
|
foreach (const QString& file, files) {
|
||||||
mFilesScannedCount++;
|
mFilesScannedCount++;
|
||||||
emit onProgress(mCurrentFile,mFilesToScanCount,mFilesScannedCount);
|
emit onProgress(mCurrentFile,mFilesToScanCount,mFilesScannedCount);
|
||||||
if (!mPreprocessor.scannedFiles().contains(file)) {
|
if (!mPreprocessor.fileScanned(file)) {
|
||||||
internalParse(file);
|
internalParse(file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1119,14 +1119,17 @@ void CppParser::unFreeze()
|
||||||
mLockCount--;
|
mLockCount--;
|
||||||
}
|
}
|
||||||
|
|
||||||
QSet<QString> CppParser::scannedFiles()
|
bool CppParser::fileScanned(const QString &fileName)
|
||||||
{
|
{
|
||||||
return mPreprocessor.scannedFiles();
|
QMutexLocker locker(&mMutex);
|
||||||
|
if (mParsing)
|
||||||
|
return false;
|
||||||
|
return mPreprocessor.fileScanned(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CppParser::isFileParsed(const QString &filename)
|
bool CppParser::isFileParsed(const QString &filename)
|
||||||
{
|
{
|
||||||
return mPreprocessor.scannedFiles().contains(filename);
|
return mPreprocessor.fileScanned(filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString CppParser::getScopePrefix(const PStatement& statement) const{
|
QString CppParser::getScopePrefix(const PStatement& statement) const{
|
||||||
|
@ -1280,7 +1283,7 @@ void CppParser::addProjectFile(const QString &fileName, bool needScan)
|
||||||
mProjectFiles.insert(fileName);
|
mProjectFiles.insert(fileName);
|
||||||
|
|
||||||
// Only parse given file
|
// Only parse given file
|
||||||
if (needScan && !mPreprocessor.scannedFiles().contains(fileName)) {
|
if (needScan && !mPreprocessor.fileScanned(fileName)) {
|
||||||
mFilesToScan.insert(fileName);
|
mFilesToScan.insert(fileName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1362,7 +1365,7 @@ PStatement CppParser::addStatement(const PStatement& parent,
|
||||||
if (oldStatement && !oldStatement->hasDefinition()) {
|
if (oldStatement && !oldStatement->hasDefinition()) {
|
||||||
oldStatement->setHasDefinition(true);
|
oldStatement->setHasDefinition(true);
|
||||||
if (oldStatement->fileName!=fileName) {
|
if (oldStatement->fileName!=fileName) {
|
||||||
PFileIncludes fileIncludes=mPreprocessor.includesList().value(fileName);
|
PFileIncludes fileIncludes=mPreprocessor.findFileIncludes(fileName);
|
||||||
if (fileIncludes) {
|
if (fileIncludes) {
|
||||||
fileIncludes->statements.insert(oldStatement->fullName,
|
fileIncludes->statements.insert(oldStatement->fullName,
|
||||||
oldStatement);
|
oldStatement);
|
||||||
|
@ -1424,7 +1427,7 @@ PStatement CppParser::addStatement(const PStatement& parent,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result->kind!= StatementKind::skBlock) {
|
if (result->kind!= StatementKind::skBlock) {
|
||||||
PFileIncludes fileIncludes = mPreprocessor.includesList().value(fileName);
|
PFileIncludes fileIncludes = mPreprocessor.findFileIncludes(fileName);
|
||||||
if (fileIncludes) {
|
if (fileIncludes) {
|
||||||
fileIncludes->statements.insert(result->fullName,result);
|
fileIncludes->statements.insert(result->fullName,result);
|
||||||
}
|
}
|
||||||
|
@ -1663,7 +1666,7 @@ void CppParser::addSoloScopeLevel(PStatement& statement, int line, bool shouldRe
|
||||||
|
|
||||||
mCurrentScope.append(statement);
|
mCurrentScope.append(statement);
|
||||||
|
|
||||||
PFileIncludes fileIncludes = mPreprocessor.includesList().value(mCurrentFile);
|
PFileIncludes fileIncludes = mPreprocessor.findFileIncludes(mCurrentFile);
|
||||||
|
|
||||||
if (fileIncludes) {
|
if (fileIncludes) {
|
||||||
fileIncludes->scopes.addScope(line,statement);
|
fileIncludes->scopes.addScope(line,statement);
|
||||||
|
@ -1695,17 +1698,17 @@ void CppParser::removeScopeLevel(int line)
|
||||||
// qDebug()<<"--remove scope"<<mCurrentFile<<line<<mCurrentClassScope.count();
|
// qDebug()<<"--remove scope"<<mCurrentFile<<line<<mCurrentClassScope.count();
|
||||||
#endif
|
#endif
|
||||||
PStatement currentScope = getCurrentScope();
|
PStatement currentScope = getCurrentScope();
|
||||||
PFileIncludes fileIncludes = mPreprocessor.includesList().value(mCurrentFile);
|
PFileIncludes fileIncludes = mPreprocessor.findFileIncludes(mCurrentFile);
|
||||||
if (currentScope) {
|
if (currentScope) {
|
||||||
if (currentScope->kind == StatementKind::skBlock) {
|
if (currentScope->kind == StatementKind::skBlock) {
|
||||||
if (currentScope->children.isEmpty()) {
|
if (currentScope->children.isEmpty()) {
|
||||||
// remove no children block
|
// remove no children block
|
||||||
if (fileIncludes) {
|
if (fileIncludes)
|
||||||
fileIncludes->scopes.removeLastScope();
|
fileIncludes->scopes.removeLastScope();
|
||||||
}
|
|
||||||
mStatementList.deleteStatement(currentScope);
|
mStatementList.deleteStatement(currentScope);
|
||||||
} else {
|
} else {
|
||||||
fileIncludes->statements.insert(currentScope->fullName,currentScope);
|
if (fileIncludes)
|
||||||
|
fileIncludes->statements.insert(currentScope->fullName,currentScope);
|
||||||
}
|
}
|
||||||
} else if (currentScope->kind == StatementKind::skClass) {
|
} else if (currentScope->kind == StatementKind::skClass) {
|
||||||
mIndex=indexOfNextSemicolon(mIndex);
|
mIndex=indexOfNextSemicolon(mIndex);
|
||||||
|
@ -1742,13 +1745,11 @@ void CppParser::internalClear()
|
||||||
QStringList CppParser::sortFilesByIncludeRelations(const QSet<QString> &files)
|
QStringList CppParser::sortFilesByIncludeRelations(const QSet<QString> &files)
|
||||||
{
|
{
|
||||||
QStringList result;
|
QStringList result;
|
||||||
QSet<QString> saveScannedFiles;
|
QSet<QString> saveScannedFiles{mPreprocessor.scannedFiles()};
|
||||||
|
|
||||||
saveScannedFiles=mPreprocessor.scannedFiles();
|
|
||||||
|
|
||||||
//rebuild file include relations
|
//rebuild file include relations
|
||||||
foreach(const QString& file, files) {
|
foreach(const QString& file, files) {
|
||||||
if (mPreprocessor.scannedFiles().contains(file))
|
if (mPreprocessor.fileScanned(file))
|
||||||
continue;
|
continue;
|
||||||
//already removed in interalInvalidateFiles
|
//already removed in interalInvalidateFiles
|
||||||
//mPreprocessor.removeScannedFile(file);
|
//mPreprocessor.removeScannedFile(file);
|
||||||
|
@ -1762,12 +1763,14 @@ QStringList CppParser::sortFilesByIncludeRelations(const QSet<QString> &files)
|
||||||
while (!fileSet.isEmpty()) {
|
while (!fileSet.isEmpty()) {
|
||||||
bool found=false;
|
bool found=false;
|
||||||
foreach (const QString& file,fileSet) {
|
foreach (const QString& file,fileSet) {
|
||||||
PFileIncludes fileIncludes = mPreprocessor.includesList().value(file);
|
PFileIncludes fileIncludes = mPreprocessor.findFileIncludes(file);
|
||||||
bool hasInclude=false;
|
bool hasInclude=false;
|
||||||
foreach(const QString& inc,fileIncludes->includeFiles.keys()) {
|
if (fileIncludes) {
|
||||||
if (fileSet.contains(inc)) {
|
foreach(const QString& inc,fileIncludes->includeFiles.keys()) {
|
||||||
hasInclude=true;
|
if (fileSet.contains(inc)) {
|
||||||
break;
|
hasInclude=true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!hasInclude) {
|
if (!hasInclude) {
|
||||||
|
@ -1784,7 +1787,7 @@ QStringList CppParser::sortFilesByIncludeRelations(const QSet<QString> &files)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
QSet<QString> newScannedFiles = mPreprocessor.scannedFiles();
|
QSet<QString> newScannedFiles{mPreprocessor.scannedFiles()};
|
||||||
foreach(const QString& file, newScannedFiles) {
|
foreach(const QString& file, newScannedFiles) {
|
||||||
if (!saveScannedFiles.contains(file))
|
if (!saveScannedFiles.contains(file))
|
||||||
mPreprocessor.removeScannedFile(file);
|
mPreprocessor.removeScannedFile(file);
|
||||||
|
@ -3454,7 +3457,7 @@ void CppParser::handlePreprocessor()
|
||||||
if (delimPos>=0) {
|
if (delimPos>=0) {
|
||||||
// qDebug()<<mCurrentScope.size()<<mCurrentFile<<mTokenizer[mIndex]->line<<s.mid(0,delimPos).trimmed();
|
// qDebug()<<mCurrentScope.size()<<mCurrentFile<<mTokenizer[mIndex]->line<<s.mid(0,delimPos).trimmed();
|
||||||
mCurrentFile = s.mid(0,delimPos).trimmed();
|
mCurrentFile = s.mid(0,delimPos).trimmed();
|
||||||
PFileIncludes fileIncludes = mPreprocessor.includesList().value(mCurrentFile);
|
PFileIncludes fileIncludes = mPreprocessor.findFileIncludes(mCurrentFile);
|
||||||
if (fileIncludes) {
|
if (fileIncludes) {
|
||||||
mCurrentFile = fileIncludes->baseFile;
|
mCurrentFile = fileIncludes->baseFile;
|
||||||
} else {
|
} else {
|
||||||
|
@ -4061,7 +4064,7 @@ void CppParser::handleUsing()
|
||||||
scopeStatement->usingList.insert(fullName);
|
scopeStatement->usingList.insert(fullName);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
PFileIncludes fileInfo = mPreprocessor.includesList().value(mCurrentFile);
|
PFileIncludes fileInfo = mPreprocessor.findFileIncludes(mCurrentFile);
|
||||||
if (!fileInfo)
|
if (!fileInfo)
|
||||||
return;
|
return;
|
||||||
if (mNamespaces.contains(usingName)) {
|
if (mNamespaces.contains(usingName)) {
|
||||||
|
@ -4538,7 +4541,7 @@ PStatement CppParser::findMacro(const QString &phrase, const QString &fileName)
|
||||||
if (statementMap.isEmpty())
|
if (statementMap.isEmpty())
|
||||||
return PStatement();
|
return PStatement();
|
||||||
StatementList statements = statementMap.values(phrase);
|
StatementList statements = statementMap.values(phrase);
|
||||||
PFileIncludes includes = mPreprocessor.includesList().value(fileName,PFileIncludes());
|
PFileIncludes includes = mPreprocessor.findFileIncludes(fileName);
|
||||||
foreach (const PStatement& s, statements) {
|
foreach (const PStatement& s, statements) {
|
||||||
if (s->kind == StatementKind::skPreprocessor) {
|
if (s->kind == StatementKind::skPreprocessor) {
|
||||||
if (includes && !includes->includeFiles.contains(s->fileName)
|
if (includes && !includes->includeFiles.contains(s->fileName)
|
||||||
|
@ -4602,7 +4605,7 @@ PStatement CppParser::findMemberOfStatement(const QString& filename,
|
||||||
return statementMap.value(s,PStatement());
|
return statementMap.value(s,PStatement());
|
||||||
} else {
|
} else {
|
||||||
QList<PStatement> stats = statementMap.values(s);
|
QList<PStatement> stats = statementMap.values(s);
|
||||||
PFileIncludes fileIncludes = mPreprocessor.includesList().value(filename,PFileIncludes());
|
PFileIncludes fileIncludes = mPreprocessor.findFileIncludes(filename);
|
||||||
foreach(const PStatement &s,stats) {
|
foreach(const PStatement &s,stats) {
|
||||||
if (s->line==-1) {
|
if (s->line==-1) {
|
||||||
return s; // hard defines
|
return s; // hard defines
|
||||||
|
@ -5952,7 +5955,7 @@ QSet<QString> CppParser::calculateFilesToBeReparsed(const QString &fileName)
|
||||||
QSet<QString> result;
|
QSet<QString> result;
|
||||||
result.insert(fileName);
|
result.insert(fileName);
|
||||||
foreach (const QString& file, mProjectFiles) {
|
foreach (const QString& file, mProjectFiles) {
|
||||||
PFileIncludes fileIncludes = mPreprocessor.includesList().value(file,PFileIncludes());
|
PFileIncludes fileIncludes = mPreprocessor.findFileIncludes(file);
|
||||||
if (fileIncludes && fileIncludes->includeFiles.contains(fileName)) {
|
if (fileIncludes && fileIncludes->includeFiles.contains(fileName)) {
|
||||||
result.insert(file);
|
result.insert(file);
|
||||||
}
|
}
|
||||||
|
|
|
@ -98,7 +98,7 @@ public:
|
||||||
bool freeze(const QString& serialId); // Freeze/Lock (stop reparse while searching)
|
bool freeze(const QString& serialId); // Freeze/Lock (stop reparse while searching)
|
||||||
QStringList getClassesList();
|
QStringList getClassesList();
|
||||||
QStringList getFileDirectIncludes(const QString& filename);
|
QStringList getFileDirectIncludes(const QString& filename);
|
||||||
QSet<QString> getFileIncludes(const QString& filename);
|
QSet<QString> getIncludedFiles(const QString& filename);
|
||||||
QSet<QString> getFileUsings(const QString& filename);
|
QSet<QString> getFileUsings(const QString& filename);
|
||||||
|
|
||||||
QString getHeaderFileName(const QString& relativeTo, const QString& headerName, bool fromNext=false);// both
|
QString getHeaderFileName(const QString& relativeTo, const QString& headerName, bool fromNext=false);// both
|
||||||
|
@ -116,7 +116,7 @@ public:
|
||||||
bool parsing() const;
|
bool parsing() const;
|
||||||
void resetParser();
|
void resetParser();
|
||||||
void unFreeze(); // UnFree/UnLock (reparse while searching)
|
void unFreeze(); // UnFree/UnLock (reparse while searching)
|
||||||
QSet<QString> scannedFiles();
|
bool fileScanned(const QString& fileName);
|
||||||
|
|
||||||
bool isFileParsed(const QString& filename);
|
bool isFileParsed(const QString& filename);
|
||||||
|
|
||||||
|
|
|
@ -857,9 +857,11 @@ void CppPreprocessor::openInclude(QString fileName)
|
||||||
//add defines of already parsed including headers;
|
//add defines of already parsed including headers;
|
||||||
addDefinesInFile(fileName);
|
addDefinesInFile(fileName);
|
||||||
PFileIncludes fileIncludes = getFileIncludesEntry(fileName);
|
PFileIncludes fileIncludes = getFileIncludesEntry(fileName);
|
||||||
for (PParsedFile& file:mIncludes) {
|
if (fileIncludes) {
|
||||||
foreach (const QString& incFile,fileIncludes->includeFiles.keys()) {
|
for (PParsedFile& file:mIncludes) {
|
||||||
file->fileIncludes->includeFiles.insert(incFile,false);
|
foreach (const QString& incFile,fileIncludes->includeFiles.keys()) {
|
||||||
|
file->fileIncludes->includeFiles.insert(incFile,false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -942,8 +944,10 @@ void CppPreprocessor::addDefinesInFile(const QString &fileName)
|
||||||
}
|
}
|
||||||
|
|
||||||
PFileIncludes fileIncludes = getFileIncludesEntry(fileName);
|
PFileIncludes fileIncludes = getFileIncludesEntry(fileName);
|
||||||
foreach (const QString& file, fileIncludes->includeFiles.keys()) {
|
if (fileIncludes) {
|
||||||
addDefinesInFile(file);
|
foreach (const QString& file, fileIncludes->includeFiles.keys()) {
|
||||||
|
addDefinesInFile(file);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2022,28 +2026,3 @@ const DefineMap &CppPreprocessor::hardDefines() const
|
||||||
{
|
{
|
||||||
return mHardDefines;
|
return mHardDefines;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QSet<QString> &CppPreprocessor::projectIncludePaths()
|
|
||||||
{
|
|
||||||
return mProjectIncludePaths;
|
|
||||||
}
|
|
||||||
|
|
||||||
const QSet<QString> &CppPreprocessor::includePaths()
|
|
||||||
{
|
|
||||||
return mIncludePaths;
|
|
||||||
}
|
|
||||||
|
|
||||||
QSet<QString> &CppPreprocessor::scannedFiles()
|
|
||||||
{
|
|
||||||
return mScannedFiles;
|
|
||||||
}
|
|
||||||
|
|
||||||
QHash<QString, PFileIncludes> &CppPreprocessor::includesList()
|
|
||||||
{
|
|
||||||
return mIncludesList;
|
|
||||||
}
|
|
||||||
|
|
||||||
const QHash<QString, PFileIncludes> &CppPreprocessor::includesList() const
|
|
||||||
{
|
|
||||||
return mIncludesList;
|
|
||||||
}
|
|
||||||
|
|
|
@ -84,15 +84,29 @@ public:
|
||||||
return mResult;
|
return mResult;
|
||||||
};
|
};
|
||||||
|
|
||||||
QHash<QString, PFileIncludes> &includesList();
|
PFileIncludes findFileIncludes(const QString& fileName) const {
|
||||||
|
return mIncludesList.value(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
const QHash<QString, PFileIncludes> &includesList() const;
|
void removeFileIncludes(const QString& fileName) {
|
||||||
|
mIncludesList.remove(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
QSet<QString> &scannedFiles();
|
bool fileScanned(const QString& fileName) const {
|
||||||
|
return mScannedFiles.contains(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
const QSet<QString> &includePaths();
|
const QSet<QString>& includePaths() const {
|
||||||
|
return mIncludePaths;
|
||||||
|
}
|
||||||
|
|
||||||
const QSet<QString> &projectIncludePaths();
|
const QSet<QString>& scannedFiles() const {
|
||||||
|
return mScannedFiles;
|
||||||
|
}
|
||||||
|
|
||||||
|
const QSet<QString> &projectIncludePaths() {
|
||||||
|
return mProjectIncludePaths;
|
||||||
|
}
|
||||||
|
|
||||||
const DefineMap &hardDefines() const;
|
const DefineMap &hardDefines() const;
|
||||||
|
|
||||||
|
|
|
@ -98,15 +98,15 @@ void CodeCompletionPopup::prepareSearch(
|
||||||
getCompletionListForComplexKeyword(preWord);
|
getCompletionListForComplexKeyword(preWord);
|
||||||
break;
|
break;
|
||||||
case CodeCompletionType::Types:
|
case CodeCompletionType::Types:
|
||||||
mIncludedFiles = mParser->getFileIncludes(filename);
|
mIncludedFiles = mParser->getIncludedFiles(filename);
|
||||||
getCompletionListForTypes(preWord,filename,line);
|
getCompletionListForTypes(preWord,filename,line);
|
||||||
break;
|
break;
|
||||||
case CodeCompletionType::FunctionWithoutDefinition:
|
case CodeCompletionType::FunctionWithoutDefinition:
|
||||||
mIncludedFiles = mParser->getFileIncludes(filename);
|
mIncludedFiles = mParser->getIncludedFiles(filename);
|
||||||
getCompletionForFunctionWithoutDefinition(preWord, ownerExpression,memberOperator,memberExpression, filename,line);
|
getCompletionForFunctionWithoutDefinition(preWord, ownerExpression,memberOperator,memberExpression, filename,line);
|
||||||
break;
|
break;
|
||||||
case CodeCompletionType::Namespaces:
|
case CodeCompletionType::Namespaces:
|
||||||
mIncludedFiles = mParser->getFileIncludes(filename);
|
mIncludedFiles = mParser->getIncludedFiles(filename);
|
||||||
getCompletionListForNamespaces(preWord,filename,line);
|
getCompletionListForNamespaces(preWord,filename,line);
|
||||||
break;
|
break;
|
||||||
case CodeCompletionType::KeywordsOnly:
|
case CodeCompletionType::KeywordsOnly:
|
||||||
|
@ -114,7 +114,7 @@ void CodeCompletionPopup::prepareSearch(
|
||||||
getKeywordCompletionFor(customKeywords);
|
getKeywordCompletionFor(customKeywords);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
mIncludedFiles = mParser->getFileIncludes(filename);
|
mIncludedFiles = mParser->getIncludedFiles(filename);
|
||||||
getCompletionFor(ownerExpression,memberOperator,memberExpression, filename,line, customKeywords);
|
getCompletionFor(ownerExpression,memberOperator,memberExpression, filename,line, customKeywords);
|
||||||
}
|
}
|
||||||
setCursor(oldCursor);
|
setCursor(oldCursor);
|
||||||
|
|
Loading…
Reference in New Issue