forked from qt-creator/qt-creator
RunControl: Show more status in Application Output pane
Change-Id: I07e80e5a987612c19247a2d9a0628382b1136a06 Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
This commit is contained in:
@@ -53,6 +53,8 @@ ClangStaticAnalyzerRunControl::ClangStaticAnalyzerRunControl(
|
|||||||
ProjectExplorer::RunConfiguration *runConfiguration)
|
ProjectExplorer::RunConfiguration *runConfiguration)
|
||||||
: AnalyzerRunControl(startParams, runConfiguration)
|
: AnalyzerRunControl(startParams, runConfiguration)
|
||||||
, m_initialFilesToProcessSize(0)
|
, m_initialFilesToProcessSize(0)
|
||||||
|
, m_filesAnalyzed(0)
|
||||||
|
, m_filesNotAnalyzed(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -126,6 +128,8 @@ bool ClangStaticAnalyzerRunControl::startEngine()
|
|||||||
}
|
}
|
||||||
m_filesToProcess = filesToProcess;
|
m_filesToProcess = filesToProcess;
|
||||||
m_initialFilesToProcessSize = m_filesToProcess.count();
|
m_initialFilesToProcessSize = m_filesToProcess.count();
|
||||||
|
m_filesAnalyzed = 0;
|
||||||
|
m_filesNotAnalyzed = 0;
|
||||||
|
|
||||||
// Set up progress information
|
// Set up progress information
|
||||||
using namespace Core;
|
using namespace Core;
|
||||||
@@ -156,7 +160,10 @@ void ClangStaticAnalyzerRunControl::stopEngine()
|
|||||||
}
|
}
|
||||||
m_runners.clear();
|
m_runners.clear();
|
||||||
m_filesToProcess.clear();
|
m_filesToProcess.clear();
|
||||||
analyzeNextFile(); // emits finished
|
appendMessage(tr("Clang Static Analyzer stopped by user.") + QLatin1Char('\n'),
|
||||||
|
Utils::NormalMessageFormat);
|
||||||
|
m_progress.reportFinished();
|
||||||
|
emit finished();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClangStaticAnalyzerRunControl::analyzeNextFile()
|
void ClangStaticAnalyzerRunControl::analyzeNextFile()
|
||||||
@@ -166,7 +173,11 @@ void ClangStaticAnalyzerRunControl::analyzeNextFile()
|
|||||||
|
|
||||||
if (m_filesToProcess.isEmpty()) {
|
if (m_filesToProcess.isEmpty()) {
|
||||||
if (m_runners.size() == 0) {
|
if (m_runners.size() == 0) {
|
||||||
appendMessage(tr("Clang Static Analyzer finished.") + QLatin1Char('\n'),
|
appendMessage(tr("Clang Static Analyzer finished: "
|
||||||
|
"Processed %1 files successfully, %2 failed.")
|
||||||
|
.arg(m_filesAnalyzed)
|
||||||
|
.arg(m_filesNotAnalyzed)
|
||||||
|
+ QLatin1Char('\n'),
|
||||||
Utils::NormalMessageFormat);
|
Utils::NormalMessageFormat);
|
||||||
m_progress.reportFinished();
|
m_progress.reportFinished();
|
||||||
emit finished();
|
emit finished();
|
||||||
@@ -182,6 +193,8 @@ void ClangStaticAnalyzerRunControl::analyzeNextFile()
|
|||||||
m_runners.insert(runner);
|
m_runners.insert(runner);
|
||||||
qCDebug(LOG) << "analyzeNextFile:" << filePath;
|
qCDebug(LOG) << "analyzeNextFile:" << filePath;
|
||||||
QTC_ASSERT(runner->run(filePath, options), return);
|
QTC_ASSERT(runner->run(filePath, options), return);
|
||||||
|
appendMessage(tr("Analyzing \"%1\".").arg(filePath) + QLatin1Char('\n'),
|
||||||
|
Utils::StdOutFormat);
|
||||||
}
|
}
|
||||||
|
|
||||||
ClangStaticAnalyzerRunner *ClangStaticAnalyzerRunControl::createRunner()
|
ClangStaticAnalyzerRunner *ClangStaticAnalyzerRunControl::createRunner()
|
||||||
@@ -201,21 +214,36 @@ ClangStaticAnalyzerRunner *ClangStaticAnalyzerRunControl::createRunner()
|
|||||||
void ClangStaticAnalyzerRunControl::onRunnerFinishedWithSuccess(const QString &logFilePath)
|
void ClangStaticAnalyzerRunControl::onRunnerFinishedWithSuccess(const QString &logFilePath)
|
||||||
{
|
{
|
||||||
qCDebug(LOG) << "onRunnerFinishedWithSuccess:" << logFilePath;
|
qCDebug(LOG) << "onRunnerFinishedWithSuccess:" << logFilePath;
|
||||||
handleFinished();
|
|
||||||
|
|
||||||
QString errorMessage;
|
QString errorMessage;
|
||||||
const QList<Diagnostic> diagnostics = LogFileReader::read(logFilePath, &errorMessage);
|
const QList<Diagnostic> diagnostics = LogFileReader::read(logFilePath, &errorMessage);
|
||||||
QTC_CHECK(errorMessage.isEmpty());
|
if (!errorMessage.isEmpty()) {
|
||||||
if (!errorMessage.isEmpty())
|
|
||||||
qCDebug(LOG) << "onRunnerFinishedWithSuccess: Error reading log file:" << errorMessage;
|
qCDebug(LOG) << "onRunnerFinishedWithSuccess: Error reading log file:" << errorMessage;
|
||||||
|
const QString filePath = qobject_cast<ClangStaticAnalyzerRunner *>(sender())->filePath();
|
||||||
|
appendMessage(tr("Failed to analyze \"%1\": %2").arg(filePath, errorMessage)
|
||||||
|
+ QLatin1Char('\n')
|
||||||
|
, Utils::StdErrFormat);
|
||||||
|
} else {
|
||||||
|
++m_filesAnalyzed;
|
||||||
if (!diagnostics.isEmpty())
|
if (!diagnostics.isEmpty())
|
||||||
emit newDiagnosticsAvailable(diagnostics);
|
emit newDiagnosticsAvailable(diagnostics);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handleFinished();
|
||||||
|
}
|
||||||
|
|
||||||
void ClangStaticAnalyzerRunControl::onRunnerFinishedWithFailure(const QString &errorMessage,
|
void ClangStaticAnalyzerRunControl::onRunnerFinishedWithFailure(const QString &errorMessage,
|
||||||
const QString &errorDetails)
|
const QString &errorDetails)
|
||||||
{
|
{
|
||||||
qCDebug(LOG) << "onRunnerFinishedWithFailure:" << errorMessage << errorDetails;
|
qCDebug(LOG) << "onRunnerFinishedWithFailure:" << errorMessage << errorDetails;
|
||||||
|
|
||||||
|
++m_filesNotAnalyzed;
|
||||||
|
const QString filePath = qobject_cast<ClangStaticAnalyzerRunner *>(sender())->filePath();
|
||||||
|
appendMessage(tr("Failed to analyze \"%1\": %2").arg(filePath, errorMessage)
|
||||||
|
+ QLatin1Char('\n')
|
||||||
|
, Utils::StdErrFormat);
|
||||||
|
appendMessage(errorDetails, Utils::StdErrFormat);
|
||||||
|
|
||||||
handleFinished();
|
handleFinished();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -76,6 +76,8 @@ private:
|
|||||||
QList<SourceFileConfiguration> m_filesToProcess;
|
QList<SourceFileConfiguration> m_filesToProcess;
|
||||||
QSet<ClangStaticAnalyzerRunner *> m_runners;
|
QSet<ClangStaticAnalyzerRunner *> m_runners;
|
||||||
int m_initialFilesToProcessSize;
|
int m_initialFilesToProcessSize;
|
||||||
|
int m_filesAnalyzed;
|
||||||
|
int m_filesNotAnalyzed;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
@@ -99,6 +99,7 @@ bool ClangStaticAnalyzerRunner::run(const QString &filePath, const QStringList &
|
|||||||
QTC_CHECK(!compilerOptions.contains(QLatin1String("-o")));
|
QTC_CHECK(!compilerOptions.contains(QLatin1String("-o")));
|
||||||
QTC_CHECK(!compilerOptions.contains(filePath));
|
QTC_CHECK(!compilerOptions.contains(filePath));
|
||||||
|
|
||||||
|
m_filePath = filePath;
|
||||||
m_processOutput.clear();
|
m_processOutput.clear();
|
||||||
|
|
||||||
m_logFile = createLogFile(filePath);
|
m_logFile = createLogFile(filePath);
|
||||||
@@ -112,6 +113,11 @@ bool ClangStaticAnalyzerRunner::run(const QString &filePath, const QStringList &
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString ClangStaticAnalyzerRunner::filePath() const
|
||||||
|
{
|
||||||
|
return m_filePath;
|
||||||
|
}
|
||||||
|
|
||||||
void ClangStaticAnalyzerRunner::onProcessStarted()
|
void ClangStaticAnalyzerRunner::onProcessStarted()
|
||||||
{
|
{
|
||||||
emit started();
|
emit started();
|
||||||
@@ -161,8 +167,8 @@ QString ClangStaticAnalyzerRunner::createLogFile(const QString &filePath) const
|
|||||||
QString ClangStaticAnalyzerRunner::processCommandlineAndOutput() const
|
QString ClangStaticAnalyzerRunner::processCommandlineAndOutput() const
|
||||||
{
|
{
|
||||||
return QObject::tr("Command line: \"%1\"\n"
|
return QObject::tr("Command line: \"%1\"\n"
|
||||||
"Process Error: \"%2\"\n"
|
"Process Error: %2\n"
|
||||||
"Output:\n\"%3\"")
|
"Output:\n%3")
|
||||||
.arg(m_commandLine,
|
.arg(m_commandLine,
|
||||||
QString::number(m_process.error()),
|
QString::number(m_process.error()),
|
||||||
QString::fromLocal8Bit(m_processOutput));
|
QString::fromLocal8Bit(m_processOutput));
|
||||||
|
@@ -45,6 +45,8 @@ public:
|
|||||||
// (2) -o output-file
|
// (2) -o output-file
|
||||||
bool run(const QString &filePath, const QStringList &compilerOptions = QStringList());
|
bool run(const QString &filePath, const QStringList &compilerOptions = QStringList());
|
||||||
|
|
||||||
|
QString filePath() const;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void started();
|
void started();
|
||||||
void finishedWithSuccess(const QString &logFilePath);
|
void finishedWithSuccess(const QString &logFilePath);
|
||||||
@@ -62,6 +64,7 @@ private:
|
|||||||
private:
|
private:
|
||||||
QString m_clangExecutable;
|
QString m_clangExecutable;
|
||||||
QString m_clangLogFileDir;
|
QString m_clangLogFileDir;
|
||||||
|
QString m_filePath;
|
||||||
QString m_logFile;
|
QString m_logFile;
|
||||||
QString m_commandLine;
|
QString m_commandLine;
|
||||||
QProcess m_process;
|
QProcess m_process;
|
||||||
|
Reference in New Issue
Block a user