GenericProject: Make dependency on CppTools optional

Especially in the light of the language server, the generic project is
currently the project one can use for language servers that require a
"project workspace".

Makes it possibly to run Qt Creator with
"-noload CppTools" if you still want to use generic
projects with some other language.

Change-Id: Ib9059289a2db4c44c0c1060a02fcdafacb885fbd
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
This commit is contained in:
Eike Ziller
2019-08-29 11:34:13 +02:00
parent 3beab5c985
commit b6c2277146
15 changed files with 110 additions and 210 deletions

View File

@@ -61,6 +61,7 @@ add_qtc_plugin(CppTools
cppprojectinfogenerator.cpp cppprojectinfogenerator.h
cppprojectpartchooser.cpp cppprojectpartchooser.h
cppprojectupdater.cpp cppprojectupdater.h
cppprojectupdaterinterface.h
cppqtstyleindenter.cpp cppqtstyleindenter.h
cpprefactoringchanges.cpp cpprefactoringchanges.h
cpprefactoringengine.cpp cpprefactoringengine.h

View File

@@ -101,4 +101,14 @@ void CppProjectUpdater::onProjectInfoGenerated()
QTC_CHECK(future != QFuture<void>());
}
CppProjectUpdaterFactory::CppProjectUpdaterFactory()
{
setObjectName("CppProjectUpdaterFactory");
}
CppProjectUpdaterInterface *CppProjectUpdaterFactory::create()
{
return new CppProjectUpdater;
}
} // namespace CppTools

View File

@@ -25,6 +25,7 @@
#pragma once
#include "cppprojectupdaterinterface.h"
#include "cpptools_global.h"
#include "projectinfo.h"
@@ -35,7 +36,18 @@ namespace CppTools {
class ProjectInfo;
class CPPTOOLS_EXPORT CppProjectUpdater : public QObject
// registered in extensionsystem's object pool for plugins with weak dependency to CppTools
class CPPTOOLS_EXPORT CppProjectUpdaterFactory : public QObject
{
Q_OBJECT
public:
CppProjectUpdaterFactory();
// keep the namespace, for the type name in the invokeMethod call
Q_INVOKABLE CppTools::CppProjectUpdaterInterface *create();
};
class CPPTOOLS_EXPORT CppProjectUpdater : public QObject, public CppProjectUpdaterInterface
{
Q_OBJECT
@@ -43,8 +55,8 @@ public:
CppProjectUpdater();
~CppProjectUpdater() override;
void update(const ProjectExplorer::ProjectUpdateInfo &projectUpdateInfo);
void cancel();
void update(const ProjectExplorer::ProjectUpdateInfo &projectUpdateInfo) override;
void cancel() override;
private:
void cancelAndWaitForFinished();

View File

@@ -0,0 +1,41 @@
/****************************************************************************
**
** 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/rawprojectpart.h>
namespace CppTools {
class CppProjectUpdaterInterface
{
public:
virtual ~CppProjectUpdaterInterface() = default;
virtual void update(const ProjectExplorer::ProjectUpdateInfo &projectUpdateInfo) = 0;
virtual void cancel() = 0;
};
} // namespace CppTools

View File

@@ -53,6 +53,7 @@ HEADERS += \
cpppointerdeclarationformatter.h \
cppprojectfile.h \
cppprojectupdater.h \
cppprojectupdaterinterface.h \
cppqtstyleindenter.h \
cpprefactoringchanges.h \
cpprefactoringengine.h \

View File

@@ -140,6 +140,7 @@ Project {
"cppprojectpartchooser.h",
"cppprojectupdater.cpp",
"cppprojectupdater.h",
"cppprojectupdaterinterface.h",
"cppqtstyleindenter.cpp",
"cppqtstyleindenter.h",
"cpprefactoringchanges.cpp",

View File

@@ -23,31 +23,33 @@
**
****************************************************************************/
#include "cpptoolsconstants.h"
#include "cpptoolsplugin.h"
#include "cppfilesettingspage.h"
#include "cppcodemodelsettingspage.h"
#include "cppcodestylesettingspage.h"
#include "cppfilesettingspage.h"
#include "cppmodelmanager.h"
#include "cpptoolsjsextension.h"
#include "cpptoolssettings.h"
#include "cpptoolsreuse.h"
#include "cppprojectfile.h"
#include "cppprojectupdater.h"
#include "cpptoolsbridge.h"
#include "cpptoolsbridgeqtcreatorimplementation.h"
#include "cpptoolsconstants.h"
#include "cpptoolsjsextension.h"
#include "cpptoolsreuse.h"
#include "cpptoolssettings.h"
#include "projectinfo.h"
#include "stringtable.h"
#include "cpptoolsbridgeqtcreatorimplementation.h"
#include <coreplugin/actionmanager/actioncontainer.h>
#include <coreplugin/actionmanager/actionmanager.h>
#include <coreplugin/editormanager/editormanager.h>
#include <coreplugin/coreconstants.h>
#include <coreplugin/documentmanager.h>
#include <coreplugin/editormanager/editormanager.h>
#include <coreplugin/icore.h>
#include <coreplugin/idocument.h>
#include <coreplugin/jsexpander.h>
#include <coreplugin/vcsmanager.h>
#include <cppeditor/cppeditorconstants.h>
#include <extensionsystem/pluginmanager.h>
#include <projectexplorer/project.h>
#include <projectexplorer/projecttree.h>
@@ -97,6 +99,7 @@ public:
delete m_cppCodeModelSettingsPage;
if (m_cppCodeStyleSettingsPage)
delete m_cppCodeStyleSettingsPage;
ExtensionSystem::PluginManager::removeObject(&m_cppProjectUpdaterFactory);
}
QSharedPointer<CppCodeModelSettings> m_codeModelSettings;
@@ -104,6 +107,7 @@ public:
CppFileSettingsPage *m_cppFileSettingsPage = nullptr;
CppCodeModelSettingsPage *m_cppCodeModelSettingsPage = nullptr;
QPointer<CppCodeStyleSettingsPage> m_cppCodeStyleSettingsPage = nullptr;
CppProjectUpdaterFactory m_cppProjectUpdaterFactory;
};
CppToolsPlugin::CppToolsPlugin()
@@ -173,6 +177,7 @@ bool CppToolsPlugin::initialize(const QStringList &arguments, QString *error)
d = new CppToolsPluginPrivate;
JsExpander::registerGlobalObject<CppToolsJsExtension>("Cpp");
ExtensionSystem::PluginManager::addObject(&d->m_cppProjectUpdaterFactory);
// Menus
ActionContainer *mtools = ActionManager::actionContainer(Core::Constants::M_TOOLS);