Creating XTEXT Grammar from existing Ecore Model - xtext

I am trying to generate xtext grammar from existing ecore model. The xtext grammar is generated fine. When I do "Generate xtext artifacts" it ends up with "2278 [main] INFO .emf.mwe2.runtime.workflow.Workflow - Done."
However, it creates errors in project like in "formatter2" saying "type cannot be resolved". Please see below image for details and guide.
Regards,
Misbah.

the java classes for the ecore are missing
these java classes are not generated automatically, but you need to trigger the creation manually.
therefore open the genmodel file and do a rightclick generate model code in the root.

Related

xtext configure generator using configuration file

I'm developing a DSL using xtext that is producing different outputs (Typescript and java).
The description files I want to put into a separate project and the generated output should go to two other different projects. To know where the two output projects are located, I need a kind of configuration. The best would be to put this configuration into a separate dedicated file together with the description files under version control.
Is there maybe a way to serve the content of the org.eclipse.xtext.generator.OutputConfigurationProvider from a configuration file ?
Do you may have a best practice to realize that ?
Thank you in advance,
Michael
Xtext already supports this through preferences in Eclipse. It is stored in a DSL specific prefs file in the .settings folder of the project. So if you use this it will work out of the box

Where can I find lifecycleMappingMetadata schema?

In eclipse:
To correct "Plugin execution not covered by lifecycle configuration..." problem, I choose to create my lifecycle-mapping-metadata.xml instead of pollute my pom with IDE concerns.
I manage to write this file with example, but I can't find a xsd or DTD for lifecycle-mapping-metadata.xml. Where is it?
A typical lifecycle-mapping-metadata.xml file in the eclipse/m2e-core repo comes without an xsd reference.
But in that same m2e repo, you also have a org.eclipse.m2e.core/mdo/lifecycle-mapping-metadata-model.xml which helps to validate that xml file. It is used as a model in the main pom.xml, when used by the modello-maven-plugin.

Xtext How to auto build referenced language

I use 2 different DSL languages in my Project and reference them like described in this tutorial:
http://christiandietrich.wordpress.com/2012/08/07/xtext-referencing-elements-of-one-dsl-from-another-dsl/
My question is:
How to configure the build of the second language, to also rebuild the referenced first language?
If I choose 'Generate Xtext Artifacts' in the second language it should also trigger the workflow to rebuild the first one.
you can have multiple language sections in one workflow (have a look at Xtexts Xbase Project). but i dont see the usecase for that in your constellation

How can I validate an Ant XML file itself?

I am using Ant files for build
The build itself is done by IBM Rational Team Concert (RTC) with the help of this Ant file.
My problem is that if I make a mistake in the build XML itself like wrongly typed attribute name, this itself is detected by RTC after loading the files from source control (normally 15-20 mins)
Is there a way to verify (validate) the Ant XML file itself?
There is no schema for an Ant XML. As explained in the FAQ an incomplete DTD can be created but will not work:
An incomplete DTD can be created by the task - but this
one has a few problems:
It doesn't know about required attributes. Only manual tweaking of
this file can help here.
It is not complete - if you add new tasks via
it won't know about it. See this page by Michel Casabianca
for a solution to this problem. Note that the DTD you can download at
this page is based on Apache Ant 0.3.1.
It may even be an invalid DTD.
As Ant allows tasks writers to define arbitrary elements, name
collisions will happen quite frequently - if your version of Ant
contains the optional and tasks, there are two XML
elements named test (the task and the nested child element of )
with different attribute lists. This problem cannot be solved; DTDs
don't give a syntax rich enough to support this.
Again, the FAQ states the DTD is not (yet?) powerful enough to do this, but I found a preliminary work for Ant 1.6 based on Michel Casabianca's work at the AntDTD page on the Ant Wiki. As for me, I do not intend to use it.

Cross referencing dsl elements in xtext from a jar

I have a DSL written in xtext. Lets say the extension is dmodel. I have created a project with two files a.dmodel and b.model based on the DSL and various elements inside them are able to cross reference each other in the editor.
Lets say, I would like to move a.dmodel to a jar and add it to a jar (and possibly add the jar to the project) and still be able to cross reference the elements from b.dmodel. How do I achieve that?
It works out of the box. You simply put the jar with the a.dmodel on the classpath of a java projects that contains the b.dmodel. Xtext will pick up that information and make the elements in a.dmodel referable.

Resources