English 中文(简体)
Getting XText to work
原标题:

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.

最佳回答

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.

问题回答

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

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.

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.





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签