forked from qt-creator/qt-creator
ClangRefactoring: Remove unused code
Change-Id: I752d688039e8bb85654fd54b61a0c8a4e6677954 Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
This commit is contained in:
@@ -22,7 +22,6 @@ HEADERS += \
|
||||
$$PWD/projectpartartefact.h \
|
||||
$$PWD/filestatuscache.h \
|
||||
$$PWD/indexdataconsumer.h \
|
||||
$$PWD/projectpartqueue.h \
|
||||
$$PWD/sourcesmanager.h \
|
||||
$$PWD/symbolindexertaskqueue.h \
|
||||
$$PWD/symbolindexertaskscheduler.h \
|
||||
@@ -76,7 +75,6 @@ SOURCES += \
|
||||
$$PWD/symbolindexer.cpp \
|
||||
$$PWD/projectpartartefact.cpp \
|
||||
$$PWD/filestatuscache.cpp \
|
||||
$$PWD/projectpartqueue.cpp \
|
||||
$$PWD/symbolindexertaskqueue.cpp \
|
||||
$$PWD/symbolindexertaskscheduler.cpp \
|
||||
$$PWD/symbolscollectormanager.cpp
|
||||
|
||||
@@ -1,107 +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 <utils/algorithm.h>
|
||||
|
||||
#include "projectpartqueue.h"
|
||||
|
||||
namespace ClangBackEnd {
|
||||
|
||||
ProjectPartQueue::ProjectPartQueue()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void ProjectPartQueue::addProjectParts(V2::ProjectPartContainers &&projectParts)
|
||||
{
|
||||
auto compare = [](const V2::ProjectPartContainer &first, const V2::ProjectPartContainer &second) {
|
||||
return first.projectPartId < second.projectPartId;
|
||||
};
|
||||
|
||||
auto merge = [](V2::ProjectPartContainer &&first,
|
||||
V2::ProjectPartContainer &&second) {
|
||||
first.arguments = std::move(second.arguments);
|
||||
first.compilerMacros = std::move(second.compilerMacros);
|
||||
first.includeSearchPaths = std::move(second.includeSearchPaths);
|
||||
FilePathIds headerPathIds;
|
||||
headerPathIds.reserve(first.headerPathIds.size() + second.headerPathIds.size());
|
||||
std::set_union(first.headerPathIds.begin(),
|
||||
first.headerPathIds.end(),
|
||||
second.headerPathIds.begin(),
|
||||
second.headerPathIds.end(),
|
||||
std::back_inserter(headerPathIds));
|
||||
first.headerPathIds = std::move(headerPathIds);
|
||||
FilePathIds sourcePathIds;
|
||||
headerPathIds.reserve(first.sourcePathIds.size() + second.sourcePathIds.size());
|
||||
std::set_union(first.sourcePathIds.begin(),
|
||||
first.sourcePathIds.end(),
|
||||
second.sourcePathIds.begin(),
|
||||
second.sourcePathIds.end(),
|
||||
std::back_inserter(sourcePathIds));
|
||||
first.sourcePathIds = std::move(sourcePathIds);
|
||||
|
||||
return first;
|
||||
};
|
||||
|
||||
m_projectParts = Utils::setUnionMerge<V2::ProjectPartContainers>(m_projectParts,
|
||||
projectParts,
|
||||
merge,
|
||||
compare);
|
||||
}
|
||||
|
||||
class CompareDifference
|
||||
{
|
||||
public:
|
||||
bool operator()(const V2::ProjectPartContainer &first, const Utils::SmallString &second)
|
||||
{
|
||||
return first.projectPartId < second;
|
||||
}
|
||||
|
||||
bool operator()(const Utils::SmallString &first, const V2::ProjectPartContainer &second)
|
||||
{
|
||||
return first < second.projectPartId;
|
||||
}
|
||||
};
|
||||
|
||||
void ProjectPartQueue::removeProjectParts(const Utils::SmallStringVector &projectsPartIds)
|
||||
{
|
||||
V2::ProjectPartContainers notToBeRemovedProjectParts;
|
||||
notToBeRemovedProjectParts.reserve(m_projectParts.size());
|
||||
std::set_difference(std::make_move_iterator(m_projectParts.begin()),
|
||||
std::make_move_iterator(m_projectParts.end()),
|
||||
projectsPartIds.begin(),
|
||||
projectsPartIds.end(),
|
||||
std::back_inserter(notToBeRemovedProjectParts),
|
||||
CompareDifference{});
|
||||
|
||||
m_projectParts = std::move(notToBeRemovedProjectParts);
|
||||
}
|
||||
|
||||
const V2::ProjectPartContainers &ProjectPartQueue::projectParts() const
|
||||
{
|
||||
return m_projectParts;
|
||||
}
|
||||
|
||||
} // namespace ClangBackEnd
|
||||
@@ -1,46 +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 <projectpartcontainerv2.h>
|
||||
|
||||
namespace ClangBackEnd {
|
||||
|
||||
class ProjectPartQueue
|
||||
{
|
||||
public:
|
||||
ProjectPartQueue();
|
||||
|
||||
void addProjectParts(V2::ProjectPartContainers &&projectParts);
|
||||
void removeProjectParts(const Utils::SmallStringVector &projectsPartIds);
|
||||
|
||||
const V2::ProjectPartContainers &projectParts() const;
|
||||
|
||||
private:
|
||||
V2::ProjectPartContainers m_projectParts;
|
||||
};
|
||||
|
||||
} // namespace ClangBackEnd
|
||||
@@ -42,12 +42,10 @@ void SymbolIndexerTaskQueue::addOrUpdateTasks(std::vector<SymbolIndexerTask> &&t
|
||||
m_tasks = Utils::setUnionMerge<std::vector<SymbolIndexerTask>>(tasks, m_tasks, merge);
|
||||
}
|
||||
|
||||
void SymbolIndexerTaskQueue::removeTasks(const Utils::SmallStringVector &projectPartIds)
|
||||
void SymbolIndexerTaskQueue::removeTasks(const std::vector<int> &projectPartIds)
|
||||
{
|
||||
std::vector<std::size_t> ids = projectPartNumberIds(projectPartIds);
|
||||
|
||||
auto shouldBeRemoved = [&] (const SymbolIndexerTask& task) {
|
||||
return std::binary_search(ids.begin(), ids.end(), task.projectPartId);
|
||||
return std::binary_search(projectPartIds.begin(), projectPartIds.end(), task.projectPartId);
|
||||
};
|
||||
|
||||
auto newEnd = std::remove_if(m_tasks.begin(), m_tasks.end(), shouldBeRemoved);
|
||||
@@ -60,33 +58,6 @@ const std::vector<SymbolIndexerTask> &SymbolIndexerTaskQueue::tasks() const
|
||||
return m_tasks;
|
||||
}
|
||||
|
||||
std::size_t SymbolIndexerTaskQueue::projectPartNumberId(Utils::SmallStringView projectPartId)
|
||||
{
|
||||
auto found = std::find(m_projectPartIds.begin(), m_projectPartIds.end(), projectPartId);
|
||||
|
||||
if (found != m_projectPartIds.end())
|
||||
return std::size_t(std::distance(m_projectPartIds.begin(), found));
|
||||
|
||||
m_projectPartIds.emplace_back(projectPartId);
|
||||
|
||||
return m_projectPartIds.size() - 1;
|
||||
}
|
||||
|
||||
std::vector<std::size_t> SymbolIndexerTaskQueue::projectPartNumberIds(const Utils::SmallStringVector &projectPartIds)
|
||||
{
|
||||
std::vector<std::size_t> ids;
|
||||
std::transform(projectPartIds.begin(),
|
||||
projectPartIds.end(),
|
||||
std::back_inserter(ids),
|
||||
[&] (Utils::SmallStringView projectPartId) {
|
||||
return projectPartNumberId(projectPartId);
|
||||
});
|
||||
|
||||
std::sort(ids.begin(), ids.end());
|
||||
|
||||
return ids;
|
||||
}
|
||||
|
||||
void SymbolIndexerTaskQueue::processTasks()
|
||||
{
|
||||
int taskCount = m_symbolIndexerScheduler.freeSlots();
|
||||
|
||||
@@ -53,14 +53,10 @@ public:
|
||||
{}
|
||||
|
||||
void addOrUpdateTasks(std::vector<SymbolIndexerTask> &&tasks);
|
||||
void removeTasks(const Utils::SmallStringVector &projectPartIds);
|
||||
void removeTasks(const std::vector<int> &projectPartIds);
|
||||
|
||||
const std::vector<SymbolIndexerTask> &tasks() const;
|
||||
|
||||
std::size_t projectPartNumberId(Utils::SmallStringView projectPartId);
|
||||
std::vector<std::size_t> projectPartNumberIds(const Utils::SmallStringVector &projectPartIds)
|
||||
/* [[ensures result: std::is_sorted(result)]] */;
|
||||
|
||||
void processTasks();
|
||||
void syncTasks();
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ public:
|
||||
|
||||
virtual void addOrUpdateTasks(std::vector<SymbolIndexerTask> &&tasks) = 0
|
||||
/* [[expects: std::is_sorted(tasks)]] */;
|
||||
virtual void removeTasks(const Utils::SmallStringVector &projectPartIds) = 0
|
||||
virtual void removeTasks(const std::vector<int> &projectPartIds) = 0
|
||||
/* [[expects: std::is_sorted(projectPartIds)]] */;
|
||||
virtual void processTasks() = 0;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user