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:
Christian Stenger
2023-01-13 14:38:39 +01:00
parent 134b71a45a
commit 5fb06bdeb9
7 changed files with 63 additions and 2 deletions

View File

@@ -24,11 +24,13 @@
#include <texteditor/texteditor.h>
#include <texteditor/textmark.h>
#include <utils/qtcassert.h>
#include <utils/utilsicons.h>
#ifdef LICENSECHECKER
# include <licensechecker/licensecheckerplugin.h>
#endif
#include <QAction>
#include <QMessageBox>
#include <QTimer>
@@ -48,6 +50,7 @@ public:
void onDocumentClosed(Core::IDocument * doc);
void clearAllMarks();
void handleIssuesForFile(const IssuesList &issues);
void fetchRuleInfo(const QString &id);
AxivionSettings m_axivionSettings;
AxivionSettingsPage m_axivionSettingsPage{&m_axivionSettings};
@@ -78,6 +81,14 @@ AxivionTextMark::AxivionTextMark(const Utils::FilePath &filePath, const ShortIss
setToolTip(issue.errorNumber + " " + markText);
setPriority(TextEditor::TextMark::NormalPriority);
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()
@@ -222,6 +233,26 @@ void AxivionPluginPrivate::fetchProjectInfo(const QString &projectName)
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)
{
if (project && ProjectExplorer::SessionManager::startupProject() != project)