让 XText 发挥作用

发布于 2024-09-01 07:27:53 字数 984 浏览 4 评论 0原文

我知道你不喜欢帮助别人做作业,但我必须制作一个 XText 语法,编写一个与该语法匹配的示例代码,并将其编译为 html 文件。

讲师向我们展示了步骤,一切都对他有用......他说“这很简单,对你来说10分钟就能完成”。我相信这一点。然而在家里几乎没有什么能按预期进行。当然,我不再需要听讲座,只有考试,我必须展示我所做的事情才能通过。此外,我发给他的电子邮件被邮件恶魔退回了...

我从 xtext 网站上获取了 Xtext 和 Eclipse IDE,我将其解压,然后按照官方教程中的步骤操作,使默认项目模板正常工作。该教程可以在这里找到:http://wiki.eclipse.org/Xtext/GettingStarted

现在我处于“模型”步骤。它说打开“MyModel.mydsl”,我这样做了,但编辑器没有打开。它说:

“无法打开编辑器:无法实例化编辑器类。这通常表明缺少无参数构造函数,或者编辑器的类名在plugin.xml中输入错误。”

由于所有内容均已生成,因此错误消息对我没有帮助...... 有一个选项可以查看堆栈跟踪(它有一英里长),并且在其顶部有一个异常:

java.lang.IllegalStateException:捆绑包尚未激活。确保 Manifest.MF 包含“Bundle-ActivationPolicy:lazy”。

我打开 Manifast.MF 和 Bundle-ActivationPolicy:lazy was set...

我用谷歌搜索了解决方案,但无济于事。这让我发疯,我放弃了。

我没有 Eclipse、Java 和 XText 的经验,我只想做我的作业并忘记一切,直到我再次需要它......

有人有 XText 的经验吗?

任何帮助表示赞赏。

ps:我也会处理这个问题,我可能会在几个小时内解决问题。但现在我不知所措。

I know you don't like helping others in their homework but I have to make an XText grammar, write a sample code that matches this grammar and compile it to a html file.

The lecturer showed us the steps and everything worked for him... He said "It's so simple it will be a 10 minute work for you". And I believed that. However at home almost nothing works as expected. And of course no more lectures to go only the exam avaits me where I have to show what I done to pass. Moreover the e-mail I sent him bounced back by the mailer-demon...

I got Xtext along with Eclipse IDE from the xtext website and I unpacked it and I followed the steps in the official tuturial to get the default project template to work. The tutorial is found here: http://wiki.eclipse.org/Xtext/GettingStarted

Now I'm at the step "Model". It says open the "MyModel.mydsl" I do that but the editor does not opened. It said:

"Could not open the editor: The editor class could not be instantiated. This usually indicates a missing no-arg constructor or that the editor's class name was mistyped in plugin.xml."

Since everything is generated, the error message does not helped me...
There was an option to look at the stack trace (it was mile long) and on the top of it there was an exception:

java.lang.IllegalStateException: The bundle has not yet been activated. Make sure the Manifest.MF contains 'Bundle-ActivationPolicy: lazy'.

I opened Manifast.MF and Bundle-ActivationPolicy: lazy was set...

I googled for the solution but no avail. It drove me nuts and I gave up.

I have no experience with Eclipse and Java and XText, I just want to do my homework and forget everything until I will need it again...

Anyone have experience with XText?

Any help appreciated.

ps: I will be on it too and I might resolve the problem in several hours. But now I am at a loss.

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

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

发布评论

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

评论(4

风吹雨成花 2024-09-08 07:27:53

您的 eclipse/XText 安装似乎存在问题。你是怎么安装的?如果您获得了 Eclipse 并随后添加了插件,则需要确保版本兼容。

这里有一个捆绑发行版

There seem to be an issue with your eclipse/XText installation. How did you install it? If you got Eclipse and added the plugin afterwards you need to make sure the versions are compatible.

There's a bundled distribution here

迷路的信 2024-09-08 07:27:53

一种可能性:在部署步骤中,请通过查看 Xtext 的安装目录(plugins 文件夹内)来检查您是否实际上创建了三个插件?如果它们放置在不同的位置,您可以将它们移动到插件文件夹中。并且,安装这些插件后您是否重新启动了Xtext eclipse?除非您重新启动,否则该平台将无法识别这些插件(和 MyDsl 编辑器)。

One possibility: In the Deployment step, please check if you have actually created three plugins by looking at the Xtext's installation directory, inside of plugins folder? If they are placed in different place, you can move them into the plugins folder. And, have you restarted Xtext eclipse after installing those plugins? The platform will not recognize those plugins (and MyDsl editor) unless you restart it.

手心的温暖 2024-09-08 07:27:53

我终于能够解决这个问题了。我意识到我可以跳过整个部署步骤,我不需要为我的 DSL 制作语法检查插件。我发现为了让事情顺利进行,我需要分配我所有的代币。

格式良好的 xtext 也是如此

SomeDeclaration:
   'declare' STRING

,但当我编译我的语言时它不会工作。它会导致很多神秘的错误......

SomeDeclaration
    'declare' declaredStuff=STRING

会的。

这是一个漫长的过程...我花了 8 个小时完成了 10 分钟的工作...

我希望这能帮助其他人开始使用 XText。

I finally was able to solve the problem. I realized I can skip the entire Deployment step I don't need to make syntax check plugin for my DSL. I found out to make things work I need to assign all my tokens.

So

SomeDeclaration:
   'declare' STRING

is well formed xtext but it won't work when I compile my language. It will cause lots of mysterious errors...

SomeDeclaration
    'declare' declaredStuff=STRING

will.

It was a long run... I did a 10 minute work for 8 hours...

I hope this will help others getting started with XText.

千笙结 2024-09-08 07:27:53

当我尝试在 Eclipse 中查看 DSL 时,我遇到了完全相同的问题(出现错误“无法打开编辑器:无法实例化编辑器类。”)。

然后我经历并尝试了在 eclipse 和 xtext 中更改配置文件的所有方法,但没有成功。

我唯一的解决方案是重新安装所有内容。我运行的是 64 位版本的 Windows(64 位 Vista),但只有 32 位 JVM 和 JDK。所以那些,eclipse和xtext都更新到了最新的64位版本,然后才可以正常工作。

我怀疑这是 eclipse 而不是 xtext 的问题,Helios(64 位 eclipse)的更新可能是造成这种差异的原因。

I was getting the exact same problems (getting error "Could not open the editor: The editor class could not be instantiated.") when I tried to view my DSL in eclipse.

I then went through and tried everything to changing config files in both eclipse and xtext but with no success.

My only solution has been to re-install everything. I am running a 64 bit version of windows (64 bit Vista) but only 32 bit JVM and JDK. So those, eclipse and xtext were updated to the latest 64 bit versions and only then has it worked ok.

I suspect this is a problem with eclipse rather than xtext and the update to Helios (64 bit eclipse) is probably what made the difference.

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