2014-09-25 11:11:58 +02:00
|
|
|
/****************************************************************************
|
|
|
|
|
**
|
2016-01-14 10:59:10 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2014-09-25 11:11:58 +02:00
|
|
|
**
|
2016-01-14 10:59:10 +01:00
|
|
|
** This file is part of Qt Creator.
|
2014-09-25 11:11:58 +02:00
|
|
|
**
|
2016-01-14 10:59:10 +01:00
|
|
|
** Commercial License Usage
|
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
|
** accordance with the commercial license agreement provided with the
|
2014-09-25 11:11:58 +02:00
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
2016-01-14 10:59:10 +01:00
|
|
|
** 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.
|
2014-09-25 11:11:58 +02:00
|
|
|
**
|
2016-01-14 10:59:10 +01:00
|
|
|
** 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.
|
2014-09-25 11:11:58 +02:00
|
|
|
**
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
2018-03-14 12:58:12 +01:00
|
|
|
#include "clangtoolsplugin.h"
|
2014-09-25 11:11:58 +02:00
|
|
|
|
|
|
|
|
#include "clangstaticanalyzerconfigwidget.h"
|
2018-01-17 15:08:30 +01:00
|
|
|
#include "clangtoolsconstants.h"
|
2015-02-19 18:08:38 +01:00
|
|
|
#include "clangstaticanalyzerprojectsettingswidget.h"
|
2017-06-16 15:21:17 +02:00
|
|
|
#include "clangstaticanalyzerruncontrol.h"
|
2014-09-25 11:11:58 +02:00
|
|
|
#include "clangstaticanalyzertool.h"
|
2018-01-17 15:08:30 +01:00
|
|
|
#include "clangtidyclazytool.h"
|
2014-09-25 11:11:58 +02:00
|
|
|
|
2015-02-04 15:19:30 +01:00
|
|
|
#ifdef WITH_TESTS
|
2016-07-08 12:07:53 +02:00
|
|
|
#include "clangstaticanalyzerpreconfiguredsessiontests.h"
|
2015-02-04 15:19:30 +01:00
|
|
|
#include "clangstaticanalyzerunittests.h"
|
|
|
|
|
#endif
|
|
|
|
|
|
2018-04-23 19:06:13 +02:00
|
|
|
#include <debugger/analyzer/analyzericons.h>
|
|
|
|
|
|
2017-06-16 15:21:17 +02:00
|
|
|
#include <utils/qtcassert.h>
|
|
|
|
|
|
2014-09-25 11:11:58 +02:00
|
|
|
#include <coreplugin/icore.h>
|
|
|
|
|
#include <coreplugin/icontext.h>
|
|
|
|
|
#include <coreplugin/actionmanager/actionmanager.h>
|
|
|
|
|
#include <coreplugin/actionmanager/command.h>
|
|
|
|
|
#include <coreplugin/actionmanager/actioncontainer.h>
|
|
|
|
|
#include <coreplugin/coreconstants.h>
|
|
|
|
|
#include <coreplugin/dialogs/ioptionspage.h>
|
2017-06-16 15:21:17 +02:00
|
|
|
|
|
|
|
|
#include <projectexplorer/kitinformation.h>
|
2015-02-19 18:08:38 +01:00
|
|
|
#include <projectexplorer/projectpanelfactory.h>
|
2017-06-16 15:21:17 +02:00
|
|
|
#include <projectexplorer/target.h>
|
2014-09-25 11:11:58 +02:00
|
|
|
|
|
|
|
|
#include <QAction>
|
|
|
|
|
#include <QDebug>
|
|
|
|
|
#include <QMainWindow>
|
|
|
|
|
#include <QMessageBox>
|
|
|
|
|
#include <QMenu>
|
|
|
|
|
|
|
|
|
|
#include <QtPlugin>
|
|
|
|
|
|
2016-07-22 15:53:01 +02:00
|
|
|
using namespace ProjectExplorer;
|
2014-09-25 11:11:58 +02:00
|
|
|
|
2018-03-14 12:58:12 +01:00
|
|
|
namespace ClangTools {
|
2014-09-25 11:11:58 +02:00
|
|
|
namespace Internal {
|
|
|
|
|
|
|
|
|
|
class ClangStaticAnalyzerOptionsPage : public Core::IOptionsPage
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
explicit ClangStaticAnalyzerOptionsPage()
|
|
|
|
|
{
|
|
|
|
|
setId("Analyzer.ClangStaticAnalyzer.Settings"); // TODO: Get it from "clangstaticanalyzersettings.h"
|
|
|
|
|
setDisplayName(QCoreApplication::translate(
|
2018-03-14 12:58:12 +01:00
|
|
|
"ClangTools::Internal::ClangStaticAnalyzerOptionsPage",
|
2014-09-25 11:11:58 +02:00
|
|
|
"Clang Static Analyzer"));
|
|
|
|
|
setCategory("T.Analyzer");
|
|
|
|
|
setDisplayCategory(QCoreApplication::translate("Analyzer", "Analyzer"));
|
2018-04-23 19:06:13 +02:00
|
|
|
setCategoryIcon(Analyzer::Icons::SETTINGSCATEGORY_ANALYZER);
|
2014-09-25 11:11:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QWidget *widget()
|
|
|
|
|
{
|
|
|
|
|
if (!m_widget)
|
2018-01-17 15:08:30 +01:00
|
|
|
m_widget = new ClangStaticAnalyzerConfigWidget(ClangToolsSettings::instance());
|
2014-09-25 11:11:58 +02:00
|
|
|
return m_widget;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void apply()
|
|
|
|
|
{
|
2018-01-17 15:08:30 +01:00
|
|
|
ClangToolsSettings::instance()->writeSettings();
|
2014-09-25 11:11:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void finish()
|
|
|
|
|
{
|
|
|
|
|
delete m_widget;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
QPointer<QWidget> m_widget;
|
|
|
|
|
};
|
|
|
|
|
|
2018-03-14 12:58:12 +01:00
|
|
|
class ClangToolsPluginPrivate
|
2014-09-25 11:11:58 +02:00
|
|
|
{
|
2018-02-07 10:03:16 +01:00
|
|
|
public:
|
2018-01-17 15:08:30 +01:00
|
|
|
ClangStaticAnalyzerTool staticAnalyzerTool;
|
2018-01-17 15:08:30 +01:00
|
|
|
ClangTidyClazyTool clangTidyClazyTool;
|
2018-02-07 10:03:16 +01:00
|
|
|
ClangStaticAnalyzerOptionsPage optionsPage;
|
|
|
|
|
};
|
2014-09-25 11:11:58 +02:00
|
|
|
|
2018-03-14 12:58:12 +01:00
|
|
|
ClangToolsPlugin::~ClangToolsPlugin()
|
2014-09-25 11:11:58 +02:00
|
|
|
{
|
2018-02-07 10:03:16 +01:00
|
|
|
delete d;
|
2014-09-25 11:11:58 +02:00
|
|
|
}
|
|
|
|
|
|
2018-03-14 12:58:12 +01:00
|
|
|
bool ClangToolsPlugin::initialize(const QStringList &arguments, QString *errorString)
|
2014-09-25 11:11:58 +02:00
|
|
|
{
|
2016-01-21 20:24:55 +02:00
|
|
|
Q_UNUSED(arguments);
|
|
|
|
|
Q_UNUSED(errorString);
|
|
|
|
|
|
2018-03-14 12:58:12 +01:00
|
|
|
d = new ClangToolsPluginPrivate;
|
2018-02-07 10:03:16 +01:00
|
|
|
|
2016-07-22 15:53:01 +02:00
|
|
|
auto panelFactory = new ProjectPanelFactory();
|
2015-02-19 18:08:38 +01:00
|
|
|
panelFactory->setPriority(100);
|
2018-01-17 15:08:30 +01:00
|
|
|
panelFactory->setDisplayName(tr("Clang Tools"));
|
2016-07-22 15:53:01 +02:00
|
|
|
panelFactory->setCreateWidgetFunction([](Project *project) { return new ProjectSettingsWidget(project); });
|
|
|
|
|
ProjectPanelFactory::registerFactory(panelFactory);
|
2014-09-25 11:11:58 +02:00
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2018-03-14 12:58:12 +01:00
|
|
|
QList<QObject *> ClangToolsPlugin::createTestObjects() const
|
2015-02-04 15:19:30 +01:00
|
|
|
{
|
|
|
|
|
QList<QObject *> tests;
|
|
|
|
|
#ifdef WITH_TESTS
|
2017-05-08 09:21:48 +02:00
|
|
|
tests << new ClangStaticAnalyzerPreconfiguredSessionTests;
|
|
|
|
|
tests << new ClangStaticAnalyzerUnitTests;
|
2015-02-04 15:19:30 +01:00
|
|
|
#endif
|
|
|
|
|
return tests;
|
|
|
|
|
}
|
|
|
|
|
|
2014-09-25 11:11:58 +02:00
|
|
|
} // namespace Internal
|
2018-03-14 12:58:12 +01:00
|
|
|
} // namespace ClangTools
|