diff --git a/src/plugins/cppeditor/cppmodelmanager.cpp b/src/plugins/cppeditor/cppmodelmanager.cpp index 1f22b3e08bd..93d830df6ee 100644 --- a/src/plugins/cppeditor/cppmodelmanager.cpp +++ b/src/plugins/cppeditor/cppmodelmanager.cpp @@ -1238,7 +1238,6 @@ static QSet filteredFilesRemoved(const QSet &files, int fileSi return files; QSet result; - QFileInfo fileInfo; QList regexes; const QStringList wildcards = ignorePattern.split('\n'); @@ -1246,19 +1245,19 @@ static QSet filteredFilesRemoved(const QSet &files, int fileSi regexes.append(QRegularExpression::fromWildcard(wildcard, Qt::CaseInsensitive, QRegularExpression::UnanchoredWildcardConversion)); - for (const QString &filePath : files) { - fileInfo.setFile(filePath); - if (fileSizeLimitInMb > 0 && fileSizeExceedsLimit(fileInfo, fileSizeLimitInMb)) + for (const QString &file : files) { + const FilePath filePath = FilePath::fromString(file); + if (fileSizeLimitInMb > 0 && fileSizeExceedsLimit(filePath, fileSizeLimitInMb)) continue; bool skip = false; if (ignoreFiles) { for (const QRegularExpression &rx: std::as_const(regexes)) { - QRegularExpressionMatch match = rx.match(fileInfo.absoluteFilePath()); + QRegularExpressionMatch match = rx.match(filePath.absoluteFilePath().path()); if (match.hasMatch()) { const QString msg = QCoreApplication::translate( "CppIndexer", "C++ Indexer: Skipping file \"%1\" because its path matches the ignore pattern.") - .arg(filePath); + .arg(filePath.displayName()); QMetaObject::invokeMethod(Core::MessageManager::instance(), [msg]() { Core::MessageManager::writeSilently(msg); }); skip = true; @@ -1268,7 +1267,7 @@ static QSet filteredFilesRemoved(const QSet &files, int fileSi } if (!skip) - result << filePath; + result << filePath.toString(); } return result; diff --git a/src/plugins/cppeditor/cppsourceprocessor.cpp b/src/plugins/cppeditor/cppsourceprocessor.cpp index df34da8edfd..97537b5e3c8 100644 --- a/src/plugins/cppeditor/cppsourceprocessor.cpp +++ b/src/plugins/cppeditor/cppsourceprocessor.cpp @@ -422,8 +422,7 @@ void CppSourceProcessor::sourceNeeded(int line, const FilePath &filePath, Includ return; } - const QFileInfo info = absoluteFilePath.toFileInfo(); - if (fileSizeExceedsLimit(info, m_fileSizeLimitInMb)) + if (fileSizeExceedsLimit(absoluteFilePath, m_fileSizeLimitInMb)) return; // TODO: Add diagnostic message // Otherwise get file contents @@ -445,8 +444,8 @@ void CppSourceProcessor::sourceNeeded(int line, const FilePath &filePath, Includ Document::Include inc(include.toString(), include, 0, IncludeLocal); document->addIncludeFile(inc); } - if (info.exists()) - document->setLastModified(info.lastModified()); + if (absoluteFilePath.exists()) + document->setLastModified(absoluteFilePath.lastModified()); const Document::Ptr previousDocument = switchCurrentDocument(document); const QByteArray preprocessedCode = m_preprocess.run(absoluteFilePath, contents); diff --git a/src/plugins/cppeditor/cpptoolsreuse.cpp b/src/plugins/cppeditor/cpptoolsreuse.cpp index dc10449d210..247c8faccff 100644 --- a/src/plugins/cppeditor/cpptoolsreuse.cpp +++ b/src/plugins/cppeditor/cpptoolsreuse.cpp @@ -39,6 +39,7 @@ #include using namespace CPlusPlus; +using namespace Utils; namespace CppEditor { @@ -336,18 +337,17 @@ int indexerFileSizeLimitInMb() return -1; } -bool fileSizeExceedsLimit(const QFileInfo &fileInfo, int sizeLimitInMb) +bool fileSizeExceedsLimit(const FilePath &filePath, int sizeLimitInMb) { if (sizeLimitInMb <= 0) return false; - const qint64 fileSizeInMB = fileInfo.size() / (1000 * 1000); + const qint64 fileSizeInMB = filePath.fileSize() / (1000 * 1000); if (fileSizeInMB > sizeLimitInMb) { - const QString absoluteFilePath = fileInfo.absoluteFilePath(); const QString msg = QCoreApplication::translate( "CppIndexer", "C++ Indexer: Skipping file \"%1\" because it is too big.") - .arg(absoluteFilePath); + .arg(filePath.displayName()); QMetaObject::invokeMethod(Core::MessageManager::instance(), [msg]() { Core::MessageManager::writeSilently(msg); }); diff --git a/src/plugins/cppeditor/cpptoolsreuse.h b/src/plugins/cppeditor/cpptoolsreuse.h index 67abc2258af..06eba69c697 100644 --- a/src/plugins/cppeditor/cpptoolsreuse.h +++ b/src/plugins/cppeditor/cpptoolsreuse.h @@ -16,12 +16,6 @@ #include #include -QT_BEGIN_NAMESPACE -class QChar; -class QFileInfo; -class QTextCursor; -QT_END_NAMESPACE - namespace CPlusPlus { class Macro; class Symbol; @@ -31,6 +25,7 @@ class LookupContext; namespace TextEditor { class AssistInterface; } namespace CppEditor { + class CppRefactoringFile; class ProjectInfo; class CppCompletionAssistProcessor; @@ -75,7 +70,7 @@ bool CPPEDITOR_EXPORT preferLowerCaseFileNames(); UsePrecompiledHeaders CPPEDITOR_EXPORT getPchUsage(); int indexerFileSizeLimitInMb(); -bool fileSizeExceedsLimit(const QFileInfo &fileInfo, int sizeLimitInMb); +bool fileSizeExceedsLimit(const Utils::FilePath &filePath, int sizeLimitInMb); ProjectExplorer::Project CPPEDITOR_EXPORT *projectForProjectInfo(const ProjectInfo &info); ProjectExplorer::Project CPPEDITOR_EXPORT *projectForProjectPart(const ProjectPart &part);