Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    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 11:41 Go to next message
Scott Finnie is currently offline Scott FinnieFriend
Messages: 94
Registered: October 2011
Member
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 11:51 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13416
Registered: July 2009
Senior Member
What about adding a required bundle to the extension projects manifest

Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/xtext/
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: elementary - all steps required to use a mixin grammar [message #821489 is a reply to message #821470] Thu, 15 March 2012 12:34 Go to previous message
Scott Finnie is currently offline Scott FinnieFriend
Messages: 94
Registered: October 2011
Member
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: Thu Apr 02 01:06:07 GMT 2020

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

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

Back to the top