forked from qt-creator/qt-creator
Add possibility to fetch rule details for issues
Allows to fetch further information of an issue and display it inside the output pane. Change-Id: I94ec27b9c060dca9f9523d763b8628a2fce7ca59 Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -13,6 +13,7 @@
|
|||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QScrollArea>
|
#include <QScrollArea>
|
||||||
#include <QStackedWidget>
|
#include <QStackedWidget>
|
||||||
|
#include <QTextBrowser>
|
||||||
|
|
||||||
namespace Axivion::Internal {
|
namespace Axivion::Internal {
|
||||||
|
|
||||||
@@ -98,6 +99,8 @@ AxivionOutputPane::AxivionOutputPane(QObject *parent)
|
|||||||
m_outputWidget = new QStackedWidget;
|
m_outputWidget = new QStackedWidget;
|
||||||
DashboardWidget *dashboardWidget = new DashboardWidget(m_outputWidget);
|
DashboardWidget *dashboardWidget = new DashboardWidget(m_outputWidget);
|
||||||
m_outputWidget->addWidget(dashboardWidget);
|
m_outputWidget->addWidget(dashboardWidget);
|
||||||
|
QTextBrowser *browser = new QTextBrowser(m_outputWidget);
|
||||||
|
m_outputWidget->addWidget(browser);
|
||||||
}
|
}
|
||||||
|
|
||||||
AxivionOutputPane::~AxivionOutputPane()
|
AxivionOutputPane::~AxivionOutputPane()
|
||||||
@@ -182,4 +185,15 @@ void AxivionOutputPane::updateDashboard()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AxivionOutputPane::updateAndShowRule(const QString &ruleHtml)
|
||||||
|
{
|
||||||
|
if (auto browser = static_cast<QTextBrowser *>(m_outputWidget->widget(1))) {
|
||||||
|
browser->setText(ruleHtml);
|
||||||
|
if (!ruleHtml.isEmpty()) {
|
||||||
|
m_outputWidget->setCurrentIndex(1);
|
||||||
|
popup(Core::IOutputPane::NoModeSwitch);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} // Axivion::Internal
|
} // Axivion::Internal
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ public:
|
|||||||
void goToPrev() override;
|
void goToPrev() override;
|
||||||
|
|
||||||
void updateDashboard();
|
void updateDashboard();
|
||||||
|
void updateAndShowRule(const QString &ruleHtml);
|
||||||
private:
|
private:
|
||||||
QStackedWidget *m_outputWidget = nullptr;
|
QStackedWidget *m_outputWidget = nullptr;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -24,11 +24,13 @@
|
|||||||
#include <texteditor/texteditor.h>
|
#include <texteditor/texteditor.h>
|
||||||
#include <texteditor/textmark.h>
|
#include <texteditor/textmark.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
|
#include <utils/utilsicons.h>
|
||||||
|
|
||||||
#ifdef LICENSECHECKER
|
#ifdef LICENSECHECKER
|
||||||
# include <licensechecker/licensecheckerplugin.h>
|
# include <licensechecker/licensecheckerplugin.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <QAction>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
|
||||||
@@ -48,6 +50,7 @@ public:
|
|||||||
void onDocumentClosed(Core::IDocument * doc);
|
void onDocumentClosed(Core::IDocument * doc);
|
||||||
void clearAllMarks();
|
void clearAllMarks();
|
||||||
void handleIssuesForFile(const IssuesList &issues);
|
void handleIssuesForFile(const IssuesList &issues);
|
||||||
|
void fetchRuleInfo(const QString &id);
|
||||||
|
|
||||||
AxivionSettings m_axivionSettings;
|
AxivionSettings m_axivionSettings;
|
||||||
AxivionSettingsPage m_axivionSettingsPage{&m_axivionSettings};
|
AxivionSettingsPage m_axivionSettingsPage{&m_axivionSettings};
|
||||||
@@ -78,6 +81,14 @@ AxivionTextMark::AxivionTextMark(const Utils::FilePath &filePath, const ShortIss
|
|||||||
setToolTip(issue.errorNumber + " " + markText);
|
setToolTip(issue.errorNumber + " " + markText);
|
||||||
setPriority(TextEditor::TextMark::NormalPriority);
|
setPriority(TextEditor::TextMark::NormalPriority);
|
||||||
setLineAnnotation(markText);
|
setLineAnnotation(markText);
|
||||||
|
setActionsProvider([this]{
|
||||||
|
auto action = new QAction;
|
||||||
|
action->setIcon(Utils::Icons::INFO.icon());
|
||||||
|
action->setToolTip(Tr::tr("Show rule details"));
|
||||||
|
QObject::connect(action, &QAction::triggered,
|
||||||
|
dd, [this]{ dd->fetchRuleInfo(m_id); });
|
||||||
|
return QList{action};
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
AxivionPlugin::AxivionPlugin()
|
AxivionPlugin::AxivionPlugin()
|
||||||
@@ -222,6 +233,26 @@ void AxivionPluginPrivate::fetchProjectInfo(const QString &projectName)
|
|||||||
runner->start();
|
runner->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AxivionPluginPrivate::fetchRuleInfo(const QString &id)
|
||||||
|
{
|
||||||
|
if (m_runningQuery) {
|
||||||
|
QTimer::singleShot(3000, [this, id]{ fetchRuleInfo(id); });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const QStringList args = id.split(':');
|
||||||
|
QTC_ASSERT(args.size() == 2, return);
|
||||||
|
m_runningQuery = true;
|
||||||
|
AxivionQuery query(AxivionQuery::RuleInfo, args);
|
||||||
|
AxivionQueryRunner *runner = new AxivionQueryRunner(query, this);
|
||||||
|
connect(runner, &AxivionQueryRunner::resultRetrieved, this, [this](const QByteArray &result){
|
||||||
|
m_runningQuery = false;
|
||||||
|
m_axivionOutputPane.updateAndShowRule(ResultParser::parseRuleInfo(result));
|
||||||
|
});
|
||||||
|
connect(runner, &AxivionQueryRunner::finished, [runner]{ runner->deleteLater(); });
|
||||||
|
runner->start();
|
||||||
|
}
|
||||||
|
|
||||||
void AxivionPluginPrivate::handleOpenedDocs(ProjectExplorer::Project *project)
|
void AxivionPluginPrivate::handleOpenedDocs(ProjectExplorer::Project *project)
|
||||||
{
|
{
|
||||||
if (project && ProjectExplorer::SessionManager::startupProject() != project)
|
if (project && ProjectExplorer::SessionManager::startupProject() != project)
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ AxivionQuery::AxivionQuery(QueryType type, const QStringList ¶meters)
|
|||||||
|
|
||||||
QString AxivionQuery::toString() const
|
QString AxivionQuery::toString() const
|
||||||
{
|
{
|
||||||
QString query = "/api"; // common for all
|
QString query = "/api"; // common for all except RuleInfo
|
||||||
switch (m_type) {
|
switch (m_type) {
|
||||||
case NoQuery:
|
case NoQuery:
|
||||||
return {};
|
return {};
|
||||||
@@ -40,6 +40,11 @@ QString AxivionQuery::toString() const
|
|||||||
+ "/issues?kind=" + m_parameters.at(1) + "&filter_path="
|
+ "/issues?kind=" + m_parameters.at(1) + "&filter_path="
|
||||||
+ QUrl::toPercentEncoding(m_parameters.at(2)) + "&format=csv";
|
+ QUrl::toPercentEncoding(m_parameters.at(2)) + "&format=csv";
|
||||||
return query;
|
return query;
|
||||||
|
case RuleInfo:
|
||||||
|
QTC_ASSERT(m_parameters.size() == 2, return {});
|
||||||
|
query = "/projects/" + QUrl::toPercentEncoding(m_parameters.first())
|
||||||
|
+ "/issues/" + m_parameters.at(1) + "/rule";
|
||||||
|
return query;
|
||||||
}
|
}
|
||||||
|
|
||||||
return {};
|
return {};
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ namespace Axivion::Internal {
|
|||||||
class AxivionQuery
|
class AxivionQuery
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
enum QueryType {NoQuery, DashboardInfo, ProjectInfo, IssuesForFileList};
|
enum QueryType {NoQuery, DashboardInfo, ProjectInfo, IssuesForFileList, RuleInfo};
|
||||||
explicit AxivionQuery(QueryType type, const QStringList ¶meters = {});
|
explicit AxivionQuery(QueryType type, const QStringList ¶meters = {});
|
||||||
|
|
||||||
QString toString() const;
|
QString toString() const;
|
||||||
|
|||||||
@@ -333,6 +333,15 @@ IssuesList parseIssuesList(const QByteArray &input)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString parseRuleInfo(const QByteArray &input) // html result!
|
||||||
|
{
|
||||||
|
auto [header, body] = splitHeaderAndBody(input);
|
||||||
|
BaseResult headerResult = prehandleHeader(header, body);
|
||||||
|
if (!headerResult.error.isEmpty())
|
||||||
|
return QString();
|
||||||
|
return QString::fromLocal8Bit(body);
|
||||||
|
}
|
||||||
|
|
||||||
} // ResultParser
|
} // ResultParser
|
||||||
|
|
||||||
} // Axivion::Internal
|
} // Axivion::Internal
|
||||||
|
|||||||
@@ -94,6 +94,7 @@ namespace ResultParser {
|
|||||||
DashboardInfo parseDashboardInfo(const QByteArray &input);
|
DashboardInfo parseDashboardInfo(const QByteArray &input);
|
||||||
ProjectInfo parseProjectInfo(const QByteArray &input);
|
ProjectInfo parseProjectInfo(const QByteArray &input);
|
||||||
IssuesList parseIssuesList(const QByteArray &input);
|
IssuesList parseIssuesList(const QByteArray &input);
|
||||||
|
QString parseRuleInfo(const QByteArray &input);
|
||||||
|
|
||||||
} // ResultParser
|
} // ResultParser
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user