Search code examples
javaeclipseeclipse-pluginxtext

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.


Solution

  • 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.