forked from qt-creator/qt-creator
Merge remote-tracking branch 'origin/4.10'
Conflicts: CMakeLists.txt tests/unit/unittest/unittest.pro Change-Id: I64296ad31502d9b35012da129a28e9277e9fcf8e
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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>;
|
||||
}
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -87,8 +87,8 @@ SymbolIndexer::SymbolIndexer(SymbolIndexerTaskQueueInterface &symbolIndexerTaskQ
|
||||
|
||||
void SymbolIndexer::updateProjectParts(ProjectPartContainers &&projectParts)
|
||||
{
|
||||
for (ProjectPartContainer &projectPart : projectParts)
|
||||
updateProjectPart(std::move(projectPart));
|
||||
for (ProjectPartContainer &projectPart : projectParts)
|
||||
updateProjectPart(std::move(projectPart));
|
||||
}
|
||||
|
||||
void SymbolIndexer::updateProjectPart(ProjectPartContainer &&projectPart)
|
||||
@@ -145,7 +145,7 @@ void SymbolIndexer::updateProjectPart(ProjectPartContainer &&projectPart)
|
||||
}
|
||||
|
||||
m_pathWatcher.updateIdPaths(
|
||||
{{projectPartId, m_buildDependencyStorage.fetchSources(projectPartId)}});
|
||||
{{projectPartId, m_buildDependencyStorage.fetchPchSources(projectPartId)}});
|
||||
m_symbolIndexerTaskQueue.addOrUpdateTasks(std::move(symbolIndexerTask));
|
||||
m_symbolIndexerTaskQueue.processEntries();
|
||||
}
|
||||
@@ -154,6 +154,8 @@ void SymbolIndexer::pathsWithIdsChanged(const ProjectPartIds &) {}
|
||||
|
||||
void SymbolIndexer::pathsChanged(const FilePathIds &filePathIds)
|
||||
{
|
||||
m_modifiedTimeChecker.pathsChanged(filePathIds);
|
||||
|
||||
FilePathIds dependentSourcePathIds = m_symbolStorage.fetchDependentSourceIds(filePathIds);
|
||||
|
||||
std::vector<SymbolIndexerTask> symbolIndexerTask;
|
||||
|
||||
@@ -29,8 +29,8 @@
|
||||
#include "symbolindexertaskqueueinterface.h"
|
||||
#include "symbolstorageinterface.h"
|
||||
#include "builddependenciesstorageinterface.h"
|
||||
#include "clangpathwatcher.h"
|
||||
|
||||
#include <clangpathwatcher.h>
|
||||
#include <filecontainerv2.h>
|
||||
#include <modifiedtimecheckerinterface.h>
|
||||
#include <precompiledheaderstorageinterface.h>
|
||||
|
||||
@@ -39,6 +39,7 @@
|
||||
#include <projectpartsstorage.h>
|
||||
|
||||
#include <filepathcachingfwd.h>
|
||||
#include <filesystem.h>
|
||||
#include <modifiedtimechecker.h>
|
||||
#include <refactoringdatabaseinitializer.h>
|
||||
|
||||
@@ -142,16 +143,12 @@ 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{
|
||||
[&](ClangBackEnd::FilePathView path) -> TimeStamp {
|
||||
return QFileInfo(QString(path)).lastModified().toSecsSinceEpoch();
|
||||
}};
|
||||
ModifiedTimeChecker<ClangBackEnd::SourceTimeStamps> m_modifiedTimeChecker{getModifiedTime,
|
||||
m_filePathCache};
|
||||
ModifiedTimeChecker<ClangBackEnd::SourceTimeStamps> m_modifiedTimeChecker{m_fileSytem};
|
||||
SymbolIndexer m_indexer;
|
||||
SymbolIndexerTaskQueue m_indexerQueue;
|
||||
SymbolIndexerTaskScheduler m_indexerScheduler;
|
||||
|
||||
@@ -129,7 +129,11 @@ bool SymbolsCollector::collectSymbols()
|
||||
|
||||
auto actionFactory = ClangBackEnd::newFrontendActionFactory(&m_collectSymbolsAction);
|
||||
|
||||
return tool.run(actionFactory.get()) != 1;
|
||||
bool noErrors = tool.run(actionFactory.get()) != 1;
|
||||
|
||||
m_clangTool = ClangTool();
|
||||
|
||||
return noErrors;
|
||||
}
|
||||
|
||||
void SymbolsCollector::doInMainThreadAfterFinished()
|
||||
|
||||
@@ -63,6 +63,8 @@ public:
|
||||
bool isUsed() const override;
|
||||
void setIsUsed(bool isUsed) override;
|
||||
|
||||
bool isClean() const { return m_clangTool.isClean(); }
|
||||
|
||||
private:
|
||||
FilePathCaching m_filePathCache;
|
||||
ClangTool m_clangTool;
|
||||
|
||||
Reference in New Issue
Block a user