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

@@ -34,7 +34,9 @@
#include <coreplugin/icore.h>
#include <coreplugin/idocument.h>
#include <cpptools/cppprojectupdater.h>
#include <cpptools/cppprojectupdaterinterface.h>
#include <extensionsystem/pluginmanager.h>
#include <projectexplorer/abi.h>
#include <projectexplorer/buildsteplist.h>
@@ -59,6 +61,7 @@
#include <QDir>
#include <QFileInfo>
#include <QHash>
#include <QMetaObject>
#include <QSet>
#include <QStringList>
@@ -170,13 +173,23 @@ static bool writeFile(const QString &filePath, const QString &contents)
GenericProject::GenericProject(const Utils::FilePath &fileName)
: Project(Constants::GENERICMIMETYPE, fileName)
, m_cppCodeModelUpdater(new CppTools::CppProjectUpdater)
, m_deployFileWatcher(new FileSystemWatcher(this))
{
setId(Constants::GENERICPROJECT_ID);
setProjectLanguages(Context(ProjectExplorer::Constants::CXX_LANGUAGE_ID));
setDisplayName(fileName.toFileInfo().completeBaseName());
QObject *projectUpdaterFactory = ExtensionSystem::PluginManager::getObjectByName(
"CppProjectUpdaterFactory");
if (projectUpdaterFactory) {
const bool successFullyCreatedProjectUpdater
= QMetaObject::invokeMethod(projectUpdaterFactory,
"create",
Q_RETURN_ARG(CppTools::CppProjectUpdaterInterface *,
m_cppCodeModelUpdater));
QTC_CHECK(successFullyCreatedProjectUpdater);
}
connect(this, &GenericProject::projectFileIsDirty, this, [this](const FilePath &p) {
if (p.endsWith(".files"))
refresh(Files);
@@ -501,6 +514,8 @@ QStringList GenericProject::processEntries(const QStringList &paths,
void GenericProject::refreshCppCodeModel()
{
if (!m_cppCodeModelUpdater)
return;
QtSupport::CppKitInfo kitInfo(this);
QTC_ASSERT(kitInfo.isValid(), return);