Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: [generator] optimized project generator and open project #869

Merged
merged 2 commits into from
Aug 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
188 changes: 109 additions & 79 deletions assets/translations/en_US.ts

Large diffs are not rendered by default.

188 changes: 109 additions & 79 deletions assets/translations/zh_CN.ts

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions src/plugins/builder/mainframe/buildmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include <DGuiApplicationHelper>
#include <DComboBox>
#include <DFrame>
#include <DDialog>

#include <QSplitter>
#include <QCoreApplication>
Expand Down Expand Up @@ -391,6 +392,9 @@ void BuildManager::execBuildStep(QList<BuildMenuType> menuTypelist)
list.append(info);
}
execCommands(list, false);
} else {
auto windowService = dpfGetService(WindowService);
windowService->notify(1, tr("Warning"), tr("The project does not have an associated build kit. Please reopen the project and select the corresponding build tool."), {});
}
}
}
Expand Down
49 changes: 0 additions & 49 deletions src/plugins/cxx/ninja/project/ninjaasynparse.h

This file was deleted.

98 changes: 0 additions & 98 deletions src/plugins/cxx/ninja/project/ninjaprojectgenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,13 @@
// SPDX-License-Identifier: GPL-3.0-or-later

#include "ninjaprojectgenerator.h"
#include "ninjaasynparse.h"

#include "common/dialog/propertiesdialog.h"
#include "services/window/windowservice.h"
#include "services/builder/builderservice.h"
#include "services/option/optionmanager.h"

#include <QtConcurrent>
#include <QtXml>
#include <QFileIconProvider>

class NinjaProjectGeneratorPrivate
{
friend class NinjaProjectGenerator;
QStandardItem* configureRootItem {nullptr};
QMenu *ninjaMenu {nullptr};
QProcess *menuGenProcess {nullptr};
QHash<QStandardItem*, NinjaAsynParse*> projectParses {};
dpfservice::ProjectInfo prjInfo;
};

NinjaProjectGenerator::NinjaProjectGenerator()
: d(new NinjaProjectGeneratorPrivate())
{
qRegisterMetaType<QList<QStandardItem*>>("QList<QStandardItem*>");
using namespace dpfservice;
Expand All @@ -40,9 +24,6 @@ NinjaProjectGenerator::NinjaProjectGenerator()
NinjaProjectGenerator::~NinjaProjectGenerator()
{
qInfo() << __FUNCTION__;

if (d)
delete d;
}

QStringList NinjaProjectGenerator::supportLanguages()
Expand All @@ -55,87 +36,8 @@ QStringList NinjaProjectGenerator::supportFileNames()
return {"build.ninja"};
}

DWidget *NinjaProjectGenerator::configureWidget(const QString &language,
const QString &projectPath)
{
d->prjInfo.setLanguage(language);
d->prjInfo.setKitName(NinjaProjectGenerator::toolKitName());
d->prjInfo.setWorkspaceFolder(projectPath);

return nullptr;
}

void NinjaProjectGenerator::acceptConfigure()
{
configure(d->prjInfo);
}

bool NinjaProjectGenerator::configure(const dpfservice::ProjectInfo &info)
{
dpfservice::ProjectGenerator::configure(info);

auto root = createRootItem(info);
using namespace dpfservice;
auto &ctx = dpfInstance.serviceContext();
ProjectService *projectService = ctx.service<ProjectService>(ProjectService::name());
if (projectService && root) {
projectService->addRootItem(root);
projectService->expandedDepth(root, 1);
}

dpfservice::ProjectGenerator::configure(info);

return true;
}

QStandardItem *NinjaProjectGenerator::createRootItem(const dpfservice::ProjectInfo &info)
{
using namespace dpfservice;
QStandardItem * rootItem = ProjectGenerator::createRootItem(info);
dpfservice::ProjectInfo::set(rootItem, info);
d->projectParses[rootItem] = new NinjaAsynParse();
QObject::connect(d->projectParses[rootItem], &NinjaAsynParse::itemsModified,
this, &NinjaProjectGenerator::doProjectChildsModified);
QMetaObject::invokeMethod(d->projectParses[rootItem], "parseProject",
Q_ARG(const dpfservice::ProjectInfo &, info));
return rootItem;
}

void NinjaProjectGenerator::removeRootItem(QStandardItem *root)
{
if (!root)
return;
auto parser = d->projectParses[root];

while (root->hasChildren()) {
root->takeRow(0);
}
d->projectParses.remove(root);

delete root;

if (parser)
delete parser;
}

QMenu *NinjaProjectGenerator::createItemMenu(const QStandardItem *item)
{
Q_UNUSED(item)
return nullptr;
}

void NinjaProjectGenerator::doProjectChildsModified(const QList<QStandardItem *> &items)
{
auto rootItem = d->projectParses.key(qobject_cast<NinjaAsynParse*>(sender()));
if (rootItem) {
while (rootItem->hasChildren()) {
rootItem->takeRow(0);
}
for (auto &item : items) {
item->setIcon(CustomIcons::icon(item->toolTip()));
}

rootItem->appendRows(items);
}
rootItem->setData(ParsingState::Done, Parsing_State_Role);
}
16 changes: 3 additions & 13 deletions src/plugins/cxx/ninja/project/ninjaprojectgenerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,23 @@
#ifndef NINJAPROJECTGENERATOR_H
#define NINJAPROJECTGENERATOR_H

#include "ninjaasynparse.h"
#include "services/project/projectservice.h"
#include "services/project/directorygenerator.h"

#include <QObject>
#include <QDomDocument>

class NinjaProjectGeneratorPrivate;
class NinjaProjectGenerator : public dpfservice::ProjectGenerator
class NinjaProjectGenerator : public dpfservice::DirectoryGenerator
{
Q_OBJECT
NinjaProjectGeneratorPrivate *const d;
public:
explicit NinjaProjectGenerator();
virtual ~NinjaProjectGenerator() override;
static QString toolKitName() { return "ninja"; }
virtual QString configureKitName() { return "ninja"; }
virtual QStringList supportLanguages() override;
virtual QStringList supportFileNames() override;
virtual DWidget* configureWidget(const QString &language,
const QString &projectPath) override;
virtual void acceptConfigure() override;
virtual bool configure(const dpfservice::ProjectInfo &info = {}) override;
virtual QStandardItem *createRootItem(const dpfservice::ProjectInfo &info) override;
virtual void removeRootItem(QStandardItem* root) override;
virtual QMenu* createItemMenu(const QStandardItem *item) override;

private slots:
void doProjectChildsModified(const QList<QStandardItem*> &items);
};

#endif // NINJAPROJECTGENERATOR_H
4 changes: 4 additions & 0 deletions src/plugins/debugger/debugmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "interface/attachinfodialog.h"

#include "services/debugger/debuggerservice.h"
#include "services/window/windowservice.h"
#include "services/language/languageservice.h"
#include "services/editor/editorservice.h"
#include "common/util/custompaths.h"
Expand Down Expand Up @@ -105,6 +106,9 @@ void DebugManager::run()
currentDebugger = debuggers[debugger];
connect(currentDebugger, &AbstractDebugger::runStateChanged, this, &DebugManager::handleRunStateChanged);
}
} else {
auto windowService = dpfGetService(WindowService);
windowService->notify(1, tr("Warning"), tr("The project does not have an associated build kit. Please reopen the project and select the corresponding build tool."), {});
}
}
AsynInvoke(currentDebugger->startDebug());
Expand Down
4 changes: 4 additions & 0 deletions src/plugins/debugger/runner/runner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

#include <DComboBox>
#include <DGuiApplicationHelper>
#include <DDialog>

#include <QMenu>
#include <QTextBlock>
Expand Down Expand Up @@ -100,6 +101,9 @@ void Runner::run()
} else {
running();
}
} else {
auto windowService = dpfGetService(WindowService);
windowService->notify(1, tr("Warning"), tr("The project does not have an associated build kit. Please reopen the project and select the corresponding build tool."), {});
}
}
}
Expand Down
2 changes: 0 additions & 2 deletions src/plugins/javascript/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ set(javascript_CPP
javascriptplugin.cpp
jsgenerator.cpp
javascriptplugin.json
project/jsasynparse.cpp
project/jsprojectgenerator.cpp
project/properties/configpropertywidget.cpp
project/properties/configutil.cpp
Expand All @@ -18,7 +17,6 @@ set(javascript_CPP
set(javascript_H
javascriptplugin.h
jsgenerator.h
project/jsasynparse.h
project/jsprojectgenerator.h
project/properties/configpropertywidget.h
project/properties/configutil.h
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/javascript/jsgenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ bool JSGenerator::requestDAPPort(const QString &ppid, const QMap<QString, QVaria
{
QString targetPath = param.value("targetPath").toString();
QStringList arguments = param.value("arguments").toStringList();
QString kit = "jsdirectory";
QString kit = "javascript";

QDBusMessage msg = QDBusMessage::createSignal("/path",
"com.deepin.unioncode.interface",
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/javascript/jsgenerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class JSGenerator : public dpfservice::LanguageGenerator
explicit JSGenerator();
virtual ~JSGenerator() override;

static QString toolKitName() { return "jsdirectory"; }
static QString toolKitName() { return "javascript"; }

QString debugger() override;
bool prepareDebug(const QMap<QString, QVariant> &param, QString &retMsg) override;
Expand Down
Loading
Loading