以编程方式运行 EMF 代码生成

发布于 2024-08-11 04:58:34 字数 455 浏览 2 评论 0原文

我创建了一个扩展名为 .system 的 EMF 模型,它将为我的工作生成代码。

现在我可以使用 Eclipse 中的启动代码生成操作来生成代码。但我想通过从独立程序启动代码生成来生成代码。

我该如何实现这一目标?

详细信息:我已经从 EMF 模型创建了一个插件,并将其包含在 Eclipse 中。

我将从我的插件中创建 .system 文件,并且我可以从我的插件生成代码。

我观察到,当我单击启动代码生成时,它会从我的插件启动一个 LauchAction 类。

如何从独立的 Java 程序启动我的 LaunchAction 类?

我的目标是运行我创建的 .system 模型并从独立的 Java 程序生成代码。

我该如何实现这一目标?

I have created an EMF model with extension .system which will generate the code for my work.

Now I can generate code using launch code generation action from Eclipse. But I want to generate the code by launching the code generation from a stand-alone program.

How do I achieve this?

Details: I have created a plugin from EMF model and have inlcluded in the Eclipse.

I will created .system files from out of my plugin and I can generate code from my plugins.

I have observed that when I click launch the code generation it is starting a LauchAction class from my plugin.

How do I start my LaunchAction class from a stand-alone Java program?

My aim is to run my created .system model and generate the code from a stand-alone Java program.

How do I achieve this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

血之狂魔 2024-08-18 04:58:34

您可以从命令行调用 Eclipse。与此类似:

eclipse.exe -noSplash -data ${workspace_location} -model -edit -editor -tests -application org.eclipse.emf.codegen.ecore.Generator ${genmodel}

此命令将静默启动 Eclipse 并生成模式代码 (-model)、编辑插件 (-edit)、编辑器插件 (< code>-editor)和测试插件(-tests)。如果不需要,请忽略这些参数中的任何一个。

You could call Eclipse from the command line. Something similar to this:

eclipse.exe -noSplash -data ${workspace_location} -model -edit -editor -tests -application org.eclipse.emf.codegen.ecore.Generator ${genmodel}

This command will start Eclipse silently and will generate mode code (-model), edit plug-in (-edit), editor plug-in (-editor), and the test plug-in (-tests). Leave out any of these parameters if they are not needed.

梦冥 2024-08-18 04:58:34

我不知道如何解决你的问题,但我认为这是可行的。我认为你必须查看 EMF 源代码来检查代码生成是如何工作的。

以下是一些起点:

  • 如果您有 PDE 和 EMF 工具,请使用“导入”>插件和片段,用于将 EMF 插件添加到您的 Eclipse 工作区中。

  • 否则,克隆并导入以下 Git 存储库:

    <前><代码>https://git.eclipse.org/c/emf/org.eclipse.emf.git/

  • 看看以下文件,也许您可​​以在那里找到您需要的内容:

    plugins/org.eclipse.emf.codegen.ecore.ui/src/org/eclipse/emf/codegen/ecore/genmodel/handler/GenerateHandler.java
    
  • 否则,看看org.eclipse.emf.codegen.ecore插件.

祝你好运!这是一个有趣的问题!如果您解决了,请回来报告!

编辑: 哦,这个问题已经有 10 年历史了,我没有注意到!

I don't know how to solve your problem, but I think it is doable. I think you have to look at the EMF source code to check how the code generation works.

Here are some starting points:

  • If you have PDE and the EMF tools, use use Import > Plug-ins and Fragments to get the EMF plugin into your Eclipse workspace.

  • Otherwise, clone and import the following Git repository:

    https://git.eclipse.org/c/emf/org.eclipse.emf.git/
    
  • Have a look at the following file, maybe you can find what you need there:

    plugins/org.eclipse.emf.codegen.ecore.ui/src/org/eclipse/emf/codegen/ecore/genmodel/handler/GenerateHandler.java
    
  • Otherwise, look in the org.eclipse.emf.codegen.ecore plugin.

Good luck! It's an interesting problem! Please report back here if you solve it!

EDIT: Ops, this question is 10 years old, I didn't notice!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文