diff options
author | Nikolai Kosjar <nikolai.kosjar@theqtcompany.com> | 2015-05-12 14:20:32 +0200 |
---|---|---|
committer | Nikolai Kosjar <nikolai.kosjar@theqtcompany.com> | 2015-05-13 08:26:52 +0000 |
commit | 1960503ae994d14d79bad6507f2ed692e5c2230d (patch) | |
tree | dbfeba4388f70ef6dfd4a382ac1d4018bf4e66c2 /src/plugins/cpptools/cppmodelmanager.cpp | |
parent | f52170737eb00c825e6e2354b9d99d2c342aa740 (diff) | |
download | qt-creator-1960503ae994d14d79bad6507f2ed692e5c2230d.tar.gz |
CppTools: Allow to limit the files to process by file size
...with the environment variable QTC_CPP_FILE_SIZE_LIMIT_MB.
Task-number: QTCREATORBUG-14390
Change-Id: Iaefaa1a3db023b58f9351b96e1b9e2139797e280
Reviewed-by: Erik Verbruggen <erik.verbruggen@theqtcompany.com>
Diffstat (limited to 'src/plugins/cpptools/cppmodelmanager.cpp')
-rw-r--r-- | src/plugins/cpptools/cppmodelmanager.cpp | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/src/plugins/cpptools/cppmodelmanager.cpp b/src/plugins/cpptools/cppmodelmanager.cpp index 9fd0a82909..fbf5760df7 100644 --- a/src/plugins/cpptools/cppmodelmanager.cpp +++ b/src/plugins/cpptools/cppmodelmanager.cpp @@ -42,6 +42,7 @@ #include "cppsourceprocessor.h" #include "cpptoolsconstants.h" #include "cpptoolsplugin.h" +#include "cpptoolsreuse.h" #include "editordocumenthandle.h" #include <coreplugin/documentmanager.h> @@ -585,15 +586,38 @@ QByteArray CppModelManager::codeModelConfiguration() const return QByteArray::fromRawData(pp_configuration, qstrlen(pp_configuration)); } +static QSet<QString> tooBigFilesRemoved(const QSet<QString> &files, int fileSizeLimit) +{ + if (fileSizeLimit == 0) + return files; + + QSet<QString> result; + QFileInfo fileInfo; + + QSetIterator<QString> i(files); + while (i.hasNext()) { + const QString filePath = i.next(); + fileInfo.setFile(filePath); + if (skipFileDueToSizeLimit(fileInfo), fileSizeLimit) + continue; + + result << filePath; + } + + return result; +} + QFuture<void> CppModelManager::updateSourceFiles(const QSet<QString> &sourceFiles, ProgressNotificationMode mode) { if (sourceFiles.isEmpty() || !d->m_indexerEnabled) return QFuture<void>(); + const auto filteredFiles = tooBigFilesRemoved(sourceFiles, fileSizeLimit()); + if (d->m_indexingSupporter) - d->m_indexingSupporter->refreshSourceFiles(sourceFiles, mode); - return d->m_internalIndexingSupport->refreshSourceFiles(sourceFiles, mode); + d->m_indexingSupporter->refreshSourceFiles(filteredFiles, mode); + return d->m_internalIndexingSupport->refreshSourceFiles(filteredFiles, mode); } QList<ProjectInfo> CppModelManager::projectInfos() const |