diff options
author | Christian Kandeler <christian.kandeler@theqtcompany.com> | 2015-02-26 16:24:53 +0100 |
---|---|---|
committer | Christian Kandeler <christian.kandeler@theqtcompany.com> | 2015-02-27 16:16:36 +0200 |
commit | f12e53e83cb3e1e04bc6eb2ec9e8ad24c28f00d5 (patch) | |
tree | 9fe4beded25bca4b5771b1d3e2d0a334631a8587 /plugins/clangstaticanalyzer | |
parent | 6e796591f445aa0f193b280b9c89fcf82fa2236d (diff) | |
download | qt-creator-f12e53e83cb3e1e04bc6eb2ec9e8ad24c28f00d5.tar.gz |
Make use of the "issues" pane when errors occur during analyzing.
They can otherwise easily get lost in the Application output pane.
Policy is as follows:
- Failure to analyze a specific file is considered a warning.
- If no file could be successfully analyzed, we add an
error and pop up the issues pane.
This approach is neither too noisy nor too quiet.
Change-Id: Ifc577a215006a6a565eee7de5099bd690427f7de
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
Diffstat (limited to 'plugins/clangstaticanalyzer')
-rw-r--r-- | plugins/clangstaticanalyzer/clangstaticanalyzerruncontrol.cpp | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/plugins/clangstaticanalyzer/clangstaticanalyzerruncontrol.cpp b/plugins/clangstaticanalyzer/clangstaticanalyzerruncontrol.cpp index 15deb7b9ce..e0576299e4 100644 --- a/plugins/clangstaticanalyzer/clangstaticanalyzerruncontrol.cpp +++ b/plugins/clangstaticanalyzer/clangstaticanalyzerruncontrol.cpp @@ -23,6 +23,7 @@ #include "clangstaticanalyzersettings.h" #include "clangstaticanalyzerutils.h" +#include <analyzerbase/analyzerconstants.h> #include <analyzerbase/analyzermanager.h> #include <clangcodemodel/clangutils.h> @@ -37,6 +38,7 @@ #include <projectexplorer/kitinformation.h> #include <projectexplorer/project.h> #include <projectexplorer/target.h> +#include <projectexplorer/taskhub.h> #include <utils/algorithm.h> @@ -51,6 +53,14 @@ static Q_LOGGING_CATEGORY(LOG, "qtc.clangstaticanalyzer.runcontrol") namespace ClangStaticAnalyzer { namespace Internal { +static void logToIssuesPane(Task::TaskType type, const QString &message) +{ + TaskHub::addTask(type, message, Analyzer::Constants::ANALYZERTASK_ID); + if (type == Task::Error) + TaskHub::requestPopup(); +} + + ClangStaticAnalyzerRunControl::ClangStaticAnalyzerRunControl( const Analyzer::AnalyzerStartParameters &startParams, ProjectExplorer::RunConfiguration *runConfiguration, @@ -191,9 +201,10 @@ bool ClangStaticAnalyzerRunControl::startEngine() const QString executable = clangExecutableFromSettings(m_toolchainType, &isValidClangExecutable); if (!isValidClangExecutable) { - emit appendMessage(tr("Clang Static Analyzer: Invalid executable \"%1\", stop.") - .arg(executable) + QLatin1Char('\n'), - Utils::ErrorMessageFormat); + const QString errorMessage = tr("Clang Static Analyzer: Invalid executable \"%1\", stop.") + .arg(executable); + appendMessage(errorMessage + QLatin1Char('\n'), Utils::ErrorMessageFormat); + logToIssuesPane(Task::Error, errorMessage); emit finished(); return false; } @@ -203,8 +214,10 @@ bool ClangStaticAnalyzerRunControl::startEngine() QTemporaryDir temporaryDir(QDir::tempPath() + QLatin1String("/qtc-clangstaticanalyzer-XXXXXX")); temporaryDir.setAutoRemove(false); if (!temporaryDir.isValid()) { - emit appendMessage(tr("Clang Static Analyzer: Failed to create temporary dir, stop.") - + QLatin1Char('\n'), Utils::ErrorMessageFormat); + const QString errorMessage + = tr("Clang Static Analyzer: Failed to create temporary dir, stop."); + appendMessage(errorMessage + QLatin1Char('\n'), Utils::ErrorMessageFormat); + logToIssuesPane(Task::Error, errorMessage); emit finished(); return false; } @@ -273,6 +286,10 @@ void ClangStaticAnalyzerRunControl::analyzeNextFile() .arg(m_filesNotAnalyzed) + QLatin1Char('\n'), Utils::NormalMessageFormat); + if (m_filesAnalyzed == 0 && m_filesNotAnalyzed != 0) { + logToIssuesPane(Task::Error, + tr("Clang Static Analyzer: Failed to analyze any files.")); + } m_progress.reportFinished(); emit finished(); } @@ -336,7 +353,8 @@ void ClangStaticAnalyzerRunControl::onRunnerFinishedWithFailure(const QString &e + QLatin1Char('\n') , Utils::StdErrFormat); appendMessage(errorDetails, Utils::StdErrFormat); - + logToIssuesPane(Task::Warning, errorMessage); + logToIssuesPane(Task::Warning, errorDetails); handleFinished(); } |