ClangStaticAnalyzer: Adapt to new simpler RunControl creation

Change-Id: Ib088828a9695938afb83bcdd2d5fd4124dd602a8
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
This commit is contained in:
hjk
2017-06-16 15:21:17 +02:00
parent 422f4cdbb8
commit 40bd9aba9c
7 changed files with 25 additions and 131 deletions

View File

@@ -11,7 +11,6 @@ SOURCES += \
clangstaticanalyzerprojectsettingsmanager.cpp \
clangstaticanalyzerprojectsettingswidget.cpp \
clangstaticanalyzerruncontrol.cpp \
clangstaticanalyzerruncontrolfactory.cpp \
clangstaticanalyzerrunner.cpp \
clangstaticanalyzersettings.cpp \
clangstaticanalyzertool.cpp \
@@ -29,7 +28,6 @@ HEADERS += \
clangstaticanalyzerprojectsettings.h \
clangstaticanalyzerprojectsettingsmanager.h \
clangstaticanalyzerprojectsettingswidget.h \
clangstaticanalyzerruncontrolfactory.h \
clangstaticanalyzerruncontrol.h \
clangstaticanalyzerrunner.h \
clangstaticanalyzersettings.h \

View File

@@ -42,8 +42,6 @@ QtcPlugin {
"clangstaticanalyzerprojectsettingswidget.ui",
"clangstaticanalyzerruncontrol.cpp",
"clangstaticanalyzerruncontrol.h",
"clangstaticanalyzerruncontrolfactory.cpp",
"clangstaticanalyzerruncontrolfactory.h",
"clangstaticanalyzerrunner.cpp",
"clangstaticanalyzerrunner.h",
"clangstaticanalyzersettings.cpp",

View File

@@ -28,7 +28,7 @@
#include "clangstaticanalyzerconfigwidget.h"
#include "clangstaticanalyzerconstants.h"
#include "clangstaticanalyzerprojectsettingswidget.h"
#include "clangstaticanalyzerruncontrolfactory.h"
#include "clangstaticanalyzerruncontrol.h"
#include "clangstaticanalyzertool.h"
#ifdef WITH_TESTS
@@ -36,7 +36,8 @@
#include "clangstaticanalyzerunittests.h"
#endif
#include <debugger/analyzer/analyzermanager.h>
#include <utils/qtcassert.h>
#include <coreplugin/icore.h>
#include <coreplugin/icontext.h>
#include <coreplugin/actionmanager/actionmanager.h>
@@ -44,7 +45,10 @@
#include <coreplugin/actionmanager/actioncontainer.h>
#include <coreplugin/coreconstants.h>
#include <coreplugin/dialogs/ioptionspage.h>
#include <projectexplorer/kitinformation.h>
#include <projectexplorer/projectpanelfactory.h>
#include <projectexplorer/target.h>
#include <QAction>
#include <QDebug>
@@ -54,7 +58,6 @@
#include <QtPlugin>
using namespace Debugger;
using namespace ProjectExplorer;
namespace ClangStaticAnalyzer {
@@ -125,9 +128,23 @@ bool ClangStaticAnalyzerPlugin::initialize(const QStringList &arguments, QString
ProjectPanelFactory::registerFactory(panelFactory);
addAutoReleasedObject(new ClangStaticAnalyzerTool);
addAutoReleasedObject(new ClangStaticAnalyzerRunControlFactory);
addAutoReleasedObject(new ClangStaticAnalyzerOptionsPage);
auto constraint = [](RunConfiguration *runConfiguration) {
Target *target = runConfiguration->target();
QTC_ASSERT(target, return false);
Project *project = target->project();
QTC_ASSERT(project, return false);
const Core::Id cxx = ProjectExplorer::Constants::CXX_LANGUAGE_ID;
return project->projectLanguages().contains(cxx)
&& ToolChainKitInformation::toolChain(target->kit(), cxx);
};
RunControl::registerWorker<ClangStaticAnalyzerToolRunner>
(Constants::CLANGSTATICANALYZER_RUN_MODE, constraint);
return true;
}

View File

@@ -69,8 +69,7 @@ static Q_LOGGING_CATEGORY(LOG, "qtc.clangstaticanalyzer.runcontrol")
namespace ClangStaticAnalyzer {
namespace Internal {
ClangStaticAnalyzerToolRunner::ClangStaticAnalyzerToolRunner(RunControl *runControl,
QString *errorMessage)
ClangStaticAnalyzerToolRunner::ClangStaticAnalyzerToolRunner(RunControl *runControl)
: RunWorker(runControl)
{
setDisplayName("ClangStaticAnalyzerRunner");
@@ -102,11 +101,9 @@ ClangStaticAnalyzerToolRunner::ClangStaticAnalyzerToolRunner(RunControl *runCont
// or even gone, so better stop here.
tool->resetCursorAndProjectInfoBeforeBuild();
if (errorMessage) {
*errorMessage = tr(
reportFailure(tr(
"The project configuration changed since the start of the Clang Static Analyzer. "
"Please re-run with current configuration.");
}
"Please re-run with current configuration."));
return;
}

View File

@@ -52,7 +52,7 @@ class ClangStaticAnalyzerToolRunner : public ProjectExplorer::RunWorker
Q_OBJECT
public:
ClangStaticAnalyzerToolRunner(ProjectExplorer::RunControl *runControl, QString *errorMessage);
explicit ClangStaticAnalyzerToolRunner(ProjectExplorer::RunControl *runControl);
void start() override;
void stop() override;

View File

@@ -1,70 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
****************************************************************************/
#include "clangstaticanalyzerruncontrolfactory.h"
#include "clangstaticanalyzerconstants.h"
#include "clangstaticanalyzerruncontrol.h"
#include <coreplugin/icontext.h>
#include <projectexplorer/kitinformation.h>
#include <projectexplorer/target.h>
#include <utils/qtcassert.h>
using namespace ProjectExplorer;
namespace ClangStaticAnalyzer {
namespace Internal {
bool ClangStaticAnalyzerRunControlFactory::canRun(RunConfiguration *runConfiguration,
Core::Id runMode) const
{
if (runMode != Constants::CLANGSTATICANALYZER_RUN_MODE)
return false;
Target *target = runConfiguration->target();
QTC_ASSERT(target, return false);
Project *project = target->project();
QTC_ASSERT(project, return false);
const Core::Id cxx = ProjectExplorer::Constants::CXX_LANGUAGE_ID;
return project->projectLanguages().contains(cxx)
&& ToolChainKitInformation::toolChain(target->kit(), cxx);
}
RunControl *ClangStaticAnalyzerRunControlFactory::create(RunConfiguration *runConfiguration,
Core::Id runMode,
QString *errorMessage)
{
auto runControl = new RunControl(runConfiguration, runMode);
(void) new ClangStaticAnalyzerToolRunner(runControl, errorMessage);
return runControl;
}
} // namespace Internal
} // namespace ClangStaticAnalyzer

View File

@@ -1,46 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
****************************************************************************/
#pragma once
#include <projectexplorer/runconfiguration.h>
namespace ClangStaticAnalyzer {
namespace Internal {
class ClangStaticAnalyzerRunControlFactory : public ProjectExplorer::IRunControlFactory
{
Q_OBJECT
public:
bool canRun(ProjectExplorer::RunConfiguration *runConfiguration,
Core::Id runMode) const override;
ProjectExplorer::RunControl *create(ProjectExplorer::RunConfiguration *runConfiguration,
Core::Id runMode, QString *errorMessage) override;
};
} // namespace Internal
} // namespace ClangStaticAnalyzer