forked from qt-creator/qt-creator
QtSupport: Use setup pattern for UIC and SCXML extracompilers
Change-Id: I4727333e9716eae41ea41a37f032fb44b383212c Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
@@ -5,6 +5,8 @@
|
||||
|
||||
#include <qtsupport/baseqtversion.h>
|
||||
#include <qtsupport/qtkitaspect.h>
|
||||
|
||||
#include <projectexplorer/extracompiler.h>
|
||||
#include <projectexplorer/target.h>
|
||||
|
||||
#include <utils/qtcassert.h>
|
||||
@@ -16,7 +18,7 @@
|
||||
using namespace ProjectExplorer;
|
||||
using namespace Utils;
|
||||
|
||||
namespace QtSupport {
|
||||
namespace QtSupport::Internal {
|
||||
|
||||
static QLoggingCategory log("qtc.qscxmlcgenerator", QtWarningMsg);
|
||||
|
||||
@@ -85,12 +87,9 @@ Tasks QScxmlcGenerator::parseIssues(const QByteArray &processStderr)
|
||||
|
||||
FilePath QScxmlcGenerator::command() const
|
||||
{
|
||||
QtSupport::QtVersion *version = nullptr;
|
||||
Target *target;
|
||||
if ((target = project()->activeTarget()))
|
||||
version = QtSupport::QtKitAspect::qtVersion(target->kit());
|
||||
else
|
||||
version = QtSupport::QtKitAspect::qtVersion(KitManager::defaultKit());
|
||||
Target *target = project()->activeTarget();
|
||||
Kit *kit = target ? target->kit() : KitManager::defaultKit();
|
||||
QtVersion *version = QtKitAspect::qtVersion(kit);
|
||||
|
||||
if (!version)
|
||||
return {};
|
||||
@@ -125,21 +124,28 @@ FileNameToContentsHash QScxmlcGenerator::handleProcessFinished(Process *process)
|
||||
return result;
|
||||
}
|
||||
|
||||
FileType QScxmlcGeneratorFactory::sourceType() const
|
||||
// QScxmlcGeneratorFactory
|
||||
|
||||
class QScxmlcGeneratorFactory final : public ExtraCompilerFactory
|
||||
{
|
||||
return FileType::StateChart;
|
||||
public:
|
||||
QScxmlcGeneratorFactory() = default;
|
||||
|
||||
FileType sourceType() const final { return FileType::StateChart; }
|
||||
|
||||
QString sourceTag() const final { return QStringLiteral("scxml"); }
|
||||
|
||||
ExtraCompiler *create(const Project *project,
|
||||
const FilePath &source,
|
||||
const FilePaths &targets) final
|
||||
{
|
||||
return new QScxmlcGenerator(project, source, targets, this);
|
||||
}
|
||||
};
|
||||
|
||||
void setupQScxmlcGenerator()
|
||||
{
|
||||
static QScxmlcGeneratorFactory theQScxmlcGeneratorFactory;
|
||||
}
|
||||
|
||||
QString QScxmlcGeneratorFactory::sourceTag() const
|
||||
{
|
||||
return QStringLiteral("scxml");
|
||||
}
|
||||
|
||||
ExtraCompiler *QScxmlcGeneratorFactory::create(
|
||||
const Project *project, const FilePath &source,
|
||||
const FilePaths &targets)
|
||||
{
|
||||
return new QScxmlcGenerator(project, source, targets, this);
|
||||
}
|
||||
|
||||
} // namespace QtSupport
|
||||
} // QtSupport::Internal
|
||||
|
@@ -3,24 +3,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <projectexplorer/extracompiler.h>
|
||||
namespace QtSupport::Internal {
|
||||
|
||||
#include <utils/filepath.h>
|
||||
void setupQScxmlcGenerator();
|
||||
|
||||
namespace QtSupport {
|
||||
|
||||
class QScxmlcGeneratorFactory : public ProjectExplorer::ExtraCompilerFactory
|
||||
{
|
||||
public:
|
||||
QScxmlcGeneratorFactory() = default;
|
||||
|
||||
ProjectExplorer::FileType sourceType() const override;
|
||||
|
||||
QString sourceTag() const override;
|
||||
|
||||
ProjectExplorer::ExtraCompiler *create(const ProjectExplorer::Project *project,
|
||||
const Utils::FilePath &source,
|
||||
const Utils::FilePaths &targets) override;
|
||||
};
|
||||
|
||||
} // QtSupport
|
||||
} // QtSupport::Internal
|
||||
|
@@ -48,9 +48,6 @@ namespace QtSupport::Internal {
|
||||
class QtSupportPluginPrivate
|
||||
{
|
||||
public:
|
||||
UicGeneratorFactory uicGeneratorFactory;
|
||||
QScxmlcGeneratorFactory qscxmlcGeneratorFactory;
|
||||
|
||||
DesignerExternalEditor designerEditor;
|
||||
LinguistEditor linguistEditor;
|
||||
|
||||
@@ -109,6 +106,8 @@ void QtSupportPlugin::initialize()
|
||||
setupGettingStartedWelcomePage();
|
||||
setupQtSettingsPage();
|
||||
setupQtOutputFormatter();
|
||||
setupUicGenerator();
|
||||
setupQScxmlcGenerator();
|
||||
|
||||
theProcessRunner() = processRunnerCallback;
|
||||
|
||||
|
@@ -7,6 +7,7 @@
|
||||
#include "qtkitaspect.h"
|
||||
|
||||
#include <projectexplorer/buildconfiguration.h>
|
||||
#include <projectexplorer/extracompiler.h>
|
||||
#include <projectexplorer/kitmanager.h>
|
||||
#include <projectexplorer/target.h>
|
||||
|
||||
@@ -19,7 +20,7 @@
|
||||
using namespace ProjectExplorer;
|
||||
using namespace Utils;
|
||||
|
||||
namespace QtSupport {
|
||||
namespace QtSupport::Internal {
|
||||
|
||||
class UicGenerator final : public ProcessExtraCompiler
|
||||
{
|
||||
@@ -32,19 +33,16 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
FilePath command() const override;
|
||||
QStringList arguments() const override { return {"-p"}; }
|
||||
FileNameToContentsHash handleProcessFinished(Process *process) override;
|
||||
FilePath command() const final;
|
||||
QStringList arguments() const final { return {"-p"}; }
|
||||
FileNameToContentsHash handleProcessFinished(Process *process) final;
|
||||
};
|
||||
|
||||
FilePath UicGenerator::command() const
|
||||
{
|
||||
QtSupport::QtVersion *version = nullptr;
|
||||
Target *target;
|
||||
if ((target = project()->activeTarget()))
|
||||
version = QtSupport::QtKitAspect::qtVersion(target->kit());
|
||||
else
|
||||
version = QtSupport::QtKitAspect::qtVersion(KitManager::defaultKit());
|
||||
Target *target = project()->activeTarget();
|
||||
Kit *kit = target ? target->kit() : KitManager::defaultKit();
|
||||
QtVersion *version = QtKitAspect::qtVersion(kit);
|
||||
|
||||
if (!version)
|
||||
return {};
|
||||
@@ -69,21 +67,28 @@ FileNameToContentsHash UicGenerator::handleProcessFinished(Process *process)
|
||||
return result;
|
||||
}
|
||||
|
||||
FileType UicGeneratorFactory::sourceType() const
|
||||
// UicGeneratorFactory
|
||||
|
||||
class UicGeneratorFactory final : public ExtraCompilerFactory
|
||||
{
|
||||
return FileType::Form;
|
||||
public:
|
||||
UicGeneratorFactory() = default;
|
||||
|
||||
FileType sourceType() const final { return FileType::Form; }
|
||||
|
||||
QString sourceTag() const final { return QLatin1String("ui"); }
|
||||
|
||||
ExtraCompiler *create(const Project *project,
|
||||
const FilePath &source,
|
||||
const FilePaths &targets) final
|
||||
{
|
||||
return new UicGenerator(project, source, targets, this);
|
||||
}
|
||||
};
|
||||
|
||||
void setupUicGenerator()
|
||||
{
|
||||
static UicGeneratorFactory theUicGeneratorFactory;
|
||||
}
|
||||
|
||||
QString UicGeneratorFactory::sourceTag() const
|
||||
{
|
||||
return QLatin1String("ui");
|
||||
}
|
||||
|
||||
ExtraCompiler *UicGeneratorFactory::create(const Project *project,
|
||||
const FilePath &source,
|
||||
const FilePaths &targets)
|
||||
{
|
||||
return new UicGenerator(project, source, targets, this);
|
||||
}
|
||||
|
||||
} // QtSupport
|
||||
} // QtSupport::Internal
|
||||
|
@@ -3,23 +3,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <projectexplorer/extracompiler.h>
|
||||
#include <utils/filepath.h>
|
||||
namespace QtSupport::Internal {
|
||||
|
||||
namespace QtSupport {
|
||||
void setupUicGenerator();
|
||||
|
||||
class UicGeneratorFactory : public ProjectExplorer::ExtraCompilerFactory
|
||||
{
|
||||
public:
|
||||
UicGeneratorFactory() = default;
|
||||
|
||||
ProjectExplorer::FileType sourceType() const override;
|
||||
|
||||
QString sourceTag() const override;
|
||||
|
||||
ProjectExplorer::ExtraCompiler *create(const ProjectExplorer::Project *project,
|
||||
const Utils::FilePath &source,
|
||||
const Utils::FilePaths &targets) override;
|
||||
};
|
||||
|
||||
} // QtSupport
|
||||
} // QtSupport::Internal
|
||||
|
Reference in New Issue
Block a user