Remove ClangRefactoring and ClangPchManager

This removes the plugins and tools, and removes all the tests that would
fail to build because of that.

Fixes: QTCREATORBUG-25659
Change-Id: I8adb5d503fc8eea313bcaada421f309dbbfa8c26
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
This commit is contained in:
Eike Ziller
2021-06-14 11:47:51 +02:00
parent 9e5ba5d679
commit baa83725f6
515 changed files with 31 additions and 51951 deletions

View File

@@ -64,7 +64,6 @@ Module {
return incl != llvmIncludeDir; return incl != llvmIncludeDir;
}) })
property stringList llvmToolingCxxFlags: clangProbe.llvmToolingCxxFlags property stringList llvmToolingCxxFlags: clangProbe.llvmToolingCxxFlags
property bool toolingEnabled: Environment.getEnv("QTC_ENABLE_CLANG_REFACTORING")
validate: { validate: {
if (!clangProbe.found) { if (!clangProbe.found) {

View File

@@ -14,7 +14,6 @@ add_qtc_library(ClangSupport
alivemessage.cpp alivemessage.h alivemessage.cpp alivemessage.h
annotationsmessage.cpp annotationsmessage.h annotationsmessage.cpp annotationsmessage.h
baseserverproxy.cpp baseserverproxy.h baseserverproxy.cpp baseserverproxy.h
cancelmessage.cpp cancelmessage.h
clangcodemodelclientinterface.cpp clangcodemodelclientinterface.h clangcodemodelclientinterface.cpp clangcodemodelclientinterface.h
clangcodemodelclientmessages.h clangcodemodelclientmessages.h
clangcodemodelclientproxy.cpp clangcodemodelclientproxy.h clangcodemodelclientproxy.cpp clangcodemodelclientproxy.h
@@ -22,124 +21,48 @@ add_qtc_library(ClangSupport
clangcodemodelserverinterface.cpp clangcodemodelserverinterface.h clangcodemodelserverinterface.cpp clangcodemodelserverinterface.h
clangcodemodelservermessages.h clangcodemodelservermessages.h
clangcodemodelserverproxy.cpp clangcodemodelserverproxy.h clangcodemodelserverproxy.cpp clangcodemodelserverproxy.h
clangpathwatcher.h
clangpathwatcherinterface.h
clangpathwatchernotifier.h
clangrefactoringclientmessages.h
clangrefactoringmessages.h
clangrefactoringservermessages.h
clangsupport_global.h clangsupport_global.h
clangsupportdebugutils.cpp clangsupportdebugutils.h clangsupportdebugutils.cpp clangsupportdebugutils.h
clangsupportexceptions.h
codecompletion.cpp codecompletion.h codecompletion.cpp codecompletion.h
codecompletionchunk.cpp codecompletionchunk.h codecompletionchunk.cpp codecompletionchunk.h
commandlinebuilder.h
compilermacro.h
completionsmessage.cpp completionsmessage.h completionsmessage.cpp completionsmessage.h
connectionclient.cpp connectionclient.h connectionclient.cpp connectionclient.h
connectionserver.cpp connectionserver.h connectionserver.cpp connectionserver.h
diagnosticcontainer.cpp diagnosticcontainer.h diagnosticcontainer.cpp diagnosticcontainer.h
directoryandfilepathid.h
directorypathid.h
documentschangedmessage.cpp documentschangedmessage.h documentschangedmessage.cpp documentschangedmessage.h
documentsclosedmessage.cpp documentsclosedmessage.h documentsclosedmessage.cpp documentsclosedmessage.h
documentsopenedmessage.cpp documentsopenedmessage.h documentsopenedmessage.cpp documentsopenedmessage.h
documentvisibilitychangedmessage.cpp documentvisibilitychangedmessage.h documentvisibilitychangedmessage.cpp documentvisibilitychangedmessage.h
dynamicastmatcherdiagnosticcontainer.cpp dynamicastmatcherdiagnosticcontainer.h
dynamicastmatcherdiagnosticcontextcontainer.cpp dynamicastmatcherdiagnosticcontextcontainer.h
dynamicastmatcherdiagnosticmessagecontainer.cpp dynamicastmatcherdiagnosticmessagecontainer.h
dynamicmatcherdiagnostics.h
echomessage.cpp echomessage.h echomessage.cpp echomessage.h
endmessage.cpp endmessage.h endmessage.cpp endmessage.h
environment.h
executeinloop.h
filecontainer.cpp filecontainer.h filecontainer.cpp filecontainer.h
filecontainerv2.cpp filecontainerv2.h
filepath.cpp filepath.h
filepathcache.h
filepathcaching.cpp filepathcaching.h
filepathcachingfwd.h
filepathcachinginterface.h
filepathexceptions.h
filepathid.cpp filepathid.h
filepathstorage.h
filepathstoragesources.h
filepathstoragesqlitestatementfactory.h
filepathview.h
filestatus.h
filestatuscache.cpp filestatuscache.h
filesystem.cpp filesystem.h
filesysteminterface.h
fixitcontainer.cpp fixitcontainer.h fixitcontainer.cpp fixitcontainer.h
followsymbolmessage.cpp followsymbolmessage.h followsymbolmessage.cpp followsymbolmessage.h
generatedfiles.cpp generatedfiles.h
generatedfilesinterface.h
idpaths.h
includesearchpath.h
ipcclientinterface.h ipcclientinterface.h
ipcclientprovider.h ipcclientprovider.h
ipcinterface.h ipcinterface.h
ipcserverinterface.h ipcserverinterface.h
lineprefixer.cpp lineprefixer.h lineprefixer.cpp lineprefixer.h
messageenvelop.cpp messageenvelop.h messageenvelop.cpp messageenvelop.h
modifiedtimechecker.h
modifiedtimecheckerinterface.h
nativefilepath.h
pchmanagerclientinterface.cpp pchmanagerclientinterface.h
pchmanagerclientproxy.cpp pchmanagerclientproxy.h
pchmanagerserverinterface.cpp pchmanagerserverinterface.h
pchmanagerserverproxy.cpp pchmanagerserverproxy.h
pchpaths.h
precompiledheadersupdatedmessage.cpp precompiledheadersupdatedmessage.h
processcreator.cpp processcreator.h processcreator.cpp processcreator.h
processexception.cpp processexception.h processexception.cpp processexception.h
processhandle.h processhandle.h
processstartedevent.cpp processstartedevent.h processstartedevent.cpp processstartedevent.h
progresscounter.h
progressmessage.h
projectmanagementserverinterface.h
projectpartartefact.cpp projectpartartefact.h
projectpartcontainer.cpp projectpartcontainer.h
projectpartid.h
projectpartpch.cpp projectpartpch.h
projectpartsstorage.h
projectpartsstorageinterface.h
readmessageblock.cpp readmessageblock.h readmessageblock.cpp readmessageblock.h
refactoringclientinterface.cpp refactoringclientinterface.h
refactoringclientproxy.cpp refactoringclientproxy.h
refactoringdatabaseinitializer.h
refactoringserverinterface.cpp refactoringserverinterface.h
refactoringserverproxy.cpp refactoringserverproxy.h
referencesmessage.cpp referencesmessage.h referencesmessage.cpp referencesmessage.h
removegeneratedfilesmessage.cpp removegeneratedfilesmessage.h
removeprojectpartsmessage.h
requestannotationsmessage.cpp requestannotationsmessage.h requestannotationsmessage.cpp requestannotationsmessage.h
requestcompletionsmessage.cpp requestcompletionsmessage.h requestcompletionsmessage.cpp requestcompletionsmessage.h
requestfollowsymbolmessage.cpp requestfollowsymbolmessage.h requestfollowsymbolmessage.cpp requestfollowsymbolmessage.h
requestreferencesmessage.cpp requestreferencesmessage.h requestreferencesmessage.cpp requestreferencesmessage.h
requestsourcerangesanddiagnosticsforquerymessage.cpp requestsourcerangesanddiagnosticsforquerymessage.h
requestsourcerangesforquerymessage.cpp requestsourcerangesforquerymessage.h
requesttooltipmessage.cpp requesttooltipmessage.h requesttooltipmessage.cpp requesttooltipmessage.h
sourceentry.h
sourcelocationcontainer.cpp sourcelocationcontainer.h sourcelocationcontainer.cpp sourcelocationcontainer.h
sourcelocationcontainerv2.cpp sourcelocationcontainerv2.h
sourcelocationscontainer.cpp sourcelocationscontainer.h sourcelocationscontainer.cpp sourcelocationscontainer.h
sourcerangecontainer.cpp sourcerangecontainer.h sourcerangecontainer.cpp sourcerangecontainer.h
sourcerangecontainerv2.cpp sourcerangecontainerv2.h
sourcerangesanddiagnosticsforquerymessage.cpp sourcerangesanddiagnosticsforquerymessage.h
sourcerangescontainer.cpp sourcerangescontainer.h
sourcerangesforquerymessage.cpp sourcerangesforquerymessage.h
sourcerangewithtextcontainer.cpp sourcerangewithtextcontainer.h
stringcache.h
stringcachealgorithms.h
stringcachefwd.h
tokeninfocontainer.cpp tokeninfocontainer.h tokeninfocontainer.cpp tokeninfocontainer.h
tooltipinfo.cpp tooltipinfo.h tooltipinfo.cpp tooltipinfo.h
tooltipmessage.cpp tooltipmessage.h tooltipmessage.cpp tooltipmessage.h
unsavedfilesremovedmessage.cpp unsavedfilesremovedmessage.h unsavedfilesremovedmessage.cpp unsavedfilesremovedmessage.h
unsavedfilesupdatedmessage.cpp unsavedfilesupdatedmessage.h unsavedfilesupdatedmessage.cpp unsavedfilesupdatedmessage.h
updategeneratedfilesmessage.cpp updategeneratedfilesmessage.h
updateprojectpartsmessage.cpp updateprojectpartsmessage.h
writemessageblock.cpp writemessageblock.h writemessageblock.cpp writemessageblock.h
) )

View File

@@ -1,39 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2016 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 "cancelmessage.h"
#include <QDebug>
namespace ClangBackEnd {
QDebug operator<<(QDebug debug, const CancelMessage &)
{
debug.nospace() << "CancelMessage()";
return debug;
}
} // namespace ClangBackEnd

View File

@@ -1,54 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2016 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 "clangsupport_global.h"
namespace ClangBackEnd {
class CancelMessage
{
public:
friend QDataStream &operator<<(QDataStream &out, const CancelMessage &/*message*/)
{
return out;
}
friend QDataStream &operator>>(QDataStream &in, CancelMessage &/*message*/)
{
return in;
}
friend bool operator==(const CancelMessage &/*first*/, const CancelMessage &/*second*/)
{
return true;
}
};
CLANGSUPPORT_EXPORT QDebug operator<<(QDebug debug, const CancelMessage &message);
DECLARE_MESSAGE(CancelMessage)
} // namespace ClangBackEnd

View File

@@ -1,449 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2016 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 "clangpathwatcherinterface.h"
#include "clangpathwatchernotifier.h"
#include "directorypathcompressor.h"
#include "filepathcachinginterface.h"
#include "filesystem.h"
#include "stringcache.h"
#include <utils/algorithm.h>
#include <QTimer>
namespace ClangBackEnd {
template<class InputIt1, class InputIt2, class Callable>
void set_greedy_intersection_call(
InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2, Callable callable)
{
while (first1 != last1 && first2 != last2) {
if (*first1 < *first2) {
++first1;
} else {
if (*first2 < *first1)
++first2;
else
callable(*first1++);
}
}
}
class WatcherEntry
{
public:
ProjectChunkId id;
DirectoryPathId directoryPathId;
FilePathId filePathId;
long long lastModified = -1;
friend bool operator==(WatcherEntry first, WatcherEntry second)
{
return first.id == second.id && first.directoryPathId == second.directoryPathId
&& first.filePathId == second.filePathId;
}
friend bool operator<(WatcherEntry first, WatcherEntry second)
{
return std::tie(first.directoryPathId, first.filePathId, first.id)
< std::tie(second.directoryPathId, second.filePathId, second.id);
}
friend bool operator<(DirectoryPathId directoryPathId, WatcherEntry entry)
{
return directoryPathId < entry.directoryPathId;
}
friend bool operator<(WatcherEntry entry, DirectoryPathId directoryPathId)
{
return entry.directoryPathId < directoryPathId;
}
operator FilePathId() const { return filePathId; }
operator DirectoryPathId() const { return directoryPathId; }
};
using WatcherEntries = std::vector<WatcherEntry>;
template<typename FileSystemWatcher, typename Timer>
class CLANGSUPPORT_GCCEXPORT ClangPathWatcher : public ClangPathWatcherInterface
{
public:
ClangPathWatcher(FilePathCachingInterface &pathCache,
FileSystemInterface &fileSystem,
ClangPathWatcherNotifier *notifier = nullptr)
: m_fileStatusCache(fileSystem)
, m_fileSystem(fileSystem)
, m_pathCache(pathCache)
, m_notifier(notifier)
{
QObject::connect(&m_fileSystemWatcher,
&FileSystemWatcher::directoryChanged,
[&](const QString &path) { compressChangedDirectoryPath(path); });
m_directoryPathCompressor.setCallback([&](ClangBackEnd::DirectoryPathIds &&directoryPathIds) {
addChangedPathForFilePath(std::move(directoryPathIds));
});
}
~ClangPathWatcher()
{
m_directoryPathCompressor.setCallback([&](DirectoryPathIds &&) {});
}
void updateIdPaths(const std::vector<IdPaths> &idPaths) override
{
auto entriesAndIds = convertIdPathsToWatcherEntriesAndIds(idPaths);
addEntries(entriesAndIds.first);
removeUnusedEntries(entriesAndIds.first, entriesAndIds.second);
}
void removeIds(const ProjectPartIds &ids) override
{
auto removedEntries = removeIdsFromWatchedEntries(ids);
auto filteredPaths = filterNotWatchedPaths(removedEntries);
if (!filteredPaths.empty())
m_fileSystemWatcher.removePaths(convertWatcherEntriesToDirectoryPathList(filteredPaths));
}
void setNotifier(ClangPathWatcherNotifier *notifier) override
{
m_notifier = notifier;
}
std::size_t sizeOfIdPaths(const std::vector<IdPaths> &idPaths)
{
auto sumSize = [] (std::size_t size, const IdPaths &idPath) {
return size + idPath.filePathIds.size();
};
return std::accumulate(idPaths.begin(), idPaths.end(), std::size_t(0), sumSize);
}
std::pair<WatcherEntries, ProjectChunkIds> convertIdPathsToWatcherEntriesAndIds(
const std::vector<IdPaths> &idPaths)
{
WatcherEntries entries;
entries.reserve(sizeOfIdPaths(idPaths));
ProjectChunkIds ids;
ids.reserve(ids.size());
auto outputIterator = std::back_inserter(entries);
for (const IdPaths &idPath : idPaths)
{
ProjectChunkId id = idPath.id;
ids.push_back(id);
outputIterator = std::transform(idPath.filePathIds.begin(),
idPath.filePathIds.end(),
outputIterator,
[&](FilePathId filePathId) {
return WatcherEntry{
id,
m_pathCache.directoryPathId(filePathId),
filePathId,
m_fileStatusCache.lastModifiedTime(filePathId)};
});
}
std::sort(entries.begin(), entries.end());
std::sort(ids.begin(), ids.end());
return {entries, ids};
}
void addEntries(const WatcherEntries &entries)
{
auto newEntries = notWatchedEntries(entries);
auto filteredPaths = filterNotWatchedPaths(newEntries);
mergeToWatchedEntries(newEntries);
if (!filteredPaths.empty())
m_fileSystemWatcher.addPaths(convertWatcherEntriesToDirectoryPathList(filteredPaths));
}
void removeUnusedEntries(const WatcherEntries &entries, const ProjectChunkIds &ids)
{
auto oldEntries = notAnymoreWatchedEntriesWithIds(entries, ids);
removeFromWatchedEntries(oldEntries);
auto filteredPaths = filterNotWatchedPaths(oldEntries);
if (!filteredPaths.empty())
m_fileSystemWatcher.removePaths(convertWatcherEntriesToDirectoryPathList(filteredPaths));
}
FileSystemWatcher &fileSystemWatcher() { return m_fileSystemWatcher; }
QStringList convertWatcherEntriesToDirectoryPathList(const DirectoryPathIds &directoryPathIds) const
{
return Utils::transform<QStringList>(directoryPathIds, [&](DirectoryPathId id) {
return QString(m_pathCache.directoryPath(id));
});
}
QStringList convertWatcherEntriesToDirectoryPathList(const WatcherEntries &watcherEntries) const
{
DirectoryPathIds directoryPathIds = Utils::transform<DirectoryPathIds>(
watcherEntries, [&](WatcherEntry entry) { return entry.directoryPathId; });
std::sort(directoryPathIds.begin(), directoryPathIds.end());
directoryPathIds.erase(std::unique(directoryPathIds.begin(), directoryPathIds.end()),
directoryPathIds.end());
return convertWatcherEntriesToDirectoryPathList(directoryPathIds);
}
WatcherEntries notWatchedEntries(const WatcherEntries &entries) const
{
WatcherEntries notWatchedEntries;
notWatchedEntries.reserve(entries.size());
std::set_difference(entries.begin(),
entries.end(),
m_watchedEntries.cbegin(),
m_watchedEntries.cend(),
std::back_inserter(notWatchedEntries));
return notWatchedEntries;
}
DirectoryPathIds notWatchedPaths(const DirectoryPathIds &ids) const
{
DirectoryPathIds notWatchedDirectoryIds;
notWatchedDirectoryIds.reserve(ids.size());
std::set_difference(ids.begin(),
ids.end(),
m_watchedEntries.cbegin(),
m_watchedEntries.cend(),
std::back_inserter(notWatchedDirectoryIds));
return notWatchedDirectoryIds;
}
template <typename Compare>
WatcherEntries notAnymoreWatchedEntries(
const WatcherEntries &newEntries,
Compare compare) const
{
WatcherEntries notAnymoreWatchedEntries;
notAnymoreWatchedEntries.reserve(m_watchedEntries.size());
std::set_difference(m_watchedEntries.cbegin(),
m_watchedEntries.cend(),
newEntries.begin(),
newEntries.end(),
std::back_inserter(notAnymoreWatchedEntries),
compare);
return notAnymoreWatchedEntries;
}
WatcherEntries notAnymoreWatchedEntriesWithIds(const WatcherEntries &newEntries,
const ProjectChunkIds &ids) const
{
auto oldEntries = notAnymoreWatchedEntries(newEntries, std::less<WatcherEntry>());
auto newEnd = std::remove_if(oldEntries.begin(),
oldEntries.end(),
[&] (WatcherEntry entry) {
return !std::binary_search(ids.begin(), ids.end(), entry.id);
});
oldEntries.erase(newEnd, oldEntries.end());
return oldEntries;
}
void mergeToWatchedEntries(const WatcherEntries &newEntries)
{
WatcherEntries newWatchedEntries;
newWatchedEntries.reserve(m_watchedEntries.size() + newEntries.size());
std::merge(m_watchedEntries.cbegin(),
m_watchedEntries.cend(),
newEntries.begin(),
newEntries.end(),
std::back_inserter(newWatchedEntries));
m_watchedEntries = std::move(newWatchedEntries);
}
static DirectoryPathIds uniquePaths(const WatcherEntries &pathEntries)
{
DirectoryPathIds uniqueDirectoryIds;
uniqueDirectoryIds.reserve(pathEntries.size());
auto compare = [](WatcherEntry first, WatcherEntry second) {
return first.directoryPathId == second.directoryPathId;
};
std::unique_copy(pathEntries.begin(),
pathEntries.end(),
std::back_inserter(uniqueDirectoryIds),
compare);
return uniqueDirectoryIds;
}
DirectoryPathIds filterNotWatchedPaths(const WatcherEntries &entries) const
{
return notWatchedPaths(uniquePaths(entries));
}
const WatcherEntries &watchedEntries() const
{
return m_watchedEntries;
}
WatcherEntries removeIdsFromWatchedEntries(const ProjectPartIds &ids)
{
auto keep = [&](WatcherEntry entry) {
return !std::binary_search(ids.begin(), ids.end(), entry.id);
};
auto found = std::stable_partition(m_watchedEntries.begin(), m_watchedEntries.end(), keep);
WatcherEntries removedEntries(found, m_watchedEntries.end());
m_watchedEntries.erase(found, m_watchedEntries.end());
return removedEntries;
}
void removeFromWatchedEntries(const WatcherEntries &oldEntries)
{
WatcherEntries newWatchedEntries;
newWatchedEntries.reserve(m_watchedEntries.size() - oldEntries.size());
std::set_difference(m_watchedEntries.cbegin(),
m_watchedEntries.cend(),
oldEntries.begin(),
oldEntries.end(),
std::back_inserter(newWatchedEntries));
m_watchedEntries = std::move(newWatchedEntries);
}
void compressChangedDirectoryPath(const QString &path)
{
m_directoryPathCompressor.addDirectoryPathId(
m_pathCache.directoryPathId(Utils::PathString{path}));
}
WatcherEntries watchedEntriesForPaths(ClangBackEnd::DirectoryPathIds &&directoryPathIds)
{
WatcherEntries foundEntries;
foundEntries.reserve(m_watchedEntries.size());
set_greedy_intersection_call(m_watchedEntries.begin(),
m_watchedEntries.end(),
directoryPathIds.begin(),
directoryPathIds.end(),
[&](WatcherEntry &entry) {
m_fileStatusCache.update(entry.filePathId);
auto currentLastModified = m_fileStatusCache.lastModifiedTime(
entry.filePathId);
if (entry.lastModified < currentLastModified) {
foundEntries.push_back(entry);
entry.lastModified = currentLastModified;
}
});
return foundEntries;
}
FilePathIds watchedPaths(const WatcherEntries &entries) const
{
auto filePathIds = Utils::transform<FilePathIds>(entries, &WatcherEntry::filePathId);
std::sort(filePathIds.begin(), filePathIds.end());
filePathIds.erase(std::unique(filePathIds.begin(), filePathIds.end()), filePathIds.end());
return filePathIds;
}
std::vector<IdPaths> idPathsForWatcherEntries(WatcherEntries &&foundEntries)
{
std::sort(foundEntries.begin(), foundEntries.end(), [](WatcherEntry first, WatcherEntry second) {
return std::tie(first.id, first.filePathId) < std::tie(second.id, second.filePathId);
});
std::vector<IdPaths> idPaths;
idPaths.reserve(foundEntries.size());
for (WatcherEntry entry : foundEntries) {
if (idPaths.empty() || idPaths.back().id != entry.id)
idPaths.emplace_back(entry.id, FilePathIds{});
idPaths.back().filePathIds.push_back(entry.filePathId);
}
return idPaths;
}
void addChangedPathForFilePath(DirectoryPathIds &&directoryPathIds)
{
if (m_notifier) {
WatcherEntries foundEntries = watchedEntriesForPaths(std::move(directoryPathIds));
FilePathIds watchedFilePathIds = watchedPaths(foundEntries);
std::vector<IdPaths> changedIdPaths = idPathsForWatcherEntries(std::move(foundEntries));
m_notifier->pathsChanged(watchedFilePathIds);
m_notifier->pathsWithIdsChanged(changedIdPaths);
}
}
FilePathCachingInterface &pathCache()
{
return m_pathCache;
}
private:
WatcherEntries m_watchedEntries;
FileSystemWatcher m_fileSystemWatcher;
FileStatusCache m_fileStatusCache;
FileSystemInterface &m_fileSystem;
FilePathCachingInterface &m_pathCache;
ClangPathWatcherNotifier *m_notifier;
DirectoryPathCompressor<Timer> m_directoryPathCompressor;
};
} // namespace ClangBackEnd

View File

@@ -1,52 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2016 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 "idpaths.h"
#include <utils/smallstringvector.h>
namespace ClangBackEnd {
class ClangPathWatcherNotifier;
class ClangPathWatcherInterface
{
public:
ClangPathWatcherInterface() = default;
ClangPathWatcherInterface(const ClangPathWatcherInterface &) = delete;
ClangPathWatcherInterface &operator=(const ClangPathWatcherInterface &) = delete;
virtual void updateIdPaths(const std::vector<IdPaths> &idPaths) = 0;
virtual void removeIds(const ProjectPartIds &ids) = 0;
virtual void setNotifier(ClangPathWatcherNotifier *notifier) = 0;
protected:
~ClangPathWatcherInterface() = default;
};
} // namespace ClangBackEnd

View File

@@ -1,50 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2016 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 "clangsupport_global.h"
#include "filepathid.h"
#include "idpaths.h"
#include <utils/smallstringvector.h>
namespace ClangBackEnd {
class ClangPathWatcherNotifier
{
public:
ClangPathWatcherNotifier() = default;
ClangPathWatcherNotifier(const ClangPathWatcherNotifier &) = delete;
ClangPathWatcherNotifier &operator=(const ClangPathWatcherNotifier &) = delete;
virtual void pathsWithIdsChanged(const std::vector<IdPaths> &idPaths) = 0;
virtual void pathsChanged(const FilePathIds &filePathIds) = 0;
protected:
~ClangPathWatcherNotifier() = default;
};
} // namespace ClangBackEnd

View File

@@ -1,31 +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 "alivemessage.h"
#include "progressmessage.h"
#include "sourcerangesanddiagnosticsforquerymessage.h"
#include "sourcerangesforquerymessage.h"

View File

@@ -1,29 +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 "clangrefactoringclientmessages.h"
#include "clangrefactoringservermessages.h"

View File

@@ -1,35 +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 "cancelmessage.h"
#include "endmessage.h"
#include "requestsourcerangesanddiagnosticsforquerymessage.h"
#include "requestsourcerangesforquerymessage.h"
#include "removegeneratedfilesmessage.h"
#include "removeprojectpartsmessage.h"
#include "updategeneratedfilesmessage.h"
#include "updateprojectpartsmessage.h"

View File

@@ -9,7 +9,6 @@ QT += network
INCLUDEPATH += $$PWD INCLUDEPATH += $$PWD
SOURCES += \ SOURCES += \
$$PWD/cancelmessage.cpp \
$$PWD/clangsupportdebugutils.cpp \ $$PWD/clangsupportdebugutils.cpp \
$$PWD/clangcodemodelclientinterface.cpp \ $$PWD/clangcodemodelclientinterface.cpp \
$$PWD/clangcodemodelclientproxy.cpp \ $$PWD/clangcodemodelclientproxy.cpp \
@@ -18,7 +17,6 @@ SOURCES += \
$$PWD/clangcodemodelserverproxy.cpp \ $$PWD/clangcodemodelserverproxy.cpp \
$$PWD/alivemessage.cpp \ $$PWD/alivemessage.cpp \
$$PWD/completionsmessage.cpp \ $$PWD/completionsmessage.cpp \
$$PWD/filesystem.cpp \
$$PWD/requestcompletionsmessage.cpp \ $$PWD/requestcompletionsmessage.cpp \
$$PWD/echomessage.cpp \ $$PWD/echomessage.cpp \
$$PWD/endmessage.cpp \ $$PWD/endmessage.cpp \
@@ -30,70 +28,34 @@ SOURCES += \
$$PWD/connectionserver.cpp \ $$PWD/connectionserver.cpp \
$$PWD/diagnosticcontainer.cpp \ $$PWD/diagnosticcontainer.cpp \
$$PWD/annotationsmessage.cpp \ $$PWD/annotationsmessage.cpp \
$$PWD/dynamicastmatcherdiagnosticcontainer.cpp \
$$PWD/dynamicastmatcherdiagnosticcontextcontainer.cpp \
$$PWD/dynamicastmatcherdiagnosticmessagecontainer.cpp \
$$PWD/filecontainer.cpp \ $$PWD/filecontainer.cpp \
$$PWD/filecontainerv2.cpp \
$$PWD/filepath.cpp \
$$PWD/fixitcontainer.cpp \ $$PWD/fixitcontainer.cpp \
$$PWD/followsymbolmessage.cpp \ $$PWD/followsymbolmessage.cpp \
$$PWD/lineprefixer.cpp \ $$PWD/lineprefixer.cpp \
$$PWD/messageenvelop.cpp \ $$PWD/messageenvelop.cpp \
$$PWD/pchmanagerclientinterface.cpp \
$$PWD/pchmanagerclientproxy.cpp \
$$PWD/pchmanagerserverinterface.cpp \
$$PWD/pchmanagerserverproxy.cpp \
$$PWD/precompiledheadersupdatedmessage.cpp \
$$PWD/projectpartpch.cpp \
$$PWD/readmessageblock.cpp \ $$PWD/readmessageblock.cpp \
$$PWD/refactoringclientinterface.cpp \
$$PWD/refactoringclientproxy.cpp \
$$PWD/refactoringserverinterface.cpp \
$$PWD/refactoringserverproxy.cpp \
$$PWD/referencesmessage.cpp \ $$PWD/referencesmessage.cpp \
$$PWD/unsavedfilesupdatedmessage.cpp \ $$PWD/unsavedfilesupdatedmessage.cpp \
$$PWD/requestannotationsmessage.cpp \ $$PWD/requestannotationsmessage.cpp \
$$PWD/requestfollowsymbolmessage.cpp \ $$PWD/requestfollowsymbolmessage.cpp \
$$PWD/requestreferencesmessage.cpp \ $$PWD/requestreferencesmessage.cpp \
$$PWD/requestsourcerangesanddiagnosticsforquerymessage.cpp \
$$PWD/requestsourcerangesforquerymessage.cpp \
$$PWD/requesttooltipmessage.cpp \ $$PWD/requesttooltipmessage.cpp \
$$PWD/sourcelocationcontainer.cpp \ $$PWD/sourcelocationcontainer.cpp \
$$PWD/sourcelocationcontainerv2.cpp \
$$PWD/sourcelocationscontainer.cpp \ $$PWD/sourcelocationscontainer.cpp \
$$PWD/sourcerangecontainer.cpp \ $$PWD/sourcerangecontainer.cpp \
$$PWD/processcreator.cpp \ $$PWD/processcreator.cpp \
$$PWD/processexception.cpp \ $$PWD/processexception.cpp \
$$PWD/processstartedevent.cpp \ $$PWD/processstartedevent.cpp \
$$PWD/sourcerangecontainerv2.cpp \
$$PWD/sourcerangesanddiagnosticsforquerymessage.cpp \
$$PWD/sourcerangescontainer.cpp \
$$PWD/sourcerangesforquerymessage.cpp \
$$PWD/sourcerangewithtextcontainer.cpp \
$$PWD/tokeninfocontainer.cpp \ $$PWD/tokeninfocontainer.cpp \
$$PWD/tooltipmessage.cpp \ $$PWD/tooltipmessage.cpp \
$$PWD/tooltipinfo.cpp \ $$PWD/tooltipinfo.cpp \
$$PWD/unsavedfilesremovedmessage.cpp \ $$PWD/unsavedfilesremovedmessage.cpp \
$$PWD/updateprojectpartsmessage.cpp \
$$PWD/documentschangedmessage.cpp \ $$PWD/documentschangedmessage.cpp \
$$PWD/documentvisibilitychangedmessage.cpp \ $$PWD/documentvisibilitychangedmessage.cpp \
$$PWD/writemessageblock.cpp \ $$PWD/writemessageblock.cpp \
$$PWD/filepathcaching.cpp \ $$PWD/baseserverproxy.cpp
$$PWD/filepathid.cpp \
$$PWD/baseserverproxy.cpp \
$$PWD/updategeneratedfilesmessage.cpp \
$$PWD/removegeneratedfilesmessage.cpp \
$$PWD/generatedfiles.cpp \
$$PWD/projectpartartefact.cpp \
$$PWD/projectpartcontainer.cpp \
$$PWD/filestatuscache.cpp
HEADERS += \ HEADERS += \
$$PWD/cancelmessage.h \
$$PWD/clangpathwatcher.h \
$$PWD/clangpathwatcherinterface.h \
$$PWD/clangpathwatchernotifier.h \
$$PWD/clangsupportdebugutils.h \ $$PWD/clangsupportdebugutils.h \
$$PWD/clangsupport_global.h \ $$PWD/clangsupport_global.h \
$$PWD/clangcodemodelclientinterface.h \ $$PWD/clangcodemodelclientinterface.h \
@@ -103,22 +65,8 @@ HEADERS += \
$$PWD/clangcodemodelserverinterface.h \ $$PWD/clangcodemodelserverinterface.h \
$$PWD/clangcodemodelservermessages.h \ $$PWD/clangcodemodelservermessages.h \
$$PWD/clangcodemodelserverproxy.h \ $$PWD/clangcodemodelserverproxy.h \
$$PWD/clangrefactoringclientmessages.h \
$$PWD/clangrefactoringmessages.h \
$$PWD/clangrefactoringservermessages.h \
$$PWD/alivemessage.h \ $$PWD/alivemessage.h \
$$PWD/clangsupportexceptions.h \
$$PWD/completionsmessage.h \ $$PWD/completionsmessage.h \
$$PWD/directoryandfilepathid.h \
$$PWD/directorypathid.h \
$$PWD/executeinloop.h \
$$PWD/filesystem.h \
$$PWD/filesysteminterface.h \
$$PWD/pchpaths.h \
$$PWD/projectpartid.h \
$$PWD/projectpartsstorage.h \
$$PWD/projectpartsstorageinterface.h \
$$PWD/projectpartstoragestructs.h \
$$PWD/requestcompletionsmessage.h \ $$PWD/requestcompletionsmessage.h \
$$PWD/echomessage.h \ $$PWD/echomessage.h \
$$PWD/endmessage.h \ $$PWD/endmessage.h \
@@ -130,99 +78,36 @@ HEADERS += \
$$PWD/connectionserver.h \ $$PWD/connectionserver.h \
$$PWD/diagnosticcontainer.h \ $$PWD/diagnosticcontainer.h \
$$PWD/annotationsmessage.h \ $$PWD/annotationsmessage.h \
$$PWD/dynamicastmatcherdiagnosticcontainer.h \
$$PWD/dynamicastmatcherdiagnosticcontextcontainer.h \
$$PWD/dynamicastmatcherdiagnosticmessagecontainer.h \
$$PWD/dynamicmatcherdiagnostics.h \
$$PWD/filecontainer.h \ $$PWD/filecontainer.h \
$$PWD/filecontainerv2.h \
$$PWD/fixitcontainer.h \ $$PWD/fixitcontainer.h \
$$PWD/followsymbolmessage.h \ $$PWD/followsymbolmessage.h \
$$PWD/idpaths.h \
$$PWD/ipcclientinterface.h \ $$PWD/ipcclientinterface.h \
$$PWD/ipcinterface.h \ $$PWD/ipcinterface.h \
$$PWD/ipcserverinterface.h \ $$PWD/ipcserverinterface.h \
$$PWD/lineprefixer.h \ $$PWD/lineprefixer.h \
$$PWD/messageenvelop.h \ $$PWD/messageenvelop.h \
$$PWD/pchmanagerclientinterface.h \
$$PWD/pchmanagerclientproxy.h \
$$PWD/pchmanagerserverinterface.h \
$$PWD/pchmanagerserverproxy.h \
$$PWD/precompiledheadersupdatedmessage.h \
$$PWD/projectpartpch.h \
$$PWD/readmessageblock.h \ $$PWD/readmessageblock.h \
$$PWD/refactoringclientinterface.h \
$$PWD/refactoringclientproxy.h \
$$PWD/refactoringserverinterface.h \
$$PWD/refactoringserverproxy.h \
$$PWD/referencesmessage.h \ $$PWD/referencesmessage.h \
$$PWD/stringcacheentry.h \
$$PWD/unsavedfilesupdatedmessage.h \ $$PWD/unsavedfilesupdatedmessage.h \
$$PWD/removeprojectpartsmessage.h \
$$PWD/requestannotationsmessage.h \ $$PWD/requestannotationsmessage.h \
$$PWD/requestfollowsymbolmessage.h \ $$PWD/requestfollowsymbolmessage.h \
$$PWD/requestreferencesmessage.h \ $$PWD/requestreferencesmessage.h \
$$PWD/requestsourcerangesanddiagnosticsforquerymessage.h \
$$PWD/requestsourcerangesforquerymessage.h \
$$PWD/requesttooltipmessage.h \ $$PWD/requesttooltipmessage.h \
$$PWD/sourcelocationcontainer.h \ $$PWD/sourcelocationcontainer.h \
$$PWD/sourcelocationcontainerv2.h \
$$PWD/sourcelocationscontainer.h \ $$PWD/sourcelocationscontainer.h \
$$PWD/sourcerangecontainer.h \ $$PWD/sourcerangecontainer.h \
$$PWD/filepath.h \
$$PWD/processcreator.h \ $$PWD/processcreator.h \
$$PWD/processexception.h \ $$PWD/processexception.h \
$$PWD/processhandle.h \ $$PWD/processhandle.h \
$$PWD/processstartedevent.h \ $$PWD/processstartedevent.h \
$$PWD/sourcerangecontainerv2.h \
$$PWD/sourcerangesanddiagnosticsforquerymessage.h \
$$PWD/sourcerangescontainer.h \
$$PWD/sourcerangesforquerymessage.h \
$$PWD/sourcerangewithtextcontainer.h \
$$PWD/stringcache.h \
$$PWD/tokeninfocontainer.h \ $$PWD/tokeninfocontainer.h \
$$PWD/tooltipmessage.h \ $$PWD/tooltipmessage.h \
$$PWD/tooltipinfo.h \ $$PWD/tooltipinfo.h \
$$PWD/unsavedfilesremovedmessage.h \ $$PWD/unsavedfilesremovedmessage.h \
$$PWD/updateprojectpartsmessage.h \
$$PWD/documentschangedmessage.h \ $$PWD/documentschangedmessage.h \
$$PWD/documentvisibilitychangedmessage.h \ $$PWD/documentvisibilitychangedmessage.h \
$$PWD/writemessageblock.h \ $$PWD/writemessageblock.h \
$$PWD/ipcclientprovider.h \ $$PWD/ipcclientprovider.h \
$$PWD/requestsourcerangesforquerymessage.h \ $$PWD/baseserverproxy.h
$$PWD/stringcachefwd.h \
$$PWD/stringcachealgorithms.h \
$$PWD/projectmanagementserverinterface.h \
$$PWD/refactoringdatabaseinitializer.h \
$$PWD/filepathcache.h \
$$PWD/filepathid.h \
$$PWD/filepathstorage.h \
$$PWD/filepathstoragesqlitestatementfactory.h \
$$PWD/filepathstoragesources.h \
$$PWD/filepathexceptions.h \
$$PWD/filepathcachinginterface.h \
$$PWD/filepathcaching.h \
$$PWD/filepathcachingfwd.h \
$$PWD/baseserverproxy.h \
$$PWD/filepath.h \
$$PWD/nativefilepath.h \
$$PWD/filepathview.h \
$$PWD/compilermacro.h \
$$PWD/updategeneratedfilesmessage.h \
$$PWD/removegeneratedfilesmessage.h \
$$PWD/generatedfiles.h \
$$PWD/generatedfilesinterface.h \
$$PWD/progressmessage.h \
$$PWD/progresscounter.h \
$$PWD/includesearchpath.h \
$$PWD/commandlinebuilder.h \
$$PWD/projectpartartefact.h \
$$PWD/projectpartcontainer.h \
$$PWD/sourceentry.h \
$$PWD/modifiedtimecheckerinterface.h \
$$PWD/environment.h \
$$PWD/filestatus.h \
$$PWD/filestatuscache.h \
$$PWD/modifiedtimechecker.h
contains(QT_CONFIG, reduce_exports):CONFIG += hide_symbols contains(QT_CONFIG, reduce_exports):CONFIG += hide_symbols

View File

@@ -169,22 +169,6 @@ enum class MessageType : quint8 {
RequestCompletionsMessage, RequestCompletionsMessage,
CompletionsMessage, CompletionsMessage,
SourceLocationsForRenamingMessage,
RequestSourceLocationsForRenamingMessage,
RequestSourceRangesAndDiagnosticsForQueryMessage,
RequestSourceRangesForQueryMessage,
SourceRangesAndDiagnosticsForQueryMessage,
SourceRangesForQueryMessage,
CancelMessage,
UpdateProjectPartsMessage,
RemoveProjectPartsMessage,
PrecompiledHeadersUpdatedMessage,
UpdateGeneratedFilesMessage,
RemoveGeneratedFilesMessage,
ProgressMessage
}; };
template<MessageType messageEnumeration> template<MessageType messageEnumeration>

View File

@@ -1,47 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2018 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 <sqliteexception.h>
namespace ClangBackEnd {
class ProjectPartArtefactParseError : public Sqlite::Exception
{
public:
ProjectPartArtefactParseError(const char *whatErrorHasHappen, Utils::SmallString &&errorMessage)
: Exception(whatErrorHasHappen, std::move(errorMessage))
{}
};
class ProjectPartDoesNotExists : public Sqlite::Exception
{
public:
ProjectPartDoesNotExists(const char *whatErrorHasHappen, Utils::SmallString &&errorMessage)
: Exception(whatErrorHasHappen, std::move(errorMessage))
{}
};
} // namespace ClangBackEnd

View File

@@ -1,313 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2018 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 "filepath.h"
#include "nativefilepath.h"
#include <compilermacro.h>
#include <includesearchpath.h>
#include <utils/smallstringvector.h>
#include <utils/cpplanguage_details.h>
#include <QCoreApplication>
#include <QDir>
namespace ClangBackEnd {
enum class InputFileType : unsigned char { Header, Source };
template<typename ProjectInfo, typename OutputContainer = Utils::SmallStringVector>
class CommandLineBuilder
{
public:
CommandLineBuilder(const ProjectInfo &projectInfo,
const Utils::SmallStringVector &toolChainArguments = {},
InputFileType sourceType = InputFileType::Header,
FilePathView sourcePath = {},
FilePathView outputPath = {},
FilePathView includePchPath = {},
NativeFilePathView preIncludeSearchPath = {})
{
commandLine.reserve(1024);
addCompiler(projectInfo.language);
disableWarnings();
addToolChainArguments(toolChainArguments);
addExtraFlags();
addLanguage(projectInfo, sourceType);
addLanguageVersion(projectInfo);
addNoStdIncAndNoStdLibInc(projectInfo.language);
addCompilerMacros(projectInfo.compilerMacros);
addPreIncludeSearchPath(preIncludeSearchPath);
addProjectIncludeSearchPaths(
sortedIncludeSearchPaths(projectInfo.projectIncludeSearchPaths));
addSystemAndBuiltInIncludeSearchPaths(
sortedIncludeSearchPaths(projectInfo.systemIncludeSearchPaths));
addIncludePchPath(includePchPath);
addOutputPath(outputPath);
addSourcePath(sourcePath);
}
void addCompiler(Utils::Language language)
{
if (language == Utils::Language::Cxx)
commandLine.emplace_back("clang++");
else
commandLine.emplace_back("clang");
}
void disableWarnings() { commandLine.emplace_back("-w"); }
void addToolChainArguments(const Utils::SmallStringVector &toolChainArguments)
{
for (Utils::SmallStringView argument : toolChainArguments)
commandLine.emplace_back(argument);
}
void addExtraFlags() { commandLine.emplace_back("-DNOMINMAX"); }
static const char *language(const ProjectInfo &projectInfo, InputFileType sourceType)
{
switch (projectInfo.language) {
case Utils::Language::C:
if (projectInfo.languageExtension && Utils::LanguageExtension::ObjectiveC)
return sourceType == InputFileType::Header ? "objective-c-header" : "objective-c";
return sourceType == InputFileType::Header ? "c-header" : "c";
case Utils::Language::Cxx:
if (projectInfo.languageExtension && Utils::LanguageExtension::ObjectiveC)
return sourceType == InputFileType::Header ? "objective-c++-header"
: "objective-c++";
return sourceType == InputFileType::Header ? "c++-header" : "c++";
case Utils::Language::None:
return "none";
}
return "none";
}
void addLanguage(const ProjectInfo &projectInfo, InputFileType sourceType)
{
commandLine.emplace_back("-x");
commandLine.emplace_back(language(projectInfo, sourceType));
}
const char *standardLanguageVersion(Utils::LanguageVersion languageVersion)
{
switch (languageVersion) {
case Utils::LanguageVersion::C89:
return "-std=c89";
case Utils::LanguageVersion::C99:
return "-std=c99";
case Utils::LanguageVersion::C11:
return "-std=c11";
case Utils::LanguageVersion::C18:
return "-std=c17";
case Utils::LanguageVersion::CXX98:
return "-std=c++98";
case Utils::LanguageVersion::CXX03:
return "-std=c++03";
case Utils::LanguageVersion::CXX11:
return "-std=c++11";
case Utils::LanguageVersion::CXX14:
return "-std=c++14";
case Utils::LanguageVersion::CXX17:
return "-std=c++17";
case Utils::LanguageVersion::CXX2a:
return "-std=c++2a";
case Utils::LanguageVersion::None:
return "";
}
return "-std=c++2a";
}
const char *gnuLanguageVersion(Utils::LanguageVersion languageVersion)
{
switch (languageVersion) {
case Utils::LanguageVersion::C89:
return "-std=gnu89";
case Utils::LanguageVersion::C99:
return "-std=gnu99";
case Utils::LanguageVersion::C11:
return "-std=gnu11";
case Utils::LanguageVersion::C18:
return "-std=gnu17";
case Utils::LanguageVersion::CXX98:
return "-std=gnu++98";
case Utils::LanguageVersion::CXX03:
return "-std=gnu++03";
case Utils::LanguageVersion::CXX11:
return "-std=gnu++11";
case Utils::LanguageVersion::CXX14:
return "-std=gnu++14";
case Utils::LanguageVersion::CXX17:
return "-std=gnu++17";
case Utils::LanguageVersion::CXX2a:
return "-std=gnu++2a";
case Utils::LanguageVersion::None:
return "";
}
return "-std=gnu++2a";
}
const char *includeOption(IncludeSearchPathType type)
{
switch (type) {
case IncludeSearchPathType::User:
case IncludeSearchPathType::System:
case IncludeSearchPathType::BuiltIn:
return "-isystem";
case IncludeSearchPathType::Framework:
return "-F";
case IncludeSearchPathType::Invalid:
return "";
}
return "-I";
}
void addLanguageVersion(const ProjectInfo &projectInfo)
{
if (projectInfo.languageExtension && Utils::LanguageExtension::Gnu)
commandLine.emplace_back(gnuLanguageVersion(projectInfo.languageVersion));
else
commandLine.emplace_back(standardLanguageVersion(projectInfo.languageVersion));
}
void addCompilerMacros(const CompilerMacros &compilerMacros)
{
CompilerMacros macros = compilerMacros;
macros.erase(std::remove_if(macros.begin(),
macros.end(),
[](const auto &macro) {
return macro.type == CompilerMacroType::NotDefined;
}),
macros.end());
std::sort(macros.begin(),
macros.end(),
[](const CompilerMacro &first, const CompilerMacro &second) {
return first.index < second.index;
});
for (const CompilerMacro &macro : macros)
commandLine.emplace_back(Utils::SmallString::join({"-D", macro.key, "=", macro.value}));
}
void addPreIncludeSearchPath(NativeFilePathView preIncludeSearchPath)
{
if (!preIncludeSearchPath.empty()) {
commandLine.emplace_back("-isystem");
commandLine.emplace_back(preIncludeSearchPath);
}
}
IncludeSearchPaths sortedIncludeSearchPaths(const IncludeSearchPaths &unsortedPaths)
{
IncludeSearchPaths paths = unsortedPaths;
std::sort(paths.begin(), paths.end(), [](const auto &first, const auto &second) {
return first.index < second.index;
});
return paths;
}
void addProjectIncludeSearchPaths(const IncludeSearchPaths &projectIncludeSearchPaths)
{
for (const IncludeSearchPath &path : projectIncludeSearchPaths) {
commandLine.emplace_back("-I");
commandLine.emplace_back(NativeFilePath(FilePathView(path.path)));
}
}
void addSystemAndBuiltInIncludeSearchPaths(const IncludeSearchPaths &systemIncludeSearchPaths)
{
addSystemIncludeSearchPaths(systemIncludeSearchPaths);
addBuiltInSystemSearchPaths(systemIncludeSearchPaths);
}
void addSystemIncludeSearchPaths(const IncludeSearchPaths &systemIncludeSearchPaths)
{
for (const IncludeSearchPath &path : systemIncludeSearchPaths) {
if (path.type != IncludeSearchPathType::BuiltIn) {
commandLine.emplace_back(includeOption(path.type));
commandLine.emplace_back(NativeFilePath(FilePathView(path.path)));
}
}
}
void addBuiltInSystemSearchPaths(const IncludeSearchPaths &systemIncludeSearchPaths)
{
for (const IncludeSearchPath &path : systemIncludeSearchPaths) {
if (path.type == IncludeSearchPathType::BuiltIn) {
commandLine.emplace_back(includeOption(path.type));
commandLine.emplace_back(NativeFilePath(FilePathView(path.path)));
}
}
}
void addOutputPath(FilePathView outputPath)
{
if (!outputPath.isEmpty()) {
commandLine.emplace_back("-o");
commandLine.emplace_back(NativeFilePath(outputPath));
}
}
void addSourcePath(FilePathView sourcePath)
{
if (!sourcePath.isEmpty())
commandLine.emplace_back(NativeFilePath(sourcePath));
}
void addIncludePchPath(FilePathView includePchPath)
{
if (!includePchPath.isEmpty()) {
commandLine.emplace_back("-Xclang");
commandLine.emplace_back("-include-pch");
commandLine.emplace_back("-Xclang");
commandLine.emplace_back(NativeFilePath(includePchPath));
}
}
void addNoStdIncAndNoStdLibInc(Utils::Language language)
{
commandLine.emplace_back("-nostdinc");
if (language == Utils::Language::Cxx)
commandLine.emplace_back("-nostdinc++");
}
public:
OutputContainer commandLine;
};
} // namespace ClangBackEnd

View File

@@ -1,99 +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 <utils/smallstringio.h>
#include <vector>
namespace ClangBackEnd {
enum class CompilerMacroType : unsigned char { Define, NotDefined };
class CompilerMacro
{
public:
constexpr CompilerMacro() = default;
CompilerMacro(Utils::SmallString &&key, Utils::SmallString &&value, int index)
: key(std::move(key))
, value(std::move(value))
, index(index)
, type(CompilerMacroType::Define)
{}
CompilerMacro(Utils::SmallString &&key)
: key(std::move(key))
{}
CompilerMacro(const Utils::SmallString &key)
: key(key)
{}
friend QDataStream &operator<<(QDataStream &out, const CompilerMacro &compilerMacro)
{
out << compilerMacro.key;
out << compilerMacro.value;
out << compilerMacro.index;
out << static_cast<unsigned char>(compilerMacro.type);
return out;
}
friend QDataStream &operator>>(QDataStream &in, CompilerMacro &compilerMacro)
{
unsigned char type;
in >> compilerMacro.key;
in >> compilerMacro.value;
in >> compilerMacro.index;
in >> type;
compilerMacro.type = static_cast<CompilerMacroType>(type);
return in;
}
friend bool operator==(const CompilerMacro &first, const CompilerMacro &second)
{
return first.key == second.key && first.value == second.value && first.type == second.type;
}
friend bool operator<(const CompilerMacro &first, const CompilerMacro &second)
{
return std::tie(first.key, first.type, first.value)
< std::tie(second.key, second.type, second.value);
}
public:
Utils::SmallString key;
Utils::SmallString value;
int index = -1;
CompilerMacroType type = CompilerMacroType::NotDefined;
};
using CompilerMacros = std::vector<CompilerMacro>;
}

View File

@@ -1,90 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2019 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 "directorypathid.h"
#include "filepathid.h"
#include <QDataStream>
#include <vector>
namespace ClangBackEnd {
class DirectoryAndFilePathId
{
public:
constexpr DirectoryAndFilePathId() = default;
DirectoryAndFilePathId(const char *) = delete;
DirectoryAndFilePathId(int directoryPathId, int filePathId)
: directoryPathId(directoryPathId)
, filePathId(filePathId)
{}
bool isValid() const { return directoryPathId.isValid() && filePathId.isValid(); }
friend bool operator==(DirectoryAndFilePathId first, DirectoryAndFilePathId second)
{
return first.isValid() && first.directoryPathId == second.directoryPathId
&& first.filePathId == second.filePathId;
}
friend bool operator!=(DirectoryAndFilePathId first, DirectoryAndFilePathId second)
{
return !(first == second);
}
friend bool operator<(DirectoryAndFilePathId first, DirectoryAndFilePathId second)
{
return std::tie(first.directoryPathId, first.filePathId)
< std::tie(second.directoryPathId, second.filePathId);
}
friend QDataStream &operator<<(QDataStream &out,
const DirectoryAndFilePathId &directoryAndFilePathId)
{
out << directoryAndFilePathId.directoryPathId;
out << directoryAndFilePathId.filePathId;
return out;
}
friend QDataStream &operator>>(QDataStream &in, DirectoryAndFilePathId &directoryAndFilePathId)
{
in >> directoryAndFilePathId.directoryPathId;
in >> directoryAndFilePathId.filePathId;
return in;
}
public:
DirectoryPathId directoryPathId;
FilePathId filePathId;
};
using DirectoryAndFilePathIds = std::vector<DirectoryAndFilePathId>;
} // namespace ClangBackEnd

View File

@@ -1,86 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2016 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 "clangsupport_global.h"
#include "filepathcachinginterface.h"
#include <QDir>
#include <QTimer>
#include <utils/algorithm.h>
#include <functional>
namespace ClangBackEnd {
template<typename Timer>
class DirectoryPathCompressor
{
public:
DirectoryPathCompressor() { m_timer.setSingleShot(true); }
virtual ~DirectoryPathCompressor() = default;
void addDirectoryPathId(DirectoryPathId directoryPathIdId)
{
auto found = std::lower_bound(m_directoryPathIds.begin(),
m_directoryPathIds.end(),
directoryPathIdId);
if (found == m_directoryPathIds.end() || *found != directoryPathIdId)
m_directoryPathIds.insert(found, directoryPathIdId);
restartTimer();
}
DirectoryPathIds takeDirectoryPathIds() { return std::move(m_directoryPathIds); }
virtual void setCallback(std::function<void(ClangBackEnd::DirectoryPathIds &&)> &&callback)
{
QObject::connect(&m_timer, &Timer::timeout, [this, callback = std::move(callback)] {
callback(takeDirectoryPathIds());
});
}
unittest_public:
virtual void restartTimer()
{
m_timer.start(20);
}
Timer &timer()
{
return m_timer;
}
private:
DirectoryPathIds m_directoryPathIds;
Timer m_timer;
};
} // namespace ClangBackEnd

View File

@@ -1,81 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2019 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 <QDataStream>
#include <vector>
namespace ClangBackEnd {
class DirectoryPathId
{
public:
constexpr DirectoryPathId() = default;
DirectoryPathId(const char *) = delete;
DirectoryPathId(int directoryPathId)
: directoryPathId(directoryPathId)
{}
bool isValid() const { return directoryPathId >= 0; }
friend bool operator==(DirectoryPathId first, DirectoryPathId second)
{
return first.isValid() && first.directoryPathId == second.directoryPathId;
}
friend bool operator!=(DirectoryPathId first, DirectoryPathId second)
{
return !(first == second);
}
friend bool operator<(DirectoryPathId first, DirectoryPathId second)
{
return first.directoryPathId < second.directoryPathId;
}
friend QDataStream &operator<<(QDataStream &out, const DirectoryPathId &directoryPathId)
{
out << directoryPathId.directoryPathId;
return out;
}
friend QDataStream &operator>>(QDataStream &in, DirectoryPathId &directoryPathId)
{
in >> directoryPathId.directoryPathId;
return in;
}
public:
int directoryPathId = -1;
};
using DirectoryPathIds = std::vector<DirectoryPathId>;
} // namespace ClangBackEnd

View File

@@ -1,40 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2016 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 "dynamicastmatcherdiagnosticcontainer.h"
namespace ClangBackEnd {
QDebug operator<<(QDebug debug, const DynamicASTMatcherDiagnosticContainer &container)
{
debug.nospace() << "DynamicASTMatcherDiagnosticContextContainer("
<< container.messages << ", "
<< container.contexts
<< ")";
return debug;
}
} // namespace ClangBackEnd

View File

@@ -1,93 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2016 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 "dynamicastmatcherdiagnosticmessagecontainer.h"
#include "dynamicastmatcherdiagnosticcontextcontainer.h"
namespace ClangBackEnd {
class DynamicASTMatcherDiagnosticContainer
{
public:
DynamicASTMatcherDiagnosticContainer() = default;
DynamicASTMatcherDiagnosticContainer(DynamicASTMatcherDiagnosticMessageContainers &&messages,
DynamicASTMatcherDiagnosticContextContainers &&contexts)
: messages(std::move(messages)),
contexts(std::move(contexts))
{
}
void insertMessage(V2::SourceRangeContainer &&sourceRange,
ClangQueryDiagnosticErrorType errorType,
Utils::SmallStringVector &&arguments) {
messages.emplace_back(std::move(sourceRange), errorType, std::move(arguments));
}
void insertContext(V2::SourceRangeContainer &&sourceRange,
ClangQueryDiagnosticContextType contextType,
Utils::SmallStringVector &&arguments) {
contexts.emplace_back(std::move(sourceRange), contextType, std::move(arguments));
}
friend QDataStream &operator<<(QDataStream &out, const DynamicASTMatcherDiagnosticContainer &container)
{
out << container.messages;
out << container.contexts;
return out;
}
friend QDataStream &operator>>(QDataStream &in, DynamicASTMatcherDiagnosticContainer &container)
{
in >> container.messages;
in >> container.contexts;
return in;
}
friend bool operator==(const DynamicASTMatcherDiagnosticContainer &first,
const DynamicASTMatcherDiagnosticContainer &second)
{
return first.messages == second.messages
&& first.contexts == second.contexts;
}
DynamicASTMatcherDiagnosticContainer clone() const
{
return *this;
}
public:
DynamicASTMatcherDiagnosticMessageContainers messages;
DynamicASTMatcherDiagnosticContextContainers contexts;
};
using DynamicASTMatcherDiagnosticContainers = std::vector<DynamicASTMatcherDiagnosticContainer>;
CLANGSUPPORT_EXPORT QDebug operator<<(QDebug debug, const DynamicASTMatcherDiagnosticContainer &container);
} // namespace ClangBackEnd

View File

@@ -1,54 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2016 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 "dynamicastmatcherdiagnosticcontextcontainer.h"
namespace ClangBackEnd {
QDebug operator<<(QDebug debug, const DynamicASTMatcherDiagnosticContextContainer &container)
{
debug.nospace() << "DynamicASTMatcherDiagnosticContextContainer("
<< container.sourceRange << ", "
<< container.contextTypeText() << ", "
<< container.arguments
<< ")";
return debug;
}
#define RETURN_CASE(name) \
case ClangQueryDiagnosticContextType::name: return #name;
Utils::SmallString DynamicASTMatcherDiagnosticContextContainer::contextTypeText() const
{
switch (contextType) {
RETURN_CASE(MatcherArg)
RETURN_CASE(MatcherConstruct)
}
Q_UNREACHABLE();
}
} // namespace ClangBackEnd

View File

@@ -1,97 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2016 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 "dynamicmatcherdiagnostics.h"
#include "sourcerangecontainerv2.h"
#include <utils/smallstringio.h>
namespace ClangBackEnd {
class DynamicASTMatcherDiagnosticContextContainer
{
public:
DynamicASTMatcherDiagnosticContextContainer() = default;
DynamicASTMatcherDiagnosticContextContainer(V2::SourceRangeContainer &&sourceRange,
ClangQueryDiagnosticContextType contextType,
Utils::SmallStringVector &&arguments)
: sourceRange(sourceRange),
contextType(contextType),
arguments(std::move(arguments))
{
}
CLANGSUPPORT_EXPORT Utils::SmallString contextTypeText() const;
friend QDataStream &operator<<(QDataStream &out, const DynamicASTMatcherDiagnosticContextContainer &container)
{
out << container.sourceRange;
out << quint32(container.contextType);
out << container.arguments;
return out;
}
friend QDataStream &operator>>(QDataStream &in, DynamicASTMatcherDiagnosticContextContainer &container)
{
quint32 contextType;
in >> container.sourceRange;
in >> contextType;
in >> container.arguments;
container.contextType = static_cast<ClangQueryDiagnosticContextType>(contextType);
return in;
}
friend bool operator==(const DynamicASTMatcherDiagnosticContextContainer &first,
const DynamicASTMatcherDiagnosticContextContainer &second)
{
return first.contextType == second.contextType
&& first.sourceRange == second.sourceRange
&& first.arguments == second.arguments;
}
DynamicASTMatcherDiagnosticContextContainer clone() const
{
return DynamicASTMatcherDiagnosticContextContainer(sourceRange.clone(),
contextType,
arguments.clone());
}
public:
V2::SourceRangeContainer sourceRange;
ClangQueryDiagnosticContextType contextType = ClangQueryDiagnosticContextType::MatcherArg;
Utils::SmallStringVector arguments;
};
using DynamicASTMatcherDiagnosticContextContainers = std::vector<DynamicASTMatcherDiagnosticContextContainer>;
CLANGSUPPORT_EXPORT QDebug operator<<(QDebug debug, const DynamicASTMatcherDiagnosticContextContainer &container);
} // namespace ClangBackEnd

View File

@@ -1,70 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2016 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 "dynamicastmatcherdiagnosticmessagecontainer.h"
#define RETURN_CASE(name) \
case ClangQueryDiagnosticErrorType::name: return #name;
namespace ClangBackEnd {
QDebug operator<<(QDebug debug, const DynamicASTMatcherDiagnosticMessageContainer &container)
{
debug.nospace() << "DynamicASTMatcherDiagnosticMessageContainer("
<< container.errorTypeText() << ", "
<< container.sourceRange << ", "
<< container.arguments
<< ")";
return debug;
}
Utils::SmallString DynamicASTMatcherDiagnosticMessageContainer::errorTypeText() const
{
switch (errorType) {
RETURN_CASE(None)
RETURN_CASE(RegistryMatcherNotFound)
RETURN_CASE(RegistryWrongArgCount)
RETURN_CASE(RegistryWrongArgType)
RETURN_CASE(RegistryNotBindable)
RETURN_CASE(RegistryAmbiguousOverload)
RETURN_CASE(RegistryValueNotFound)
RETURN_CASE(ParserStringError)
RETURN_CASE(ParserNoOpenParen)
RETURN_CASE(ParserNoCloseParen)
RETURN_CASE(ParserNoComma)
RETURN_CASE(ParserNoCode)
RETURN_CASE(ParserNotAMatcher)
RETURN_CASE(ParserInvalidToken)
RETURN_CASE(ParserMalformedBindExpr)
RETURN_CASE(ParserTrailingCode)
RETURN_CASE(ParserNumberError)
RETURN_CASE(ParserOverloadedType)
}
Q_UNREACHABLE();
}
} // namespace ClangBackEnd

View File

@@ -1,95 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2016 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 "dynamicmatcherdiagnostics.h"
#include "sourcerangecontainerv2.h"
#include <utils/smallstringio.h>
namespace ClangBackEnd {
class DynamicASTMatcherDiagnosticMessageContainer
{
public:
DynamicASTMatcherDiagnosticMessageContainer() = default;
DynamicASTMatcherDiagnosticMessageContainer(V2::SourceRangeContainer &&sourceRange,
ClangQueryDiagnosticErrorType errorType,
Utils::SmallStringVector &&arguments)
: sourceRange(sourceRange),
errorType(errorType),
arguments(std::move(arguments))
{
}
CLANGSUPPORT_EXPORT Utils::SmallString errorTypeText() const;
friend QDataStream &operator<<(QDataStream &out, const DynamicASTMatcherDiagnosticMessageContainer &container)
{
out << container.sourceRange;
out << quint32(container.errorType);
out << container.arguments;
return out;
}
friend QDataStream &operator>>(QDataStream &in, DynamicASTMatcherDiagnosticMessageContainer &container)
{
quint32 errorType;
in >> container.sourceRange;
in >> errorType;
in >> container.arguments;
container.errorType = static_cast<ClangQueryDiagnosticErrorType>(errorType);
return in;
}
friend bool operator==(const DynamicASTMatcherDiagnosticMessageContainer &first,
const DynamicASTMatcherDiagnosticMessageContainer &second)
{
return first.errorType == second.errorType
&& first.sourceRange == second.sourceRange
&& first.arguments == second.arguments;
}
DynamicASTMatcherDiagnosticMessageContainer clone() const
{
return *this;
}
public:
V2::SourceRangeContainer sourceRange;
ClangQueryDiagnosticErrorType errorType = ClangQueryDiagnosticErrorType::None;
Utils::SmallStringVector arguments;
};
using DynamicASTMatcherDiagnosticMessageContainers = std::vector<DynamicASTMatcherDiagnosticMessageContainer>;
CLANGSUPPORT_EXPORT QDebug operator<<(QDebug debug, const DynamicASTMatcherDiagnosticMessageContainer &container);
} // namespace ClangBackEnd

View File

@@ -1,58 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2016 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
namespace ClangBackEnd {
enum class ClangQueryDiagnosticContextType {
MatcherArg,
MatcherConstruct
};
enum class ClangQueryDiagnosticErrorType {
None,
RegistryMatcherNotFound,
RegistryWrongArgCount,
RegistryWrongArgType,
RegistryNotBindable,
RegistryAmbiguousOverload,
RegistryValueNotFound,
ParserStringError,
ParserNoOpenParen,
ParserNoCloseParen,
ParserNoComma,
ParserNoCode,
ParserNotAMatcher,
ParserInvalidToken,
ParserMalformedBindExpr,
ParserTrailingCode,
ParserNumberError,
ParserOverloadedType
};
} // namespace ClangBackEnd

View File

@@ -1,47 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2016 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 <nativefilepath.h>
namespace ClangBackEnd {
class Environment
{
public:
Environment() = default;
Environment(const Environment &) = delete;
Environment &operator=(const Environment &) = delete;
virtual Utils::PathString pchBuildDirectory() const = 0;
virtual uint hardwareConcurrency() const = 0;
virtual NativeFilePathView preIncludeSearchPath() const = 0;
protected:
~Environment() = default;
};
} // namespace ClangBackEnd

View File

@@ -1,39 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2018 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 <QAbstractEventDispatcher>
#include <QCoreApplication>
#include <QThread>
template<typename Callable>
void executeInLoop(Callable &&callable, QObject *object = QCoreApplication::instance())
{
if (QThread *thread = qobject_cast<QThread *>(object))
object = QAbstractEventDispatcher::instance(thread);
QMetaObject::invokeMethod(object, std::forward<Callable>(callable));
}

View File

@@ -1,44 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2016 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 "filecontainerv2.h"
namespace ClangBackEnd {
namespace V2 {
QDebug operator<<(QDebug debug, const FileContainer &container)
{
debug.nospace() << "FileContainer(" << container.filePath << ", "
<< container.commandLineArguments << ", "
<< container.unsavedFileContent.hasContent() << ", "
<< container.documentRevision;
debug.nospace() << ")";
return debug;
}
} // namespace V2
} // namespace ClangBackEnd

View File

@@ -1,102 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2016 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 "clangsupport_global.h"
#include "filepath.h"
#include "filepathid.h"
#include <vector>
namespace ClangBackEnd {
namespace V2 {
class FileContainer
{
public:
FileContainer() = default;
FileContainer(FilePath &&filePath,
FilePathId filePathId,
Utils::SmallString &&unsavedFileContent,
Utils::SmallStringVector &&commandLineArguments = {},
quint32 documentRevision = 0)
: filePath(std::move(filePath))
, filePathId(filePathId)
, unsavedFileContent(std::move(unsavedFileContent))
, commandLineArguments(std::move(commandLineArguments))
, documentRevision(documentRevision)
{
}
friend QDataStream &operator<<(QDataStream &out, const FileContainer &container)
{
out << container.filePath;
out << container.commandLineArguments;
out << container.unsavedFileContent;
out << container.documentRevision;
return out;
}
friend QDataStream &operator>>(QDataStream &in, FileContainer &container)
{
in >> container.filePath;
in >> container.commandLineArguments;
in >> container.unsavedFileContent;
in >> container.documentRevision;
return in;
}
friend bool operator==(const FileContainer &first, const FileContainer &second)
{
return first.filePath == second.filePath
&& first.commandLineArguments == second.commandLineArguments;
}
friend bool operator<(const FileContainer &first, const FileContainer &second)
{
return std::tie(first.filePath, first.documentRevision, first.unsavedFileContent, first.commandLineArguments)
< std::tie(second.filePath, second.documentRevision, second.unsavedFileContent, second.commandLineArguments);
}
FileContainer clone() const { return *this; }
public:
FilePath filePath;
FilePathId filePathId;
Utils::SmallString unsavedFileContent;
Utils::SmallStringVector commandLineArguments;
quint32 documentRevision = 0;
};
using FileContainers = std::vector<FileContainer>;
CLANGSUPPORT_EXPORT QDebug operator<<(QDebug debug, const FileContainer &container);
} // namespace V2
} // namespace ClangBackEnd

View File

@@ -1,37 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2016 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 "filepath.h"
namespace ClangBackEnd {
QDebug operator<<(QDebug debug, const FilePath &filePath)
{
debug.nospace() << filePath.directory() << "/" << filePath.name();
return debug;
}
} // namespace ClangBackEnd

View File

@@ -1,197 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2016 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 "clangsupport_global.h"
#include "filepathview.h"
#include <utils/hostosinfo.h>
#include <utils/smallstringio.h>
#include <QDataStream>
namespace ClangBackEnd {
class NativeFilePath;
class FilePath : public Utils::PathString
{
using size_type = Utils::PathString::size_type;
public:
FilePath() = default;
explicit FilePath(Utils::PathString &&filePath)
: Utils::PathString(std::move(filePath))
{
FilePathView view{*this};
m_slashIndex = view.slashIndex();
}
explicit FilePath(Utils::SmallStringView &&filePath)
: Utils::PathString(filePath)
{
FilePathView view{*this};
m_slashIndex = view.slashIndex();
}
FilePath(FilePathView filePathView)
: Utils::PathString(filePathView.toStringView()),
m_slashIndex(filePathView.slashIndex())
{
}
template<size_type Size>
FilePath(const char(&string)[Size]) noexcept
: FilePath(FilePathView(string, Size - 1))
{
static_assert(Size >= 1, "Invalid string literal! Length is zero!");
}
explicit FilePath(const Utils::PathString &filePath)
: FilePath(filePath.clone())
{
}
explicit FilePath(Utils::PathString &&filePath, std::ptrdiff_t slashIndex)
: Utils::PathString(std::move(filePath)),
m_slashIndex(slashIndex)
{
}
explicit FilePath(const QString &filePath)
: FilePath(Utils::PathString(filePath))
{
}
FilePath(Utils::SmallStringView directory, Utils::SmallStringView name)
: Utils::PathString(Utils::PathString::join({directory, "/", name}))
, m_slashIndex(std::ptrdiff_t(directory.size()))
{}
bool isValid() const { return size() > 0 && m_slashIndex >= 0; }
Utils::SmallStringView directory() const noexcept
{
return mid(0, std::size_t(std::max(std::ptrdiff_t(0), m_slashIndex)));
}
Utils::SmallStringView name() const noexcept
{
return mid(std::size_t(m_slashIndex + 1),
std::size_t(std::ptrdiff_t(size()) - m_slashIndex - std::ptrdiff_t(1)));
}
const Utils::PathString &path() const noexcept
{
return *this;
}
operator FilePathView() const noexcept
{
return FilePathView(toStringView());
}
operator Utils::SmallStringView() const noexcept
{
return toStringView();
}
friend QDataStream &operator<<(QDataStream &out, const FilePath &filePath)
{
out << static_cast<const Utils::PathString&>(filePath);
out << uint(filePath.m_slashIndex);
return out;
}
friend QDataStream &operator>>(QDataStream &in, FilePath &filePath)
{
uint slashIndex;
in >> static_cast<Utils::PathString&>(filePath);
in >> slashIndex;
filePath.m_slashIndex = slashIndex;
return in;
}
friend bool operator==(const FilePath &first, const FilePath &second)
{
return first.slashIndex() == second.slashIndex()
&& first.name() == second.name()
&& first.directory() == second.directory();
}
friend bool operator==(const FilePath &first, const FilePathView &second)
{
return first.toStringView() == second.toStringView();
}
friend bool operator==(const FilePathView &first, const FilePath &second)
{
return second == first;
}
friend bool operator<(const FilePath &first, const FilePath &second)
{
return std::make_tuple(first.slashIndex(), first.name(), first.directory())
< std::make_tuple(second.slashIndex(), second.name(), second.directory());
}
FilePath clone() const
{
return *this;
}
std::ptrdiff_t slashIndex() const
{
return m_slashIndex;
}
template<typename String>
static FilePath fromNativeFilePath(const String &filePath)
{
Utils::PathString nativePath{filePath.data(), filePath.size()};
if (Utils::HostOsInfo::isWindowsHost())
nativePath.replace('\\', '/');
return FilePath(std::move(nativePath));
}
private:
std::ptrdiff_t m_slashIndex = -1;
};
using FilePaths = std::vector<FilePath>;
CLANGSUPPORT_EXPORT QDebug operator<<(QDebug debug, const FilePath &filePath);
} // namespace ClangBackEnd

View File

@@ -1,206 +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 "directorypathid.h"
#include "filepath.h"
#include "filepathexceptions.h"
#include "filepathid.h"
#include "filepathstoragesources.h"
#include "filepathview.h"
#include "stringcache.h"
#include <sqlitetransaction.h>
#include <algorithm>
namespace ClangBackEnd {
template<typename FilePathStorage, typename Mutex = SharedMutex>
class CLANGSUPPORT_GCCEXPORT FilePathCache
{
FilePathCache(const FilePathCache &) = default;
FilePathCache &operator=(const FilePathCache &) = default;
template<typename Storage, typename M>
friend class FilePathCache;
public:
using DirectoryPathCache = StringCache<Utils::PathString,
Utils::SmallStringView,
int,
Mutex,
decltype(&Utils::reverseCompare),
Utils::reverseCompare,
Sources::Directory>;
using FileNameCache = StringCache<FileNameEntry,
FileNameView,
int,
Mutex,
decltype(&FileNameView::compare),
FileNameView::compare,
Sources::Source>;
FilePathCache(FilePathStorage &filePathStorage)
: m_filePathStorage(filePathStorage)
{
populateIfEmpty();
}
FilePathCache(FilePathCache &&) = default;
FilePathCache &operator=(FilePathCache &&) = default;
void populateIfEmpty()
{
if (m_fileNameCache.isEmpty()) {
m_directoryPathCache.populate(m_filePathStorage.fetchAllDirectories());
m_fileNameCache.populate(m_filePathStorage.fetchAllSources());
}
}
template<typename Cache>
Cache clone()
{
using DirectoryPathCache = typename Cache::DirectoryPathCache;
using FileNameCache = typename Cache::FileNameCache;
Cache cache{m_filePathStorage};
cache.m_directoryPathCache = m_directoryPathCache.template clone<DirectoryPathCache>();
cache.m_fileNameCache = m_fileNameCache.template clone<FileNameCache>();
return cache;
}
FilePathId filePathId(FilePathView filePath) const
{
Utils::SmallStringView directoryPath = filePath.directory();
int directoryId = m_directoryPathCache.stringId(
directoryPath, [&](const Utils::SmallStringView directoryPath) {
return m_filePathStorage.fetchDirectoryId(directoryPath);
});
Utils::SmallStringView fileName = filePath.name();
int fileNameId = m_fileNameCache.stringId({fileName, directoryId},
[&] (const FileNameView) {
return m_filePathStorage.fetchSourceId(directoryId, fileName);
});
return fileNameId;
}
DirectoryPathId directoryPathId(Utils::SmallStringView directoryPath) const
{
Utils::SmallStringView path = directoryPath.back() == '/'
? directoryPath.mid(0, directoryPath.size() - 1)
: directoryPath;
return m_directoryPathCache.stringId(path, [&](const Utils::SmallStringView directoryPath) {
return m_filePathStorage.fetchDirectoryId(directoryPath);
});
}
FilePath filePath(FilePathId filePathId) const
{
if (Q_UNLIKELY(!filePathId.isValid()))
throw NoFilePathForInvalidFilePathId();
auto fetchSoureNameAndDirectoryId = [&] (int id) {
auto entry = m_filePathStorage.fetchSourceNameAndDirectoryId(id);
return FileNameEntry{entry.sourceName, entry.directoryId};
};
auto entry = m_fileNameCache.string(filePathId.filePathId, fetchSoureNameAndDirectoryId);
auto fetchDirectoryPath = [&] (int id) { return m_filePathStorage.fetchDirectoryPath(id); };
Utils::PathString directoryPath = m_directoryPathCache.string(entry.directoryId,
fetchDirectoryPath);
return FilePath{directoryPath, entry.fileName};
}
Utils::PathString directoryPath(DirectoryPathId directoryPathId) const
{
if (Q_UNLIKELY(!directoryPathId.isValid()))
throw NoDirectoryPathForInvalidDirectoryPathId();
auto fetchDirectoryPath = [&](int id) { return m_filePathStorage.fetchDirectoryPath(id); };
return m_directoryPathCache.string(directoryPathId.directoryPathId, fetchDirectoryPath);
}
DirectoryPathId directoryPathId(FilePathId filePathId) const
{
if (Q_UNLIKELY(!filePathId.isValid()))
throw NoFilePathForInvalidFilePathId();
auto fetchSoureNameAndDirectoryId = [&](int id) {
auto entry = m_filePathStorage.fetchSourceNameAndDirectoryId(id);
return FileNameEntry{entry.sourceName, entry.directoryId};
};
return m_fileNameCache.string(filePathId.filePathId, fetchSoureNameAndDirectoryId).directoryId;
}
template<typename Container>
void addFilePaths(Container &&filePaths)
{
auto directoryPaths = Utils::transform<std::vector<Utils::SmallStringView>>(
filePaths, [](FilePathView filePath) { return filePath.directory(); });
std::unique_ptr<Sqlite::DeferredTransaction> transaction;
m_directoryPathCache.addStrings(std::move(directoryPaths), [&](Utils::SmallStringView directoryPath) {
if (!transaction)
transaction = std::make_unique<Sqlite::DeferredTransaction>(
m_filePathStorage.database());
return m_filePathStorage.fetchDirectoryIdUnguarded(directoryPath);
});
auto sourcePaths = Utils::transform<std::vector<FileNameView>>(filePaths, [&](FilePathView filePath) {
return FileNameView{filePath.name(), m_directoryPathCache.stringId(filePath.directory())};
});
m_fileNameCache.addStrings(std::move(sourcePaths), [&](FileNameView fileNameView) {
if (!transaction)
transaction = std::make_unique<Sqlite::DeferredTransaction>(
m_filePathStorage.database());
return m_filePathStorage.fetchSourceIdUnguarded(fileNameView.directoryId,
fileNameView.fileName);
});
if (transaction)
transaction->commit();
}
private:
mutable DirectoryPathCache m_directoryPathCache;
mutable FileNameCache m_fileNameCache;
FilePathStorage &m_filePathStorage;
};
} // namespace ClangBackEnd

View File

@@ -1,100 +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 "filepathcaching.h"
namespace ClangBackEnd {
FilePathId FilePathCaching::filePathId(FilePathView filePath) const
{
return m_cache.filePathId(filePath);
}
FilePath FilePathCaching::filePath(FilePathId filePathId) const
{
return m_cache.filePath(filePathId);
}
DirectoryPathId FilePathCaching::directoryPathId(Utils::SmallStringView directoryPath) const
{
return m_cache.directoryPathId(directoryPath);
}
Utils::PathString FilePathCaching::directoryPath(DirectoryPathId directoryPathId) const
{
return m_cache.directoryPath(directoryPathId);
}
DirectoryPathId FilePathCaching::directoryPathId(FilePathId filePathId) const
{
return m_cache.directoryPathId(filePathId);
}
void FilePathCaching::addFilePaths(const FilePaths &filePaths)
{
m_cache.addFilePaths(filePaths);
}
void FilePathCaching::populateIfEmpty()
{
m_cache.populateIfEmpty();
}
FilePathId CopyableFilePathCaching::filePathId(FilePathView filePath) const
{
return m_cache.filePathId(filePath);
}
FilePath CopyableFilePathCaching::filePath(FilePathId filePathId) const
{
return m_cache.filePath(filePathId);
}
DirectoryPathId CopyableFilePathCaching::directoryPathId(Utils::SmallStringView directoryPath) const
{
return m_cache.directoryPathId(directoryPath);
}
Utils::PathString CopyableFilePathCaching::directoryPath(DirectoryPathId directoryPathId) const
{
return m_cache.directoryPath(directoryPathId);
}
DirectoryPathId CopyableFilePathCaching::directoryPathId(FilePathId filePathId) const
{
return m_cache.directoryPathId(filePathId);
}
void CopyableFilePathCaching::addFilePaths(const FilePaths &filePaths)
{
m_cache.addFilePaths(filePaths);
}
void CopyableFilePathCaching::populateIfEmpty()
{
m_cache.populateIfEmpty();
}
} // namespace ClangBackEnd

View File

@@ -1,90 +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 "clangsupport_global.h"
#include "filepathcachinginterface.h"
#include "filepathcache.h"
#include "filepathstoragesqlitestatementfactory.h"
#include "filepathstorage.h"
#include <sqlitedatabase.h>
#include <sqlitereadstatement.h>
#include <sqlitewritestatement.h>
namespace ClangBackEnd {
class CLANGSUPPORT_EXPORT FilePathCaching final : public FilePathCachingInterface
{
friend class CopyableFilePathCaching;
using Factory = FilePathStorageSqliteStatementFactory<Sqlite::Database>;
using Storage = FilePathStorage<Factory>;
using Cache = FilePathCache<Storage>;
public:
FilePathCaching(Sqlite::Database &database)
: m_factory(database)
{}
FilePathId filePathId(FilePathView filePath) const override;
FilePath filePath(FilePathId filePathId) const override;
DirectoryPathId directoryPathId(Utils::SmallStringView directoryPath) const override;
Utils::PathString directoryPath(DirectoryPathId directoryPathId) const override;
DirectoryPathId directoryPathId(FilePathId filePathId) const override;
void addFilePaths(const ClangBackEnd::FilePaths &filePaths) override;
void populateIfEmpty() override;
private:
Factory m_factory;
Storage m_storage{m_factory};
Cache m_cache{m_storage};
};
class CLANGSUPPORT_EXPORT CopyableFilePathCaching final : public FilePathCachingInterface
{
using Factory = FilePathStorageSqliteStatementFactory<Sqlite::Database>;
using Storage = FilePathStorage<Factory>;
using Cache = FilePathCache<Storage, NonLockingMutex>;
public:
CopyableFilePathCaching(FilePathCaching &cache)
: m_cache(cache.m_cache.clone<Cache>())
{}
FilePathId filePathId(FilePathView filePath) const override;
FilePath filePath(FilePathId filePathId) const override;
DirectoryPathId directoryPathId(Utils::SmallStringView directoryPath) const override;
Utils::PathString directoryPath(DirectoryPathId directoryPathId) const override;
DirectoryPathId directoryPathId(FilePathId filePathId) const override;
void addFilePaths(const ClangBackEnd::FilePaths &filePaths) override;
void populateIfEmpty() override;
private:
Cache m_cache;
};
} // namespace ClangBackEnd

View File

@@ -1,32 +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
namespace ClangBackEnd {
class FilePathCachingInterface;
} // namespace ClangBackEnd

View File

@@ -1,89 +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 "directorypathid.h"
#include "filepath.h"
#include "filepathid.h"
#include "filepathview.h"
namespace ClangBackEnd {
class FilePathCachingInterface
{
public:
FilePathCachingInterface() = default;
FilePathCachingInterface(const FilePathCachingInterface &) = delete;
FilePathCachingInterface &operator=(const FilePathCachingInterface &) = delete;
virtual FilePathId filePathId(FilePathView filePath) const = 0;
virtual FilePath filePath(FilePathId filePathId) const = 0;
virtual DirectoryPathId directoryPathId(Utils::SmallStringView directoryPath) const = 0;
virtual DirectoryPathId directoryPathId(FilePathId filePathId) const = 0;
virtual Utils::PathString directoryPath(DirectoryPathId directoryPathId) const = 0;
virtual void addFilePaths(const ClangBackEnd::FilePaths &filePaths) = 0;
virtual void populateIfEmpty() = 0;
template<typename Container>
FilePathIds filePathIds(Container &&filePaths) const
{
FilePathIds filePathIds;
filePathIds.reserve(filePaths.size());
std::transform(filePaths.begin(),
filePaths.end(),
std::back_inserter(filePathIds),
[&] (const auto &filePath) { return this->filePathId(filePath); });
std::sort(filePathIds.begin(), filePathIds.end());
return filePathIds;
}
template <typename Element>
FilePathIds filePathIds(std::initializer_list<Element> filePaths) const
{
return filePathIds(std::vector<Element>(filePaths));
}
FilePaths filePaths(const FilePathIds &filePathIds) const
{
FilePaths filePaths;
filePaths.reserve(filePathIds.size());
std::transform(filePathIds.begin(),
filePathIds.end(),
std::back_inserter(filePaths),
[&] (auto filePathId) { return this->filePath(filePathId); });
return filePaths;
}
protected:
~FilePathCachingInterface() = default;
};
} // namespace ClangBackEnd

View File

@@ -1,68 +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 <exception>
namespace ClangBackEnd {
class NoFilePathForInvalidFilePathId : std::exception
{
public:
const char *what() const noexcept override
{
return "You cannot get a file path for an invalid file path id!";
}
};
class NoDirectoryPathForInvalidDirectoryPathId : std::exception
{
public:
const char *what() const noexcept override
{
return "You cannot get a directory path for an invalid directory path id!";
}
};
class SourceNameIdDoesNotExists : std::exception
{
public:
const char *what() const noexcept override
{
return "The source name id does not exist in the database!";
}
};
class DirectoryPathIdDoesNotExists : std::exception
{
public:
const char *what() const noexcept override
{
return "The directory path id does not exist in the database!";
}
};
} // namespace ClangBackEnd

View File

@@ -1,39 +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 "filepathid.h"
#include <QDebug>
namespace ClangBackEnd {
QDebug operator<<(QDebug debug, const FilePathId &filePathId)
{
debug.nospace() << "(" << filePathId.filePathId << ")";
return debug;
}
} // namespace ClangBackEnd

View File

@@ -1,103 +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 "clangsupport_global.h"
#include <QDataStream>
#include <cstdint>
#include <tuple>
#include <vector>
namespace ClangBackEnd {
class FilePathId
{
public:
constexpr FilePathId() = default;
FilePathId(const char *) = delete;
FilePathId(int filePathId)
: filePathId(filePathId)
{}
bool isValid() const
{
return filePathId >= 0;
}
friend bool operator==(FilePathId first, FilePathId second)
{
return first.isValid() && first.filePathId == second.filePathId;
}
friend bool operator!=(FilePathId first, FilePathId second)
{
return !(first==second);
}
friend bool operator<(FilePathId first, FilePathId second)
{
return first.filePathId < second.filePathId;
}
friend QDataStream &operator<<(QDataStream &out, const FilePathId &filePathId)
{
out << filePathId.filePathId;
return out;
}
friend QDataStream &operator>>(QDataStream &in, FilePathId &filePathId)
{
in >> filePathId.filePathId;
return in;
}
public:
int filePathId = -1;
};
using FilePathIds = std::vector<FilePathId>;
CLANGSUPPORT_EXPORT QDebug operator<<(QDebug debug, const FilePathId &filePathId);
} // namespace ClangBackEnd
namespace std {
template<> struct hash<ClangBackEnd::FilePathId>
{
using argument_type = ClangBackEnd::FilePathId;
using result_type = std::size_t;
result_type operator()(const argument_type& filePathId) const
{
return std::hash<int>{}(filePathId.filePathId);
}
};
} // namespace std

View File

@@ -1,246 +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 "filepathexceptions.h"
#include "filepathid.h"
#include "filepathstoragesources.h"
#include <sqliteexception.h>
#include <sqlitetransaction.h>
#include <utils/optional.h>
namespace ClangBackEnd {
template <typename StatementFactory>
class FilePathStorage
{
template<int ResultCount>
using ReadStatement = typename StatementFactory::template ReadStatement<ResultCount>;
using WriteStatement = typename StatementFactory::WriteStatement;
using Database = typename StatementFactory::Database;
public:
FilePathStorage(StatementFactory &statementFactory)
: m_statementFactory(statementFactory)
{}
int fetchDirectoryIdUnguarded(Utils::SmallStringView directoryPath)
{
Utils::optional<int> optionalDirectoryId = readDirectoryId(directoryPath);
if (optionalDirectoryId)
return optionalDirectoryId.value();
return writeDirectoryId(directoryPath);
}
int fetchDirectoryId(Utils::SmallStringView directoryPath)
{
try {
Sqlite::DeferredTransaction transaction{m_statementFactory.database};
Utils::optional<int> optionalDirectoryId = readDirectoryId(directoryPath);
int directoryId = -1;
if (optionalDirectoryId)
directoryId = optionalDirectoryId.value();
else
directoryId = writeDirectoryId(directoryPath);
transaction.commit();
return directoryId;
} catch (const Sqlite::StatementIsBusy &) {
return fetchDirectoryId(directoryPath);
} catch (const Sqlite::ConstraintPreventsModification &) {
return fetchDirectoryId(directoryPath);
}
}
Utils::optional<int> readDirectoryId(Utils::SmallStringView directoryPath)
{
auto &statement = m_statementFactory.selectDirectoryIdFromDirectoriesByDirectoryPath;
return statement.template optionalValue<int>(directoryPath);
}
int writeDirectoryId(Utils::SmallStringView directoryPath)
{
WriteStatement &statement = m_statementFactory.insertIntoDirectories;
statement.write(directoryPath);
return int(m_statementFactory.database.lastInsertedRowId());
}
Utils::PathString fetchDirectoryPath(int directoryPathId)
{
try {
Sqlite::DeferredTransaction transaction{m_statementFactory.database};
auto &statement = m_statementFactory.selectDirectoryPathFromDirectoriesByDirectoryId;
auto optionalDirectoryPath = statement.template optionalValue<Utils::PathString>(directoryPathId);
if (!optionalDirectoryPath)
throw DirectoryPathIdDoesNotExists();
transaction.commit();
return optionalDirectoryPath.value();
} catch (const Sqlite::StatementIsBusy &) {
return fetchDirectoryPath(directoryPathId);
}
}
std::vector<Sources::Directory> fetchAllDirectories()
{
try {
Sqlite::DeferredTransaction transaction{m_statementFactory.database};
auto &statement = m_statementFactory.selectAllDirectories;
auto directories = statement.template values<Sources::Directory>(256);
transaction.commit();
return directories;
} catch (const Sqlite::StatementIsBusy &) {
return fetchAllDirectories();
}
}
int fetchSourceIdUnguarded(int directoryId, Utils::SmallStringView sourceName)
{
Utils::optional<int> optionalSourceId = readSourceId(directoryId, sourceName);
if (optionalSourceId)
return optionalSourceId.value();
return writeSourceId(directoryId, sourceName);
}
int fetchSourceId(int directoryId, Utils::SmallStringView sourceName)
{
try {
Sqlite::DeferredTransaction transaction{m_statementFactory.database};
int sourceId = fetchSourceIdUnguarded(directoryId, sourceName);
transaction.commit();
return sourceId;
} catch (const Sqlite::StatementIsBusy &) {
return fetchSourceId(directoryId, sourceName);
} catch (const Sqlite::ConstraintPreventsModification &) {
return fetchSourceId(directoryId, sourceName);
}
}
int writeSourceId(int directoryId, Utils::SmallStringView sourceName)
{
auto &statement = m_statementFactory.insertIntoSources;
statement.write(directoryId, sourceName);
return int(m_statementFactory.database.lastInsertedRowId());
}
Utils::optional<int> readSourceId(int directoryId, Utils::SmallStringView sourceName)
{
auto &statement = m_statementFactory.selectSourceIdFromSourcesByDirectoryIdAndSourceName;
return statement.template optionalValue<int>(directoryId, sourceName);
}
Sources::SourceNameAndDirectoryId fetchSourceNameAndDirectoryId(int sourceId)
{
try {
Sqlite::DeferredTransaction transaction{m_statementFactory.database};
auto &statement = m_statementFactory.selectSourceNameAndDirectoryIdFromSourcesBySourceId;
auto optionalSourceName = statement.template optionalValue<Sources::SourceNameAndDirectoryId>(
sourceId);
if (!optionalSourceName)
throw SourceNameIdDoesNotExists();
transaction.commit();
return *optionalSourceName;
} catch (const Sqlite::StatementIsBusy &) {
return fetchSourceNameAndDirectoryId(sourceId);
}
}
int fetchDirectoryId(int sourceId)
{
try {
Sqlite::DeferredTransaction transaction{m_statementFactory.database};
auto &statement = m_statementFactory.selectDirectoryIdFromSourcesBySourceId;
auto optionalDirectoryId = statement.template optionalValue<int>(sourceId);
if (!optionalDirectoryId)
throw SourceNameIdDoesNotExists();
transaction.commit();
return *optionalDirectoryId;
} catch (const Sqlite::StatementIsBusy &) {
return fetchDirectoryId(sourceId);
}
}
std::vector<Sources::Source> fetchAllSources()
{
try {
Sqlite::DeferredTransaction transaction{m_statementFactory.database};
auto &statement = m_statementFactory.selectAllSources;
auto sources = statement.template values<Sources::Source>(8192);
transaction.commit();
return sources;
} catch (const Sqlite::StatementIsBusy &) {
return fetchAllSources();
}
}
Database &database() { return m_statementFactory.database; }
private:
StatementFactory &m_statementFactory;
};
} // namespace ClangBackEnd

View File

@@ -1,146 +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 "stringcacheentry.h"
#include <utils/smallstring.h>
#include <cstdint>
#include <vector>
#include <tuple>
#include <unordered_map>
namespace ClangBackEnd {
class FileNameView
{
public:
friend bool operator==(const FileNameView &first, const FileNameView &second)
{
return first.directoryId == second.directoryId && first.fileName == second.fileName;
}
static int compare(FileNameView first, FileNameView second) noexcept
{
int directoryDifference = first.directoryId - second.directoryId;
if (directoryDifference)
return directoryDifference;
return Utils::compare(first.fileName, second.fileName);
}
public:
Utils::SmallStringView fileName;
int directoryId;
};
class FileNameEntry
{
public:
FileNameEntry(Utils::SmallStringView fileName, int directoryId)
: fileName(fileName)
, directoryId(directoryId)
{}
FileNameEntry(FileNameView view)
: fileName(view.fileName)
, directoryId(view.directoryId)
{}
friend bool operator==(const FileNameEntry &first, const FileNameEntry &second)
{
return first.directoryId == second.directoryId && first.fileName == second.fileName;
}
friend bool operator!=(const FileNameEntry &first, const FileNameEntry &second)
{
return !(first == second);
}
friend bool operator==(const FileNameEntry &first, const FileNameView &second)
{
return first.directoryId == second.directoryId && first.fileName == second.fileName;
}
friend bool operator!=(const FileNameEntry &first, const FileNameView &second)
{
return !(first == second);
}
operator FileNameView() const { return {fileName, directoryId}; }
operator Utils::SmallString() && { return std::move(fileName); }
public:
Utils::SmallString fileName;
int directoryId;
};
namespace Sources {
class Directory : public StringCacheEntry<Utils::PathString, Utils::SmallStringView, int>
{
using Base = StringCacheEntry<Utils::PathString, Utils::SmallStringView, int>;
public:
using Base::Base;
friend bool operator==(const Directory &first, const Directory &second)
{
return first.id == second.id && first.string == second.string;
}
};
class Source : public StringCacheEntry<FileNameEntry, FileNameView, int>
{
using Base = StringCacheEntry<FileNameEntry, FileNameView, int>;
public:
using Base::Base;
Source(Utils::SmallStringView sourceName, int directoryId, int sourceId)
: Base{{sourceName, directoryId}, sourceId}
{}
friend bool operator==(const Source &first, const Source &second)
{
return first.id == second.id && first.string == second.string;
}
};
class SourceNameAndDirectoryId
{
public:
SourceNameAndDirectoryId(Utils::SmallStringView sourceName, int directoryId)
: sourceName(sourceName), directoryId(directoryId)
{}
Utils::SmallString sourceName;
int directoryId = -1;
};
} // namespace ClangBackEnd
} // namespace ClangBackEnd

View File

@@ -1,74 +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 <sqlitetransaction.h>
#include <sqlitetable.h>
namespace ClangBackEnd {
template<typename DatabaseType>
class FilePathStorageSqliteStatementFactory
{
public:
using Database = DatabaseType;
template<int ResultCount>
using ReadStatement = typename Database::template ReadStatement<ResultCount>;
using WriteStatement = typename Database::WriteStatement;
FilePathStorageSqliteStatementFactory(Database &database)
: database(database)
{
}
public:
Database &database;
ReadStatement<1> selectDirectoryIdFromDirectoriesByDirectoryPath{
"SELECT directoryId FROM directories WHERE directoryPath = ?", database};
ReadStatement<1> selectDirectoryPathFromDirectoriesByDirectoryId{
"SELECT directoryPath FROM directories WHERE directoryId = ?", database};
ReadStatement<2> selectAllDirectories{"SELECT directoryPath, directoryId FROM directories",
database};
WriteStatement insertIntoDirectories{
"INSERT INTO directories(directoryPath) VALUES (?)",
database
};
ReadStatement<1> selectSourceIdFromSourcesByDirectoryIdAndSourceName{
"SELECT sourceId FROM sources WHERE directoryId = ? AND sourceName = ?", database};
ReadStatement<2> selectSourceNameAndDirectoryIdFromSourcesBySourceId{
"SELECT sourceName, directoryId FROM sources WHERE sourceId = ?", database};
ReadStatement<1> selectDirectoryIdFromSourcesBySourceId{
"SELECT directoryId FROM sources WHERE sourceId = ?", database};
WriteStatement insertIntoSources{
"INSERT INTO sources(directoryId, sourceName) VALUES (?,?)",
database
};
ReadStatement<3> selectAllSources{"SELECT sourceName, directoryId, sourceId FROM sources",
database};
};
} // namespace ClangBackEnd

View File

@@ -1,112 +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 <utils/hostosinfo.h>
#include <utils/smallstringview.h>
#include <algorithm>
#include <vector>
namespace ClangBackEnd {
template <char WindowsSlash>
class AbstractFilePathView : public Utils::SmallStringView
{
public:
constexpr AbstractFilePathView() = default;
explicit AbstractFilePathView(const char *const string, const size_type size) noexcept
: AbstractFilePathView{Utils::SmallStringView{string, size}}
{
}
explicit AbstractFilePathView(Utils::SmallStringView filePath)
: Utils::SmallStringView(filePath)
, m_slashIndex(lastSlashIndex(filePath))
{
}
template <typename String,
typename = std::enable_if_t<std::is_lvalue_reference<String>::value>>
explicit AbstractFilePathView(String &&filePath)
: AbstractFilePathView(filePath.data(), filePath.size())
{
}
template<size_type Size>
AbstractFilePathView(const char(&string)[Size]) noexcept
: AbstractFilePathView(string, Size - 1)
{
static_assert(Size >= 1, "Invalid string literal! Length is zero!");
}
Utils::SmallStringView toStringView() const
{
return *this;
}
std::ptrdiff_t slashIndex() const
{
return m_slashIndex;
}
Utils::SmallStringView directory() const noexcept
{
return mid(0, std::size_t(std::max(std::ptrdiff_t(0), m_slashIndex)));
}
Utils::SmallStringView name() const noexcept
{
return mid(std::size_t(m_slashIndex + 1),
std::size_t(std::ptrdiff_t(size()) - m_slashIndex - std::ptrdiff_t(1)));
}
static
std::ptrdiff_t lastSlashIndex(Utils::SmallStringView filePath)
{
constexpr char separator = Utils::HostOsInfo::isWindowsHost() ? WindowsSlash : '/';
auto foundReverse = std::find(filePath.rbegin(), filePath.rend(), separator);
auto found = foundReverse.base();
auto distance = std::distance(filePath.begin(), found);
return distance - 1;
}
friend bool operator==(const AbstractFilePathView &first, const AbstractFilePathView &second)
{
return first.toStringView() == second.toStringView();
}
private:
std::ptrdiff_t m_slashIndex = -1;
};
using FilePathView = AbstractFilePathView<'/'>;
using NativeFilePathView = AbstractFilePathView<'\\'>;
using FilePathViews = std::vector<FilePathView>;
using NativeFilePathViews = std::vector<NativeFilePathView>;
}

View File

@@ -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>;
}

View File

@@ -1,136 +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 "filesystem.h"
#include <utils/algorithm.h>
#include <utils/set_algorithm.h>
#include <QDateTime>
#include <QFileInfo>
namespace ClangBackEnd {
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)
found->lastModified = m_fileSystem.lastModified(filePathId);
}
void FileStatusCache::update(FilePathIds filePathIds)
{
std::set_intersection(m_cacheEntries.begin(),
m_cacheEntries.end(),
filePathIds.begin(),
filePathIds.end(),
Utils::make_iterator([&](auto &entry) {
entry.lastModified = m_fileSystem.lastModified(entry.filePathId);
}));
}
FilePathIds FileStatusCache::modified(FilePathIds filePathIds) const
{
FilePathIds modifiedFilePathIds;
modifiedFilePathIds.reserve(filePathIds.size());
std::set_intersection(m_cacheEntries.begin(),
m_cacheEntries.end(),
filePathIds.begin(),
filePathIds.end(),
Utils::make_iterator([&](auto &entry) {
auto newLastModified = m_fileSystem.lastModified(entry.filePathId);
if (newLastModified > entry.lastModified) {
modifiedFilePathIds.push_back(entry.filePathId);
entry.lastModified = newLastModified;
}
}));
Internal::FileStatusCacheEntries newEntries;
newEntries.reserve(filePathIds.size());
std::set_difference(filePathIds.begin(),
filePathIds.end(),
m_cacheEntries.begin(),
m_cacheEntries.end(),
Utils::make_iterator([&](FilePathId newFilePathId) {
newEntries.emplace_back(newFilePathId,
m_fileSystem.lastModified(newFilePathId));
modifiedFilePathIds.push_back(newFilePathId);
}));
if (newEntries.size()) {
Internal::FileStatusCacheEntries mergedEntries;
mergedEntries.reserve(m_cacheEntries.size() + newEntries.size());
std::set_union(newEntries.begin(),
newEntries.end(),
m_cacheEntries.begin(),
m_cacheEntries.end(),
std::back_inserter(mergedEntries));
m_cacheEntries = std::move(mergedEntries);
}
std::sort(modifiedFilePathIds.begin(), modifiedFilePathIds.end());
return modifiedFilePathIds;
}
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;
auto inserted = m_cacheEntries.emplace(found, filePathId, m_fileSystem.lastModified(filePathId));
return *inserted;
}
} // namespace ClangBackEnd

View File

@@ -1,96 +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 {
class FileSystemInterface;
namespace Internal {
class FileStatusCacheEntry
{
public:
FileStatusCacheEntry(ClangBackEnd::FilePathId filePathId,
long long lastModified = 0)
: filePathId(filePathId),
lastModified(lastModified)
{}
friend bool operator<(FileStatusCacheEntry first, FileStatusCacheEntry second)
{
return first.filePathId < second.filePathId;
}
friend bool operator<(FileStatusCacheEntry first, FilePathId second)
{
return first.filePathId < second;
}
friend bool operator<(FilePathId first, FileStatusCacheEntry second)
{
return first < second.filePathId;
}
public:
FilePathId filePathId;
long long lastModified;
};
using FileStatusCacheEntries = std::vector<FileStatusCacheEntry>;
}
class CLANGSUPPORT_EXPORT FileStatusCache
{
public:
using size_type = Internal::FileStatusCacheEntries::size_type;
FileStatusCache(FileSystemInterface &fileSystem)
: m_fileSystem(fileSystem)
{}
FileStatusCache &operator=(const FileStatusCache &) = delete;
FileStatusCache(const FileStatusCache &) = delete;
long long lastModifiedTime(FilePathId filePathId) const;
void update(FilePathId filePathId);
void update(FilePathIds filePathIds);
FilePathIds modified(FilePathIds filePathIds) const;
size_type size() const;
private:
Internal::FileStatusCacheEntry findEntry(FilePathId filePathId) const;
private:
mutable Internal::FileStatusCacheEntries m_cacheEntries;
FileSystemInterface &m_fileSystem;
};
} // namespace ClangBackEnd

View File

@@ -1,70 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2019 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 "filesystem.h"
#include "filepathcachinginterface.h"
#include <utils/algorithm.h>
#include <QDateTime>
#include <QDir>
#include <QFileInfo>
namespace ClangBackEnd {
FilePathIds FileSystem::directoryEntries(const QString &directoryPath) const
{
QDir directory{directoryPath};
QFileInfoList fileInfos = directory.entryInfoList();
FilePathIds filePathIds = Utils::transform<FilePathIds>(fileInfos, [&](const QFileInfo &fileInfo) {
return m_filePathCache.filePathId(FilePath{fileInfo.path()});
});
std::sort(filePathIds.begin(), filePathIds.end());
return filePathIds;
}
long long FileSystem::lastModified(FilePathId filePathId) const
{
QFileInfo fileInfo(QString(m_filePathCache.filePath(filePathId)));
fileInfo.refresh();
if (fileInfo.exists())
return fileInfo.lastModified().toMSecsSinceEpoch() / 1000;
return 0;
}
void FileSystem::remove(const FilePathIds &filePathIds)
{
for (FilePathId filePathId : filePathIds)
QFile::remove(QString{m_filePathCache.filePath(filePathId)});
}
} // namespace ClangBackEnd

View File

@@ -1,50 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2019 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 "filestatuscache.h"
#include "filesysteminterface.h"
namespace ClangBackEnd {
class FilePathCachingInterface;
class CLANGSUPPORT_EXPORT FileSystem final : public FileSystemInterface
{
public:
FileSystem(FilePathCachingInterface &filePathCache)
: m_filePathCache(filePathCache)
{}
FilePathIds directoryEntries(const QString &directoryPath) const override;
long long lastModified(FilePathId filePathId) const override;
void remove(const FilePathIds &filePathIds) override;
private:
FilePathCachingInterface &m_filePathCache;
};
} // namespace ClangBackEnd

View File

@@ -1,44 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2019 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 <utils/smallstringview.h>
namespace ClangBackEnd {
class FileSystemInterface
{
public:
virtual FilePathIds directoryEntries(const QString &directoryPath) const = 0;
virtual long long lastModified(FilePathId filePathId) const = 0;
virtual void remove(const FilePathIds &filePathIds) = 0;
protected:
~FileSystemInterface() = default;
};
} // namespace ClangBackEnd

View File

@@ -1,128 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2018 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 "generatedfiles.h"
#include <utils/algorithm.h>
namespace ClangBackEnd {
void GeneratedFiles::update(V2::FileContainers &&fileContainers)
{
V2::FileContainers unionFileContainers;
unionFileContainers.reserve(m_fileContainers.size() + fileContainers.size());
auto compare = [](const V2::FileContainer &first, const V2::FileContainer &second) {
return first.filePath < second.filePath;
};
Utils::set_union(std::make_move_iterator(fileContainers.begin()),
std::make_move_iterator(fileContainers.end()),
std::make_move_iterator(m_fileContainers.begin()),
std::make_move_iterator(m_fileContainers.end()),
std::back_inserter(unionFileContainers),
compare);
m_fileContainers = std::move(unionFileContainers);
}
void GeneratedFiles::update(const V2::FileContainers &fileContainers)
{
V2::FileContainers unionFileContainers;
unionFileContainers.reserve(m_fileContainers.size() + fileContainers.size());
auto compare = [](const V2::FileContainer &first, const V2::FileContainer &second) {
return first.filePath < second.filePath;
};
Utils::set_union(fileContainers.begin(),
fileContainers.end(),
std::make_move_iterator(m_fileContainers.begin()),
std::make_move_iterator(m_fileContainers.end()),
std::back_inserter(unionFileContainers),
compare);
m_fileContainers = std::move(unionFileContainers);
}
class Compare {
public:
bool operator()(const FilePath &first, const FilePath &second) { return first < second; }
bool operator()(const V2::FileContainer &first, const V2::FileContainer &second)
{
return first.filePath < second.filePath;
}
bool operator()(const V2::FileContainer &first, const FilePath &second)
{
return first.filePath < second;
}
bool operator()(const FilePath &first, const V2::FileContainer &second)
{
return first < second.filePath;
}
};
void GeneratedFiles::remove(const FilePaths &filePaths)
{
V2::FileContainers differenceFileContainers;
differenceFileContainers.reserve(m_fileContainers.size());
std::set_difference(std::make_move_iterator(m_fileContainers.begin()),
std::make_move_iterator(m_fileContainers.end()),
filePaths.begin(),
filePaths.end(),
std::back_inserter(differenceFileContainers),
Compare{});
m_fileContainers = std::move(differenceFileContainers);
}
bool GeneratedFiles::isValid() const
{
return std::all_of(m_fileContainers.begin(),
m_fileContainers.end(),
[](const V2::FileContainer &container) {
return container.unsavedFileContent.hasContent();
});
}
const V2::FileContainers &GeneratedFiles::fileContainers() const
{
return m_fileContainers;
}
FilePathIds GeneratedFiles::filePathIds() const
{
auto ids = Utils::transform<FilePathIds>(m_fileContainers,
[](const V2::FileContainer &fileContainer) {
return fileContainer.filePathId;
});
std::sort(ids.begin(), ids.end());
return ids;
}
} // namespace ClangBackEnd

View File

@@ -1,47 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2018 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 "generatedfilesinterface.h"
namespace ClangBackEnd {
class CLANGSUPPORT_EXPORT GeneratedFiles final : public GeneratedFilesInterface
{
public:
void update(V2::FileContainers &&fileContainers);
void update(const V2::FileContainers &fileContainers);
void remove(const FilePaths &filePaths);
bool isValid() const;
const V2::FileContainers &fileContainers() const;
FilePathIds filePathIds() const;
private:
V2::FileContainers m_fileContainers;
};
} // namespace ClangBackEnd

View File

@@ -1,47 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2018 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 <filecontainerv2.h>
namespace ClangBackEnd {
class GeneratedFilesInterface
{
public:
virtual void update(V2::FileContainers &&fileContainers) = 0;
virtual void update(const V2::FileContainers &fileContainers) = 0;
virtual void remove(const FilePaths &filePaths) = 0;
virtual bool isValid() const = 0;
virtual const V2::FileContainers &fileContainers() const = 0;
virtual FilePathIds filePathIds() const = 0;
protected:
~GeneratedFilesInterface() = default;
};
} // namespace ClangBackEnd

View File

@@ -1,94 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2016 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 "projectpartid.h"
#include "sourceentry.h"
namespace ClangBackEnd {
class ProjectChunkId
{
public:
ProjectPartId id;
SourceType sourceType;
friend bool operator==(ProjectChunkId first, ProjectChunkId second)
{
return first.id == second.id && first.sourceType == second.sourceType;
}
friend bool operator==(ProjectChunkId first, ProjectPartId second)
{
return first.id == second;
}
friend bool operator==(ProjectPartId first, ProjectChunkId second)
{
return first == second.id;
}
friend bool operator!=(ProjectChunkId first, ProjectChunkId second)
{
return !(first == second);
}
friend bool operator<(ProjectChunkId first, ProjectChunkId second)
{
return std::tie(first.id, first.sourceType) < std::tie(second.id, second.sourceType);
}
friend bool operator<(ProjectChunkId first, ProjectPartId second) { return first.id < second; }
friend bool operator<(ProjectPartId first, ProjectChunkId second) { return first < second.id; }
};
class IdPaths
{
public:
IdPaths(ProjectPartId projectPartId, SourceType sourceType, FilePathIds &&filePathIds)
: id{projectPartId, sourceType}
, filePathIds(std::move(filePathIds))
{}
IdPaths(ProjectChunkId projectChunkId, FilePathIds &&filePathIds)
: id(projectChunkId)
, filePathIds(std::move(filePathIds))
{}
friend bool operator==(IdPaths first, IdPaths second)
{
return first.id == second.id && first.filePathIds == second.filePathIds;
}
public:
ProjectChunkId id;
FilePathIds filePathIds;
};
using ProjectChunkIds = std::vector<ProjectChunkId>;
} // namespace ClangBackEnd

View File

@@ -1,102 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2018 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 <utils/smallstringio.h>
#include <QDataStream>
#include <vector>
namespace ClangBackEnd {
enum class IncludeSearchPathType : unsigned char {
Invalid,
User,
BuiltIn,
System,
Framework,
};
class IncludeSearchPath
{
public:
IncludeSearchPath() = default;
IncludeSearchPath(Utils::PathString &&path, int index, IncludeSearchPathType type)
: path(std::move(path))
, index(index)
, type(type)
{}
IncludeSearchPath(Utils::PathString &&path, int index, int type)
: path(std::move(path))
, index(index)
, type(static_cast<IncludeSearchPathType>(type))
{}
friend QDataStream &operator<<(QDataStream &out, const IncludeSearchPath &includeSearchPath)
{
out << includeSearchPath.path;
out << includeSearchPath.index;
out << static_cast<unsigned char>(includeSearchPath.type);
return out;
}
friend QDataStream &operator>>(QDataStream &in, IncludeSearchPath &includeSearchPath)
{
unsigned char type;
in >> includeSearchPath.path;
in >> includeSearchPath.index;
in >> type;
includeSearchPath.type = static_cast<IncludeSearchPathType>(type);
return in;
}
friend bool operator==(const IncludeSearchPath &first, const IncludeSearchPath &second)
{
return std::tie(first.type, first.index, first.path)
== std::tie(second.type, second.index, second.path);
}
friend bool operator<(const IncludeSearchPath &first, const IncludeSearchPath &second)
{
return std::tie(first.path, first.index, first.type)
< std::tie(second.path, second.index, second.type);
}
public:
Utils::PathString path;
int index = -1;
IncludeSearchPathType type = IncludeSearchPathType::Invalid;
};
using IncludeSearchPaths = std::vector<IncludeSearchPath>;
} // namespace ClangBackEnd

View File

@@ -1,120 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2018 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 "filesysteminterface.h"
#include "modifiedtimecheckerinterface.h"
#include <utils/set_algorithm.h>
#include <algorithm>
#include <iterator>
namespace ClangBackEnd {
template<typename SourceEntries = ::ClangBackEnd::SourceEntries>
class ModifiedTimeChecker final : public ModifiedTimeCheckerInterface<SourceEntries>
{
using SourceEntry = typename SourceEntries::value_type;
public:
ModifiedTimeChecker(FileSystemInterface &fileSystem)
: m_fileSystem(fileSystem)
{}
bool isUpToDate(const SourceEntries &sourceEntries) const override
{
if (sourceEntries.empty())
return false;
updateCurrentSourceTimeStamps(sourceEntries);
return compareEntries(sourceEntries);
}
void pathsChanged(const FilePathIds &filePathIds) override
{
std::set_intersection(m_currentSourceTimeStamps.begin(),
m_currentSourceTimeStamps.end(),
filePathIds.begin(),
filePathIds.end(),
Utils::make_iterator([&](SourceTimeStamp &sourceTimeStamp) {
sourceTimeStamp.timeStamp = m_fileSystem.lastModified(
sourceTimeStamp.sourceId);
}));
}
private:
bool compareEntries(const SourceEntries &sourceEntries) const
{
return !Utils::set_intersection_compare(
m_currentSourceTimeStamps.begin(),
m_currentSourceTimeStamps.end(),
sourceEntries.begin(),
sourceEntries.end(),
[](auto first, auto second) { return first.timeStamp > second.timeStamp; },
[](auto first, auto second) { return first.sourceId < second.sourceId; });
}
void updateCurrentSourceTimeStamps(const SourceEntries &sourceEntries) const
{
SourceTimeStamps sourceTimeStamps = newSourceTimeStamps(sourceEntries);
auto split = sourceTimeStamps.insert(sourceTimeStamps.end(),
m_currentSourceTimeStamps.begin(),
m_currentSourceTimeStamps.end());
std::inplace_merge(sourceTimeStamps.begin(), split, sourceTimeStamps.end());
m_currentSourceTimeStamps = std::move(sourceTimeStamps);
}
SourceTimeStamps newSourceTimeStamps(const SourceEntries &sourceEntries) const
{
SourceTimeStamps newTimeStamps;
newTimeStamps.reserve(sourceEntries.size());
std::set_difference(sourceEntries.begin(),
sourceEntries.end(),
m_currentSourceTimeStamps.begin(),
m_currentSourceTimeStamps.end(),
Utils::make_iterator([&](const SourceEntry &sourceEntry) {
newTimeStamps.emplace_back(sourceEntry.sourceId,
m_fileSystem.lastModified(
sourceEntry.sourceId));
}),
[](auto first, auto second) {
return first.sourceId < second.sourceId;
});
return newTimeStamps;
}
private:
mutable SourceTimeStamps m_currentSourceTimeStamps;
FileSystemInterface &m_fileSystem;
};
} // namespace ClangBackEnd

View File

@@ -1,48 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2018 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 "sourceentry.h"
namespace ClangBackEnd {
template<typename SourceEntries = ::ClangBackEnd::SourceEntries>
class ModifiedTimeCheckerInterface
{
public:
ModifiedTimeCheckerInterface() = default;
ModifiedTimeCheckerInterface(const ModifiedTimeCheckerInterface &) = delete;
ModifiedTimeCheckerInterface &operator=(const ModifiedTimeCheckerInterface &) = delete;
virtual bool isUpToDate(const SourceEntries &sourceEntries) const = 0;
virtual void pathsChanged(const FilePathIds &filePathIds) = 0;
protected:
~ModifiedTimeCheckerInterface() = default;
};
} // namespace ClangBackEnd

View File

@@ -1,189 +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 "filepathview.h"
#include <utils/hostosinfo.h>
#include <utils/smallstringio.h>
namespace ClangBackEnd {
class FilePath;
class NativeFilePath
{
using size_type = Utils::PathString::size_type;
public:
NativeFilePath() = default;
explicit NativeFilePath(Utils::PathString &&filePath)
: m_path(std::move(filePath))
{
NativeFilePathView view{m_path};
m_slashIndex = view.slashIndex();
}
NativeFilePath(NativeFilePathView filePathView)
: m_path(filePathView.toStringView()),
m_slashIndex(filePathView.slashIndex())
{}
explicit NativeFilePath(FilePathView filePathView) { *this = fromFilePath(filePathView); }
explicit NativeFilePath(const FilePath &filePath)
: NativeFilePath{FilePathView{filePath}}
{}
template<size_type Size>
NativeFilePath(const char(&string)[Size]) noexcept
: NativeFilePath(NativeFilePathView(string, Size - 1))
{
static_assert(Size >= 1, "Invalid string literal! Length is zero!");
}
explicit NativeFilePath(const Utils::PathString &filePath)
: NativeFilePath(filePath.clone())
{
}
explicit NativeFilePath(Utils::PathString &&filePath, std::ptrdiff_t slashIndex)
: m_path(std::move(filePath)),
m_slashIndex(slashIndex)
{
}
explicit NativeFilePath(const QString &filePath)
: NativeFilePath(Utils::PathString(filePath))
{
}
NativeFilePath(Utils::SmallStringView directory, Utils::SmallStringView name)
: m_path(Utils::PathString::join(
{directory, Utils::HostOsInfo::isWindowsHost() ? "\\" : "/", name}))
, m_slashIndex(directory.size())
{}
Utils::SmallStringView directory() const noexcept
{
return m_path.mid(0, std::size_t(std::max(std::ptrdiff_t(0), m_slashIndex))); }
Utils::SmallStringView name() const noexcept
{
return m_path.mid(std::size_t(m_slashIndex + 1),
std::size_t(std::ptrdiff_t(m_path.size()) - m_slashIndex - std::ptrdiff_t(1)));
}
bool empty() const
{
return m_path.empty();
}
const Utils::PathString &path() const noexcept
{
return m_path;
}
operator const Utils::PathString&() const noexcept
{
return m_path;
}
operator NativeFilePathView() const noexcept
{
return NativeFilePathView(Utils::SmallStringView(m_path));
}
friend QDataStream &operator<<(QDataStream &out, const NativeFilePath &filePath)
{
out << filePath.m_path;
out << uint(filePath.m_slashIndex);
return out;
}
friend QDataStream &operator>>(QDataStream &in, NativeFilePath &filePath)
{
uint slashIndex;
in >> filePath.m_path;
in >> slashIndex;
filePath.m_slashIndex = slashIndex;
return in;
}
friend bool operator==(const NativeFilePath &first, const NativeFilePath &second)
{
return first.m_path == second.m_path;
}
friend bool operator==(const NativeFilePath &first, const NativeFilePathView &second)
{
return first.path() == second.toStringView();
}
friend bool operator==(const NativeFilePathView &first, const NativeFilePath &second)
{
return second == first;
}
friend bool operator<(const NativeFilePath &first, const NativeFilePath &second)
{
return first.m_path < second.m_path;
}
NativeFilePath clone() const
{
return *this;
}
std::ptrdiff_t slashIndex() const
{
return m_slashIndex;
}
template<typename String>
static NativeFilePath fromFilePath(String filePath)
{
Utils::PathString nativePath{filePath.data(), size_type(filePath.size())};
if (Utils::HostOsInfo::isWindowsHost())
nativePath.replace('/', '\\');
return NativeFilePath(std::move(nativePath));
}
private:
Utils::PathString m_path;
std::ptrdiff_t m_slashIndex = -1;
};
using NativeFilePaths = std::vector<NativeFilePath>;
} // namespace ClangBackEnd

View File

@@ -1,53 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2016 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 "pchmanagerclientinterface.h"
#include "messageenvelop.h"
#include <precompiledheadersupdatedmessage.h>
#include <progressmessage.h>
#include <QDebug>
namespace ClangBackEnd {
void PchManagerClientInterface::dispatch(const MessageEnvelop &messageEnvelop)
{
switch (messageEnvelop.messageType()) {
case MessageType::AliveMessage:
alive();
break;
case MessageType::PrecompiledHeadersUpdatedMessage:
precompiledHeadersUpdated(messageEnvelop.message<PrecompiledHeadersUpdatedMessage>());
break;
case MessageType::ProgressMessage:
progress(messageEnvelop.message<ProgressMessage>());
break;
default:
qWarning() << "Unknown IpcClientMessage";
}
}
} // namespace ClangBackEnd

View File

@@ -1,45 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2016 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 "ipcclientinterface.h"
namespace ClangBackEnd {
class PrecompiledHeadersUpdatedMessage;
class ProgressMessage;
class CLANGSUPPORT_EXPORT PchManagerClientInterface : public IpcClientInterface
{
public:
void dispatch(const MessageEnvelop &messageEnvelop) override;
virtual void alive() = 0;
virtual void precompiledHeadersUpdated(PrecompiledHeadersUpdatedMessage &&message) = 0;
virtual void progress(ProgressMessage &&message) = 0;
};
} // namespace ClangBackEnd

View File

@@ -1,81 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2016 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 "pchmanagerclientproxy.h"
#include "alivemessage.h"
#include "messageenvelop.h"
#include "pchmanagerserverinterface.h"
#include "precompiledheadersupdatedmessage.h"
#include "progressmessage.h"
#include <QDebug>
#include <QLocalSocket>
namespace ClangBackEnd {
PchManagerClientProxy::PchManagerClientProxy(PchManagerServerInterface *server,
QLocalSocket *localSocket)
: writeMessageBlock(localSocket)
, readMessageBlock(localSocket)
, server(server)
{
QObject::connect(localSocket, &QIODevice::readyRead, [this]() {
PchManagerClientProxy::readMessages();
});
}
PchManagerClientProxy::PchManagerClientProxy(PchManagerServerInterface *server, QIODevice *ioDevice)
: writeMessageBlock(ioDevice)
, readMessageBlock(ioDevice)
, server(server)
{
QObject::connect(ioDevice, &QIODevice::readyRead, [this]() {
PchManagerClientProxy::readMessages();
});
}
void PchManagerClientProxy::readMessages()
{
for (const MessageEnvelop &message : readMessageBlock.readAll())
server->dispatch(message);
}
void PchManagerClientProxy::alive()
{
writeMessageBlock.write(AliveMessage());
}
void PchManagerClientProxy::precompiledHeadersUpdated(PrecompiledHeadersUpdatedMessage &&message)
{
writeMessageBlock.write(message);
}
void PchManagerClientProxy::progress(ProgressMessage &&message)
{
writeMessageBlock.write(message);
}
} // namespace ClangBackEnd

View File

@@ -1,57 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2016 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 "clangsupport_global.h"
#include "pchmanagerclientinterface.h"
#include "readmessageblock.h"
#include "writemessageblock.h"
namespace ClangBackEnd {
class PchManagerServerInterface;
class CLANGSUPPORT_EXPORT PchManagerClientProxy final : public PchManagerClientInterface
{
public:
explicit PchManagerClientProxy(PchManagerServerInterface *server, QLocalSocket *localSocket);
explicit PchManagerClientProxy(PchManagerServerInterface *server, QIODevice *ioDevice);
PchManagerClientProxy(const PchManagerClientProxy&) = delete;
const PchManagerClientProxy &operator=(const PchManagerClientProxy&) = delete;
void readMessages();
void alive() override;
void precompiledHeadersUpdated(PrecompiledHeadersUpdatedMessage &&message) override;
void progress(ProgressMessage &&message) override;
private:
ClangBackEnd::WriteMessageBlock writeMessageBlock;
ClangBackEnd::ReadMessageBlock readMessageBlock;
PchManagerServerInterface *server = nullptr;
};
} // namespace ClangBackEnd

View File

@@ -1,61 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2016 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 "pchmanagerserverinterface.h"
#include "messageenvelop.h"
#include "removegeneratedfilesmessage.h"
#include "removeprojectpartsmessage.h"
#include "updategeneratedfilesmessage.h"
#include "updateprojectpartsmessage.h"
#include <QDebug>
namespace ClangBackEnd {
void PchManagerServerInterface::dispatch(const MessageEnvelop &messageEnvelop)
{
switch (messageEnvelop.messageType()) {
case MessageType::EndMessage:
end();
break;
case MessageType::UpdateProjectPartsMessage:
updateProjectParts(messageEnvelop.message<UpdateProjectPartsMessage>());
break;
case MessageType::RemoveProjectPartsMessage:
removeProjectParts(messageEnvelop.message<RemoveProjectPartsMessage>());
break;
case MessageType::UpdateGeneratedFilesMessage:
updateGeneratedFiles(messageEnvelop.message<UpdateGeneratedFilesMessage>());
break;
case MessageType::RemoveGeneratedFilesMessage:
removeGeneratedFiles(messageEnvelop.message<RemoveGeneratedFilesMessage>());
break;
default:
qWarning() << "Unknown IpcClientMessage";
}
}
} // namespace ClangBackEnd

View File

@@ -1,44 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2016 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 "projectmanagementserverinterface.h"
#include <memory>
namespace ClangBackEnd {
class PchManagerClientInterface;
class CLANGSUPPORT_EXPORT PchManagerServerInterface : public ProjectManagementServerInterface
{
public:
void dispatch(const MessageEnvelop &messageEnvelop) override;
virtual void end() = 0;
};
} // namespace ClangBackEnd

View File

@@ -1,76 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2016 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 "pchmanagerserverproxy.h"
#include "endmessage.h"
#include "messageenvelop.h"
#include "pchmanagerclientinterface.h"
#include "removegeneratedfilesmessage.h"
#include "removeprojectpartsmessage.h"
#include "updategeneratedfilesmessage.h"
#include "updateprojectpartsmessage.h"
#include <QIODevice>
#include <QVector>
namespace ClangBackEnd {
PchManagerServerProxy::PchManagerServerProxy(PchManagerClientInterface *client,
QLocalSocket *localSocket)
: BaseServerProxy(client, localSocket)
{}
PchManagerServerProxy::PchManagerServerProxy(PchManagerClientInterface *client, QIODevice *ioDevice)
: BaseServerProxy(client, ioDevice)
{
}
void PchManagerServerProxy::end()
{
m_writeMessageBlock.write(EndMessage());
}
void PchManagerServerProxy::updateProjectParts(UpdateProjectPartsMessage &&message)
{
m_writeMessageBlock.write(message);
}
void PchManagerServerProxy::removeProjectParts(RemoveProjectPartsMessage &&message)
{
m_writeMessageBlock.write(message);
}
void PchManagerServerProxy::updateGeneratedFiles(UpdateGeneratedFilesMessage &&message)
{
m_writeMessageBlock.write(message);
}
void PchManagerServerProxy::removeGeneratedFiles(RemoveGeneratedFilesMessage &&message)
{
m_writeMessageBlock.write(message);
}
} // namespace ClangBackEnd

View File

@@ -1,60 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2016 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 "baseserverproxy.h"
#include "clangsupport_global.h"
#include "pchmanagerserverinterface.h"
#include "readmessageblock.h"
#include "writemessageblock.h"
#include <QtGlobal>
#include <memory>
QT_BEGIN_NAMESPACE
class QIODevice;
QT_END_NAMESPACE
namespace ClangBackEnd {
class PchManagerClientInterface;
class CLANGSUPPORT_EXPORT PchManagerServerProxy final : public BaseServerProxy,
public PchManagerServerInterface
{
public:
explicit PchManagerServerProxy(PchManagerClientInterface *client, QLocalSocket *localSocket);
explicit PchManagerServerProxy(PchManagerClientInterface *client, QIODevice *ioDevice);
void end() override;
void updateProjectParts(UpdateProjectPartsMessage &&message) override;
void removeProjectParts(RemoveProjectPartsMessage &&message) override;
void updateGeneratedFiles(UpdateGeneratedFilesMessage &&message) override;
void removeGeneratedFiles(RemoveGeneratedFilesMessage &&message) override;
};
} // namespace ClangBackEnd

View File

@@ -1,52 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2018 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 "filepath.h"
namespace ClangBackEnd {
class PchPaths
{
public:
PchPaths() = default;
PchPaths(Utils::SmallStringView projectPchPath, Utils::SmallStringView systemPchPath)
: projectPchPath(FilePathView{projectPchPath})
, systemPchPath(FilePathView{systemPchPath})
{}
friend bool operator==(const PchPaths &first, const PchPaths &second)
{
return first.projectPchPath == second.projectPchPath
&& first.systemPchPath == second.systemPchPath;
}
public:
FilePath projectPchPath;
FilePath systemPchPath;
};
} // namespace ClangBackEnd

View File

@@ -1,39 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2016 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 "precompiledheadersupdatedmessage.h"
#include <QDebug>
namespace ClangBackEnd {
CLANGSUPPORT_EXPORT QDebug operator<<(QDebug debug, const PrecompiledHeadersUpdatedMessage &)
{
debug.nospace() << "PrecompiledHeaderUpdatedMessage()";
return debug;
}
} // namespace ClangBackEnd

View File

@@ -1,81 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2016 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 "clangsupport_global.h"
#include "filepathid.h"
#include "projectpartid.h"
#include <utils/smallstringio.h>
namespace ClangBackEnd {
class PrecompiledHeadersUpdatedMessage
{
public:
PrecompiledHeadersUpdatedMessage() = default;
PrecompiledHeadersUpdatedMessage(ProjectPartId projectPartId)
{
projectPartIds.push_back(projectPartId);
}
PrecompiledHeadersUpdatedMessage(ProjectPartIds &&projectPartIds)
: projectPartIds(std::move(projectPartIds))
{}
ProjectPartIds takeProjectPartIds() const { return std::move(projectPartIds); }
friend QDataStream &operator<<(QDataStream &out, const PrecompiledHeadersUpdatedMessage &message)
{
out << message.projectPartIds;
return out;
}
friend QDataStream &operator>>(QDataStream &in, PrecompiledHeadersUpdatedMessage &message)
{
in >> message.projectPartIds;
return in;
}
friend bool operator==(const PrecompiledHeadersUpdatedMessage &first,
const PrecompiledHeadersUpdatedMessage &second)
{
return first.projectPartIds == second.projectPartIds;
}
PrecompiledHeadersUpdatedMessage clone() const { return *this; }
public:
ProjectPartIds projectPartIds;
};
CLANGSUPPORT_EXPORT QDebug operator<<(QDebug debug, const PrecompiledHeadersUpdatedMessage &message);
DECLARE_MESSAGE(PrecompiledHeadersUpdatedMessage)
} // namespace ClangBackEnd

View File

@@ -1,108 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2018 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 <functional>
#include <mutex>
namespace ClangBackEnd {
class ProgressCounter
{
public:
using SetProgressCallback = std::function<void(int, int)>;
using Lock = std::lock_guard<std::mutex>;
ProgressCounter(SetProgressCallback &&progressCallback)
: m_progressCallback(std::move(progressCallback))
{}
void addTotal(int total)
{
Lock lock(m_mutex);
if (total) {
m_total += total;
m_progressCallback(m_progress, m_total);
}
}
void removeTotal(int total)
{
Lock lock(m_mutex);
if (total) {
m_total -= total;
sendProgress();
}
}
void addProgress(int progress)
{
Lock lock(m_mutex);
if (progress) {
m_progress += progress;
sendProgress();
}
}
int total() const
{
Lock lock(m_mutex);
return m_total;
}
int progress() const
{
Lock lock(m_mutex);
return m_progress;
}
private:
void sendProgress()
{
m_progressCallback(m_progress, m_total);
if (m_progress >= m_total) {
m_progress = 0;
m_total = 0;
}
}
private:
mutable std::mutex m_mutex;
std::function<void(int, int)> m_progressCallback;
int m_progress = 0;
int m_total = 0;
};
}

View File

@@ -1,83 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2018 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 "clangsupport_global.h"
#include <QDataStream>
namespace ClangBackEnd {
class ProgressMessage
{
public:
ProgressMessage() = default;
ProgressMessage(ProgressType progressType, int progress, int total)
: progress(progress)
, total(total)
, progressType(progressType)
{}
friend QDataStream &operator<<(QDataStream &out, const ProgressMessage &message)
{
out << message.progress;
out << message.total;
out << static_cast<int>(message.progressType);
return out;
}
friend QDataStream &operator>>(QDataStream &in, ProgressMessage &message)
{
int progressTupe;
in >> message.progress;
in >> message.total;
in >> progressTupe;
message.progressType = static_cast<ProgressType>(progressTupe);
return in;
}
friend bool operator==(const ProgressMessage &first, const ProgressMessage &second)
{
return first.progress == second.progress
&& first.total == second.total;
}
ProgressMessage clone() const
{
return *this;
}
public:
int progress = 0;
int total = 0;
ProgressType progressType = ProgressType::Invalid;
};
DECLARE_MESSAGE(ProgressMessage)
} // namespace ClangBackEnd

View File

@@ -1,46 +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 "ipcserverinterface.h"
namespace ClangBackEnd {
class RemoveGeneratedFilesMessage;
class RemoveProjectPartsMessage;
class UpdateGeneratedFilesMessage;
class UpdateProjectPartsMessage;
class ProjectManagementServerInterface : public IpcServerInterface
{
public:
virtual void updateProjectParts(UpdateProjectPartsMessage &&message) = 0;
virtual void removeProjectParts(RemoveProjectPartsMessage &&message) = 0;
virtual void updateGeneratedFiles(UpdateGeneratedFilesMessage &&message) = 0;
virtual void removeGeneratedFiles(RemoveGeneratedFilesMessage &&message) = 0;
};
} // namespace ClangBackEnd

View File

@@ -1,128 +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 "projectpartartefact.h"
#include <utils/algorithm.h>
#include <QJsonArray>
#include <QJsonDocument>
#include <QJsonObject>
namespace ClangBackEnd {
Utils::SmallStringVector ProjectPartArtefact::toStringVector(Utils::SmallStringView jsonText)
{
if (jsonText.isEmpty())
return {};
QJsonDocument document = createJsonDocument(jsonText, "Compiler arguments parsing error");
return Utils::transform<Utils::SmallStringVector>(document.array(), [] (const QJsonValue &value) {
return Utils::SmallString{value.toString()};
});
}
CompilerMacros ProjectPartArtefact::createCompilerMacrosFromDocument(const QJsonDocument &document)
{
QJsonArray array = document.array();
CompilerMacros macros;
macros.reserve(array.size());
for (const QJsonValueRef entry : array) {
const QJsonArray entryArray = entry.toArray();
macros.emplace_back(
entryArray[0].toString(), entryArray[1].toString(), entryArray[2].toInt());
}
std::sort(macros.begin(), macros.end());
return macros;
}
IncludeSearchPaths ProjectPartArtefact::createIncludeSearchPathsFromDocument(const QJsonDocument &document)
{
QJsonArray array = document.array();
IncludeSearchPaths paths;
paths.reserve(array.size());
for (const QJsonValueRef entry : array) {
const QJsonArray entryArray = entry.toArray();
paths.emplace_back(entryArray[0].toString(), entryArray[1].toInt(), entryArray[2].toInt());
}
return paths;
}
CompilerMacros ProjectPartArtefact::toCompilerMacros(Utils::SmallStringView jsonText)
{
if (jsonText.isEmpty())
return {};
QJsonDocument document = createJsonDocument(jsonText, "Compiler macros parsing error");
return createCompilerMacrosFromDocument(document);
}
QJsonDocument ProjectPartArtefact::createJsonDocument(Utils::SmallStringView jsonText,
const char *whatError)
{
QJsonParseError error;
QJsonDocument document = QJsonDocument::fromJson(
QByteArray::fromRawData(jsonText.data(), int(jsonText.size())),
&error);
checkError(whatError, error);
return document;
}
IncludeSearchPaths ProjectPartArtefact::toIncludeSearchPaths(Utils::SmallStringView jsonText)
{
if (jsonText.isEmpty())
return {};
QJsonDocument document = createJsonDocument(jsonText, "Include search paths parsing error");
return createIncludeSearchPathsFromDocument(document);
}
void ProjectPartArtefact::checkError(const char *whatError, const QJsonParseError &error)
{
if (error.error != QJsonParseError::NoError) {
throw ProjectPartArtefactParseError(whatError,
error.errorString());
}
}
bool operator==(const ProjectPartArtefact &first, const ProjectPartArtefact &second)
{
return first.toolChainArguments == second.toolChainArguments
&& first.compilerMacros == second.compilerMacros
&& first.systemIncludeSearchPaths == second.systemIncludeSearchPaths
&& first.projectIncludeSearchPaths == second.projectIncludeSearchPaths;
}
} // namespace ClangBackEnd

View File

@@ -1,122 +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 "clangsupport_global.h"
#include "clangsupportexceptions.h"
#include "projectpartid.h"
#include <utils/cpplanguage_details.h>
#include <utils/smallstringvector.h>
#include <compilermacro.h>
#include <includesearchpath.h>
QT_FORWARD_DECLARE_CLASS(QJsonDocument)
QT_FORWARD_DECLARE_STRUCT(QJsonParseError)
namespace ClangBackEnd {
class CLANGSUPPORT_EXPORT ProjectPartArtefact
{
public:
ProjectPartArtefact() = default;
ProjectPartArtefact(ProjectPartId projectPartId,
Utils::SmallStringVector &&toolChainArguments,
CompilerMacros &&compilerMacros,
IncludeSearchPaths &&systemIncludeSearchPaths,
IncludeSearchPaths &&projectIncludeSearchPaths,
Utils::Language language,
Utils::LanguageVersion languageVersion,
Utils::LanguageExtension languageExtension)
: projectPartId(projectPartId)
, toolChainArguments(std::move(toolChainArguments))
, compilerMacros(std::move(compilerMacros))
, systemIncludeSearchPaths(std::move(systemIncludeSearchPaths))
, projectIncludeSearchPaths(std::move(projectIncludeSearchPaths))
, language(language)
, languageVersion(languageVersion)
, languageExtension(languageExtension)
{}
ProjectPartArtefact(Utils::SmallStringView compilerArgumentsText,
Utils::SmallStringView compilerMacrosText,
Utils::SmallStringView systemIncludeSearchPathsText,
Utils::SmallStringView projectIncludeSearchPathsText,
int projectPartId,
int language,
int languageVersion,
int languageExtension)
: projectPartId(projectPartId)
, toolChainArguments(toStringVector(compilerArgumentsText))
, compilerMacros(toCompilerMacros(compilerMacrosText))
, systemIncludeSearchPaths(toIncludeSearchPaths(systemIncludeSearchPathsText))
, projectIncludeSearchPaths(toIncludeSearchPaths(projectIncludeSearchPathsText))
, language(static_cast<Utils::Language>(language))
, languageVersion(static_cast<Utils::LanguageVersion>(languageVersion))
, languageExtension(static_cast<Utils::LanguageExtension>(languageExtension))
{}
ProjectPartArtefact(Utils::SmallStringView compilerArgumentsText,
Utils::SmallStringView compilerMacrosText,
Utils::SmallStringView systemIncludeSearchPathsText,
Utils::SmallStringView projectIncludeSearchPathsText,
int projectPartId,
Utils::Language language,
Utils::LanguageVersion languageVersion,
Utils::LanguageExtension languageExtension)
: projectPartId(projectPartId)
, toolChainArguments(toStringVector(compilerArgumentsText))
, compilerMacros(toCompilerMacros(compilerMacrosText))
, systemIncludeSearchPaths(toIncludeSearchPaths(systemIncludeSearchPathsText))
, projectIncludeSearchPaths(toIncludeSearchPaths(projectIncludeSearchPathsText))
, language(language)
, languageVersion(languageVersion)
, languageExtension(languageExtension)
{}
static Utils::SmallStringVector toStringVector(Utils::SmallStringView jsonText);
static CompilerMacros createCompilerMacrosFromDocument(const QJsonDocument &document);
static IncludeSearchPaths createIncludeSearchPathsFromDocument(const QJsonDocument &document);
static CompilerMacros toCompilerMacros(Utils::SmallStringView jsonText);
static QJsonDocument createJsonDocument(Utils::SmallStringView jsonText, const char *whatError);
static IncludeSearchPaths toIncludeSearchPaths(Utils::SmallStringView jsonText);
static void checkError(const char *whatError, const QJsonParseError &error);
friend bool operator==(const ProjectPartArtefact &first, const ProjectPartArtefact &second);
public:
ProjectPartId projectPartId;
Utils::SmallStringVector toolChainArguments;
CompilerMacros compilerMacros;
IncludeSearchPaths systemIncludeSearchPaths;
IncludeSearchPaths projectIncludeSearchPaths;
Utils::Language language = Utils::Language::None;
Utils::LanguageVersion languageVersion = Utils::LanguageVersion::None;
Utils::LanguageExtension languageExtension = Utils::LanguageExtension::None;
};
using ProjectPartArtefacts = std::vector<ProjectPartArtefact>;
} // namespace ClangBackEnd

View File

@@ -1,38 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2016 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 "projectpartcontainer.h"
namespace ClangBackEnd {
QDebug operator<<(QDebug debug, const ProjectPartContainer &container)
{
debug.nospace() << "ProjectPartContainer(" << container.projectPartId.projectPathId << ","
<< container.toolChainArguments << ", " << container.headerPathIds << ", "
<< container.sourcePathIds << ")";
return debug;
}
} // namespace ClangBackEnd

View File

@@ -1,184 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2016 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 "clangsupport_global.h"
#include "compilermacro.h"
#include "filepathid.h"
#include "includesearchpath.h"
#include "projectpartartefact.h"
#include "projectpartid.h"
#include "sourceentry.h"
#include <utils/cpplanguage_details.h>
#include <utils/smallstringio.h>
namespace ClangBackEnd {
class ProjectPartContainer : public ProjectPartArtefact
{
using uchar = unsigned char;
public:
ProjectPartContainer() = default;
ProjectPartContainer(ProjectPartId projectPartId,
Utils::SmallStringVector &&toolChainArguments,
CompilerMacros &&compilerMacros,
IncludeSearchPaths &&systemIncludeSearchPaths,
IncludeSearchPaths &&projectIncludeSearchPaths,
FilePathIds &&headerPathIds,
FilePathIds &&sourcePathIds,
Utils::Language language,
Utils::LanguageVersion languageVersion,
Utils::LanguageExtension languageExtension)
: ProjectPartArtefact(projectPartId,
std::move(toolChainArguments),
std::move(compilerMacros),
std::move(systemIncludeSearchPaths),
std::move(projectIncludeSearchPaths),
language,
languageVersion,
languageExtension)
, headerPathIds(std::move(headerPathIds))
, sourcePathIds(std::move(sourcePathIds))
{}
ProjectPartContainer(Utils::SmallStringView compilerArgumentsText,
Utils::SmallStringView compilerMacrosText,
Utils::SmallStringView systemIncludeSearchPathsText,
Utils::SmallStringView projectIncludeSearchPathsText,
int projectPartId,
int language,
int languageVersion,
int languageExtension)
: ProjectPartArtefact(compilerArgumentsText,
compilerMacrosText,
systemIncludeSearchPathsText,
projectIncludeSearchPathsText,
projectPartId,
language,
languageVersion,
languageExtension)
{}
friend QDataStream &operator<<(QDataStream &out, const ProjectPartContainer &container)
{
out << container.projectPartId;
out << container.toolChainArguments;
out << container.compilerMacros;
out << container.systemIncludeSearchPaths;
out << container.projectIncludeSearchPaths;
out << container.headerPathIds;
out << container.sourcePathIds;
out << uchar(container.language);
out << uchar(container.languageVersion);
out << uchar(container.languageExtension);
return out;
}
friend QDataStream &operator>>(QDataStream &in, ProjectPartContainer &container)
{
uchar language;
uchar languageVersion;
uchar languageExtension;
in >> container.projectPartId;
in >> container.toolChainArguments;
in >> container.compilerMacros;
in >> container.systemIncludeSearchPaths;
in >> container.projectIncludeSearchPaths;
in >> container.headerPathIds;
in >> container.sourcePathIds;
in >> language;
in >> languageVersion;
in >> languageExtension;
container.language = static_cast<Utils::Language>(language);
container.languageVersion = static_cast<Utils::LanguageVersion>(languageVersion);
container.languageExtension = static_cast<Utils::LanguageExtension>(languageExtension);
return in;
}
friend bool operator==(const ProjectPartContainer &first, const ProjectPartContainer &second)
{
return first.projectPartId == second.projectPartId
&& first.toolChainArguments == second.toolChainArguments
&& first.compilerMacros == second.compilerMacros
&& first.systemIncludeSearchPaths == second.systemIncludeSearchPaths
&& first.projectIncludeSearchPaths == second.projectIncludeSearchPaths
&& first.headerPathIds == second.headerPathIds
&& first.sourcePathIds == second.sourcePathIds && first.language == second.language
&& first.languageVersion == second.languageVersion
&& first.languageExtension == second.languageExtension;
}
friend bool operator<(const ProjectPartContainer &first, const ProjectPartContainer &second)
{
return std::tie(first.projectPartId,
first.toolChainArguments,
first.compilerMacros,
first.systemIncludeSearchPaths,
first.projectIncludeSearchPaths,
first.headerPathIds,
first.sourcePathIds,
first.language,
first.languageVersion,
first.languageExtension,
first.preCompiledHeaderWasGenerated)
< std::tie(second.projectPartId,
second.toolChainArguments,
second.compilerMacros,
second.systemIncludeSearchPaths,
second.projectIncludeSearchPaths,
second.headerPathIds,
second.sourcePathIds,
second.language,
second.languageVersion,
second.languageExtension,
second.preCompiledHeaderWasGenerated);
}
ProjectPartContainer clone() const
{
return *this;
}
public:
FilePathIds headerPathIds;
FilePathIds sourcePathIds;
bool updateIsDeferred = false;
bool preCompiledHeaderWasGenerated = true;
};
using ProjectPartContainerReference = std::reference_wrapper<ProjectPartContainer>;
using ProjectPartContainers = std::vector<ProjectPartContainer>;
using ProjectPartContainerReferences = std::vector<ProjectPartContainerReference>;
CLANGSUPPORT_EXPORT QDebug operator<<(QDebug debug, const ProjectPartContainer &container);
} // namespace ClangBackEnd

View File

@@ -1,97 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2018 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 <QDataStream>
#include <vector>
namespace ClangBackEnd {
class ProjectPartId
{
template<typename StringType,
typename StringViewType,
typename IndexType,
typename Mutex,
typename Compare,
Compare compare,
typename CacheEntry>
friend class StringCache;
public:
constexpr ProjectPartId() = default;
ProjectPartId(const char *) = delete;
ProjectPartId(int projectPathId)
: projectPathId(projectPathId)
{}
bool isValid() const { return projectPathId >= 0; }
friend bool operator==(ProjectPartId first, ProjectPartId second)
{
return first.isValid() && first.projectPathId == second.projectPathId;
}
friend bool operator==(ProjectPartId first, int second)
{
return first == ProjectPartId{second};
}
friend bool operator!=(ProjectPartId first, ProjectPartId second) { return !(first == second); }
friend bool operator<(ProjectPartId first, ProjectPartId second)
{
return first.projectPathId < second.projectPathId;
}
friend QDataStream &operator<<(QDataStream &out, ProjectPartId projectPathId)
{
out << projectPathId.projectPathId;
return out;
}
friend QDataStream &operator>>(QDataStream &in, ProjectPartId &projectPathId)
{
in >> projectPathId.projectPathId;
return in;
}
private:
operator int() const { return projectPathId; }
ProjectPartId operator++() { return ++projectPathId; }
public:
int projectPathId = -1;
};
using ProjectPartIds = std::vector<ProjectPartId>;
} // namespace ClangBackEnd

View File

@@ -1,37 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2016 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 "projectpartpch.h"
namespace ClangBackEnd {
QDebug operator<<(QDebug debug, const ProjectPartPch &projectPartPch)
{
debug.nospace() << "FileContainer(" << projectPartPch.projectPartId.projectPathId << ")";
return debug;
}
} // namespace ClangBackEnd

View File

@@ -1,94 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2016 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 "clangsupport_global.h"
#include <filepath.h>
#include <projectpartid.h>
namespace ClangBackEnd {
class ProjectPartPch
{
public:
ProjectPartPch() = default;
ProjectPartPch(ProjectPartId projectPartId, FilePath &&pchPath, long long lastModified)
: projectPartId(projectPartId)
, pchPath(std::move(pchPath))
, lastModified(lastModified)
{}
ProjectPartPch(int projectPartId, Utils::SmallStringView pchPath, long long lastModified)
: projectPartId(projectPartId)
, pchPath(FilePathView(pchPath))
, lastModified(lastModified)
{}
bool isValid() const
{
return projectPartId.isValid() && pchPath.isValid() && lastModified >= 0;
}
friend QDataStream &operator<<(QDataStream &out, const ProjectPartPch &container)
{
out << container.projectPartId;
out << container.pchPath;
out << container.lastModified;
return out;
}
friend QDataStream &operator>>(QDataStream &in, ProjectPartPch &container)
{
in >> container.projectPartId;
in >> container.pchPath;
in >> container.lastModified;
return in;
}
friend bool operator==(const ProjectPartPch &first,
const ProjectPartPch &second)
{
return first.projectPartId == second.projectPartId && first.pchPath == second.pchPath;
}
ProjectPartPch clone() const
{
return *this;
}
public:
ProjectPartId projectPartId;
FilePath pchPath;
long long lastModified = -1;
};
using ProjectPartPchs = std::vector<ProjectPartPch>;
CLANGSUPPORT_EXPORT QDebug operator<<(QDebug debug, const ProjectPartPch &projectPartPch);
} // namespace ClangBackEnd

View File

@@ -1,416 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2018 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 "clangsupportexceptions.h"
#include "projectpartsstorageinterface.h"
#include <sqliteexception.h>
#include <sqlitetransaction.h>
namespace ClangBackEnd {
template<typename Database = Sqlite::Database>
class ProjectPartsStorage final : public ProjectPartsStorageInterface
{
template<int ResultCount>
using ReadStatement = typename Database::template ReadStatement<ResultCount>;
using WriteStatement = typename Database::WriteStatement;
public:
ProjectPartsStorage(Database &database)
: transaction(database)
, database(database)
{
transaction.commit();
}
ProjectPartContainers fetchProjectParts() const override
{
try {
Sqlite::DeferredTransaction transaction{database};
auto values = fetchProjectPartsStatement.template values<ProjectPartContainer>(4096);
transaction.commit();
return values;
} catch (const Sqlite::StatementIsBusy &) {
return fetchProjectParts();
}
}
FilePathIds fetchHeaders(ProjectPartId projectPartId) const
{
return fetchProjectPartsHeadersByIdStatement
.template values<FilePathId>(1024, projectPartId.projectPathId);
}
FilePathIds fetchSources(ProjectPartId projectPartId) const
{
return fetchProjectPartsSourcesByIdStatement
.template values<FilePathId>(1024, projectPartId.projectPathId);
}
bool preCompiledHeaderWasGenerated(ProjectPartId projectPartId) const
{
auto value = fetchProjectPrecompiledHeaderBuildTimeStatement.template optionalValue<long long>(
projectPartId.projectPathId);
return value && *value > 0;
}
ProjectPartContainers fetchProjectParts(const ProjectPartIds &projectPartIds) const override
{
try {
ProjectPartContainers projectParts;
projectParts.reserve(projectPartIds.size());
Sqlite::DeferredTransaction transaction{database};
for (ProjectPartId projectPartId : projectPartIds) {
auto value = fetchProjectPartByIdStatement.template optionalValue<ProjectPartContainer>(
projectPartId.projectPathId);
if (value) {
value->headerPathIds = fetchHeaders(projectPartId);
value->sourcePathIds = fetchSources(projectPartId);
value->preCompiledHeaderWasGenerated = preCompiledHeaderWasGenerated(projectPartId);
projectParts.push_back(*std::move(value));
}
}
transaction.commit();
return projectParts;
} catch (const Sqlite::StatementIsBusy &) {
return fetchProjectParts(projectPartIds);
}
}
ProjectPartId fetchProjectPartIdUnguarded(Utils::SmallStringView projectPartName) const override
{
auto optionalProjectPartId = fetchProjectPartIdStatement.template optionalValue<ProjectPartId>(
projectPartName);
if (optionalProjectPartId) {
return *optionalProjectPartId;
} else {
insertProjectPartNameStatement.write(projectPartName);
return static_cast<int>(database.lastInsertedRowId());
}
return {};
}
ProjectPartId fetchProjectPartId(Utils::SmallStringView projectPartName) const override
{
try {
Sqlite::DeferredTransaction transaction{database};
ProjectPartId projectPartId = fetchProjectPartIdUnguarded(projectPartName);
transaction.commit();
return projectPartId;
} catch (const Sqlite::StatementIsBusy &) {
return fetchProjectPartId(projectPartName);
}
}
Utils::PathString fetchProjectPartName(ProjectPartId projectPartId) const override
{
try {
Sqlite::DeferredTransaction transaction{database};
auto optionalProjectPartName = fetchProjectPartNameStatement
.template optionalValue<Utils::PathString>(
projectPartId.projectPathId);
transaction.commit();
if (optionalProjectPartName)
return *std::move(optionalProjectPartName);
} catch (const Sqlite::StatementIsBusy &) {
return fetchProjectPartName(projectPartId);
}
throwProjectPartDoesNotExists(projectPartId);
}
void insertHeaders(ProjectPartId projectPartId, const FilePathIds &headerPathIds)
{
deleteProjectPartsHeadersByIdStatement.write(projectPartId.projectPathId);
for (FilePathId headerPathId : headerPathIds) {
insertProjectPartsHeadersStatement.write(projectPartId.projectPathId,
headerPathId.filePathId);
}
}
void insertSources(ProjectPartId projectPartId, const FilePathIds &sourcePathIds)
{
deleteProjectPartsSourcesByIdStatement.write(projectPartId.projectPathId);
for (FilePathId sourcePathId : sourcePathIds) {
insertProjectPartsSourcesStatement.write(projectPartId.projectPathId,
sourcePathId.filePathId);
}
}
void updateProjectPart(ProjectPartId projectPartId,
const Utils::SmallStringVector &toolChainArguments,
const CompilerMacros &compilerMacros,
const IncludeSearchPaths &systemIncludeSearchPaths,
const IncludeSearchPaths &projectIncludeSearchPaths,
Utils::Language language,
Utils::LanguageVersion languageVersion,
Utils::LanguageExtension languageExtension) override
{
Utils::SmallString toolChainArgumentsAsJson = toJson(toolChainArguments);
Utils::SmallString compilerMacrosAsJson = toJson(compilerMacros);
Utils::SmallString systemIncludeSearchPathsAsJason = toJson(systemIncludeSearchPaths);
Utils::SmallString projectIncludeSearchPathsAsJason = toJson(projectIncludeSearchPaths);
updateProjectPartStatement.write(projectPartId.projectPathId,
toolChainArgumentsAsJson,
compilerMacrosAsJson,
systemIncludeSearchPathsAsJason,
projectIncludeSearchPathsAsJason,
static_cast<int>(language),
static_cast<int>(languageVersion),
static_cast<int>(languageExtension));
}
void updateProjectPart(const ProjectPartContainer &projectPart)
{
Utils::SmallString toolChainArgumentsAsJson = toJson(projectPart.toolChainArguments);
Utils::SmallString compilerMacrosAsJson = toJson(projectPart.compilerMacros);
Utils::SmallString systemIncludeSearchPathsAsJason = toJson(
projectPart.systemIncludeSearchPaths);
Utils::SmallString projectIncludeSearchPathsAsJason = toJson(
projectPart.projectIncludeSearchPaths);
updateProjectPartStatement.write(projectPart.projectPartId.projectPathId,
toolChainArgumentsAsJson,
compilerMacrosAsJson,
systemIncludeSearchPathsAsJason,
projectIncludeSearchPathsAsJason,
static_cast<int>(projectPart.language),
static_cast<int>(projectPart.languageVersion),
static_cast<int>(projectPart.languageExtension));
insertHeaders(projectPart.projectPartId, projectPart.headerPathIds);
insertSources(projectPart.projectPartId, projectPart.sourcePathIds);
}
void updateProjectParts(const ProjectPartContainers &projectParts) override
{
try {
Sqlite::ImmediateTransaction transaction{database};
for (const ProjectPartContainer &projectPart : projectParts)
updateProjectPart(projectPart);
transaction.commit();
} catch (const Sqlite::StatementIsBusy &) {
updateProjectParts(projectParts);
}
}
Utils::optional<ProjectPartArtefact> fetchProjectPartArtefact(FilePathId sourceId) const override
{
try {
Sqlite::DeferredTransaction transaction{database};
auto &statement = getProjectPartArtefactsBySourceId;
auto value = statement.template optionalValue<ProjectPartArtefact>(sourceId.filePathId);
transaction.commit();
return value;
} catch (const Sqlite::StatementIsBusy &) {
return fetchProjectPartArtefact(sourceId);
}
}
Utils::optional<ProjectPartArtefact> fetchProjectPartArtefact(ProjectPartId projectPartId) const override
{
try {
Sqlite::DeferredTransaction transaction{database};
auto &statement = getProjectPartArtefactsByProjectPartId;
auto value = statement.template optionalValue<ProjectPartArtefact>(
projectPartId.projectPathId);
transaction.commit();
return value;
} catch (const Sqlite::StatementIsBusy &) {
return fetchProjectPartArtefact(projectPartId);
}
}
void resetIndexingTimeStamps(const ProjectPartContainers &projectsParts) override
{
try {
Sqlite::ImmediateTransaction transaction{database};
for (const ProjectPartContainer &projectPart : projectsParts) {
for (FilePathId sourcePathId : projectPart.sourcePathIds)
resetDependentIndexingTimeStampsStatement.write(sourcePathId.filePathId);
}
transaction.commit();
} catch (const Sqlite::StatementIsBusy &) {
resetIndexingTimeStamps(projectsParts);
}
}
Sqlite::TransactionInterface &transactionBackend() override { return database; }
static Utils::SmallString toJson(const Utils::SmallStringVector &strings)
{
QJsonDocument document;
QJsonArray array;
std::transform(strings.begin(),
strings.end(),
std::back_inserter(array),
[](const auto &string) { return QJsonValue(string.data()); });
document.setArray(array);
return document.toJson(QJsonDocument::Compact);
}
static Utils::SmallString toJson(const CompilerMacros &compilerMacros)
{
QJsonDocument document;
QJsonArray array;
for (const CompilerMacro &macro : compilerMacros)
array.push_back(QJsonArray{{QString(macro.key), QString(macro.value), macro.index}});
document.setArray(array);
return document.toJson(QJsonDocument::Compact);
}
static Utils::SmallString toJson(const IncludeSearchPaths &includeSearchPaths)
{
QJsonDocument document;
QJsonArray array;
for (const IncludeSearchPath &path : includeSearchPaths)
array.push_back(QJsonArray{{path.path.data(), path.index, int(path.type)}});
document.setArray(array);
return document.toJson(QJsonDocument::Compact);
}
[[noreturn]] void throwProjectPartDoesNotExists(ProjectPartId projectPartId) const
{
throw ProjectPartDoesNotExists("Try to fetch non existing project part id: ",
Utils::SmallString::number(projectPartId.projectPathId));
}
Internal::ProjectPartNameIds fetchAllProjectPartNamesAndIds() const override
{
try {
Sqlite::DeferredTransaction transaction{database};
auto &statement = fetchAllProjectPartNamesAndIdsStatement;
auto values = statement.template values<Internal::ProjectPartNameId>(256);
transaction.commit();
return values;
} catch (const Sqlite::StatementIsBusy &) {
return fetchAllProjectPartNamesAndIds();
}
}
public:
Sqlite::ImmediateNonThrowingDestructorTransaction transaction;
Database &database;
mutable ReadStatement<1> fetchProjectPartIdStatement{
"SELECT projectPartId FROM projectParts WHERE projectPartName = ?", database};
mutable WriteStatement insertProjectPartNameStatement{
"INSERT INTO projectParts(projectPartName) VALUES (?)", database};
mutable ReadStatement<1> fetchProjectPartNameStatement{
"SELECT projectPartName FROM projectParts WHERE projectPartId = ?", database};
mutable ReadStatement<8> fetchProjectPartsStatement{
"SELECT toolChainArguments, compilerMacros, systemIncludeSearchPaths, "
"projectIncludeSearchPaths, projectPartId, language, languageVersion, languageExtension "
"FROM projectParts",
database};
mutable ReadStatement<8> fetchProjectPartByIdStatement{
"SELECT toolChainArguments, compilerMacros, systemIncludeSearchPaths, "
"projectIncludeSearchPaths, projectPartId, language, languageVersion, languageExtension "
"FROM projectParts WHERE projectPartId = ?",
database};
WriteStatement updateProjectPartStatement{
"UPDATE projectParts SET toolChainArguments=?002, compilerMacros=?003, "
"systemIncludeSearchPaths=?004, projectIncludeSearchPaths=?005, language=?006, "
"languageVersion=?007, languageExtension=?008 WHERE projectPartId = ?001",
database};
mutable ReadStatement<8> getProjectPartArtefactsBySourceId{
"SELECT toolChainArguments, compilerMacros, systemIncludeSearchPaths, "
"projectIncludeSearchPaths, projectPartId, language, languageVersion, languageExtension "
"FROM projectParts WHERE projectPartId = (SELECT "
"projectPartId FROM projectPartsFiles WHERE sourceId = ?)",
database};
mutable ReadStatement<8> getProjectPartArtefactsByProjectPartId{
"SELECT toolChainArguments, compilerMacros, systemIncludeSearchPaths, "
"projectIncludeSearchPaths, projectPartId, language, languageVersion, languageExtension "
"FROM projectParts WHERE projectPartId = ?",
database};
WriteStatement deleteProjectPartsHeadersByIdStatement{
"DELETE FROM projectPartsHeaders WHERE projectPartId = ?", database};
WriteStatement deleteProjectPartsSourcesByIdStatement{
"DELETE FROM projectPartsSources WHERE projectPartId = ?", database};
WriteStatement insertProjectPartsHeadersStatement{
"INSERT INTO projectPartsHeaders(projectPartId, sourceId) VALUES (?,?)", database};
WriteStatement insertProjectPartsSourcesStatement{
"INSERT INTO projectPartsSources(projectPartId, sourceId) VALUES (?,?)", database};
mutable ReadStatement<1> fetchProjectPartsHeadersByIdStatement{
"SELECT sourceId FROM projectPartsHeaders WHERE projectPartId = ? ORDER BY sourceId",
database};
mutable ReadStatement<1> fetchProjectPartsSourcesByIdStatement{
"SELECT sourceId FROM projectPartsSources WHERE projectPartId = ? ORDER BY sourceId",
database};
mutable ReadStatement<1> fetchProjectPrecompiledHeaderBuildTimeStatement{
"SELECT projectPchBuildTime FROM precompiledHeaders WHERE projectPartId = ?", database};
WriteStatement resetDependentIndexingTimeStampsStatement{
"UPDATE fileStatuses SET indexingTimeStamp = NULL WHERE sourceId = ?", database};
mutable ReadStatement<2> fetchAllProjectPartNamesAndIdsStatement{
"SELECT projectPartName, projectPartId FROM projectParts", database};
};
} // namespace ClangBackEnd

View File

@@ -1,77 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2018 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 "projectpartcontainer.h"
#include "projectpartstoragestructs.h"
#include <sqlitetransaction.h>
#include <utils/optional.h>
#include <utils/smallstringview.h>
#include <QJsonArray>
#include <QJsonDocument>
#include <QJsonObject>
namespace ClangBackEnd {
class ProjectPartsStorageInterface
{
public:
ProjectPartsStorageInterface() = default;
ProjectPartsStorageInterface(const ProjectPartsStorageInterface &) = delete;
ProjectPartsStorageInterface &operator=(const ProjectPartsStorageInterface &) = delete;
virtual ProjectPartContainers fetchProjectParts() const = 0;
virtual ProjectPartContainers fetchProjectParts(const ProjectPartIds &projectPartIds) const = 0;
virtual ProjectPartId fetchProjectPartIdUnguarded(Utils::SmallStringView projectPartName) const = 0;
virtual ProjectPartId fetchProjectPartId(Utils::SmallStringView projectPartName) const = 0;
virtual Utils::PathString fetchProjectPartName(ProjectPartId projectPartId) const = 0;
virtual Internal::ProjectPartNameIds fetchAllProjectPartNamesAndIds() const = 0;
virtual void updateProjectPart(ProjectPartId projectPartId,
const Utils::SmallStringVector &commandLineArguments,
const CompilerMacros &compilerMacros,
const ClangBackEnd::IncludeSearchPaths &systemIncludeSearchPaths,
const ClangBackEnd::IncludeSearchPaths &projectIncludeSearchPaths,
Utils::Language language,
Utils::LanguageVersion languageVersion,
Utils::LanguageExtension languageExtension)
= 0;
virtual void updateProjectParts(const ProjectPartContainers &projectParts) = 0;
virtual Utils::optional<ProjectPartArtefact> fetchProjectPartArtefact(FilePathId sourceId) const = 0;
virtual Utils::optional<ProjectPartArtefact> fetchProjectPartArtefact(
ProjectPartId projectPartId) const = 0;
virtual void resetIndexingTimeStamps(const ProjectPartContainers &projectsParts) = 0;
virtual Sqlite::TransactionInterface &transactionBackend() = 0;
protected:
~ProjectPartsStorageInterface() = default;
};
} // namespace ClangBackEnd

View File

@@ -1,55 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2019 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 "projectpartid.h"
#include "stringcacheentry.h"
#include <utils/smallstring.h>
#include <vector>
namespace ClangBackEnd {
namespace Internal {
class ProjectPartNameId
: public StringCacheEntry<Utils::PathString, Utils::SmallStringView, ProjectPartId>
{
using Base = StringCacheEntry<Utils::PathString, Utils::SmallStringView, ProjectPartId>;
public:
using Base::Base;
ProjectPartNameId(Utils::SmallStringView projectPartName, int projectPartId)
: Base(projectPartName, projectPartId)
{}
};
using ProjectPartNameIds = std::vector<ProjectPartNameId>;
} // namespace Internal
} // namespace ClangBackEnd

View File

@@ -1,55 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2016 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 "refactoringclientinterface.h"
#include "messageenvelop.h"
#include "clangrefactoringclientmessages.h"
#include <QDebug>
namespace ClangBackEnd {
void RefactoringClientInterface::dispatch(const MessageEnvelop &messageEnvelop)
{
switch (messageEnvelop.messageType()) {
case MessageType::AliveMessage:
alive();
break;
case MessageType::SourceRangesAndDiagnosticsForQueryMessage:
sourceRangesAndDiagnosticsForQueryMessage(messageEnvelop.message<SourceRangesAndDiagnosticsForQueryMessage>());
break;
case MessageType::SourceRangesForQueryMessage:
sourceRangesForQueryMessage(messageEnvelop.message<SourceRangesForQueryMessage>());
break;
case MessageType::ProgressMessage:
progress(messageEnvelop.message<ProgressMessage>());
break;
default:
qWarning() << "Unknown IpcClientMessage";
}
}
} // namespace ClangBackEnd

View File

@@ -1,55 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2016 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 "ipcclientinterface.h"
#include <functional>
namespace ClangBackEnd {
class ProgressMessage;
class SourceLocationsForRenamingMessage;
class SourceRangesAndDiagnosticsForQueryMessage;
class SourceRangesForQueryMessage;
class SourceLocationsContainer;
class CLANGSUPPORT_EXPORT RefactoringClientInterface : public IpcClientInterface
{
public:
using RenameCallback = std::function<void(const QString &,
const SourceLocationsContainer &,
int)>;
void dispatch(const MessageEnvelop &messageEnvelop) override;
virtual void alive() = 0;
virtual void sourceRangesAndDiagnosticsForQueryMessage(SourceRangesAndDiagnosticsForQueryMessage &&message) = 0;
virtual void sourceRangesForQueryMessage(SourceRangesForQueryMessage &&message) = 0;
virtual void progress(ProgressMessage &&message) = 0;
};
} // namespace ClangBackEnd

View File

@@ -1,84 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2016 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 "refactoringclientproxy.h"
#include "alivemessage.h"
#include "messageenvelop.h"
#include "refactoringserverinterface.h"
#include "clangrefactoringclientmessages.h"
#include <QDebug>
#include <QLocalSocket>
namespace ClangBackEnd {
RefactoringClientProxy::RefactoringClientProxy(RefactoringServerInterface *server,
QLocalSocket *localSocket)
: writeMessageBlock(localSocket)
, readMessageBlock(localSocket)
, server(server)
{
QObject::connect(localSocket, &QIODevice::readyRead, [this]() {
RefactoringClientProxy::readMessages();
});
}
RefactoringClientProxy::RefactoringClientProxy(RefactoringServerInterface *server,
QIODevice *ioDevice)
: writeMessageBlock(ioDevice)
, readMessageBlock(ioDevice)
, server(server)
{
QObject::connect(ioDevice, &QIODevice::readyRead, [this] () {RefactoringClientProxy::readMessages();});
}
void RefactoringClientProxy::readMessages()
{
for (const MessageEnvelop &message : readMessageBlock.readAll())
server->dispatch(message);
}
void RefactoringClientProxy::alive()
{
writeMessageBlock.write(AliveMessage());
}
void RefactoringClientProxy::sourceRangesAndDiagnosticsForQueryMessage(SourceRangesAndDiagnosticsForQueryMessage &&message)
{
writeMessageBlock.write(message);
}
void RefactoringClientProxy::sourceRangesForQueryMessage(SourceRangesForQueryMessage &&message)
{
writeMessageBlock.write(message);
}
void RefactoringClientProxy::progress(ProgressMessage &&message)
{
writeMessageBlock.write(message);
}
} // namespace ClangBackEnd

View File

@@ -1,63 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2016 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 "clangsupport_global.h"
#include "refactoringclientinterface.h"
#include "readmessageblock.h"
#include "writemessageblock.h"
#include <memory>
namespace ClangBackEnd {
class RefactoringServerInterface;
class CLANGSUPPORT_EXPORT RefactoringClientProxy : public RefactoringClientInterface
{
public:
explicit RefactoringClientProxy(RefactoringServerInterface *server, QLocalSocket *localSocket);
explicit RefactoringClientProxy(RefactoringServerInterface *server, QIODevice *ioDevice);
RefactoringClientProxy(const RefactoringClientProxy&) = delete;
const RefactoringClientProxy &operator=(const RefactoringClientProxy&) = delete;
RefactoringClientProxy(RefactoringClientProxy &&other) = delete;
RefactoringClientProxy &operator=(RefactoringClientProxy &&other) = delete;
void readMessages();
void alive() override;
void sourceRangesAndDiagnosticsForQueryMessage(SourceRangesAndDiagnosticsForQueryMessage &&message) override;
void sourceRangesForQueryMessage(SourceRangesForQueryMessage &&message) override;
void progress(ProgressMessage &&message) override;
private:
ClangBackEnd::WriteMessageBlock writeMessageBlock;
ClangBackEnd::ReadMessageBlock readMessageBlock;
RefactoringServerInterface *server = nullptr;
};
} // namespace ClangBackEnd

View File

@@ -1,240 +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 <createtablesqlstatementbuilder.h>
#include <sqlitetransaction.h>
#include <sqlitetable.h>
namespace ClangBackEnd {
template<typename DatabaseType>
class RefactoringDatabaseInitializer
{
public:
RefactoringDatabaseInitializer(DatabaseType &database)
: database(database)
{
if (!database.isInitialized()) {
Sqlite::ExclusiveTransaction transaction{database};
createSymbolsTable();
createLocationsTable();
createSourcesTable();
createDirectoriesTable();
createProjectPartsTable();
createProjectPartsFilesTable();
createUsedMacrosTable();
createFileStatusesTable();
createSourceDependenciesTable();
createPrecompiledHeadersTable();
createProjectPartsHeadersTable();
createProjectPartsSourcesTable();
transaction.commit();
database.setIsInitialized(true);
}
}
void createSymbolsTable()
{
Sqlite::Table table;
table.setUseIfNotExists(true);
table.setName("symbols");
table.addColumn("symbolId", Sqlite::ColumnType::Integer, {Sqlite::PrimaryKey{}});
const Sqlite::Column &usrColumn = table.addColumn("usr", Sqlite::ColumnType::Text);
const Sqlite::Column &symbolNameColumn = table.addColumn("symbolName", Sqlite::ColumnType::Text);
const Sqlite::Column &symbolKindColumn = table.addColumn("symbolKind", Sqlite::ColumnType::Integer);
table.addColumn("signature", Sqlite::ColumnType::Text);
table.addIndex({usrColumn});
table.addIndex({symbolKindColumn, symbolNameColumn});
table.initialize(database);
}
void createLocationsTable()
{
Sqlite::Table table;
table.setUseIfNotExists(true);
table.setName("locations");
const Sqlite::Column &symbolIdColumn = table.addColumn("symbolId",
Sqlite::ColumnType::Integer);
const Sqlite::Column &lineColumn = table.addColumn("line", Sqlite::ColumnType::Integer);
const Sqlite::Column &columnColumn = table.addColumn("column", Sqlite::ColumnType::Integer);
const Sqlite::Column &sourceIdColumn = table.addColumn("sourceId", Sqlite::ColumnType::Integer);
const Sqlite::Column &locationKindColumn = table.addColumn("locationKind", Sqlite::ColumnType::Integer);
table.addUniqueIndex({sourceIdColumn, lineColumn, columnColumn});
table.addIndex({sourceIdColumn, locationKindColumn});
table.addIndex({symbolIdColumn});
table.initialize(database);
}
void createSourcesTable()
{
Sqlite::Table table;
table.setUseIfNotExists(true);
table.setName("sources");
table.addColumn("sourceId", Sqlite::ColumnType::Integer, {Sqlite::PrimaryKey{}});
const Sqlite::Column &directoryIdColumn = table.addColumn("directoryId", Sqlite::ColumnType::Integer);
const Sqlite::Column &sourceNameColumn = table.addColumn("sourceName", Sqlite::ColumnType::Text);
table.addUniqueIndex({directoryIdColumn, sourceNameColumn});
table.initialize(database);
}
void createDirectoriesTable()
{
Sqlite::Table table;
table.setUseIfNotExists(true);
table.setName("directories");
table.addColumn("directoryId", Sqlite::ColumnType::Integer, {Sqlite::PrimaryKey{}});
const Sqlite::Column &directoryPathColumn = table.addColumn("directoryPath", Sqlite::ColumnType::Text);
table.addUniqueIndex({directoryPathColumn});
table.initialize(database);
}
void createProjectPartsTable()
{
Sqlite::Table table;
table.setUseIfNotExists(true);
table.setName("projectParts");
table.addColumn("projectPartId", Sqlite::ColumnType::Integer, {Sqlite::PrimaryKey{}});
const Sqlite::Column &projectPartNameColumn = table.addColumn("projectPartName", Sqlite::ColumnType::Text);
table.addColumn("toolChainArguments", Sqlite::ColumnType::Text);
table.addColumn("compilerMacros", Sqlite::ColumnType::Text);
table.addColumn("systemIncludeSearchPaths", Sqlite::ColumnType::Text);
table.addColumn("projectIncludeSearchPaths", Sqlite::ColumnType::Text);
table.addColumn("language", Sqlite::ColumnType::Integer);
table.addColumn("languageVersion", Sqlite::ColumnType::Integer);
table.addColumn("languageExtension", Sqlite::ColumnType::Integer);
table.addUniqueIndex({projectPartNameColumn});
table.initialize(database);
}
void createProjectPartsFilesTable()
{
Sqlite::Table table;
table.setUseIfNotExists(true);
table.setName("projectPartsFiles");
const Sqlite::Column &projectPartIdColumn = table.addColumn("projectPartId", Sqlite::ColumnType::Integer);
const Sqlite::Column &sourceIdColumn = table.addColumn("sourceId", Sqlite::ColumnType::Integer);
const Sqlite::Column &sourceType = table.addColumn("sourceType", Sqlite::ColumnType::Integer);
table.addColumn("pchCreationTimeStamp", Sqlite::ColumnType::Integer);
table.addColumn("hasMissingIncludes", Sqlite::ColumnType::Integer);
table.addUniqueIndex({sourceIdColumn, projectPartIdColumn});
table.addIndex({projectPartIdColumn, sourceType});
table.initialize(database);
}
void createUsedMacrosTable()
{
Sqlite::Table table;
table.setUseIfNotExists(true);
table.setName("usedMacros");
table.addColumn("usedMacroId", Sqlite::ColumnType::Integer, {Sqlite::PrimaryKey{}});
const Sqlite::Column &sourceIdColumn = table.addColumn("sourceId", Sqlite::ColumnType::Integer);
const Sqlite::Column &macroNameColumn = table.addColumn("macroName", Sqlite::ColumnType::Text);
table.addIndex({sourceIdColumn, macroNameColumn});
table.addIndex({macroNameColumn});
table.initialize(database);
}
void createFileStatusesTable()
{
Sqlite::Table table;
table.setUseIfNotExists(true);
table.setName("fileStatuses");
table.addColumn("sourceId", Sqlite::ColumnType::Integer, {Sqlite::PrimaryKey{}});
table.addColumn("size", Sqlite::ColumnType::Integer);
table.addColumn("lastModified", Sqlite::ColumnType::Integer);
table.addColumn("indexingTimeStamp", Sqlite::ColumnType::Integer);
table.initialize(database);
}
void createSourceDependenciesTable()
{
Sqlite::Table table;
table.setUseIfNotExists(true);
table.setName("sourceDependencies");
const Sqlite::Column &sourceIdColumn = table.addColumn("sourceId", Sqlite::ColumnType::Integer);
const Sqlite::Column &dependencySourceIdColumn = table.addColumn("dependencySourceId", Sqlite::ColumnType::Integer);
table.addIndex({sourceIdColumn, dependencySourceIdColumn});
table.addIndex({dependencySourceIdColumn, sourceIdColumn});
table.initialize(database);
}
void createPrecompiledHeadersTable()
{
Sqlite::Table table;
table.setUseIfNotExists(true);
table.setName("precompiledHeaders");
table.addColumn("projectPartId", Sqlite::ColumnType::Integer, {Sqlite::PrimaryKey{}});
table.addColumn("projectPchPath", Sqlite::ColumnType::Text);
table.addColumn("projectPchBuildTime", Sqlite::ColumnType::Integer);
table.addColumn("systemPchPath", Sqlite::ColumnType::Text);
table.addColumn("systemPchBuildTime", Sqlite::ColumnType::Integer);
table.initialize(database);
}
void createProjectPartsHeadersTable()
{
Sqlite::Table table;
table.setUseIfNotExists(true);
table.setName("projectPartsHeaders");
const Sqlite::Column &projectPartIdColumn = table.addColumn("projectPartId",
Sqlite::ColumnType::Integer);
table.addColumn("sourceId", Sqlite::ColumnType::Integer);
table.addIndex({projectPartIdColumn});
table.initialize(database);
}
void createProjectPartsSourcesTable()
{
Sqlite::Table table;
table.setUseIfNotExists(true);
table.setName("projectPartsSources");
const Sqlite::Column &projectPartIdColumn = table.addColumn("projectPartId",
Sqlite::ColumnType::Integer);
table.addColumn("sourceId", Sqlite::ColumnType::Integer);
table.addIndex({projectPartIdColumn});
table.initialize(database);
}
public:
DatabaseType &database;
};
} // namespace ClangBackEnd

View File

@@ -1,67 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2016 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 "refactoringserverinterface.h"
#include "messageenvelop.h"
#include "clangrefactoringservermessages.h"
#include <QDebug>
namespace ClangBackEnd {
void RefactoringServerInterface::dispatch(const MessageEnvelop &messageEnvelop)
{
switch (messageEnvelop.messageType()) {
case MessageType::EndMessage:
end();
break;
case MessageType::RequestSourceRangesAndDiagnosticsForQueryMessage:
requestSourceRangesAndDiagnosticsForQueryMessage(messageEnvelop.message<RequestSourceRangesAndDiagnosticsForQueryMessage>());
break;
case MessageType::RequestSourceRangesForQueryMessage:
requestSourceRangesForQueryMessage(messageEnvelop.message<RequestSourceRangesForQueryMessage>());
break;
case MessageType::UpdateProjectPartsMessage:
updateProjectParts(messageEnvelop.message<UpdateProjectPartsMessage>());
break;
case MessageType::UpdateGeneratedFilesMessage:
updateGeneratedFiles(messageEnvelop.message<UpdateGeneratedFilesMessage>());
break;
case MessageType::RemoveProjectPartsMessage:
removeProjectParts(messageEnvelop.message<RemoveProjectPartsMessage>());
break;
case MessageType::RemoveGeneratedFilesMessage:
removeGeneratedFiles(messageEnvelop.message<RemoveGeneratedFilesMessage>());
break;
case MessageType::CancelMessage:
cancel();
break;
default:
qWarning() << "Unknown IpcClientMessage";
}
}
} // namespace ClangBackEnd

View File

@@ -1,65 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2016 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 "projectmanagementserverinterface.h"
#include <memory>
namespace ClangBackEnd {
class RefactoringClientInterface;
class RequestSourceRangesAndDiagnosticsForQueryMessage;
class RequestSourceRangesForQueryMessage;
class CancelMessage;
class UpdateProjectPartsMessage;
class RemoveProjectPartsMessage;
class CLANGSUPPORT_EXPORT RefactoringServerInterface : public ProjectManagementServerInterface
{
public:
void dispatch(const MessageEnvelop &messageEnvelop) override;
virtual void end() = 0;
virtual void requestSourceRangesAndDiagnosticsForQueryMessage(RequestSourceRangesAndDiagnosticsForQueryMessage &&message) = 0;
virtual void requestSourceRangesForQueryMessage(RequestSourceRangesForQueryMessage &&message) = 0;
virtual void cancel() = 0;
bool isAvailable() const
{
return isAvailable_;
}
void setAvailable(bool isAvailable)
{
isAvailable_ = isAvailable;
}
private:
bool isAvailable_ = false;
};
} // namespace ClangBackEnd

View File

@@ -1,88 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2016 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 "refactoringserverproxy.h"
#include "messageenvelop.h"
#include "refactoringclientinterface.h"
#include "clangrefactoringservermessages.h"
#include <QIODevice>
#include <QVector>
namespace ClangBackEnd {
RefactoringServerProxy::RefactoringServerProxy(RefactoringClientInterface *client,
QLocalSocket *localSocket)
: BaseServerProxy(client, localSocket)
{}
RefactoringServerProxy::RefactoringServerProxy(RefactoringClientInterface *client,
QIODevice *ioDevice)
: BaseServerProxy(client, ioDevice)
{
}
void RefactoringServerProxy::end()
{
m_writeMessageBlock.write(EndMessage());
}
void RefactoringServerProxy::requestSourceRangesAndDiagnosticsForQueryMessage(RequestSourceRangesAndDiagnosticsForQueryMessage &&message)
{
m_writeMessageBlock.write(message);
}
void RefactoringServerProxy::requestSourceRangesForQueryMessage(RequestSourceRangesForQueryMessage &&message)
{
m_writeMessageBlock.write(message);
}
void RefactoringServerProxy::updateProjectParts(UpdateProjectPartsMessage &&message)
{
m_writeMessageBlock.write(message);
}
void RefactoringServerProxy::removeProjectParts(RemoveProjectPartsMessage &&message)
{
m_writeMessageBlock.write(message);
}
void RefactoringServerProxy::updateGeneratedFiles(UpdateGeneratedFilesMessage &&message)
{
m_writeMessageBlock.write(message);
}
void RefactoringServerProxy::removeGeneratedFiles(RemoveGeneratedFilesMessage &&message)
{
m_writeMessageBlock.write(message);
}
void RefactoringServerProxy::cancel()
{
m_writeMessageBlock.write(CancelMessage());
}
} // namespace ClangBackEnd

View File

@@ -1,64 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2016 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 "baseserverproxy.h"
#include "clangsupport_global.h"
#include "refactoringserverinterface.h"
#include "readmessageblock.h"
#include "writemessageblock.h"
#include <QtGlobal>
#include <memory>
QT_BEGIN_NAMESPACE
class QIODevice;
QT_END_NAMESPACE
namespace ClangBackEnd {
class RefactoringClientInterface;
class CLANGSUPPORT_EXPORT RefactoringServerProxy final : public BaseServerProxy,
public RefactoringServerInterface
{
public:
explicit RefactoringServerProxy(RefactoringClientInterface *client,
QLocalSocket *localSocket = {});
explicit RefactoringServerProxy(RefactoringClientInterface *client, QIODevice *ioDevice);
void end() override;
void requestSourceRangesAndDiagnosticsForQueryMessage(RequestSourceRangesAndDiagnosticsForQueryMessage &&message) override;
void requestSourceRangesForQueryMessage(RequestSourceRangesForQueryMessage &&message) override;
void updateProjectParts(UpdateProjectPartsMessage &&message) override;
void removeProjectParts(RemoveProjectPartsMessage &&message) override;
void updateGeneratedFiles(UpdateGeneratedFilesMessage &&message) override;
void removeGeneratedFiles(RemoveGeneratedFilesMessage &&message) override;
void cancel() override;
};
} // namespace ClangBackEnd

View File

@@ -1,37 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2018 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 "removegeneratedfilesmessage.h"
namespace ClangBackEnd {
QDebug operator<<(QDebug debug, const RemoveGeneratedFilesMessage &message)
{
debug.nospace() << "RemoveGeneratedFilesMessage("
<< message.generatedFiles << ")";
return debug;
}
} // namespace ClangBackEnd

View File

@@ -1,79 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2018 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 <clangsupport_global.h>
#include "filepath.h"
namespace ClangBackEnd {
class RemoveGeneratedFilesMessage
{
public:
RemoveGeneratedFilesMessage() = default;
RemoveGeneratedFilesMessage(FilePaths &&generatedFiles)
: generatedFiles(std::move(generatedFiles))
{}
FilePaths takeGeneratedFiles()
{
return std::move(generatedFiles);
}
friend QDataStream &operator<<(QDataStream &out, const RemoveGeneratedFilesMessage &message)
{
out << message.generatedFiles;
return out;
}
friend QDataStream &operator>>(QDataStream &in, RemoveGeneratedFilesMessage &message)
{
in >> message.generatedFiles;
return in;
}
friend bool operator==(const RemoveGeneratedFilesMessage &first,
const RemoveGeneratedFilesMessage &second)
{
return first.generatedFiles == second.generatedFiles;
}
RemoveGeneratedFilesMessage clone() const
{
return *this;
}
public:
FilePaths generatedFiles;
};
CLANGSUPPORT_EXPORT QDebug operator<<(QDebug debug, const RemoveGeneratedFilesMessage &message);
DECLARE_MESSAGE(RemoveGeneratedFilesMessage)
} // namespace ClangBackEnd

View File

@@ -1,73 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2016 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 "projectpartcontainer.h"
namespace ClangBackEnd {
class RemoveProjectPartsMessage
{
public:
RemoveProjectPartsMessage() = default;
RemoveProjectPartsMessage(ProjectPartIds &&projectsPartIds)
: projectsPartIds(std::move(projectsPartIds))
{}
ProjectPartIds takeProjectsPartIds() { return std::move(projectsPartIds); }
friend QDataStream &operator<<(QDataStream &out, const RemoveProjectPartsMessage &message)
{
out << message.projectsPartIds;
return out;
}
friend QDataStream &operator>>(QDataStream &in, RemoveProjectPartsMessage &message)
{
in >> message.projectsPartIds;
return in;
}
friend bool operator==(const RemoveProjectPartsMessage &first,
const RemoveProjectPartsMessage &second)
{
return first.projectsPartIds == second.projectsPartIds;
}
RemoveProjectPartsMessage clone() const
{
return *this;
}
public:
ProjectPartIds projectsPartIds;
};
DECLARE_MESSAGE(RemoveProjectPartsMessage)
} // namespace ClangBackEnd

View File

@@ -1,39 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2016 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 "requestsourcerangesanddiagnosticsforquerymessage.h"
namespace ClangBackEnd {
QDebug operator<<(QDebug debug, const RequestSourceRangesAndDiagnosticsForQueryMessage &message)
{
debug.nospace() << "RequestSourceRangesAndDiagnosticsForQuery("
<< message.query << ", "
<< message.source << ")";
return debug;
}
} // namespace ClangBackEnd

View File

@@ -1,89 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2016 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 "filecontainerv2.h"
namespace ClangBackEnd {
class RequestSourceRangesAndDiagnosticsForQueryMessage
{
public:
RequestSourceRangesAndDiagnosticsForQueryMessage() = default;
RequestSourceRangesAndDiagnosticsForQueryMessage(Utils::SmallString &&query,
V2::FileContainer &&source)
: query(std::move(query)),
source(std::move(source))
{}
V2::FileContainer takeSource()
{
return std::move(source);
}
Utils::SmallString takeQuery()
{
return std::move(query);
}
friend QDataStream &operator<<(QDataStream &out, const RequestSourceRangesAndDiagnosticsForQueryMessage &message)
{
out << message.query;
out << message.source;
return out;
}
friend QDataStream &operator>>(QDataStream &in, RequestSourceRangesAndDiagnosticsForQueryMessage &message)
{
in >> message.query;
in >> message.source;
return in;
}
friend bool operator==(const RequestSourceRangesAndDiagnosticsForQueryMessage &first,
const RequestSourceRangesAndDiagnosticsForQueryMessage &second)
{
return first.query == second.query
&& first.source == second.source;
}
RequestSourceRangesAndDiagnosticsForQueryMessage clone() const
{
return *this;
}
public:
Utils::SmallString query;
V2::FileContainer source;
};
CLANGSUPPORT_EXPORT QDebug operator<<(QDebug debug, const RequestSourceRangesAndDiagnosticsForQueryMessage &message);
DECLARE_MESSAGE(RequestSourceRangesAndDiagnosticsForQueryMessage)
} // namespace ClangBackEnd

View File

@@ -1,39 +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 "requestsourcerangesforquerymessage.h"
namespace ClangBackEnd {
QDebug operator<<(QDebug debug, const RequestSourceRangesForQueryMessage &message)
{
debug.nospace() << "RequestSourceRangesForQueryMessage("
<< message.query << ")";
return debug;
}
} // namespace ClangBackEnd

View File

@@ -1,101 +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 "filecontainerv2.h"
namespace ClangBackEnd {
class RequestSourceRangesForQueryMessage
{
public:
RequestSourceRangesForQueryMessage() = default;
RequestSourceRangesForQueryMessage(Utils::SmallString &&query,
std::vector<V2::FileContainer> &&sources,
std::vector<V2::FileContainer> &&unsavedContent)
: query(std::move(query)),
sources(std::move(sources)),
unsavedContent(std::move(unsavedContent))
{}
std::vector<V2::FileContainer> takeSources()
{
return std::move(sources);
}
std::vector<V2::FileContainer> takeUnsavedContent()
{
return std::move(unsavedContent);
}
Utils::SmallString takeQuery()
{
return std::move(query);
}
friend QDataStream &operator<<(QDataStream &out, const RequestSourceRangesForQueryMessage &message)
{
out << message.query;
out << message.sources;
out << message.unsavedContent;
return out;
}
friend QDataStream &operator>>(QDataStream &in, RequestSourceRangesForQueryMessage &message)
{
in >> message.query;
in >> message.sources;
in >> message.unsavedContent;
return in;
}
friend bool operator==(const RequestSourceRangesForQueryMessage &first,
const RequestSourceRangesForQueryMessage &second)
{
return first.query == second.query
&& first.sources == second.sources
&& first.unsavedContent == second.unsavedContent;
}
RequestSourceRangesForQueryMessage clone() const
{
return *this;
}
public:
Utils::SmallString query;
std::vector<V2::FileContainer> sources;
std::vector<V2::FileContainer> unsavedContent;
};
CLANGSUPPORT_EXPORT QDebug operator<<(QDebug debug, const RequestSourceRangesForQueryMessage &message);
DECLARE_MESSAGE(RequestSourceRangesForQueryMessage)
} // namespace ClangBackEnd

View File

@@ -1,169 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2018 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 <vector>
namespace ClangBackEnd {
enum class SourceType : unsigned char {
TopProjectInclude,
TopSystemInclude,
UserInclude,
ProjectInclude,
SystemInclude,
Source
};
enum class HasMissingIncludes : unsigned char { No, Yes };
class TimeStamp
{
using int64 = long long;
public:
TimeStamp() = default;
TimeStamp(int64 value)
: value(value)
{}
operator int64() const
{
return value;
}
int64 value = -1;
};
class PrecompiledHeaderTimeStamps
{
public:
PrecompiledHeaderTimeStamps() = default;
PrecompiledHeaderTimeStamps(long long projectTimeStamp, long long systemTimeStamp)
: project(projectTimeStamp)
, system(systemTimeStamp)
{}
TimeStamp project;
TimeStamp system;
};
class SourceTimeStamp
{
using int64 = long long;
public:
SourceTimeStamp(int sourceId, int64 lastModified)
: timeStamp(lastModified)
, sourceId(sourceId)
{}
SourceTimeStamp(FilePathId sourceId, TimeStamp lastModified)
: timeStamp(lastModified)
, sourceId(sourceId)
{}
friend bool operator<(SourceTimeStamp first, SourceTimeStamp second)
{
return first.sourceId < second.sourceId;
}
friend bool operator<(SourceTimeStamp first, FilePathId second)
{
return first.sourceId < second;
}
friend bool operator<(FilePathId first, SourceTimeStamp second)
{
return first < second.sourceId;
}
friend bool operator==(SourceTimeStamp first, SourceTimeStamp second)
{
return first.sourceId == second.sourceId && first.timeStamp == second.timeStamp;
}
friend bool operator!=(SourceTimeStamp first, SourceTimeStamp second)
{
return !(first == second);
}
public:
TimeStamp timeStamp;
FilePathId sourceId;
};
using SourceTimeStamps = std::vector<SourceTimeStamp>;
class SourceEntry
{
using int64 = long long;
public:
SourceEntry(int sourceId, int64 timeStamp, int sourceType, int hasMissingIncludes)
: timeStamp(timeStamp)
, sourceId(sourceId)
, sourceType(static_cast<SourceType>(sourceType))
, hasMissingIncludes(static_cast<HasMissingIncludes>(hasMissingIncludes))
{}
SourceEntry(FilePathId sourceId,
SourceType sourceType,
TimeStamp timeStamp,
HasMissingIncludes hasMissingIncludes = HasMissingIncludes::No)
: timeStamp(timeStamp)
, sourceId(sourceId)
, sourceType(sourceType)
, hasMissingIncludes(hasMissingIncludes)
{}
friend bool operator<(SourceEntry first, SourceEntry second) {
return first.sourceId < second.sourceId;
}
friend bool operator<(SourceEntry first, FilePathId second) { return first.sourceId < second; }
friend bool operator<(FilePathId first, SourceEntry second) { return first < second.sourceId; }
friend bool operator==(SourceEntry first, SourceEntry second)
{
return first.sourceId == second.sourceId && first.sourceType == second.sourceType
&& first.timeStamp == second.timeStamp;
}
friend bool operator!=(SourceEntry first, SourceEntry second) { return !(first == second); }
public:
TimeStamp timeStamp;
FilePathId sourceId;
SourceType sourceType = SourceType::UserInclude;
HasMissingIncludes hasMissingIncludes = HasMissingIncludes::No;
};
using SourceEntries = std::vector<SourceEntry>;
using SourceEntryReference = std::reference_wrapper<SourceEntry>;
using SourceEntryReferences = std::vector<SourceEntryReference>;
} // namespace ClangBackEnd

View File

@@ -1,45 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2016 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 "sourcelocationcontainerv2.h"
#include <QDebug>
namespace ClangBackEnd {
namespace V2 {
QDebug operator<<(QDebug debug, const SourceLocationContainer &container)
{
debug.nospace() << "SourceLocationContainer("
<< container.line << ", "
<< container.column << ", "
<< container.offset << ", "
<< container.filePathId.filePathId
<< ")";
return debug;
}
} // namespace V2
} // namespace ClangBackEnd

View File

@@ -1,106 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2016 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 "clangsupport_global.h"
#include "filepathid.h"
#include <QDataStream>
namespace ClangBackEnd {
namespace V2 {
class SourceLocationContainer
{
public:
SourceLocationContainer() = default;
SourceLocationContainer(FilePathId filePathId,
uint line,
uint column,
uint offset)
: filePathId(filePathId),
line(line),
column(column),
offset(offset)
{
}
friend QDataStream &operator<<(QDataStream &out, const SourceLocationContainer &container)
{
out << container.filePathId;
out << container.line;
out << container.column;
out << container.offset;
return out;
}
friend QDataStream &operator>>(QDataStream &in, SourceLocationContainer &container)
{
in >> container.filePathId;
in >> container.line;
in >> container.column;
in >> container.offset;
return in;
}
friend bool operator==(const SourceLocationContainer &first, const SourceLocationContainer &second)
{
return !(first != second);
}
friend bool operator!=(const SourceLocationContainer &first, const SourceLocationContainer &second)
{
return first.line != second.line
|| first.column != second.column
|| first.filePathId != second.filePathId;
}
friend bool operator<(const SourceLocationContainer &first,
const SourceLocationContainer &second)
{
return std::tie(first.filePathId, first.line, first.column)
< std::tie(second.filePathId, second.line, second.column);
}
SourceLocationContainer clone() const
{
return *this;
}
public:
FilePathId filePathId;
uint line = 1;
uint column = 1;
uint offset = 0;
};
CLANGSUPPORT_EXPORT QDebug operator<<(QDebug debug, const SourceLocationContainer &container);
} // namespace V2
} // namespace ClangBackEnd

Some files were not shown because too many files have changed in this diff Show More