forked from qt-creator/qt-creator
Axivion: Add projectInfoRecipe()
Change-Id: I825ba27ed523654b81fd0b1b2b7d1e2acc6e4c11 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -818,6 +818,52 @@ Group dashboardInfoRecipe(const DashboardInfoHandler &handler)
|
|||||||
return root;
|
return root;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Group projectInfoRecipe(const QString &projectName)
|
||||||
|
{
|
||||||
|
const auto onSetup = [projectName] {
|
||||||
|
dd->clearAllMarks();
|
||||||
|
dd->m_currentProjectInfo = {};
|
||||||
|
dd->m_analysisVersion = {};
|
||||||
|
if (!projectName.isEmpty())
|
||||||
|
return SetupResult::Continue;
|
||||||
|
|
||||||
|
updateDashboard();
|
||||||
|
return SetupResult::StopWithSuccess;
|
||||||
|
};
|
||||||
|
|
||||||
|
const auto onTaskTreeSetup = [projectName](TaskTree &taskTree) {
|
||||||
|
if (!dd->m_dashboardInfo) {
|
||||||
|
MessageManager::writeDisrupting(QString("Axivion: %1")
|
||||||
|
.arg(Tr::tr("Fetching DashboardInfo error.")));
|
||||||
|
return SetupResult::StopWithError;
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto it = dd->m_dashboardInfo->projectUrls.constFind(projectName);
|
||||||
|
if (it == dd->m_dashboardInfo->projectUrls.constEnd()) {
|
||||||
|
MessageManager::writeDisrupting(QString("Axivion: %1")
|
||||||
|
.arg(Tr::tr("The DashboardInfo doesn't contain project \"%1\".").arg(projectName)));
|
||||||
|
return SetupResult::StopWithError;
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto handler = [](const Dto::ProjectInfoDto &data) {
|
||||||
|
dd->m_currentProjectInfo = data;
|
||||||
|
if (!dd->m_currentProjectInfo->versions.empty())
|
||||||
|
setAnalysisVersion(dd->m_currentProjectInfo->versions.back().date);
|
||||||
|
updateDashboard();
|
||||||
|
};
|
||||||
|
|
||||||
|
taskTree.setRecipe(
|
||||||
|
fetchDataRecipe<Dto::ProjectInfoDto>(dd->m_dashboardInfo->source.resolved(*it), handler));
|
||||||
|
return SetupResult::Continue;
|
||||||
|
};
|
||||||
|
|
||||||
|
return {
|
||||||
|
onGroupSetup(onSetup),
|
||||||
|
authorizationRecipe(),
|
||||||
|
TaskTreeTask(onTaskTreeSetup)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
Group issueTableRecipe(const IssueListSearch &search, const IssueTableHandler &handler)
|
Group issueTableRecipe(const IssueListSearch &search, const IssueTableHandler &handler)
|
||||||
{
|
{
|
||||||
QTC_ASSERT(dd->m_currentProjectInfo, return {}); // TODO: Call handler with unexpected?
|
QTC_ASSERT(dd->m_currentProjectInfo, return {}); // TODO: Call handler with unexpected?
|
||||||
@@ -873,49 +919,7 @@ void AxivionPluginPrivate::fetchDashboardInfo(const DashboardInfoHandler &handle
|
|||||||
|
|
||||||
void AxivionPluginPrivate::fetchProjectInfo(const QString &projectName)
|
void AxivionPluginPrivate::fetchProjectInfo(const QString &projectName)
|
||||||
{
|
{
|
||||||
const auto onSetup = [this, projectName] {
|
m_taskTreeRunner.start(projectInfoRecipe(projectName));
|
||||||
clearAllMarks();
|
|
||||||
m_currentProjectInfo = {};
|
|
||||||
m_analysisVersion = {};
|
|
||||||
if (!projectName.isEmpty())
|
|
||||||
return SetupResult::Continue;
|
|
||||||
|
|
||||||
updateDashboard();
|
|
||||||
return SetupResult::StopWithSuccess;
|
|
||||||
};
|
|
||||||
|
|
||||||
const auto onTaskTreeSetup = [this, projectName](TaskTree &taskTree) {
|
|
||||||
if (!m_dashboardInfo) {
|
|
||||||
MessageManager::writeDisrupting(QString("Axivion: %1")
|
|
||||||
.arg(Tr::tr("Fetching DashboardInfo error.")));
|
|
||||||
return SetupResult::StopWithError;
|
|
||||||
}
|
|
||||||
|
|
||||||
const auto it = m_dashboardInfo->projectUrls.constFind(projectName);
|
|
||||||
if (it == m_dashboardInfo->projectUrls.constEnd()) {
|
|
||||||
MessageManager::writeDisrupting(QString("Axivion: %1")
|
|
||||||
.arg(Tr::tr("The DashboardInfo doesn't contain project \"%1\".").arg(projectName)));
|
|
||||||
return SetupResult::StopWithError;
|
|
||||||
}
|
|
||||||
|
|
||||||
const auto handler = [this](const Dto::ProjectInfoDto &data) {
|
|
||||||
m_currentProjectInfo = data;
|
|
||||||
if (!m_currentProjectInfo->versions.empty())
|
|
||||||
setAnalysisVersion(m_currentProjectInfo->versions.back().date);
|
|
||||||
updateDashboard();
|
|
||||||
};
|
|
||||||
|
|
||||||
taskTree.setRecipe(
|
|
||||||
fetchDataRecipe<Dto::ProjectInfoDto>(m_dashboardInfo->source.resolved(*it), handler));
|
|
||||||
return SetupResult::Continue;
|
|
||||||
};
|
|
||||||
|
|
||||||
const Group root {
|
|
||||||
onGroupSetup(onSetup),
|
|
||||||
authorizationRecipe(),
|
|
||||||
TaskTreeTask(onTaskTreeSetup)
|
|
||||||
};
|
|
||||||
m_taskTreeRunner.start(root);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Group tableInfoRecipe(const QString &prefix, const TableInfoHandler &handler)
|
Group tableInfoRecipe(const QString &prefix, const TableInfoHandler &handler)
|
||||||
|
@@ -63,6 +63,8 @@ public:
|
|||||||
using DashboardInfoHandler = std::function<void(const Utils::expected_str<DashboardInfo> &)>;
|
using DashboardInfoHandler = std::function<void(const Utils::expected_str<DashboardInfo> &)>;
|
||||||
Tasking::Group dashboardInfoRecipe(const DashboardInfoHandler &handler = {});
|
Tasking::Group dashboardInfoRecipe(const DashboardInfoHandler &handler = {});
|
||||||
|
|
||||||
|
Tasking::Group projectInfoRecipe(const QString &projectName);
|
||||||
|
|
||||||
// TODO: Wrap into expected_str<>?
|
// TODO: Wrap into expected_str<>?
|
||||||
using TableInfoHandler = std::function<void(const Dto::TableInfoDto &)>;
|
using TableInfoHandler = std::function<void(const Dto::TableInfoDto &)>;
|
||||||
Tasking::Group tableInfoRecipe(const QString &prefix, const TableInfoHandler &handler);
|
Tasking::Group tableInfoRecipe(const QString &prefix, const TableInfoHandler &handler);
|
||||||
|
Reference in New Issue
Block a user