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
|
|
|
|
2018-04-30 16:07:59 +02:00
|
|
|
#include "clangtoolsconfigwidget.h"
|
2018-01-17 15:08:30 +01:00
|
|
|
#include "clangtoolsconstants.h"
|
2018-05-08 17:33:29 +02:00
|
|
|
#include "clangtoolsprojectsettingswidget.h"
|
2018-01-17 15:08:30 +01:00
|
|
|
#include "clangtidyclazytool.h"
|
2018-05-07 17:04:26 +02:00
|
|
|
#include "clangtoolsprojectsettings.h"
|
2014-09-25 11:11:58 +02:00
|
|
|
|
2015-02-04 15:19:30 +01:00
|
|
|
#ifdef WITH_TESTS
|
2018-05-08 17:33:29 +02:00
|
|
|
#include "clangtoolspreconfiguredsessiontests.h"
|
2018-04-24 15:30:19 +02:00
|
|
|
#include "clangtoolsunittests.h"
|
2015-02-04 15:19:30 +01:00
|
|
|
#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
|
|
|
|
2018-08-29 15:58:13 +02:00
|
|
|
#include <cpptools/cpptoolsconstants.h>
|
|
|
|
|
#include <cpptools/cppmodelmanager.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>
|
|
|
|
|
|
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 {
|
|
|
|
|
|
2018-04-30 16:07:59 +02:00
|
|
|
class ClangToolsOptionsPage : public Core::IOptionsPage
|
2014-09-25 11:11:58 +02:00
|
|
|
{
|
|
|
|
|
public:
|
2019-03-21 08:09:35 +01:00
|
|
|
ClangToolsOptionsPage()
|
2014-09-25 11:11:58 +02:00
|
|
|
{
|
2019-01-10 11:38:06 +01:00
|
|
|
setId(Constants::SETTINGS_PAGE_ID);
|
2014-09-25 11:11:58 +02:00
|
|
|
setDisplayName(QCoreApplication::translate(
|
2018-04-30 16:07:59 +02:00
|
|
|
"ClangTools::Internal::ClangToolsOptionsPage",
|
|
|
|
|
"Clang Tools"));
|
2014-09-25 11:11:58 +02:00
|
|
|
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
|
|
|
}
|
|
|
|
|
|
2018-11-04 22:30:54 +01:00
|
|
|
QWidget *widget() override
|
2014-09-25 11:11:58 +02:00
|
|
|
{
|
|
|
|
|
if (!m_widget)
|
2018-04-30 16:07:59 +02:00
|
|
|
m_widget = new ClangToolsConfigWidget(ClangToolsSettings::instance());
|
2014-09-25 11:11:58 +02:00
|
|
|
return m_widget;
|
|
|
|
|
}
|
|
|
|
|
|
2018-11-04 22:30:54 +01:00
|
|
|
void apply() override
|
2014-09-25 11:11:58 +02:00
|
|
|
{
|
2018-01-17 15:08:30 +01:00
|
|
|
ClangToolsSettings::instance()->writeSettings();
|
2014-09-25 11:11:58 +02:00
|
|
|
}
|
|
|
|
|
|
2018-11-04 22:30:54 +01:00
|
|
|
void finish() override
|
2014-09-25 11:11:58 +02:00
|
|
|
{
|
|
|
|
|
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
|
|
|
ClangTidyClazyTool clangTidyClazyTool;
|
2018-04-30 16:07:59 +02:00
|
|
|
ClangToolsOptionsPage optionsPage;
|
2018-05-07 17:04:26 +02:00
|
|
|
ClangToolsProjectSettingsManager settingsManager;
|
2018-02-07 10:03:16 +01:00
|
|
|
};
|
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
|
|
|
{
|
2019-07-23 10:58:00 +02:00
|
|
|
Q_UNUSED(arguments)
|
|
|
|
|
Q_UNUSED(errorString)
|
2016-01-21 20:24:55 +02:00
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2019-05-27 14:12:11 +02:00
|
|
|
QVector<QObject *> ClangToolsPlugin::createTestObjects() const
|
2015-02-04 15:19:30 +01:00
|
|
|
{
|
2019-05-27 14:12:11 +02:00
|
|
|
QVector<QObject *> tests;
|
2015-02-04 15:19:30 +01:00
|
|
|
#ifdef WITH_TESTS
|
2018-05-08 17:33:29 +02:00
|
|
|
tests << new PreconfiguredSessionTests;
|
2018-04-24 15:30:19 +02:00
|
|
|
tests << new ClangToolsUnitTests;
|
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
|