forked from qt-creator/qt-creator
Axivion: Store origin URL besides payload gotten from Dashboard
This prepares using (relative) URLs gotten from Dashboard instead of using hard-coded ones. Change-Id: Iea19c4010eac1e3f30a33d495a738d37738dc083 Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -94,21 +94,22 @@ void DashboardWidget::updateUi()
|
||||
delete child->widget();
|
||||
delete child;
|
||||
}
|
||||
std::shared_ptr<const Dto::ProjectInfoDto> info = AxivionPlugin::projectInfo();
|
||||
if (!info)
|
||||
std::shared_ptr<const DashboardClient::ProjectInfo> projectInfo = AxivionPlugin::projectInfo();
|
||||
if (!projectInfo)
|
||||
return;
|
||||
m_project->setText(info->name);
|
||||
if (info->versions.empty())
|
||||
const Dto::ProjectInfoDto &info = projectInfo->data;
|
||||
m_project->setText(info.name);
|
||||
if (info.versions.empty())
|
||||
return;
|
||||
|
||||
const Dto::AnalysisVersionDto &last = info->versions.back();
|
||||
const Dto::AnalysisVersionDto &last = info.versions.back();
|
||||
if (last.linesOfCode.has_value())
|
||||
m_loc->setText(QString::number(last.linesOfCode.value()));
|
||||
const QDateTime timeStamp = QDateTime::fromString(last.date, Qt::ISODate);
|
||||
m_timestamp->setText(timeStamp.isValid() ? timeStamp.toString("yyyy-MM-dd HH:mm:ss t")
|
||||
: Tr::tr("unknown"));
|
||||
|
||||
const std::vector<Dto::IssueKindInfoDto> &issueKinds = info->issueKinds;
|
||||
const std::vector<Dto::IssueKindInfoDto> &issueKinds = info.issueKinds;
|
||||
auto toolTip = [issueKinds](const QString &prefix){
|
||||
for (const Dto::IssueKindInfoDto &kind : issueKinds) {
|
||||
if (kind.prefix == prefix)
|
||||
|
||||
@@ -47,7 +47,7 @@ class AxivionPluginPrivate : public QObject
|
||||
public:
|
||||
void onStartupProjectChanged();
|
||||
void fetchProjectInfo(const QString &projectName);
|
||||
void handleProjectInfo(Utils::expected_str<Dto::ProjectInfoDto> rawInfo);
|
||||
void handleProjectInfo(DashboardClient::RawProjectInfo rawInfo);
|
||||
void handleOpenedDocs(ProjectExplorer::Project *project);
|
||||
void onDocumentOpened(Core::IDocument *doc);
|
||||
void onDocumentClosed(Core::IDocument * doc);
|
||||
@@ -57,7 +57,7 @@ public:
|
||||
|
||||
Utils::NetworkAccessManager *m_networkAccessManager = Utils::NetworkAccessManager::instance();
|
||||
AxivionOutputPane m_axivionOutputPane;
|
||||
std::shared_ptr<const Dto::ProjectInfoDto> m_currentProjectInfo;
|
||||
std::shared_ptr<const DashboardClient::ProjectInfo> m_currentProjectInfo;
|
||||
bool m_runningQuery = false;
|
||||
};
|
||||
|
||||
@@ -122,7 +122,7 @@ void AxivionPlugin::fetchProjectInfo(const QString &projectName)
|
||||
dd->fetchProjectInfo(projectName);
|
||||
}
|
||||
|
||||
std::shared_ptr<const Dto::ProjectInfoDto> AxivionPlugin::projectInfo()
|
||||
std::shared_ptr<const DashboardClient::ProjectInfo> AxivionPlugin::projectInfo()
|
||||
{
|
||||
QTC_ASSERT(dd, return {});
|
||||
return dd->m_currentProjectInfo;
|
||||
@@ -207,14 +207,14 @@ void AxivionPluginPrivate::clearAllMarks()
|
||||
onDocumentClosed(doc);
|
||||
}
|
||||
|
||||
void AxivionPluginPrivate::handleProjectInfo(Utils::expected_str<Dto::ProjectInfoDto> rawInfo)
|
||||
void AxivionPluginPrivate::handleProjectInfo(DashboardClient::RawProjectInfo rawInfo)
|
||||
{
|
||||
m_runningQuery = false;
|
||||
if (!rawInfo) {
|
||||
Core::MessageManager::writeFlashing(QStringLiteral(u"Axivion: ") + rawInfo.error());
|
||||
return;
|
||||
}
|
||||
m_currentProjectInfo = std::make_shared<const Dto::ProjectInfoDto>(std::move(rawInfo.value()));
|
||||
m_currentProjectInfo = std::make_shared<const DashboardClient::ProjectInfo>(std::move(rawInfo.value()));
|
||||
m_axivionOutputPane.updateDashboard();
|
||||
// handle already opened documents
|
||||
if (auto buildSystem = ProjectExplorer::ProjectManager::startupBuildSystem();
|
||||
@@ -238,7 +238,7 @@ void AxivionPluginPrivate::onDocumentOpened(Core::IDocument *doc)
|
||||
|
||||
Utils::FilePath relative = doc->filePath().relativeChildPath(project->projectDirectory());
|
||||
// for now only style violations
|
||||
AxivionQuery query(AxivionQuery::IssuesForFileList, {m_currentProjectInfo->name, "SV",
|
||||
AxivionQuery query(AxivionQuery::IssuesForFileList, {m_currentProjectInfo->data.name, "SV",
|
||||
relative.path() } );
|
||||
AxivionQueryRunner *runner = new AxivionQueryRunner(query, this);
|
||||
connect(runner, &AxivionQueryRunner::resultRetrieved, this, [this](const QByteArray &result){
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "dashboard/dto.h"
|
||||
#include "dashboard/dashboardclient.h"
|
||||
|
||||
#include <extensionsystem/iplugin.h>
|
||||
|
||||
@@ -26,7 +26,7 @@ public:
|
||||
~AxivionPlugin() final;
|
||||
|
||||
static void fetchProjectInfo(const QString &projectName);
|
||||
static std::shared_ptr<const Dto::ProjectInfoDto> projectInfo();
|
||||
static std::shared_ptr<const DashboardClient::ProjectInfo> projectInfo();
|
||||
|
||||
private:
|
||||
void initialize() final;
|
||||
|
||||
@@ -30,7 +30,7 @@ static void deleteLater(QObject *obj)
|
||||
obj->deleteLater();
|
||||
}
|
||||
|
||||
using RawBody = Utils::expected_str<QByteArray>;
|
||||
using RawBody = Utils::expected_str<DataWithOrigin<QByteArray>>;
|
||||
|
||||
class RawBodyReader final
|
||||
{
|
||||
@@ -48,7 +48,7 @@ public:
|
||||
return tl::make_unexpected(QString::number(error)
|
||||
+ QLatin1String(": ")
|
||||
+ m_reply->errorString());
|
||||
return m_reply->readAll();
|
||||
return DataWithOrigin(m_reply->url(), m_reply->readAll());
|
||||
}
|
||||
|
||||
private:
|
||||
@@ -56,12 +56,14 @@ private:
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
static Utils::expected_str<T> RawBodyParser(RawBody rawBody)
|
||||
static Utils::expected_str<DataWithOrigin<T>> RawBodyParser(RawBody rawBody)
|
||||
{
|
||||
if (!rawBody)
|
||||
return tl::make_unexpected(std::move(rawBody.error()));
|
||||
try {
|
||||
return { T::deserialize(rawBody.value()) };
|
||||
T data = T::deserialize(rawBody.value().data);
|
||||
return DataWithOrigin(std::move(rawBody.value().origin),
|
||||
std::move(data));
|
||||
} catch (const Dto::invalid_dto_exception &e) {
|
||||
return tl::make_unexpected(QString::fromUtf8(e.what()));
|
||||
}
|
||||
|
||||
@@ -13,14 +13,26 @@
|
||||
#include <utils/networkaccessmanager.h>
|
||||
|
||||
#include <QFuture>
|
||||
#include <QNetworkReply>
|
||||
|
||||
namespace Axivion::Internal
|
||||
{
|
||||
|
||||
template<typename T>
|
||||
class DataWithOrigin
|
||||
{
|
||||
public:
|
||||
QUrl origin;
|
||||
T data;
|
||||
|
||||
DataWithOrigin(QUrl origin, T data) : origin(std::move(origin)), data(std::move(data)) { }
|
||||
};
|
||||
|
||||
class DashboardClient
|
||||
{
|
||||
public:
|
||||
using RawProjectInfo = Utils::expected_str<Dto::ProjectInfoDto>;
|
||||
using ProjectInfo = DataWithOrigin<Dto::ProjectInfoDto>;
|
||||
using RawProjectInfo = Utils::expected_str<ProjectInfo>;
|
||||
|
||||
DashboardClient(Utils::NetworkAccessManager &networkAccessManager);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user