CMake: make project file system tree scanner persistent

Project source tree is a same for all build configurations so it is
a good idea to keep it persistent between CMake runs, configurations
switches and so on. It safes a lot of time for big projects.

Move more operations to the scanner thread:
 - Nodes filtering: skip .user files on top level of the project, skip
well-known extensions and octet-streams: In most cases these are not
required to be shown in the project tree.
 - Nodes sorting

Fix small memory leak: we have .user in the scanner result. After this
node filtered out, but is not feed (old code at the
BuildDirManager::generateProjectTree()). Now .user file skips during scan
without memory allocation at all.

Allow user manually rescan project tree by call Build -> Rescan project
tree. It runs CMake and Tree Scanner together: in most cases only CMake
run requires but time to time (VCS update) full rescan also required.

Change-Id: I4a6e6c897202da557509291c79932dd7751860e5
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
Alexander Drozdov
2016-12-04 03:36:12 +10:00
parent 357cefe67c
commit dfaf01614d
13 changed files with 428 additions and 85 deletions

View File

@@ -26,6 +26,7 @@
#pragma once
#include "cmake_global.h"
#include "treescanner.h"
#include <projectexplorer/extracompiler.h>
#include <projectexplorer/project.h>
@@ -33,6 +34,7 @@
#include <utils/fileutils.h>
#include <QFuture>
#include <QHash>
QT_BEGIN_NAMESPACE
class QFileSystemWatcher;
@@ -95,6 +97,7 @@ public:
bool supportsKit(ProjectExplorer::Kit *k, QString *errorMessage = 0) const final;
void runCMake();
void scanProjectTree();
// Context menu actions:
void buildCMakeTarget(const QString &buildTarget);
@@ -113,6 +116,7 @@ private:
void handleActiveTargetChanged();
void handleActiveBuildConfigurationChanged();
void handleParsingStarted();
void handleTreeScanningFinished();
void updateProjectData(Internal::CMakeBuildConfiguration *cmakeBc);
void updateQmlJSCodeModel();
@@ -128,6 +132,10 @@ private:
QFuture<void> m_codeModelFuture;
QList<ProjectExplorer::ExtraCompiler *> m_extraCompilers;
Internal::TreeScanner m_treeScanner;
QHash<QString, bool> m_mimeBinaryCache;
QList<ProjectExplorer::FileNode *> m_allFiles;
friend class Internal::CMakeBuildConfiguration;
friend class Internal::CMakeBuildSettingsWidget;
};