Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Two DSL in same project(How I configure two DSL in one project)
Two DSL in same project [message #1740725] Wed, 17 August 2016 19:22 Go to next message
Márcio Koch is currently offline Márcio KochFriend
Messages: 57
Registered: August 2013
Member
Hi,
I already have a DSL (xtext file) in my project working fine and also a mwe2 with workflow, bean = StandaloneSetup and a language = auto-inject section. It's an Eclipse plugin already in production. But I would like to add one more DSL in this project (other xtext file) to generate some others helper files and use the same Eclipse plugin. I've created this other xtext file (together with the first file). But in the second xtext file, it has compilation errors as: Cannot create type for ServiceProperties because its EPackage is unknown. I think it happens because the artifacts for this DSL aren't being generated. If I put into the begining of xtext file the line: generate mydsl "http://www.some.com/x/y", the erros disappear. So I configure one more secction language = auto-inject in my mwe2 file and run MWE2 Workflow but happens the error: Could not find a GenModel for EPackage 'http://www.some.com/x/y' from http://www.some.com/x/y.
Someone can help me?
Re: Two DSL in same project [message #1740726 is a reply to message #1740725] Wed, 17 August 2016 19:25 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
Can you post the full workflow?

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Two DSL in same project [message #1740728 is a reply to message #1740726] Wed, 17 August 2016 19:39 Go to previous messageGo to next message
Márcio Koch is currently offline Márcio KochFriend
Messages: 57
Registered: August 2013
Member
Yes I can.
  • Attachment: GenerateSDL.mwe2
    (Size: 9.82KB, Downloaded 120 times)
  • Attachment: PDL.xtext
    (Size: 1.73KB, Downloaded 104 times)
Re: Two DSL in same project [message #1740729 is a reply to message #1740728] Wed, 17 August 2016 19:45 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
if you use a generated metamodel and not a imported one you need emfgeneratorfragment (compare your workflow with a newly created one.
and you have to take care for the file extensions.

is there a reason you want to have this in one project?

module org.xtext.example.mydsla.GenerateMyDslA

import org.eclipse.emf.mwe.utils.*
import org.eclipse.xtext.generator.*
import org.eclipse.xtext.ui.generator.*

var grammarURI = "classpath:/org/xtext/example/mydsla/MyDslA.xtext"
var grammarURI2 = "classpath:/org/xtext/example/mydsla/MyDslB.xtext"
var projectName = "org.xtext.example.mydsls"
var runtimeProject = "../${projectName}"
var generateXtendStub = true
var encoding = "UTF-8"

Workflow {
    bean = StandaloneSetup {
    	scanClassPath = true
    	platformUri = "${runtimeProject}/.."
    	// The following two lines can be removed, if Xbase is not used.
    	registerGeneratedEPackage = "org.eclipse.xtext.xbase.XbasePackage"
    	registerGenModelFile = "platform:/resource/org.eclipse.xtext.xbase/model/Xbase.genmodel"
    }
    
    component = DirectoryCleaner {
    	directory = "${runtimeProject}/src-gen"
    }
    
    component = DirectoryCleaner {
    	directory = "${runtimeProject}/model/generated"
    }
    
    component = DirectoryCleaner {
    	directory = "${runtimeProject}.ui/src-gen"
    }
    
    component = DirectoryCleaner {
    	directory = "${runtimeProject}.tests/src-gen"
    }
    
    component = Generator {
    	pathRtProject = runtimeProject
    	pathUiProject = "${runtimeProject}.ui"
    	pathTestProject = "${runtimeProject}.tests"
    	projectNameRt = projectName
    	projectNameUi = "${projectName}.ui"
    	encoding = encoding
    	language = auto-inject {
    		fileExtensions = "mydsla"
    		uri = grammarURI
    
    		// Java API to access grammar elements (required by several other fragments)
    		fragment = grammarAccess.GrammarAccessFragment auto-inject {}
    
    		// generates Java API for the generated EPackages
    		fragment = ecore.EMFGeneratorFragment auto-inject {}
    
    		// the old serialization component
    		// fragment = parseTreeConstructor.ParseTreeConstructorFragment auto-inject {}    
    
    		// serializer 2.0
    		fragment = serializer.SerializerFragment auto-inject {
    			generateStub = false
    		}
    
    		// a custom ResourceFactory for use with EMF
    		fragment = resourceFactory.ResourceFactoryFragment auto-inject {}
    
    		// The antlr parser generator fragment.
    		fragment = parser.antlr.XtextAntlrGeneratorFragment auto-inject {
    		//  options = {
    		//      backtrack = true
    		//  }
    		}
    
    		// Xtend-based API for validation
    		fragment = validation.ValidatorFragment auto-inject {
    		//    composedCheck = "org.eclipse.xtext.validation.ImportUriValidator"
    		//    composedCheck = "org.eclipse.xtext.validation.NamesAreUniqueValidator"
    		}
    
    		// old scoping and exporting API
    		// fragment = scoping.ImportURIScopingFragment auto-inject {}
    		// fragment = exporting.SimpleNamesFragment auto-inject {}
    
    		// scoping and exporting API
    		fragment = scoping.ImportNamespacesScopingFragment auto-inject {}
    		fragment = exporting.QualifiedNamesFragment auto-inject {}
    		fragment = builder.BuilderIntegrationFragment auto-inject {}
    
    		// generator API
    		fragment = generator.GeneratorFragment auto-inject {}
    
    		// formatter API
    		fragment = formatting.FormatterFragment auto-inject {}
    
    		// labeling API
    		fragment = labeling.LabelProviderFragment auto-inject {}
    
    		// outline API
    		fragment = outline.OutlineTreeProviderFragment auto-inject {}
    		fragment = outline.QuickOutlineFragment auto-inject {}
    
    		// quickfix API
    		fragment = quickfix.QuickfixProviderFragment auto-inject {}
    
    		// content assist API
    		fragment = contentAssist.ContentAssistFragment auto-inject {}
    
    		// generates a more lightweight Antlr parser and lexer tailored for content assist
    		fragment = parser.antlr.XtextAntlrUiGeneratorFragment auto-inject {}
    
    		// generates junit test support classes into Generator#pathTestProject
    		fragment = junit.Junit4Fragment auto-inject {}
    
    		// rename refactoring
    		fragment = refactoring.RefactorElementNameFragment auto-inject {}
    
    		// provides the necessary bindings for java types integration
    		fragment = types.TypesGeneratorFragment auto-inject {}
    
    		// generates the required bindings only if the grammar inherits from Xbase
    		fragment = xbase.XbaseGeneratorFragment auto-inject {}
    		
    		// generates the required bindings only if the grammar inherits from Xtype
    		fragment = xbase.XtypeGeneratorFragment auto-inject {}
    
    		// provides a preference page for template proposals
    		fragment = templates.CodetemplatesGeneratorFragment auto-inject {}
    
    		// provides a compare view
    		fragment = compare.CompareFragment auto-inject {
    			fileExtensions = "mydsla"
    		}
    	}
    	language = auto-inject {
    		fileExtensions = "mydslb"
    		uri = grammarURI2
    
    		// Java API to access grammar elements (required by several other fragments)
    		fragment = grammarAccess.GrammarAccessFragment auto-inject {}
    
    		// generates Java API for the generated EPackages
    		fragment = ecore.EMFGeneratorFragment auto-inject {}
    
    		// the old serialization component
    		// fragment = parseTreeConstructor.ParseTreeConstructorFragment auto-inject {}    
    
    		// serializer 2.0
    		fragment = serializer.SerializerFragment auto-inject {
    			generateStub = false
    		}
    
    		// a custom ResourceFactory for use with EMF
    		fragment = resourceFactory.ResourceFactoryFragment auto-inject {}
    
    		// The antlr parser generator fragment.
    		fragment = parser.antlr.XtextAntlrGeneratorFragment auto-inject {
    		//  options = {
    		//      backtrack = true
    		//  }
    		}
    
    		// Xtend-based API for validation
    		fragment = validation.ValidatorFragment auto-inject {
    		//    composedCheck = "org.eclipse.xtext.validation.ImportUriValidator"
    		//    composedCheck = "org.eclipse.xtext.validation.NamesAreUniqueValidator"
    		}
    
    		// old scoping and exporting API
    		// fragment = scoping.ImportURIScopingFragment auto-inject {}
    		// fragment = exporting.SimpleNamesFragment auto-inject {}
    
    		// scoping and exporting API
    		fragment = scoping.ImportNamespacesScopingFragment auto-inject {}
    		fragment = exporting.QualifiedNamesFragment auto-inject {}
    		fragment = builder.BuilderIntegrationFragment auto-inject {}
    
    		// generator API
    		fragment = generator.GeneratorFragment auto-inject {}
    
    		// formatter API
    		fragment = formatting.FormatterFragment auto-inject {}
    
    		// labeling API
    		fragment = labeling.LabelProviderFragment auto-inject {}
    
    		// outline API
    		fragment = outline.OutlineTreeProviderFragment auto-inject {}
    		fragment = outline.QuickOutlineFragment auto-inject {}
    
    		// quickfix API
    		fragment = quickfix.QuickfixProviderFragment auto-inject {}
    
    		// content assist API
    		fragment = contentAssist.ContentAssistFragment auto-inject {}
    
    		// generates a more lightweight Antlr parser and lexer tailored for content assist
    		fragment = parser.antlr.XtextAntlrUiGeneratorFragment auto-inject {}
    
    		// generates junit test support classes into Generator#pathTestProject
    		fragment = junit.Junit4Fragment auto-inject {}
    
    		// rename refactoring
    		fragment = refactoring.RefactorElementNameFragment auto-inject {}
    
    		// provides the necessary bindings for java types integration
    		fragment = types.TypesGeneratorFragment auto-inject {}
    
    		// generates the required bindings only if the grammar inherits from Xbase
    		fragment = xbase.XbaseGeneratorFragment auto-inject {}
    		
    		// generates the required bindings only if the grammar inherits from Xtype
    		fragment = xbase.XtypeGeneratorFragment auto-inject {}
    
    		// provides a preference page for template proposals
    		fragment = templates.CodetemplatesGeneratorFragment auto-inject {}
    
    		// provides a compare view
    		fragment = compare.CompareFragment auto-inject {
    			fileExtensions = "mydslb"
    		}
    	}
    }
}




Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Two DSL in same project [message #1740730 is a reply to message #1740729] Wed, 17 August 2016 19:55 Go to previous messageGo to next message
Márcio Koch is currently offline Márcio KochFriend
Messages: 57
Registered: August 2013
Member
I'll follow your tips and I'll try again.
The reason of to use them together is for convenience. I am doing some experiments.

Thanks very much.
Re: Two DSL in same project [message #1740832 is a reply to message #1740730] Thu, 18 August 2016 19:05 Go to previous messageGo to next message
Márcio Koch is currently offline Márcio KochFriend
Messages: 57
Registered: August 2013
Member
Hi, I changed my mwe2 file like your example, and run "MWE2 Workflow" popup menu, it ran without errors. After, I done "Run As > Eclipse Application" and I did some tests: the old DSL "*.sdl" works fine, but the new DSL "*.pdl" don't work, the editor do nothing with the files "*.pdl", treats it as a plain text.
Some suggestion?
  • Attachment: GenerateSDL.mwe2
    (Size: 9.96KB, Downloaded 108 times)
  • Attachment: PDL.xtext
    (Size: 1.72KB, Downloaded 103 times)
Re: Two DSL in same project [message #1740833 is a reply to message #1740832] Thu, 18 August 2016 19:09 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
Did you merge / copy the plugin.xml_gen files with plugin.xml

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Two DSL in same project [message #1740911 is a reply to message #1740833] Fri, 19 August 2016 17:18 Go to previous messageGo to next message
Márcio Koch is currently offline Márcio KochFriend
Messages: 57
Registered: August 2013
Member
Thanks, now it is working fine.
Re: Two DSL in same project [message #1740920 is a reply to message #1740911] Fri, 19 August 2016 18:16 Go to previous message
Márcio Koch is currently offline Márcio KochFriend
Messages: 57
Registered: August 2013
Member
Can I have each dsl files and generated files in its own package for better organization? For now I have it all together.
Previous Topic:invoking MWE2 workflows from a central MWE2 workflow
Next Topic:Model inferrer assign non final content to body
Goto Forum:
  


Current Time: Thu Mar 28 19:05:12 GMT 2024

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

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

Back to the top