forked from qt-creator/qt-creator
ClangStaticAnalyzer: Adapt to new simpler RunControl creation
Change-Id: Ib088828a9695938afb83bcdd2d5fd4124dd602a8 Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
This commit is contained in:
@@ -11,7 +11,6 @@ SOURCES += \
|
|||||||
clangstaticanalyzerprojectsettingsmanager.cpp \
|
clangstaticanalyzerprojectsettingsmanager.cpp \
|
||||||
clangstaticanalyzerprojectsettingswidget.cpp \
|
clangstaticanalyzerprojectsettingswidget.cpp \
|
||||||
clangstaticanalyzerruncontrol.cpp \
|
clangstaticanalyzerruncontrol.cpp \
|
||||||
clangstaticanalyzerruncontrolfactory.cpp \
|
|
||||||
clangstaticanalyzerrunner.cpp \
|
clangstaticanalyzerrunner.cpp \
|
||||||
clangstaticanalyzersettings.cpp \
|
clangstaticanalyzersettings.cpp \
|
||||||
clangstaticanalyzertool.cpp \
|
clangstaticanalyzertool.cpp \
|
||||||
@@ -29,7 +28,6 @@ HEADERS += \
|
|||||||
clangstaticanalyzerprojectsettings.h \
|
clangstaticanalyzerprojectsettings.h \
|
||||||
clangstaticanalyzerprojectsettingsmanager.h \
|
clangstaticanalyzerprojectsettingsmanager.h \
|
||||||
clangstaticanalyzerprojectsettingswidget.h \
|
clangstaticanalyzerprojectsettingswidget.h \
|
||||||
clangstaticanalyzerruncontrolfactory.h \
|
|
||||||
clangstaticanalyzerruncontrol.h \
|
clangstaticanalyzerruncontrol.h \
|
||||||
clangstaticanalyzerrunner.h \
|
clangstaticanalyzerrunner.h \
|
||||||
clangstaticanalyzersettings.h \
|
clangstaticanalyzersettings.h \
|
||||||
|
|||||||
@@ -42,8 +42,6 @@ QtcPlugin {
|
|||||||
"clangstaticanalyzerprojectsettingswidget.ui",
|
"clangstaticanalyzerprojectsettingswidget.ui",
|
||||||
"clangstaticanalyzerruncontrol.cpp",
|
"clangstaticanalyzerruncontrol.cpp",
|
||||||
"clangstaticanalyzerruncontrol.h",
|
"clangstaticanalyzerruncontrol.h",
|
||||||
"clangstaticanalyzerruncontrolfactory.cpp",
|
|
||||||
"clangstaticanalyzerruncontrolfactory.h",
|
|
||||||
"clangstaticanalyzerrunner.cpp",
|
"clangstaticanalyzerrunner.cpp",
|
||||||
"clangstaticanalyzerrunner.h",
|
"clangstaticanalyzerrunner.h",
|
||||||
"clangstaticanalyzersettings.cpp",
|
"clangstaticanalyzersettings.cpp",
|
||||||
|
|||||||
@@ -28,7 +28,7 @@
|
|||||||
#include "clangstaticanalyzerconfigwidget.h"
|
#include "clangstaticanalyzerconfigwidget.h"
|
||||||
#include "clangstaticanalyzerconstants.h"
|
#include "clangstaticanalyzerconstants.h"
|
||||||
#include "clangstaticanalyzerprojectsettingswidget.h"
|
#include "clangstaticanalyzerprojectsettingswidget.h"
|
||||||
#include "clangstaticanalyzerruncontrolfactory.h"
|
#include "clangstaticanalyzerruncontrol.h"
|
||||||
#include "clangstaticanalyzertool.h"
|
#include "clangstaticanalyzertool.h"
|
||||||
|
|
||||||
#ifdef WITH_TESTS
|
#ifdef WITH_TESTS
|
||||||
@@ -36,7 +36,8 @@
|
|||||||
#include "clangstaticanalyzerunittests.h"
|
#include "clangstaticanalyzerunittests.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <debugger/analyzer/analyzermanager.h>
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
#include <coreplugin/icontext.h>
|
#include <coreplugin/icontext.h>
|
||||||
#include <coreplugin/actionmanager/actionmanager.h>
|
#include <coreplugin/actionmanager/actionmanager.h>
|
||||||
@@ -44,7 +45,10 @@
|
|||||||
#include <coreplugin/actionmanager/actioncontainer.h>
|
#include <coreplugin/actionmanager/actioncontainer.h>
|
||||||
#include <coreplugin/coreconstants.h>
|
#include <coreplugin/coreconstants.h>
|
||||||
#include <coreplugin/dialogs/ioptionspage.h>
|
#include <coreplugin/dialogs/ioptionspage.h>
|
||||||
|
|
||||||
|
#include <projectexplorer/kitinformation.h>
|
||||||
#include <projectexplorer/projectpanelfactory.h>
|
#include <projectexplorer/projectpanelfactory.h>
|
||||||
|
#include <projectexplorer/target.h>
|
||||||
|
|
||||||
#include <QAction>
|
#include <QAction>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
@@ -54,7 +58,6 @@
|
|||||||
|
|
||||||
#include <QtPlugin>
|
#include <QtPlugin>
|
||||||
|
|
||||||
using namespace Debugger;
|
|
||||||
using namespace ProjectExplorer;
|
using namespace ProjectExplorer;
|
||||||
|
|
||||||
namespace ClangStaticAnalyzer {
|
namespace ClangStaticAnalyzer {
|
||||||
@@ -125,9 +128,23 @@ bool ClangStaticAnalyzerPlugin::initialize(const QStringList &arguments, QString
|
|||||||
ProjectPanelFactory::registerFactory(panelFactory);
|
ProjectPanelFactory::registerFactory(panelFactory);
|
||||||
|
|
||||||
addAutoReleasedObject(new ClangStaticAnalyzerTool);
|
addAutoReleasedObject(new ClangStaticAnalyzerTool);
|
||||||
addAutoReleasedObject(new ClangStaticAnalyzerRunControlFactory);
|
|
||||||
addAutoReleasedObject(new ClangStaticAnalyzerOptionsPage);
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -69,8 +69,7 @@ static Q_LOGGING_CATEGORY(LOG, "qtc.clangstaticanalyzer.runcontrol")
|
|||||||
namespace ClangStaticAnalyzer {
|
namespace ClangStaticAnalyzer {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
ClangStaticAnalyzerToolRunner::ClangStaticAnalyzerToolRunner(RunControl *runControl,
|
ClangStaticAnalyzerToolRunner::ClangStaticAnalyzerToolRunner(RunControl *runControl)
|
||||||
QString *errorMessage)
|
|
||||||
: RunWorker(runControl)
|
: RunWorker(runControl)
|
||||||
{
|
{
|
||||||
setDisplayName("ClangStaticAnalyzerRunner");
|
setDisplayName("ClangStaticAnalyzerRunner");
|
||||||
@@ -102,11 +101,9 @@ ClangStaticAnalyzerToolRunner::ClangStaticAnalyzerToolRunner(RunControl *runCont
|
|||||||
// or even gone, so better stop here.
|
// or even gone, so better stop here.
|
||||||
|
|
||||||
tool->resetCursorAndProjectInfoBeforeBuild();
|
tool->resetCursorAndProjectInfoBeforeBuild();
|
||||||
if (errorMessage) {
|
reportFailure(tr(
|
||||||
*errorMessage = tr(
|
|
||||||
"The project configuration changed since the start of the Clang Static Analyzer. "
|
"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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ class ClangStaticAnalyzerToolRunner : public ProjectExplorer::RunWorker
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ClangStaticAnalyzerToolRunner(ProjectExplorer::RunControl *runControl, QString *errorMessage);
|
explicit ClangStaticAnalyzerToolRunner(ProjectExplorer::RunControl *runControl);
|
||||||
|
|
||||||
void start() override;
|
void start() override;
|
||||||
void stop() override;
|
void stop() override;
|
||||||
|
|||||||
@@ -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
|
|
||||||
@@ -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
|
|
||||||
Reference in New Issue
Block a user