fix: "." and ".." in included header paths not correctly handled
This commit is contained in:
parent
e13217a395
commit
09c7b5e791
|
@ -814,28 +814,40 @@ void CppParser::parseFile(const QString &fileName, bool inProject, bool onlyIfNo
|
||||||
if (onlyIfNotParsed && mPreprocessor.scannedFiles().contains(fName))
|
if (onlyIfNotParsed && mPreprocessor.scannedFiles().contains(fName))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
QSet<QString> filesToReparsed = calculateFilesToBeReparsed(fileName);
|
if (inProject) {
|
||||||
internalInvalidateFiles(filesToReparsed);
|
QSet<QString> filesToReparsed = calculateFilesToBeReparsed(fileName);
|
||||||
|
internalInvalidateFiles(filesToReparsed);
|
||||||
|
|
||||||
QStringList files = sortFilesByIncludeRelations(filesToReparsed);
|
QStringList files = sortFilesByIncludeRelations(filesToReparsed);
|
||||||
|
|
||||||
if (inProject)
|
mFilesToScanCount = files.count();
|
||||||
mProjectFiles.insert(fileName);
|
mFilesScannedCount = 0;
|
||||||
else {
|
|
||||||
mProjectFiles.remove(fileName);
|
foreach (const QString& file,files) {
|
||||||
|
mFilesScannedCount++;
|
||||||
|
emit onProgress(file,mFilesToScanCount,mFilesScannedCount);
|
||||||
|
if (!mPreprocessor.scannedFiles().contains(file)) {
|
||||||
|
internalParse(file);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
internalInvalidateFile(fileName);
|
||||||
|
mFilesToScanCount = 1;
|
||||||
|
mFilesScannedCount = 0;
|
||||||
|
|
||||||
|
mFilesScannedCount++;
|
||||||
|
emit onProgress(fileName,mFilesToScanCount,mFilesScannedCount);
|
||||||
|
internalParse(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if (inProject)
|
||||||
|
// mProjectFiles.insert(fileName);
|
||||||
|
// else {
|
||||||
|
// mProjectFiles.remove(fileName);
|
||||||
|
// }
|
||||||
|
|
||||||
// Parse from disk or stream
|
// Parse from disk or stream
|
||||||
mFilesToScanCount = files.count();
|
|
||||||
mFilesScannedCount = 0;
|
|
||||||
|
|
||||||
foreach (const QString& file,files) {
|
|
||||||
mFilesScannedCount++;
|
|
||||||
emit onProgress(file,mFilesToScanCount,mFilesScannedCount);
|
|
||||||
if (!mPreprocessor.scannedFiles().contains(file)) {
|
|
||||||
internalParse(file);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1442,7 +1454,8 @@ QStringList CppParser::sortFilesByIncludeRelations(const QSet<QString> &files)
|
||||||
if (mOnGetFileStream) {
|
if (mOnGetFileStream) {
|
||||||
mOnGetFileStream(file,buffer);
|
mOnGetFileStream(file,buffer);
|
||||||
}
|
}
|
||||||
mPreprocessor.setScanOptions(mParseGlobalHeaders, mParseLocalHeaders);
|
//we only use local include relations
|
||||||
|
mPreprocessor.setScanOptions(false, true);
|
||||||
mPreprocessor.preprocess(file,buffer);
|
mPreprocessor.preprocess(file,buffer);
|
||||||
mPreprocessor.clearTempResults();
|
mPreprocessor.clearTempResults();
|
||||||
}
|
}
|
||||||
|
@ -4324,10 +4337,11 @@ QSet<QString> CppParser::calculateFilesToBeReparsed(const QString &fileName)
|
||||||
return QSet<QString>();
|
return QSet<QString>();
|
||||||
QSet<QString> result;
|
QSet<QString> result;
|
||||||
result.insert(fileName);
|
result.insert(fileName);
|
||||||
foreach (const QString& file,mPreprocessor.includesList().keys()) {
|
foreach (const QString& file, mProjectFiles) {
|
||||||
PFileIncludes fileIncludes = mPreprocessor.includesList()[file];
|
PFileIncludes fileIncludes = mPreprocessor.includesList()[file];
|
||||||
if (fileIncludes->includeFiles.contains(fileName))
|
if (fileIncludes->includeFiles.contains(fileName)) {
|
||||||
result.insert(file);
|
result.insert(file);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -479,7 +479,6 @@ void CppPreprocessor::handleInclude(const QString &line, bool fromNext)
|
||||||
mOnGetFileStream(fileName,buffer);
|
mOnGetFileStream(fileName,buffer);
|
||||||
}
|
}
|
||||||
openInclude(fileName, buffer);
|
openInclude(fileName, buffer);
|
||||||
//oldCurrentIncludes->includeFiles.insert(fileName,true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CppPreprocessor::handlePreprocessor(const QString &value)
|
void CppPreprocessor::handlePreprocessor(const QString &value)
|
||||||
|
@ -730,12 +729,6 @@ void CppPreprocessor::openInclude(const QString &fileName, QStringList bufferedT
|
||||||
// do NOT create a new item for a file that's already in the list
|
// do NOT create a new item for a file that's already in the list
|
||||||
mCurrentIncludes = std::make_shared<FileIncludes>();
|
mCurrentIncludes = std::make_shared<FileIncludes>();
|
||||||
mCurrentIncludes->baseFile = fileName;
|
mCurrentIncludes->baseFile = fileName;
|
||||||
//mCurrentIncludes->includeFiles;
|
|
||||||
//mCurrentIncludes->usings;
|
|
||||||
//mCurrentIncludes->statements;
|
|
||||||
//mCurrentIncludes->scopes;
|
|
||||||
//mCurrentIncludes->dependedFiles;
|
|
||||||
//mCurrentIncludes->dependingFiles;
|
|
||||||
mIncludesList.insert(fileName,mCurrentIncludes);
|
mIncludesList.insert(fileName,mCurrentIncludes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -748,7 +741,7 @@ void CppPreprocessor::openInclude(const QString &fileName, QStringList bufferedT
|
||||||
mScannedFiles.insert(fileName);
|
mScannedFiles.insert(fileName);
|
||||||
|
|
||||||
// Only load up the file if we are allowed to parse it
|
// Only load up the file if we are allowed to parse it
|
||||||
bool isSystemFile = isSystemHeaderFile(fileName, mIncludePaths);
|
bool isSystemFile = isSystemHeaderFile(fileName, mIncludePaths) || isSystemHeaderFile(fileName, mProjectIncludePaths);
|
||||||
if ((mParseSystem && isSystemFile) || (mParseLocal && !isSystemFile)) {
|
if ((mParseSystem && isSystemFile) || (mParseLocal && !isSystemFile)) {
|
||||||
if (!bufferedText.isEmpty()) {
|
if (!bufferedText.isEmpty()) {
|
||||||
parsedFile->buffer = bufferedText;
|
parsedFile->buffer = bufferedText;
|
||||||
|
@ -764,9 +757,6 @@ void CppPreprocessor::openInclude(const QString &fileName, QStringList bufferedT
|
||||||
foreach (const QString& incFile,fileIncludes->includeFiles.keys()) {
|
foreach (const QString& incFile,fileIncludes->includeFiles.keys()) {
|
||||||
file->fileIncludes->includeFiles.insert(incFile,false);
|
file->fileIncludes->includeFiles.insert(incFile,false);
|
||||||
}
|
}
|
||||||
// file->fileIncludes->includeFiles =
|
|
||||||
// file->fileIncludes->includeFiles.unite(fileIncludes->includeFiles);
|
|
||||||
// file->fileIncludes->includeFiles.insert(fileIncludes->includeFiles);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mIncludes.append(parsedFile);
|
mIncludes.append(parsedFile);
|
||||||
|
|
|
@ -391,6 +391,7 @@ QString getHeaderFilename(const QString &relativeTo, const QString &line,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -400,7 +401,7 @@ QString getLocalHeaderFilename(const QString &relativeTo, const QString &fileNam
|
||||||
QDir dir = relativeFile.dir();
|
QDir dir = relativeFile.dir();
|
||||||
// Search local directory
|
// Search local directory
|
||||||
if (dir.exists(fileName)) {
|
if (dir.exists(fileName)) {
|
||||||
return dir.absoluteFilePath(fileName);
|
return QDir::cleanPath(dir.absoluteFilePath(fileName));
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
@ -411,8 +412,9 @@ QString getSystemHeaderFilename(const QString &fileName, const QStringList& incl
|
||||||
// Search compiler include directories
|
// Search compiler include directories
|
||||||
for (const QString& path:includePaths) {
|
for (const QString& path:includePaths) {
|
||||||
QDir dir(path);
|
QDir dir(path);
|
||||||
if (dir.exists(fileName))
|
if (dir.exists(fileName)) {
|
||||||
return dir.absoluteFilePath(fileName);
|
return QDir::cleanPath(dir.absoluteFilePath(fileName));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//not found
|
//not found
|
||||||
return "";
|
return "";
|
||||||
|
|
|
@ -76,14 +76,14 @@ enum StatementKind {
|
||||||
skEnumType,
|
skEnumType,
|
||||||
skEnumClassType,
|
skEnumClassType,
|
||||||
skTypedef,
|
skTypedef,
|
||||||
|
skConstructor,
|
||||||
|
skDestructor,
|
||||||
skFunction,
|
skFunction,
|
||||||
skVariable,
|
skVariable,
|
||||||
skGlobalVariable,
|
skGlobalVariable,
|
||||||
skLocalVariable,
|
skLocalVariable,
|
||||||
skEnum,
|
skEnum,
|
||||||
skOperator,
|
skOperator,
|
||||||
skConstructor,
|
|
||||||
skDestructor,
|
|
||||||
skParameter,
|
skParameter,
|
||||||
skBlock,
|
skBlock,
|
||||||
skUserCodeSnippet, // user code template
|
skUserCodeSnippet, // user code template
|
||||||
|
|
Loading…
Reference in New Issue