Skip to main content



      Home
Home » Modeling » TMF (Xtext) » elementary - all steps required to use a mixin grammar
elementary - all steps required to use a mixin grammar [message #821460] Thu, 15 March 2012 07:41 Go to next message
Eclipse UserFriend
Apologies, this must be documented somewhere - but can't find or figure it out.

I have two xtext projects for two different languages:

org.domainmodels.base
org.domainmodels.extension

I want to reuse base from extension so extension.xtext reads:

grammar org.domainmodels.extension with org.domainmodels.base
//...


The IDE gives an error: "Couldn't resolve reference to Grammar 'org.domainmodels.base'"

Both projects are in the same eclipse workspace.

I tried:
- adding package org.domainmodels.base to the extension project's MANIFEST.MF
- adding a reference to org.domainmodels.base to the project references in org.domainmodels.extension.

But still have the same problem. Would appreciate if someone would point out (a) where I'm going wrong and (b) where it's documented (since I'm sure it must be..).

Thanks.
Re: elementary - all steps required to use a mixin grammar [message #821470 is a reply to message #821460] Thu, 15 March 2012 07:51 Go to previous messageGo to next message
Eclipse UserFriend
What about adding a required bundle to the extension projects manifest
Re: elementary - all steps required to use a mixin grammar [message #821489 is a reply to message #821470] Thu, 15 March 2012 08:34 Go to previous message
Eclipse UserFriend
Thanks Christian. That solved the IDE error but created an exception during generation ("Could not find a GenModel for EPackage 'http://www.domainmodels.org/base'"). Solved that thanks to this post.

For the sake of anyone facing the same problem, the steps to follow are:

1. In the extending grammar, add a reference to the extended grammar (as per the documentation). e.g

grammar org.example.extension with org.example.base


2. In org.example.extension/META-INF/MANIFEST.MF add a required bundle for the base:

 //...
Require-Bundle: //lots of other bundles, then append:
 org.example.base
Import-Package: org.apache.commons.logging,
//...


3. In org.example.extension/src/org.example.extension/GenerateExtension.mwe2 edit section StandaloneSetup:

Workflow {
    bean = StandaloneSetup {
        scanClassPath = true
        platformUri = "${runtimeProject}/.."
        // Add the following 2 lines:
        registerGeneratedEPackage = "org.example.base.BasePackage"
        registerGenModelFile = "platform:/resource/org.example.base/src-gen/org/example/Base.genmodel"
    }
//...


You should then be able to generate successfully from extension.xtext.

Hope that helps, please suggest any corrections. Thx.
Previous Topic:Get all written text out of the editor
Next Topic:Building Updatesite Problem for Xtext 2.0 plugins
Goto Forum:
  


Current Time: Sun Jul 13 15:43:54 EDT 2025

Powered by FUDForum. Page generated in 0.02921 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top