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 me开发者_StackOverflow中文版ssage 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.
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 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.
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.
精彩评论