aboutsummaryrefslogtreecommitdiffstats
path: root/src/tools
diff options
context:
space:
mode:
authorMarco Bubke <marco.bubke@qt.io>2019-06-06 10:57:55 +0200
committerMarco Bubke <marco.bubke@qt.io>2019-06-27 12:31:52 +0000
commitbbd58ca30b32f6015a5e7eb16884dfb9f6108f17 (patch)
tree8f50bd05c6953797a1f73c6938925742284b24bc /src/tools
parent9d290fc68206ce8323c259aab099faba93f7ec83 (diff)
Clang: Watch directories instead of files
Because there a limited resources to watch files we watch now directories. So we need much less resources. Change-Id: Iac558832e9521a7a1a67c5ea99b42ad1b0b5129c Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
Diffstat (limited to 'src/tools')
-rw-r--r--src/tools/clangpchmanagerbackend/clangpchmanagerbackendmain.cpp4
-rw-r--r--src/tools/clangrefactoringbackend/source/clangrefactoringbackend-source.pri5
-rw-r--r--src/tools/clangrefactoringbackend/source/filestatus.h63
-rw-r--r--src/tools/clangrefactoringbackend/source/filestatuscache.cpp93
-rw-r--r--src/tools/clangrefactoringbackend/source/filestatuscache.h76
-rw-r--r--src/tools/clangrefactoringbackend/source/symbolindexing.h6
6 files changed, 8 insertions, 239 deletions
diff --git a/src/tools/clangpchmanagerbackend/clangpchmanagerbackendmain.cpp b/src/tools/clangpchmanagerbackend/clangpchmanagerbackendmain.cpp
index 0ce49e829d..d9e7dd3175 100644
--- a/src/tools/clangpchmanagerbackend/clangpchmanagerbackendmain.cpp
+++ b/src/tools/clangpchmanagerbackend/clangpchmanagerbackendmain.cpp
@@ -31,6 +31,7 @@
#include <environment.h>
#include <executeinloop.h>
#include <filepathcaching.h>
+#include <filesystem.h>
#include <generatedfiles.h>
#include <modifiedtimechecker.h>
#include <pchcreator.h>
@@ -179,7 +180,8 @@ struct Data // because we have a cycle dependency
Sqlite::Database database;
ClangBackEnd::RefactoringDatabaseInitializer<Sqlite::Database> databaseInitializer{database};
ClangBackEnd::FilePathCaching filePathCache{database};
- ClangPathWatcher<QFileSystemWatcher, QTimer> includeWatcher{filePathCache};
+ ClangBackEnd::FileSystem fileSystem{filePathCache};
+ ClangPathWatcher<QFileSystemWatcher, QTimer> includeWatcher{filePathCache, fileSystem};
ApplicationEnvironment environment;
ProjectPartsStorage<> projectPartsStorage{database};
PrecompiledHeaderStorage<> preCompiledHeaderStorage{database};
diff --git a/src/tools/clangrefactoringbackend/source/clangrefactoringbackend-source.pri b/src/tools/clangrefactoringbackend/source/clangrefactoringbackend-source.pri
index e7e83da788..a3da84d83b 100644
--- a/src/tools/clangrefactoringbackend/source/clangrefactoringbackend-source.pri
+++ b/src/tools/clangrefactoringbackend/source/clangrefactoringbackend-source.pri
@@ -17,8 +17,6 @@ HEADERS += \
$$PWD/symbolsvisitorbase.h \
$$PWD/usedmacro.h \
$$PWD/sourcedependency.h \
- $$PWD/filestatus.h \
- $$PWD/filestatuscache.h \
$$PWD/indexdataconsumer.h \
$$PWD/sourcesmanager.h \
$$PWD/symbolindexertaskqueue.h \
@@ -67,5 +65,4 @@ HEADERS += \
SOURCES += \
$$PWD/filestatuspreprocessorcallbacks.cpp \
$$PWD/sourcerangefilter.cpp \
- $$PWD/symbolindexer.cpp \
- $$PWD/filestatuscache.cpp
+ $$PWD/symbolindexer.cpp
diff --git a/src/tools/clangrefactoringbackend/source/filestatus.h b/src/tools/clangrefactoringbackend/source/filestatus.h
deleted file mode 100644
index da2be4a304..0000000000
--- a/src/tools/clangrefactoringbackend/source/filestatus.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of Qt Creator.
-**
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-****************************************************************************/
-
-#pragma once
-
-#include <filepathid.h>
-
-#include <ctime>
-#include <sys/types.h>
-#include <vector>
-
-namespace ClangBackEnd {
-
-class FileStatus
-{
-public:
- FileStatus(FilePathId filePathId, off_t size, std::time_t lastModified)
- : filePathId(filePathId), size(size), lastModified(lastModified) {}
-
- friend
- bool operator==(const FileStatus &first, const FileStatus &second)
- {
- return first.filePathId == second.filePathId
- && first.size == second.size
- && first.lastModified == second.lastModified;
- }
-
- friend
- bool operator<(const FileStatus &first, const FileStatus &second)
- {
- return first.filePathId < second.filePathId;
- }
-
-public:
- FilePathId filePathId;
- off_t size;
- std::time_t lastModified;
-};
-
-using FileStatuses = std::vector<FileStatus>;
-}
diff --git a/src/tools/clangrefactoringbackend/source/filestatuscache.cpp b/src/tools/clangrefactoringbackend/source/filestatuscache.cpp
deleted file mode 100644
index 14ad48da14..0000000000
--- a/src/tools/clangrefactoringbackend/source/filestatuscache.cpp
+++ /dev/null
@@ -1,93 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of Qt Creator.
-**
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-****************************************************************************/
-
-#include "filestatuscache.h"
-
-#include <QDateTime>
-#include <QFileInfo>
-
-namespace ClangBackEnd {
-
-FileStatusCache::FileStatusCache(FilePathCachingInterface &filePathCache)
- : m_filePathCache(filePathCache)
-{
-
-}
-
-long long FileStatusCache::lastModifiedTime(FilePathId filePathId) const
-{
- return findEntry(filePathId).lastModified;
-}
-
-void FileStatusCache::update(FilePathId filePathId)
-{
- auto found = std::lower_bound(m_cacheEntries.begin(),
- m_cacheEntries.end(),
- Internal::FileStatusCacheEntry{filePathId},
- [] (const auto &first, const auto &second) {
- return first.filePathId < second.filePathId;
- });
-
- if (found != m_cacheEntries.end() && found->filePathId == filePathId) {
- QFileInfo fileInfo = qFileInfo(filePathId);
- found->lastModified = fileInfo.lastModified().toMSecsSinceEpoch() / 1000;
- }
-}
-
-FileStatusCache::size_type FileStatusCache::size() const
-{
- return m_cacheEntries.size();
-}
-
-Internal::FileStatusCacheEntry FileStatusCache::findEntry(FilePathId filePathId) const
-{
- auto found = std::lower_bound(m_cacheEntries.begin(),
- m_cacheEntries.end(),
- Internal::FileStatusCacheEntry{filePathId},
- [] (const auto &first, const auto &second) {
- return first.filePathId < second.filePathId;
- });
-
- if (found != m_cacheEntries.end() && found->filePathId == filePathId)
- return *found;
-
- QFileInfo fileInfo = qFileInfo(filePathId);
- auto inserted = m_cacheEntries.emplace(found,
- filePathId,
- fileInfo.lastModified().toMSecsSinceEpoch() / 1000);
-
- return *inserted;
-}
-
-QFileInfo FileStatusCache::qFileInfo(FilePathId filePathId) const
-{
- QFileInfo fileInfo(QString(m_filePathCache.filePath(filePathId)));
-
- fileInfo.refresh();
-
- return fileInfo;
-}
-
-} // namespace ClangBackEnd
diff --git a/src/tools/clangrefactoringbackend/source/filestatuscache.h b/src/tools/clangrefactoringbackend/source/filestatuscache.h
deleted file mode 100644
index 23195da605..0000000000
--- a/src/tools/clangrefactoringbackend/source/filestatuscache.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of Qt Creator.
-**
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-****************************************************************************/
-
-#pragma once
-
-#include <filepathcachinginterface.h>
-
-QT_FORWARD_DECLARE_CLASS(QFileInfo)
-
-namespace ClangBackEnd {
-
-namespace Internal {
-class FileStatusCacheEntry
-{
-public:
- FileStatusCacheEntry(ClangBackEnd::FilePathId filePathId,
- long long lastModified = 0)
- : filePathId(filePathId),
- lastModified(lastModified)
- {}
-
-public:
- ClangBackEnd::FilePathId filePathId;
- long long lastModified;
-};
-
-using FileStatusCacheEntries = std::vector<FileStatusCacheEntry>;
-
-}
-
-class FileStatusCache
-{
-public:
- using size_type = Internal::FileStatusCacheEntries::size_type;
-
- FileStatusCache(FilePathCachingInterface &filePathCache);
- FileStatusCache &operator=(const FileStatusCache &) = delete;
- FileStatusCache(const FileStatusCache &) = delete;
-
- long long lastModifiedTime(ClangBackEnd::FilePathId filePathId) const;
- void update(ClangBackEnd::FilePathId filePathId);
-
- size_type size() const;
-
-private:
- Internal::FileStatusCacheEntry findEntry(ClangBackEnd::FilePathId filePathId) const;
- QFileInfo qFileInfo(ClangBackEnd::FilePathId filePathId) const;
-
-private:
- mutable Internal::FileStatusCacheEntries m_cacheEntries;
- FilePathCachingInterface &m_filePathCache;
-};
-
-} // namespace ClangBackEnd
diff --git a/src/tools/clangrefactoringbackend/source/symbolindexing.h b/src/tools/clangrefactoringbackend/source/symbolindexing.h
index 5c391503bf..bed279904d 100644
--- a/src/tools/clangrefactoringbackend/source/symbolindexing.h
+++ b/src/tools/clangrefactoringbackend/source/symbolindexing.h
@@ -39,6 +39,7 @@
#include <projectpartsstorage.h>
#include <filepathcachingfwd.h>
+#include <filesystem.h>
#include <modifiedtimechecker.h>
#include <refactoringdatabaseinitializer.h>
@@ -142,8 +143,9 @@ private:
PrecompiledHeaderStorage<Sqlite::Database> m_precompiledHeaderStorage;
ProjectPartsStorage<Sqlite::Database> m_projectPartsStorage;
SymbolStorage m_symbolStorage;
- ClangPathWatcher<QFileSystemWatcher, QTimer> m_sourceWatcher{m_filePathCache};
- FileStatusCache m_fileStatusCache{m_filePathCache};
+ FileSystem m_fileSytem{m_filePathCache};
+ ClangPathWatcher<QFileSystemWatcher, QTimer> m_sourceWatcher{m_filePathCache, m_fileSytem};
+ FileStatusCache m_fileStatusCache{m_fileSytem};
SymbolsCollectorManager m_collectorManger;
ProgressCounter m_progressCounter;
std::function<TimeStamp(FilePathView filePath)> getModifiedTime{