KEMBAR78
Using Xcore with Xtext | PDF
modelsUsing
with
Holger Schill
Generated model
Generated model
Generated model
You will come to the point…
Where you want to take control…
Problem
grammar org.xtext.example.mydsl.MyDsl with org.eclipse.xtext.common.Terminals
generate myDsl "http://www.xtext.org/example/mydsl/MyDsl"
Model:
elements+=AbstractElement*;
AbstractElement:
Element | SecondElement | ThirdElement
;
Element:
'Element' name=ID ref=[AbstractElement]
;
SecondElement:
'SecondElement' name=ID
;
ThirdElement:
'ThirdElement' name=ID
;
Example
Problem
grammar org.xtext.example.mydsl.MyDsl with org.eclipse.xtext.common.Terminals
generate myDsl "http://www.xtext.org/example/mydsl/MyDsl"
Model:
elements+=AbstractElement*;
AbstractElement:
Element | SecondElement | ThirdElement
;
Element:
'Element' name=ID ref=[AbstractElement]
;
SecondElement:
'SecondElement' name=ID
;
ThirdElement:
'ThirdElement' name=ID
;
Example
grammar org.xtext.example.mydsl.MyDsl with org.eclipse.xtext.common.Terminals
generate myDsl "http://www.xtext.org/example/mydsl/MyDsl"
Model:
elements+=AbstractElement*;
AbstractElement:
Element | SecondElement | ThirdElement
;
Element:
'Element' name=ID ref=[Referenceable]
;
SecondElement:
'SecondElement' name=ID
;
ThirdElement:
'ThirdElement' name=ID
;
Referenceable:
SecondElement | ThirdElement
;
Never invoked by the parser
Example
Fake Rules to influence EMF Generator
For rapid prototyping the generated model is fine
When to stay with the generated model
For rapid prototyping the generated model is fine
Automatic synchronisation from grammar to model
When to stay with the generated model
For rapid prototyping the generated model is fine
Automatic synchronisation from grammar to model
If you do not need to introduce fake rules
When to stay with the generated model
But what if…
DSL DSL DSL
Order for generating DSLs is important
But what if…
DSL DSL DSL
Order for generating DSLs is important
Eagerly loaded
DSL DSL
DSLs reference each other
But what if…
Imported Model
Imported Model
Imported Model
Xtext Nature !
Still that tree editor…
Still that tree editor…
Merging can be difficult
Generation Gap Pattern…
What is Xcore?
The MyDSL example in Xcore
Derives ecore and genmodel
Put code directly in the model
Put code directly in the model
Load Xcore file
No Registration needed
Workflow configuration
Don’t forget the Xcore dependency
Don’t forget the Xcore dependency
Caused by: org.xml.sax.SAXParseExceptionpublicId: platform:/resource/org.xtext.example.mydsl.model/model/MyDsl.xcore; systemId:
platform:/resource/org.xtext.example.mydsl.model/model/MyDsl.xcore; lineNumber: 1; columnNumber: 1; Content is not allowed in
prolog.
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:203)
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(ErrorHandlerWrapper.java:177)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:441)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:368)
at com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(XMLScanner.java:1436)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(XMLDocumentScannerImpl.java:999)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:606)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:
510)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:848)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:777)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141)
Invokes XcoreStandaloneSetup to register *.xcore
There is a wizard for that…
More complex setups
Ecore
model
Xcore
model
Xtext DSL
Xcore imports another ecore model
Xtext DSL imports Xcore
Ecore
model
Xcore
model
Ecore
model
Xcore
model
Xtext DSL
Caused by: java.lang.IllegalStateException: Problem parsing 'classpath:/org/xtext/example/
mydsl/MyDsl.xtext':
TransformationDiagnostic: null:9 Cannot find compatible feature name in sealed EClass
Greeting from imported package http://www.xtext.org/example/mydsl/MyDsl: The type 'Greeting'
does not have a feature 'name'. (ErrorCode: CannotCreateTypeInSealedMetamodel)
at org.eclipse.xtext.generator.LanguageConfig.setUri(LanguageConfig.java:247)
... 42 more
You will face that Exception
Caused by: java.lang.IllegalStateException: Problem parsing 'classpath:/org/xtext/example/
mydsl/MyDsl.xtext':
TransformationDiagnostic: null:9 Cannot find compatible feature name in sealed EClass
Greeting from imported package http://www.xtext.org/example/mydsl/MyDsl: The type 'Greeting'
does not have a feature 'name'. (ErrorCode: CannotCreateTypeInSealedMetamodel)
at org.eclipse.xtext.generator.LanguageConfig.setUri(LanguageConfig.java:247)
... 42 more
You will face that Exception
Ecore
model
Xcore
model
Proxy not resolvable
Index is not aware of genmodel
that the Xcore model links against
Proxy
But I added that stuff in the StandaloneSetup…?
But I added that stuff in the StandaloneSetup…?
ResourceSet
Resource
Resource
Resource
Resource
ResourceSet
Resource
Resource
Ecore
model
Xcore
model
Proxy
What’s happening?
ResourceSet
Grammar
Xcore resource
Ecore model
Genmodel
Index
ResourceDescription
ResourceDescription
ResourceDescription
ResourceDescription
Ecore
model
Xcore
model
Proxy
What’s happening?
Name
Index
ResourceDescription
ResourceDescription
ResourceDescription
ResourceDescription
Ecore
model
Xcore
model
Proxy
What’s happening?
URI
Index
ResourceDescription
ResourceDescription
ResourceDescription
ResourceDescription
Ecore
model
Xcore
model
What’s happening?
resolved
Index
ResourceDescription
ResourceDescription
ResourceDescription
ResourceDescription
Force same ResourceSet
More elegant
More complex example
Xtext DSL Xtext DSL
Languages referencing each other
More complex example
Xtext DSL Xtext DSL
Languages referencing each other
Plugin
Xtext
DSL 1
Plugin
Xtext
DSL 1
Problem
Circular dependency
Buddypolicy
Introduce a Ecore model as a protocol
Xtext DSL Xtext DSL
Ecore
model
Generated
Model
Generated
Model
grammar org.xtext.example.mydsl.MyDsl with org.eclipse.xtext.common.Terminals
generate myDsl "http://www.xtext.org/example/mydsl/MyDsl"
import "http://www.xtext.org/common/model" as common
PackageDeclaration returns common::PackageDeclaration:
'package' name=FQN
content+=Element
;
Element returns common::NamedElement:
{Element}
'element' name=ID '{'
ref=[common::Referenceable | FQN]?
'}'
;
FQN:
ID ('.' ID)*
;
Introduce a Ecore model as a protocol
grammar org.xtext.example.mydsl.MyDsl with org.eclipse.xtext.common.Terminals
generate myDsl "http://www.xtext.org/example/mydsl/MyDsl"
import "http://www.xtext.org/common/model" as common
PackageDeclaration returns common::PackageDeclaration:
'package' name=FQN
content+=Element
;
Element returns common::NamedElement:
{Element}
'element' name=ID '{'
ref=[common::Referenceable | FQN]?
'}'
;
FQN:
ID ('.' ID)*
;
Introduce a Ecore model as a protocol
More complex example
Xtext DSL Xtext DSL
Xcore
model
Xcore
model
Imported
Model
Imported
Model
More complex example
Xtext DSL Xtext DSL
Xcore
model
Xcore
model
Imported
Model
Imported
Model
Same Plugin
More complex example
Xtext DSL Xtext DSL
Xcore
model
Xcore
model
Imported
Model
Imported
Model
Different plugins
More complex example
Xtext DSL Xtext DSL
Ecore
model
Xcore
model
Xcore
model
Imported
Model
Imported
Model
Ecore
model
Xcore
model
Xcore
model
grammar org.xtext.example.firstdsl.Lang with org.eclipse.xtext.common.Terminals
import "org.xtext.example.myfirstdsl"
import "http://www.eclipse.org/emf/2002/Ecore" as ecore
import "http://www.xtext.org/common/model" as common
import "org.xtext.example.myseconddsl" as second
PackageDeclaration returns common::PackageDeclaration :
'package' name=FQN
content+=FirstElement*
;
FirstElement :
'element' name=ID '{'
ref=[second::SecondElement| FQN]?
'}'
;
FQN:
ID ('.' ID)*
;
A lot of imports…
grammar org.xtext.example.firstdsl.Lang with org.eclipse.xtext.common.Terminals
import "org.xtext.example.myfirstdsl"
import "http://www.eclipse.org/emf/2002/Ecore" as ecore
import "http://www.xtext.org/common/model" as common
import "org.xtext.example.myseconddsl" as second
PackageDeclaration returns common::PackageDeclaration :
'package' name=FQN
content+=FirstElement*
;
FirstElement :
'element' name=ID '{'
ref=[second::SecondElement| FQN]?
'}'
;
FQN:
ID ('.' ID)*
;
Have same root node…
grammar org.xtext.example.firstdsl.Lang with org.eclipse.xtext.common.Terminals
import "org.xtext.example.myfirstdsl"
import "http://www.eclipse.org/emf/2002/Ecore" as ecore
import "http://www.xtext.org/common/model" as common
import "org.xtext.example.myseconddsl" as second
PackageDeclaration returns common::PackageDeclaration :
'package' name=FQN
content+=FirstElement*
;
FirstElement :
'element' name=ID '{'
ref=[second::SecondElement| FQN]?
'}'
;
FQN:
ID ('.' ID)*
;
Use implicitly imported classifier
MWE2 configuration
Same for both languages
grammar org.xtext.example.firstdsl.Lang with org.eclipse.xtext.common.Terminals
import "org.xtext.example.myfirstdsl"
import "http://www.eclipse.org/emf/2002/Ecore" as ecore
import "http://www.xtext.org/common/model" as common
import "org.xtext.example.myseconddsl" as second
PackageDeclaration returns common::PackageDeclaration :
'package' name=FQN
content+=FirstElement*
;
FirstElement :
'element' name=ID '{'
ref=[second::SecondElement| FQN]?
'}'
;
FQN:
ID ('.' ID)*
;
But there is a small problem
grammar org.xtext.example.firstdsl.Lang with org.eclipse.xtext.common.Terminals
import "org.xtext.example.myfirstdsl"
import "http://www.eclipse.org/emf/2002/Ecore" as ecore
import "http://www.xtext.org/common/model" as common
import "org.xtext.example.myseconddsl" as second
PackageDeclaration returns common::PackageDeclaration :
'package' name=FQN
content+=FirstElement*
;
FirstElement :
'element' name=ID '{'
ref=[second::SecondElement| FQN]?
'}'
;
FQN:
ID ('.' ID)*
;
CA is showing both elements?
grammar org.xtext.example.firstdsl.Lang with org.eclipse.xtext.common.Terminals
import "org.xtext.example.myfirstdsl"
import "http://www.eclipse.org/emf/2002/Ecore" as ecore
import "http://www.xtext.org/common/model" as common
import "org.xtext.example.myseconddsl" as second
PackageDeclaration returns common::PackageDeclaration :
'package' name=FQN
content+=FirstElement*
;
FirstElement :
'element' name=ID '{'
ref=[second::SecondElement| FQN]?
'}'
;
FQN:
ID ('.' ID)*
;
CA is showing both elements?
Xtext DSL Xtext DSL
Ecore
model
Xcore
model
Xcore
model
generated
Model
generated
Model
One way to solve that…
One way to solve that…
One way to solve that…
grammar org.xtext.example.seconddsl.Lang with org.eclipse.xtext.common.Terminals
generate generatedSecondModel "http://www.xtext.org/generatedSecondModel"
import "org.xtext.example.myseconddsl"
import "http://www.xtext.org/common/model" as common
import "http://www.eclipse.org/emf/2002/Ecore" as ecore
import "org.xtext.example.myfirstdsl" as first
PackageDeclaration returns common::PackageDeclaration :
'package' name=FQN
content+=SecondElement*
;
SecondElement returns SecondElement:
{CustomSecondElement}
'element' name=ID '{'
ref=[first::FirstElement | FQN]?
'}'
;
FQN:
ID ('.' ID)*
;
One way to solve that…
grammar org.xtext.example.seconddsl.Lang with org.eclipse.xtext.common.Terminals
generate generatedSecondModel "http://www.xtext.org/generatedSecondModel"
import "org.xtext.example.myseconddsl"
import "http://www.xtext.org/common/model" as common
import "http://www.eclipse.org/emf/2002/Ecore" as ecore
import "org.xtext.example.myfirstdsl" as first
PackageDeclaration returns common::PackageDeclaration :
'package' name=FQN
content+=SecondElement*
;
SecondElement returns SecondElement:
{CustomSecondElement}
'element' name=ID '{'
ref=[first::FirstElement | FQN]?
'}'
;
FQN:
ID ('.' ID)*
;
But when I run it….
[ERROR]: GeneratorException: (Element: -UNKNOWN-; Reported by: Generator)
java.lang.RuntimeException: Could not find a GenModel for EPackage 'http://www.xtext.org/
generatedSecondModel' from http://www.xtext.org/generatedSecondModel
If the missing GenModel has been generated via EMFGeneratorFragment or EcoreGeneratorFragment make
sure to run it first in the workflow.
If you have a *.genmodel-file, make sure to register it via
StandaloneSetup.registerGenModelFile(String)
at org.eclipse.xtext.generator.GenModelAccess.getGenModelResource(GenModelAccess.java:137)
at org.eclipse.xtext.generator.GenModelAccess.getGenPackage(GenModelAccess.java:85)
But when I run it….
// generates Java API for the generated EPackages
fragment = ecore.EMFGeneratorFragment auto-inject {}
Don’t forget the EMFGeneratorFragment
[ERROR]: GeneratorException: (Element: -UNKNOWN-; Reported by: Generator)
java.lang.RuntimeException: Could not find a GenModel for EPackage 'http://www.xtext.org/
generatedSecondModel' from http://www.xtext.org/generatedSecondModel
If the missing GenModel has been generated via EMFGeneratorFragment or EcoreGeneratorFragment make
sure to run it first in the workflow.
If you have a *.genmodel-file, make sure to register it via
StandaloneSetup.registerGenModelFile(String)
at org.eclipse.xtext.generator.GenModelAccess.getGenModelResource(GenModelAccess.java:137)
at org.eclipse.xtext.generator.GenModelAccess.getGenPackage(GenModelAccess.java:85)
There was nothing about Xbase so far…
Using Xbase
Wizard does crazy things…// automatically generated by Xtext
grammar org.xtext.example.mydsl.MyDsl with org.eclipse.xtext.common.Terminals
import "http://www.xtext.org/example/xbase"
import "http://www.eclipse.org/xtext/common/JavaVMTypes" as types
import "http://www.eclipse.org/xtext/xbase/Xbase" as xbase
import "http://www.eclipse.org/emf/2002/Ecore" as ecore
MyClass returns MyClass:
{MyClass}
'MyClass'
'{'
('ref' ref=JvmTypeReference)?
('body' body=XBlockExpression)?
'}';
JvmTypeReference returns types::JvmTypeReference:
JvmParameterizedTypeReference_Impl | JvmGenericArrayTypeReference | JvmWildcardTypeReference | JvmAnyTypeReference | JvmMultiTypeReference | JvmDelegateTypeReference | JvmSynonymTypeReference | JvmUnknownTypeReference | JvmInnerTypeReference;
XExpression returns xbase::XExpression:
XIfExpression | XSwitchExpression | XBlockExpression | XVariableDeclaration | XMemberFeatureCall | XFeatureCall | XConstructorCall | XBooleanLiteral | XNullLiteral | XNumberLiteral | XStringLiteral | XListLiteral | XSetLiteral | XClosure | XCastedExpression | XBinaryOperation | XUnaryOperation | XPostfixOperation | XForLoopExpression | XBasicForLoopExpression | XDoWhileExpression | XWhileExpression | XTypeLiteral | XInstanceOfExpression | XThrowExpression | XTryCatchFinallyExpression | XAssignment | XReturnExpression | XSynchronizedExpression;
JvmType returns types::JvmType:
JvmVoid | JvmPrimitiveType | JvmArrayType | JvmTypeParameter | JvmAnnotationType | JvmEnumerationType | JvmGenericType;
JvmTypeConstraint returns types::JvmTypeConstraint:
JvmUpperBound | JvmLowerBound;
JvmParameterizedTypeReference returns types::JvmParameterizedTypeReference:
JvmParameterizedTypeReference_Impl | JvmInnerTypeReference;
JvmMember returns types::JvmMember:
JvmAnnotationType | JvmEnumerationType | JvmEnumerationLiteral | JvmGenericType | JvmField_Impl | JvmConstructor | JvmOperation;
JvmAnnotationValue returns types::JvmAnnotationValue:
JvmIntAnnotationValue | JvmBooleanAnnotationValue | JvmByteAnnotationValue | JvmShortAnnotationValue | JvmLongAnnotationValue | JvmDoubleAnnotationValue | JvmFloatAnnotationValue | JvmCharAnnotationValue | JvmStringAnnotationValue | JvmTypeAnnotationValue | JvmAnnotationAnnotationValue | JvmEnumAnnotationValue | JvmCustomAnnotationValue;
JvmIdentifiableElement returns types::JvmIdentifiableElement:
JvmVoid | JvmPrimitiveType | JvmArrayType | JvmTypeParameter | JvmAnnotationType | JvmEnumerationType | JvmEnumerationLiteral | JvmGenericType | JvmField_Impl | JvmConstructor | JvmOperation | JvmFormalParameter;
XBlockExpression returns xbase::XBlockExpression:
{xbase::XBlockExpression}
'XBlockExpression'
'{'
('expressions' '{' expressions+=XExpression ( "," expressions+=XExpression)* '}' )?
'}';
JvmParameterizedTypeReference_Impl returns types::JvmParameterizedTypeReference:
{types::JvmParameterizedTypeReference}
'JvmParameterizedTypeReference'
'{'
('type' type=[types::JvmType|EString])?
('arguments' '{' arguments+=JvmTypeReference ( "," arguments+=JvmTypeReference)* '}' )?
'}';
JvmGenericArrayTypeReference returns types::JvmGenericArrayTypeReference:
{types::JvmGenericArrayTypeReference}
'JvmGenericArrayTypeReference'
'{'
('componentType' componentType=JvmTypeReference)?
'}';
JvmWildcardTypeReference returns types::JvmWildcardTypeReference:
{types::JvmWildcardTypeReference}
'JvmWildcardTypeReference'
'{'
('constraints' '{' constraints+=JvmTypeConstraint ( "," constraints+=JvmTypeConstraint)* '}' )?
'}';
JvmAnyTypeReference returns types::JvmAnyTypeReference:
{types::JvmAnyTypeReference}
'JvmAnyTypeReference'
'{'
('type' type=[types::JvmType|EString])?
'}';
JvmMultiTypeReference returns types::JvmMultiTypeReference:
{types::JvmMultiTypeReference}
'JvmMultiTypeReference'
'{'
('type' type=[types::JvmType|EString])?
('references' '{' references+=JvmTypeReference ( "," references+=JvmTypeReference)* '}' )?
'}';
JvmDelegateTypeReference returns types::JvmDelegateTypeReference:
{types::JvmDelegateTypeReference}
'JvmDelegateTypeReference'
'{'
('delegate' delegate=[types::JvmTypeReference|EString])?
'}';
JvmSynonymTypeReference returns types::JvmSynonymTypeReference:
{types::JvmSynonymTypeReference}
'JvmSynonymTypeReference'
'{'
('type' type=[types::JvmType|EString])?
('references' '{' references+=JvmTypeReference ( "," references+=JvmTypeReference)* '}' )?
'}';
JvmUnknownTypeReference returns types::JvmUnknownTypeReference:
{types::JvmUnknownTypeReference}
'JvmUnknownTypeReference'
;
JvmInnerTypeReference returns types::JvmInnerTypeReference:
{types::JvmInnerTypeReference}
'JvmInnerTypeReference'
'{'
('type' type=[types::JvmType|EString])?
('arguments' '{' arguments+=JvmTypeReference ( "," arguments+=JvmTypeReference)* '}' )?
('outer' outer=JvmParameterizedTypeReference)?
'}';
JvmVoid returns types::JvmVoid:
{types::JvmVoid}
'JvmVoid'
;
JvmPrimitiveType returns types::JvmPrimitiveType:
{types::JvmPrimitiveType}
'JvmPrimitiveType'
'{'
('simpleName' simpleName=EString)?
('arrayType' arrayType=JvmArrayType)?
'}';
JvmArrayType returns types::JvmArrayType:
{types::JvmArrayType}
'JvmArrayType'
'{'
('arrayType' arrayType=JvmArrayType)?
'}';
JvmTypeParameter returns types::JvmTypeParameter:
{types::JvmTypeParameter}
'JvmTypeParameter'
name=EString
'{'
('arrayType' arrayType=JvmArrayType)?
('constraints' '{' constraints+=JvmTypeConstraint ( "," constraints+=JvmTypeConstraint)* '}' )?
'}';
JvmAnnotationType returns types::JvmAnnotationType:
{types::JvmAnnotationType}
(deprecated?='deprecated')?
(abstract?='abstract')?
(static?='static')?
(final?='final')?
'JvmAnnotationType'
'{'
('visibility' visibility=JvmVisibility)?
('simpleName' simpleName=EString)?
('packageName' packageName=EString)?
('annotations' '{' annotations+=JvmAnnotationReference ( "," annotations+=JvmAnnotationReference)* '}' )?
('arrayType' arrayType=JvmArrayType)?
('superTypes' '{' superTypes+=JvmTypeReference ( "," superTypes+=JvmTypeReference)* '}' )?
('members' '{' members+=JvmMember ( "," members+=JvmMember)* '}' )?
'}';
JvmEnumerationType returns types::JvmEnumerationType:
{types::JvmEnumerationType}
(deprecated?='deprecated')?
(abstract?='abstract')?
(static?='static')?
(final?='final')?
'JvmEnumerationType'
'{'
('visibility' visibility=JvmVisibility)?
('simpleName' simpleName=EString)?
('packageName' packageName=EString)?
('annotations' '{' annotations+=JvmAnnotationReference ( "," annotations+=JvmAnnotationReference)* '}' )?
('arrayType' arrayType=JvmArrayType)?
('superTypes' '{' superTypes+=JvmTypeReference ( "," superTypes+=JvmTypeReference)* '}' )?
('members' '{' members+=JvmMember ( "," members+=JvmMember)* '}' )?
'}';
JvmGenericType returns types::JvmGenericType:
{types::JvmGenericType}
(deprecated?='deprecated')?
(abstract?='abstract')?
(static?='static')?
(final?='final')?
(interface?='interface')?
(strictFloatingPoint?='strictFloatingPoint')?
(anonymous?='anonymous')?
'JvmGenericType'
'{'
('visibility' visibility=JvmVisibility)?
('simpleName' simpleName=EString)?
('packageName' packageName=EString)?
('annotations' '{' annotations+=JvmAnnotationReference ( "," annotations+=JvmAnnotationReference)* '}' )?
('arrayType' arrayType=JvmArrayType)?
('superTypes' '{' superTypes+=JvmTypeReference ( "," superTypes+=JvmTypeReference)* '}' )?
('members' '{' members+=JvmMember ( "," members+=JvmMember)* '}' )?
('typeParameters' '{' typeParameters+=JvmTypeParameter ( "," typeParameters+=JvmTypeParameter)* '}' )?
'}';
EString returns ecore::EString:
STRING | ID;
JvmAnnotationReference returns types::JvmAnnotationReference:
{types::JvmAnnotationReference}
'JvmAnnotationReference'
'{'
('annotation' annotation=[types::JvmAnnotationType|EString])?
('explicitValues' '{' explicitValues+=JvmAnnotationValue ( "," explicitValues+=JvmAnnotationValue)* '}' )?
'}';
enum JvmVisibility returns types::JvmVisibility:
DEFAULT = 'DEFAULT' | PRIVATE = 'PRIVATE' | PROTECTED = 'PROTECTED' | PUBLIC = 'PUBLIC';
EBoolean returns ecore::EBoolean:
'true' | 'false';
JvmOperation returns types::JvmOperation:
{types::JvmOperation}
(deprecated?='deprecated')?
(varArgs?='varArgs')?
(static?='static')?
(final?='final')?
(abstract?='abstract')?
(synchronized?='synchronized')?
(default?='default')?
(native?='native')?
(strictFloatingPoint?='strictFloatingPoint')?
'JvmOperation'
'{'
('visibility' visibility=JvmVisibility)?
('simpleName' simpleName=EString)?
('annotations' '{' annotations+=JvmAnnotationReference ( "," annotations+=JvmAnnotationReference)* '}' )?
('localClasses' '{' localClasses+=JvmGenericType ( "," localClasses+=JvmGenericType)* '}' )?
('typeParameters' '{' typeParameters+=JvmTypeParameter ( "," typeParameters+=JvmTypeParameter)* '}' )?
('parameters' '{' parameters+=JvmFormalParameter ( "," parameters+=JvmFormalParameter)* '}' )?
('exceptions' '{' exceptions+=JvmTypeReference ( "," exceptions+=JvmTypeReference)* '}' )?
('returnType' returnType=JvmTypeReference)?
('defaultValue' defaultValue=JvmAnnotationValue)?
'}';
JvmIntAnnotationValue returns types::JvmIntAnnotationValue:
{types::JvmIntAnnotationValue}
'JvmIntAnnotationValue'
'{'
('values' '{' values+=EInt ( "," values+=EInt)* '}' )?
('operation' operation=[types::JvmOperation|EString])?
'}';
JvmBooleanAnnotationValue returns types::JvmBooleanAnnotationValue:
{types::JvmBooleanAnnotationValue}
'JvmBooleanAnnotationValue'
'{'
('values' '{' values+=EBoolean ( "," values+=EBoolean)* '}' )?
('operation' operation=[types::JvmOperation|EString])?
'}';
JvmByteAnnotationValue returns types::JvmByteAnnotationValue:
{types::JvmByteAnnotationValue}
'JvmByteAnnotationValue'
'{'
('values' '{' values+=EByte ( "," values+=EByte)* '}' )?
('operation' operation=[types::JvmOperation|EString])?
'}';
JvmShortAnnotationValue returns types::JvmShortAnnotationValue:
{types::JvmShortAnnotationValue}
'JvmShortAnnotationValue'
'{'
('values' '{' values+=EShort ( "," values+=EShort)* '}' )?
('operation' operation=[types::JvmOperation|EString])?
'}';
JvmLongAnnotationValue returns types::JvmLongAnnotationValue:
{types::JvmLongAnnotationValue}
'JvmLongAnnotationValue'
'{'
('values' '{' values+=ELong ( "," values+=ELong)* '}' )?
('operation' operation=[types::JvmOperation|EString])?
'}';
JvmDoubleAnnotationValue returns types::JvmDoubleAnnotationValue:
{types::JvmDoubleAnnotationValue}
'JvmDoubleAnnotationValue'
'{'
('values' '{' values+=EDouble ( "," values+=EDouble)* '}' )?
('operation' operation=[types::JvmOperation|EString])?
'}';
JvmFloatAnnotationValue returns types::JvmFloatAnnotationValue:
{types::JvmFloatAnnotationValue}
'JvmFloatAnnotationValue'
'{'
('values' '{' values+=EFloat ( "," values+=EFloat)* '}' )?
('operation' operation=[types::JvmOperation|EString])?
'}';
JvmCharAnnotationValue returns types::JvmCharAnnotationValue:
{types::JvmCharAnnotationValue}
'JvmCharAnnotationValue'
'{'
('values' '{' values+=EChar ( "," values+=EChar)* '}' )?
('operation' operation=[types::JvmOperation|EString])?
'}';
JvmStringAnnotationValue returns types::JvmStringAnnotationValue:
{types::JvmStringAnnotationValue}
'JvmStringAnnotationValue'
'{'
('values' '{' values+=EString ( "," values+=EString)* '}' )?
('operation' operation=[types::JvmOperation|EString])?
'}';
JvmTypeAnnotationValue returns types::JvmTypeAnnotationValue:
{types::JvmTypeAnnotationValue}
'JvmTypeAnnotationValue'
'{'
('operation' operation=[types::JvmOperation|EString])?
('values' '{' values+=JvmTypeReference ( "," values+=JvmTypeReference)* '}' )?
'}';
JvmAnnotationAnnotationValue returns types::JvmAnnotationAnnotationValue:
{types::JvmAnnotationAnnotationValue}
'JvmAnnotationAnnotationValue'
'{'
('operation' operation=[types::JvmOperation|EString])?
('values' '{' values+=JvmAnnotationReference ( "," values+=JvmAnnotationReference)* '}' )?
'}';
JvmEnumAnnotationValue returns types::JvmEnumAnnotationValue:
{types::JvmEnumAnnotationValue}
'JvmEnumAnnotationValue'
'{'
('operation' operation=[types::JvmOperation|EString])?
('values' '(' values+=[types::JvmEnumerationLiteral|EString] ( "," values+=[types::JvmEnumerationLiteral|EString])* ')' )?
'}';
JvmCustomAnnotationValue returns types::JvmCustomAnnotationValue:
{types::JvmCustomAnnotationValue}
'JvmCustomAnnotationValue'
'{'
('operation' operation=[types::JvmOperation|EString])?
('values' '(' values+=[ecore::EObject|EString] ( "," values+=[ecore::EObject|EString])* ')' )?
'}';
JvmFormalParameter returns types::JvmFormalParameter:
{types::JvmFormalParameter}
'JvmFormalParameter'
name=EString
'{'
('annotations' '{' annotations+=JvmAnnotationReference ( "," annotations+=JvmAnnotationReference)* '}' )?
('parameterType' parameterType=JvmTypeReference)?
'}';
EInt returns ecore::EInt:
'-'? INT;
EByte returns ecore::EByte:
'-'? INT;
EShort returns ecore::EShort:
'-'? INT;
ELong returns ecore::ELong:
'-'? INT;
EDouble returns ecore::EDouble:
'-'? INT? '.' INT (('E'|'e') '-'? INT)?;
EFloat returns ecore::EFloat:
'-'? INT? '.' INT (('E'|'e') '-'? INT)?;
EChar returns ecore::EChar:
'-'? INT;
JvmEnumerationLiteral returns types::JvmEnumerationLiteral:
{types::JvmEnumerationLiteral}
(deprecated?='deprecated')?
(static?='static')?
(final?='final')?
(volatile?='volatile')?
(transient?='transient')?
(constant?='constant')?
'JvmEnumerationLiteral'
'{'
('visibility' visibility=JvmVisibility)?
('simpleName' simpleName=EString)?
('constantValue' constantValue=EJavaObject)?
('annotations' '{' annotations+=JvmAnnotationReference ( "," annotations+=JvmAnnotationReference)* '}' )?
('localClasses' '{' localClasses+=JvmGenericType ( "," localClasses+=JvmGenericType)* '}' )?
('type' type=JvmTypeReference)?
'}';
EJavaObject returns ecore::EJavaObject:
'EJavaObject' /* TODO: implement this rule and an appropriate IValueConverter */;
EObject returns ecore::EObject:
{ecore::EObject}
'EObject'
;
JvmField_Impl returns types::JvmField:
{types::JvmField}
(deprecated?='deprecated')?
(static?='static')?
(final?='final')?
(volatile?='volatile')?
(transient?='transient')?
(constant?='constant')?
'JvmField'
'{'
('visibility' visibility=JvmVisibility)?
('simpleName' simpleName=EString)?
('constantValue' constantValue=EJavaObject)?
('annotations' '{' annotations+=JvmAnnotationReference ( "," annotations+=JvmAnnotationReference)* '}' )?
('localClasses' '{' localClasses+=JvmGenericType ( "," localClasses+=JvmGenericType)* '}' )?
('type' type=JvmTypeReference)?
'}';
JvmConstructor returns types::JvmConstructor:
{types::JvmConstructor}
(deprecated?='deprecated')?
(varArgs?='varArgs')?
'JvmConstructor'
'{'
('visibility' visibility=JvmVisibility)?
('simpleName' simpleName=EString)?
('annotations' '{' annotations+=JvmAnnotationReference ( "," annotations+=JvmAnnotationReference)* '}' )?
('localClasses' '{' localClasses+=JvmGenericType ( "," localClasses+=JvmGenericType)* '}' )?
('typeParameters' '{' typeParameters+=JvmTypeParameter ( "," typeParameters+=JvmTypeParameter)* '}' )?
('parameters' '{' parameters+=JvmFormalParameter ( "," parameters+=JvmFormalParameter)* '}' )?
('exceptions' '{' exceptions+=JvmTypeReference ( "," exceptions+=JvmTypeReference)* '}' )?
'}';
JvmUpperBound returns types::JvmUpperBound:
{types::JvmUpperBound}
'JvmUpperBound'
'{'
('typeReference' typeReference=JvmTypeReference)?
'}';
JvmLowerBound returns types::JvmLowerBound:
{types::JvmLowerBound}
'JvmLowerBound'
'{'
('typeReference' typeReference=JvmTypeReference)?
'}';
XIfExpression returns xbase::XIfExpression:
{xbase::XIfExpression}
'XIfExpression'
'{'
('if' if=XExpression)?
('then' then=XExpression)?
('else' else=XExpression)?
'}';
XSwitchExpression returns xbase::XSwitchExpression:
{xbase::XSwitchExpression}
'XSwitchExpression'
'{'
('switch' switch=XExpression)?
('cases' '{' cases+=XCasePart ( "," cases+=XCasePart)* '}' )?
('default' default=XExpression)?
('declaredParam' declaredParam=JvmFormalParameter)?
'}';
XVariableDeclaration returns xbase::XVariableDeclaration:
{xbase::XVariableDeclaration}
(writeable?='writeable')?
'XVariableDeclaration'
name=EString
'{'
('type' type=JvmTypeReference)?
('right' right=XExpression)?
'}';
XMemberFeatureCall returns xbase::XMemberFeatureCall:
{xbase::XMemberFeatureCall}
(explicitOperationCall?='explicitOperationCall')?
(explicitStatic?='explicitStatic')?
(nullSafe?='nullSafe')?
'XMemberFeatureCall'
'{'
('feature' feature=[types::JvmIdentifiableElement|EString])?
('typeArguments' '{' typeArguments+=JvmTypeReference ( "," typeArguments+=JvmTypeReference)* '}' )?
('memberCallTarget' memberCallTarget=XExpression)?
('memberCallArguments' '{' memberCallArguments+=XExpression ( "," memberCallArguments+=XExpression)* '}' )?
'}';
XFeatureCall returns xbase::XFeatureCall:
{xbase::XFeatureCall}
(explicitOperationCall?='explicitOperationCall')?
'XFeatureCall'
'{'
('feature' feature=[types::JvmIdentifiableElement|EString])?
('typeArguments' '{' typeArguments+=JvmTypeReference ( "," typeArguments+=JvmTypeReference)* '}' )?
('featureCallArguments' '{' featureCallArguments+=XExpression ( "," featureCallArguments+=XExpression)* '}' )?
'}';
XConstructorCall returns xbase::XConstructorCall:
{xbase::XConstructorCall}
(explicitConstructorCall?='explicitConstructorCall')?
'XConstructorCall'
'{'
('constructor' constructor=[types::JvmConstructor|EString])?
('arguments' '{' arguments+=XExpression ( "," arguments+=XExpression)* '}' )?
('typeArguments' '{' typeArguments+=JvmTypeReference ( "," typeArguments+=JvmTypeReference)* '}' )?
'}';
XBooleanLiteral returns xbase::XBooleanLiteral:
{xbase::XBooleanLiteral}
(isTrue?='isTrue')?
'XBooleanLiteral'
;
XNullLiteral returns xbase::XNullLiteral:
{xbase::XNullLiteral}
'XNullLiteral'
;
XNumberLiteral returns xbase::XNumberLiteral:
{xbase::XNumberLiteral}
'XNumberLiteral'
'{'
('value' value=EString)?
'}';
XStringLiteral returns xbase::XStringLiteral:
{xbase::XStringLiteral}
'XStringLiteral'
'{'
('value' value=EString)?
'}';
XListLiteral returns xbase::XListLiteral:
{xbase::XListLiteral}
'XListLiteral'
'{'
('elements' '{' elements+=XExpression ( "," elements+=XExpression)* '}' )?
'}';
XSetLiteral returns xbase::XSetLiteral:
{xbase::XSetLiteral}
'XSetLiteral'
'{'
('elements' '{' elements+=XExpression ( "," elements+=XExpression)* '}' )?
'}';
XClosure returns xbase::XClosure:
{xbase::XClosure}
(explicitSyntax?='explicitSyntax')?
'XClosure'
'{'
('declaredFormalParameters' '{' declaredFormalParameters+=JvmFormalParameter ( "," declaredFormalParameters+=JvmFormalParameter)* '}' )?
('expression' expression=XExpression)?
'}';
XCastedExpression returns xbase::XCastedExpression:
{xbase::XCastedExpression}
'XCastedExpression'
'{'
('type' type=JvmTypeReference)?
('target' target=XExpression)?
'}';
XBinaryOperation returns xbase::XBinaryOperation:
{xbase::XBinaryOperation}
(reassignFirstArgument?='reassignFirstArgument')?
'XBinaryOperation'
'{'
('feature' feature=[types::JvmIdentifiableElement|EString])?
('typeArguments' '{' typeArguments+=JvmTypeReference ( "," typeArguments+=JvmTypeReference)* '}' )?
('leftOperand' leftOperand=XExpression)?
('rightOperand' rightOperand=XExpression)?
'}';
XUnaryOperation returns xbase::XUnaryOperation:
{xbase::XUnaryOperation}
'XUnaryOperation'
'{'
('feature' feature=[types::JvmIdentifiableElement|EString])?
('typeArguments' '{' typeArguments+=JvmTypeReference ( "," typeArguments+=JvmTypeReference)* '}' )?
('operand' operand=XExpression)?
'}';
XPostfixOperation returns xbase::XPostfixOperation:
{xbase::XPostfixOperation}
'XPostfixOperation'
'{'
('feature' feature=[types::JvmIdentifiableElement|EString])?
('typeArguments' '{' typeArguments+=JvmTypeReference ( "," typeArguments+=JvmTypeReference)* '}' )?
('operand' operand=XExpression)?
'}';
XForLoopExpression returns xbase::XForLoopExpression:
{xbase::XForLoopExpression}
'XForLoopExpression'
'{'
('forExpression' forExpression=XExpression)?
('eachExpression' eachExpression=XExpression)?
('declaredParam' declaredParam=JvmFormalParameter)?
'}';
XBasicForLoopExpression returns xbase::XBasicForLoopExpression:
{xbase::XBasicForLoopExpression}
'XBasicForLoopExpression'
'{'
('expression' expression=XExpression)?
('eachExpression' eachExpression=XExpression)?
('initExpressions' '{' initExpressions+=XExpression ( "," initExpressions+=XExpression)* '}' )?
('updateExpressions' '{' updateExpressions+=XExpression ( "," updateExpressions+=XExpression)* '}' )?
'}';
XDoWhileExpression returns xbase::XDoWhileExpression:
{xbase::XDoWhileExpression}
'XDoWhileExpression'
'{'
('predicate' predicate=XExpression)?
('body' body=XExpression)?
'}';
XWhileExpression returns xbase::XWhileExpression:
{xbase::XWhileExpression}
'XWhileExpression'
'{'
('predicate' predicate=XExpression)?
('body' body=XExpression)?
'}';
XTypeLiteral returns xbase::XTypeLiteral:
'XTypeLiteral'
'{'
('arrayDimensions' '{' arrayDimensions+=EString ( "," arrayDimensions+=EString)* '}' )?
'type' type=[types::JvmType|EString]
'}';
XInstanceOfExpression returns xbase::XInstanceOfExpression:
'XInstanceOfExpression'
'{'
'type' type=JvmTypeReference
'expression' expression=XExpression
'}';
XThrowExpression returns xbase::XThrowExpression:
{xbase::XThrowExpression}
'XThrowExpression'
'{'
('expression' expression=XExpression)?
'}';
XTryCatchFinallyExpression returns xbase::XTryCatchFinallyExpression:
{xbase::XTryCatchFinallyExpression}
'XTryCatchFinallyExpression'
'{'
('expression' expression=XExpression)?
('finallyExpression' finallyExpression=XExpression)?
('catchClauses' '{' catchClauses+=XCatchClause ( "," catchClauses+=XCatchClause)* '}' )?
'}';
XAssignment returns xbase::XAssignment:
{xbase::XAssignment}
(explicitStatic?='explicitStatic')?
'XAssignment'
'{'
('feature' feature=[types::JvmIdentifiableElement|EString])?
('typeArguments' '{' typeArguments+=JvmTypeReference ( "," typeArguments+=JvmTypeReference)* '}' )?
('assignable' assignable=XExpression)?
('value' value=XExpression)?
'}';
Rebuilds Xbase grammar without reusing it…
Wizard does crazy things…// automatically generated by Xtext
grammar org.xtext.example.mydsl.MyDsl with org.eclipse.xtext.common.Terminals
import "http://www.xtext.org/example/xbase"
import "http://www.eclipse.org/xtext/common/JavaVMTypes" as types
import "http://www.eclipse.org/xtext/xbase/Xbase" as xbase
import "http://www.eclipse.org/emf/2002/Ecore" as ecore
MyClass returns MyClass:
{MyClass}
'MyClass'
'{'
('ref' ref=JvmTypeReference)?
('body' body=XBlockExpression)?
'}';
JvmTypeReference returns types::JvmTypeReference:
JvmParameterizedTypeReference_Impl | JvmGenericArrayTypeReference | JvmWildcardTypeReference | JvmAnyTypeReference | JvmMultiTypeReference | JvmDelegateTypeReference | JvmSynonymTypeReference | JvmUnknownTypeReference | JvmInnerTypeReference;
XExpression returns xbase::XExpression:
XIfExpression | XSwitchExpression | XBlockExpression | XVariableDeclaration | XMemberFeatureCall | XFeatureCall | XConstructorCall | XBooleanLiteral | XNullLiteral | XNumberLiteral | XStringLiteral | XListLiteral | XSetLiteral | XClosure | XCastedExpression | XBinaryOperation | XUnaryOperation | XPostfixOperation | XForLoopExpression | XBasicForLoopExpression | XDoWhileExpression | XWhileExpression | XTypeLiteral | XInstanceOfExpression | XThrowExpression | XTryCatchFinallyExpression | XAssignment | XReturnExpression | XSynchronizedExpression;
JvmType returns types::JvmType:
JvmVoid | JvmPrimitiveType | JvmArrayType | JvmTypeParameter | JvmAnnotationType | JvmEnumerationType | JvmGenericType;
JvmTypeConstraint returns types::JvmTypeConstraint:
JvmUpperBound | JvmLowerBound;
JvmParameterizedTypeReference returns types::JvmParameterizedTypeReference:
JvmParameterizedTypeReference_Impl | JvmInnerTypeReference;
JvmMember returns types::JvmMember:
JvmAnnotationType | JvmEnumerationType | JvmEnumerationLiteral | JvmGenericType | JvmField_Impl | JvmConstructor | JvmOperation;
JvmAnnotationValue returns types::JvmAnnotationValue:
JvmIntAnnotationValue | JvmBooleanAnnotationValue | JvmByteAnnotationValue | JvmShortAnnotationValue | JvmLongAnnotationValue | JvmDoubleAnnotationValue | JvmFloatAnnotationValue | JvmCharAnnotationValue | JvmStringAnnotationValue | JvmTypeAnnotationValue | JvmAnnotationAnnotationValue | JvmEnumAnnotationValue | JvmCustomAnnotationValue;
JvmIdentifiableElement returns types::JvmIdentifiableElement:
JvmVoid | JvmPrimitiveType | JvmArrayType | JvmTypeParameter | JvmAnnotationType | JvmEnumerationType | JvmEnumerationLiteral | JvmGenericType | JvmField_Impl | JvmConstructor | JvmOperation | JvmFormalParameter;
XBlockExpression returns xbase::XBlockExpression:
{xbase::XBlockExpression}
'XBlockExpression'
'{'
('expressions' '{' expressions+=XExpression ( "," expressions+=XExpression)* '}' )?
'}';
JvmParameterizedTypeReference_Impl returns types::JvmParameterizedTypeReference:
{types::JvmParameterizedTypeReference}
'JvmParameterizedTypeReference'
'{'
('type' type=[types::JvmType|EString])?
('arguments' '{' arguments+=JvmTypeReference ( "," arguments+=JvmTypeReference)* '}' )?
'}';
JvmGenericArrayTypeReference returns types::JvmGenericArrayTypeReference:
{types::JvmGenericArrayTypeReference}
'JvmGenericArrayTypeReference'
'{'
('componentType' componentType=JvmTypeReference)?
'}';
JvmWildcardTypeReference returns types::JvmWildcardTypeReference:
{types::JvmWildcardTypeReference}
'JvmWildcardTypeReference'
'{'
('constraints' '{' constraints+=JvmTypeConstraint ( "," constraints+=JvmTypeConstraint)* '}' )?
'}';
JvmAnyTypeReference returns types::JvmAnyTypeReference:
{types::JvmAnyTypeReference}
'JvmAnyTypeReference'
'{'
('type' type=[types::JvmType|EString])?
'}';
JvmMultiTypeReference returns types::JvmMultiTypeReference:
{types::JvmMultiTypeReference}
'JvmMultiTypeReference'
'{'
('type' type=[types::JvmType|EString])?
('references' '{' references+=JvmTypeReference ( "," references+=JvmTypeReference)* '}' )?
'}';
JvmDelegateTypeReference returns types::JvmDelegateTypeReference:
{types::JvmDelegateTypeReference}
'JvmDelegateTypeReference'
'{'
('delegate' delegate=[types::JvmTypeReference|EString])?
'}';
JvmSynonymTypeReference returns types::JvmSynonymTypeReference:
{types::JvmSynonymTypeReference}
'JvmSynonymTypeReference'
'{'
('type' type=[types::JvmType|EString])?
('references' '{' references+=JvmTypeReference ( "," references+=JvmTypeReference)* '}' )?
'}';
JvmUnknownTypeReference returns types::JvmUnknownTypeReference:
{types::JvmUnknownTypeReference}
'JvmUnknownTypeReference'
;
JvmInnerTypeReference returns types::JvmInnerTypeReference:
{types::JvmInnerTypeReference}
'JvmInnerTypeReference'
'{'
('type' type=[types::JvmType|EString])?
('arguments' '{' arguments+=JvmTypeReference ( "," arguments+=JvmTypeReference)* '}' )?
('outer' outer=JvmParameterizedTypeReference)?
'}';
JvmVoid returns types::JvmVoid:
{types::JvmVoid}
'JvmVoid'
;
JvmPrimitiveType returns types::JvmPrimitiveType:
{types::JvmPrimitiveType}
'JvmPrimitiveType'
'{'
('simpleName' simpleName=EString)?
('arrayType' arrayType=JvmArrayType)?
'}';
JvmArrayType returns types::JvmArrayType:
{types::JvmArrayType}
'JvmArrayType'
'{'
('arrayType' arrayType=JvmArrayType)?
'}';
JvmTypeParameter returns types::JvmTypeParameter:
{types::JvmTypeParameter}
'JvmTypeParameter'
name=EString
'{'
('arrayType' arrayType=JvmArrayType)?
('constraints' '{' constraints+=JvmTypeConstraint ( "," constraints+=JvmTypeConstraint)* '}' )?
'}';
JvmAnnotationType returns types::JvmAnnotationType:
{types::JvmAnnotationType}
(deprecated?='deprecated')?
(abstract?='abstract')?
(static?='static')?
(final?='final')?
'JvmAnnotationType'
'{'
('visibility' visibility=JvmVisibility)?
('simpleName' simpleName=EString)?
('packageName' packageName=EString)?
('annotations' '{' annotations+=JvmAnnotationReference ( "," annotations+=JvmAnnotationReference)* '}' )?
('arrayType' arrayType=JvmArrayType)?
('superTypes' '{' superTypes+=JvmTypeReference ( "," superTypes+=JvmTypeReference)* '}' )?
('members' '{' members+=JvmMember ( "," members+=JvmMember)* '}' )?
'}';
JvmEnumerationType returns types::JvmEnumerationType:
{types::JvmEnumerationType}
(deprecated?='deprecated')?
(abstract?='abstract')?
(static?='static')?
(final?='final')?
'JvmEnumerationType'
'{'
('visibility' visibility=JvmVisibility)?
('simpleName' simpleName=EString)?
('packageName' packageName=EString)?
('annotations' '{' annotations+=JvmAnnotationReference ( "," annotations+=JvmAnnotationReference)* '}' )?
('arrayType' arrayType=JvmArrayType)?
('superTypes' '{' superTypes+=JvmTypeReference ( "," superTypes+=JvmTypeReference)* '}' )?
('members' '{' members+=JvmMember ( "," members+=JvmMember)* '}' )?
'}';
JvmGenericType returns types::JvmGenericType:
{types::JvmGenericType}
(deprecated?='deprecated')?
(abstract?='abstract')?
(static?='static')?
(final?='final')?
(interface?='interface')?
(strictFloatingPoint?='strictFloatingPoint')?
(anonymous?='anonymous')?
'JvmGenericType'
'{'
('visibility' visibility=JvmVisibility)?
('simpleName' simpleName=EString)?
('packageName' packageName=EString)?
('annotations' '{' annotations+=JvmAnnotationReference ( "," annotations+=JvmAnnotationReference)* '}' )?
('arrayType' arrayType=JvmArrayType)?
('superTypes' '{' superTypes+=JvmTypeReference ( "," superTypes+=JvmTypeReference)* '}' )?
('members' '{' members+=JvmMember ( "," members+=JvmMember)* '}' )?
('typeParameters' '{' typeParameters+=JvmTypeParameter ( "," typeParameters+=JvmTypeParameter)* '}' )?
'}';
EString returns ecore::EString:
STRING | ID;
JvmAnnotationReference returns types::JvmAnnotationReference:
{types::JvmAnnotationReference}
'JvmAnnotationReference'
'{'
('annotation' annotation=[types::JvmAnnotationType|EString])?
('explicitValues' '{' explicitValues+=JvmAnnotationValue ( "," explicitValues+=JvmAnnotationValue)* '}' )?
'}';
enum JvmVisibility returns types::JvmVisibility:
DEFAULT = 'DEFAULT' | PRIVATE = 'PRIVATE' | PROTECTED = 'PROTECTED' | PUBLIC = 'PUBLIC';
EBoolean returns ecore::EBoolean:
'true' | 'false';
JvmOperation returns types::JvmOperation:
{types::JvmOperation}
(deprecated?='deprecated')?
(varArgs?='varArgs')?
(static?='static')?
(final?='final')?
(abstract?='abstract')?
(synchronized?='synchronized')?
(default?='default')?
(native?='native')?
(strictFloatingPoint?='strictFloatingPoint')?
'JvmOperation'
'{'
('visibility' visibility=JvmVisibility)?
('simpleName' simpleName=EString)?
('annotations' '{' annotations+=JvmAnnotationReference ( "," annotations+=JvmAnnotationReference)* '}' )?
('localClasses' '{' localClasses+=JvmGenericType ( "," localClasses+=JvmGenericType)* '}' )?
('typeParameters' '{' typeParameters+=JvmTypeParameter ( "," typeParameters+=JvmTypeParameter)* '}' )?
('parameters' '{' parameters+=JvmFormalParameter ( "," parameters+=JvmFormalParameter)* '}' )?
('exceptions' '{' exceptions+=JvmTypeReference ( "," exceptions+=JvmTypeReference)* '}' )?
('returnType' returnType=JvmTypeReference)?
('defaultValue' defaultValue=JvmAnnotationValue)?
'}';
JvmIntAnnotationValue returns types::JvmIntAnnotationValue:
{types::JvmIntAnnotationValue}
'JvmIntAnnotationValue'
'{'
('values' '{' values+=EInt ( "," values+=EInt)* '}' )?
('operation' operation=[types::JvmOperation|EString])?
'}';
JvmBooleanAnnotationValue returns types::JvmBooleanAnnotationValue:
{types::JvmBooleanAnnotationValue}
'JvmBooleanAnnotationValue'
'{'
('values' '{' values+=EBoolean ( "," values+=EBoolean)* '}' )?
('operation' operation=[types::JvmOperation|EString])?
'}';
JvmByteAnnotationValue returns types::JvmByteAnnotationValue:
{types::JvmByteAnnotationValue}
'JvmByteAnnotationValue'
'{'
('values' '{' values+=EByte ( "," values+=EByte)* '}' )?
('operation' operation=[types::JvmOperation|EString])?
'}';
JvmShortAnnotationValue returns types::JvmShortAnnotationValue:
{types::JvmShortAnnotationValue}
'JvmShortAnnotationValue'
'{'
('values' '{' values+=EShort ( "," values+=EShort)* '}' )?
('operation' operation=[types::JvmOperation|EString])?
'}';
JvmLongAnnotationValue returns types::JvmLongAnnotationValue:
{types::JvmLongAnnotationValue}
'JvmLongAnnotationValue'
'{'
('values' '{' values+=ELong ( "," values+=ELong)* '}' )?
('operation' operation=[types::JvmOperation|EString])?
'}';
JvmDoubleAnnotationValue returns types::JvmDoubleAnnotationValue:
{types::JvmDoubleAnnotationValue}
'JvmDoubleAnnotationValue'
'{'
('values' '{' values+=EDouble ( "," values+=EDouble)* '}' )?
('operation' operation=[types::JvmOperation|EString])?
'}';
JvmFloatAnnotationValue returns types::JvmFloatAnnotationValue:
{types::JvmFloatAnnotationValue}
'JvmFloatAnnotationValue'
'{'
('values' '{' values+=EFloat ( "," values+=EFloat)* '}' )?
('operation' operation=[types::JvmOperation|EString])?
'}';
JvmCharAnnotationValue returns types::JvmCharAnnotationValue:
{types::JvmCharAnnotationValue}
'JvmCharAnnotationValue'
'{'
('values' '{' values+=EChar ( "," values+=EChar)* '}' )?
('operation' operation=[types::JvmOperation|EString])?
'}';
JvmStringAnnotationValue returns types::JvmStringAnnotationValue:
{types::JvmStringAnnotationValue}
'JvmStringAnnotationValue'
'{'
('values' '{' values+=EString ( "," values+=EString)* '}' )?
('operation' operation=[types::JvmOperation|EString])?
'}';
JvmTypeAnnotationValue returns types::JvmTypeAnnotationValue:
{types::JvmTypeAnnotationValue}
'JvmTypeAnnotationValue'
'{'
('operation' operation=[types::JvmOperation|EString])?
('values' '{' values+=JvmTypeReference ( "," values+=JvmTypeReference)* '}' )?
'}';
JvmAnnotationAnnotationValue returns types::JvmAnnotationAnnotationValue:
{types::JvmAnnotationAnnotationValue}
'JvmAnnotationAnnotationValue'
'{'
('operation' operation=[types::JvmOperation|EString])?
('values' '{' values+=JvmAnnotationReference ( "," values+=JvmAnnotationReference)* '}' )?
'}';
JvmEnumAnnotationValue returns types::JvmEnumAnnotationValue:
{types::JvmEnumAnnotationValue}
'JvmEnumAnnotationValue'
'{'
('operation' operation=[types::JvmOperation|EString])?
('values' '(' values+=[types::JvmEnumerationLiteral|EString] ( "," values+=[types::JvmEnumerationLiteral|EString])* ')' )?
'}';
JvmCustomAnnotationValue returns types::JvmCustomAnnotationValue:
{types::JvmCustomAnnotationValue}
'JvmCustomAnnotationValue'
'{'
('operation' operation=[types::JvmOperation|EString])?
('values' '(' values+=[ecore::EObject|EString] ( "," values+=[ecore::EObject|EString])* ')' )?
'}';
JvmFormalParameter returns types::JvmFormalParameter:
{types::JvmFormalParameter}
'JvmFormalParameter'
name=EString
'{'
('annotations' '{' annotations+=JvmAnnotationReference ( "," annotations+=JvmAnnotationReference)* '}' )?
('parameterType' parameterType=JvmTypeReference)?
'}';
EInt returns ecore::EInt:
'-'? INT;
EByte returns ecore::EByte:
'-'? INT;
EShort returns ecore::EShort:
'-'? INT;
ELong returns ecore::ELong:
'-'? INT;
EDouble returns ecore::EDouble:
'-'? INT? '.' INT (('E'|'e') '-'? INT)?;
EFloat returns ecore::EFloat:
'-'? INT? '.' INT (('E'|'e') '-'? INT)?;
EChar returns ecore::EChar:
'-'? INT;
JvmEnumerationLiteral returns types::JvmEnumerationLiteral:
{types::JvmEnumerationLiteral}
(deprecated?='deprecated')?
(static?='static')?
(final?='final')?
(volatile?='volatile')?
(transient?='transient')?
(constant?='constant')?
'JvmEnumerationLiteral'
'{'
('visibility' visibility=JvmVisibility)?
('simpleName' simpleName=EString)?
('constantValue' constantValue=EJavaObject)?
('annotations' '{' annotations+=JvmAnnotationReference ( "," annotations+=JvmAnnotationReference)* '}' )?
('localClasses' '{' localClasses+=JvmGenericType ( "," localClasses+=JvmGenericType)* '}' )?
('type' type=JvmTypeReference)?
'}';
EJavaObject returns ecore::EJavaObject:
'EJavaObject' /* TODO: implement this rule and an appropriate IValueConverter */;
EObject returns ecore::EObject:
{ecore::EObject}
'EObject'
;
JvmField_Impl returns types::JvmField:
{types::JvmField}
(deprecated?='deprecated')?
(static?='static')?
(final?='final')?
(volatile?='volatile')?
(transient?='transient')?
(constant?='constant')?
'JvmField'
'{'
('visibility' visibility=JvmVisibility)?
('simpleName' simpleName=EString)?
('constantValue' constantValue=EJavaObject)?
('annotations' '{' annotations+=JvmAnnotationReference ( "," annotations+=JvmAnnotationReference)* '}' )?
('localClasses' '{' localClasses+=JvmGenericType ( "," localClasses+=JvmGenericType)* '}' )?
('type' type=JvmTypeReference)?
'}';
JvmConstructor returns types::JvmConstructor:
{types::JvmConstructor}
(deprecated?='deprecated')?
(varArgs?='varArgs')?
'JvmConstructor'
'{'
('visibility' visibility=JvmVisibility)?
('simpleName' simpleName=EString)?
('annotations' '{' annotations+=JvmAnnotationReference ( "," annotations+=JvmAnnotationReference)* '}' )?
('localClasses' '{' localClasses+=JvmGenericType ( "," localClasses+=JvmGenericType)* '}' )?
('typeParameters' '{' typeParameters+=JvmTypeParameter ( "," typeParameters+=JvmTypeParameter)* '}' )?
('parameters' '{' parameters+=JvmFormalParameter ( "," parameters+=JvmFormalParameter)* '}' )?
('exceptions' '{' exceptions+=JvmTypeReference ( "," exceptions+=JvmTypeReference)* '}' )?
'}';
JvmUpperBound returns types::JvmUpperBound:
{types::JvmUpperBound}
'JvmUpperBound'
'{'
('typeReference' typeReference=JvmTypeReference)?
'}';
JvmLowerBound returns types::JvmLowerBound:
{types::JvmLowerBound}
'JvmLowerBound'
'{'
('typeReference' typeReference=JvmTypeReference)?
'}';
XIfExpression returns xbase::XIfExpression:
{xbase::XIfExpression}
'XIfExpression'
'{'
('if' if=XExpression)?
('then' then=XExpression)?
('else' else=XExpression)?
'}';
XSwitchExpression returns xbase::XSwitchExpression:
{xbase::XSwitchExpression}
'XSwitchExpression'
'{'
('switch' switch=XExpression)?
('cases' '{' cases+=XCasePart ( "," cases+=XCasePart)* '}' )?
('default' default=XExpression)?
('declaredParam' declaredParam=JvmFormalParameter)?
'}';
XVariableDeclaration returns xbase::XVariableDeclaration:
{xbase::XVariableDeclaration}
(writeable?='writeable')?
'XVariableDeclaration'
name=EString
'{'
('type' type=JvmTypeReference)?
('right' right=XExpression)?
'}';
XMemberFeatureCall returns xbase::XMemberFeatureCall:
{xbase::XMemberFeatureCall}
(explicitOperationCall?='explicitOperationCall')?
(explicitStatic?='explicitStatic')?
(nullSafe?='nullSafe')?
'XMemberFeatureCall'
'{'
('feature' feature=[types::JvmIdentifiableElement|EString])?
('typeArguments' '{' typeArguments+=JvmTypeReference ( "," typeArguments+=JvmTypeReference)* '}' )?
('memberCallTarget' memberCallTarget=XExpression)?
('memberCallArguments' '{' memberCallArguments+=XExpression ( "," memberCallArguments+=XExpression)* '}' )?
'}';
XFeatureCall returns xbase::XFeatureCall:
{xbase::XFeatureCall}
(explicitOperationCall?='explicitOperationCall')?
'XFeatureCall'
'{'
('feature' feature=[types::JvmIdentifiableElement|EString])?
('typeArguments' '{' typeArguments+=JvmTypeReference ( "," typeArguments+=JvmTypeReference)* '}' )?
('featureCallArguments' '{' featureCallArguments+=XExpression ( "," featureCallArguments+=XExpression)* '}' )?
'}';
XConstructorCall returns xbase::XConstructorCall:
{xbase::XConstructorCall}
(explicitConstructorCall?='explicitConstructorCall')?
'XConstructorCall'
'{'
('constructor' constructor=[types::JvmConstructor|EString])?
('arguments' '{' arguments+=XExpression ( "," arguments+=XExpression)* '}' )?
('typeArguments' '{' typeArguments+=JvmTypeReference ( "," typeArguments+=JvmTypeReference)* '}' )?
'}';
XBooleanLiteral returns xbase::XBooleanLiteral:
{xbase::XBooleanLiteral}
(isTrue?='isTrue')?
'XBooleanLiteral'
;
XNullLiteral returns xbase::XNullLiteral:
{xbase::XNullLiteral}
'XNullLiteral'
;
XNumberLiteral returns xbase::XNumberLiteral:
{xbase::XNumberLiteral}
'XNumberLiteral'
'{'
('value' value=EString)?
'}';
XStringLiteral returns xbase::XStringLiteral:
{xbase::XStringLiteral}
'XStringLiteral'
'{'
('value' value=EString)?
'}';
XListLiteral returns xbase::XListLiteral:
{xbase::XListLiteral}
'XListLiteral'
'{'
('elements' '{' elements+=XExpression ( "," elements+=XExpression)* '}' )?
'}';
XSetLiteral returns xbase::XSetLiteral:
{xbase::XSetLiteral}
'XSetLiteral'
'{'
('elements' '{' elements+=XExpression ( "," elements+=XExpression)* '}' )?
'}';
XClosure returns xbase::XClosure:
{xbase::XClosure}
(explicitSyntax?='explicitSyntax')?
'XClosure'
'{'
('declaredFormalParameters' '{' declaredFormalParameters+=JvmFormalParameter ( "," declaredFormalParameters+=JvmFormalParameter)* '}' )?
('expression' expression=XExpression)?
'}';
XCastedExpression returns xbase::XCastedExpression:
{xbase::XCastedExpression}
'XCastedExpression'
'{'
('type' type=JvmTypeReference)?
('target' target=XExpression)?
'}';
XBinaryOperation returns xbase::XBinaryOperation:
{xbase::XBinaryOperation}
(reassignFirstArgument?='reassignFirstArgument')?
'XBinaryOperation'
'{'
('feature' feature=[types::JvmIdentifiableElement|EString])?
('typeArguments' '{' typeArguments+=JvmTypeReference ( "," typeArguments+=JvmTypeReference)* '}' )?
('leftOperand' leftOperand=XExpression)?
('rightOperand' rightOperand=XExpression)?
'}';
XUnaryOperation returns xbase::XUnaryOperation:
{xbase::XUnaryOperation}
'XUnaryOperation'
'{'
('feature' feature=[types::JvmIdentifiableElement|EString])?
('typeArguments' '{' typeArguments+=JvmTypeReference ( "," typeArguments+=JvmTypeReference)* '}' )?
('operand' operand=XExpression)?
'}';
XPostfixOperation returns xbase::XPostfixOperation:
{xbase::XPostfixOperation}
'XPostfixOperation'
'{'
('feature' feature=[types::JvmIdentifiableElement|EString])?
('typeArguments' '{' typeArguments+=JvmTypeReference ( "," typeArguments+=JvmTypeReference)* '}' )?
('operand' operand=XExpression)?
'}';
XForLoopExpression returns xbase::XForLoopExpression:
{xbase::XForLoopExpression}
'XForLoopExpression'
'{'
('forExpression' forExpression=XExpression)?
('eachExpression' eachExpression=XExpression)?
('declaredParam' declaredParam=JvmFormalParameter)?
'}';
XBasicForLoopExpression returns xbase::XBasicForLoopExpression:
{xbase::XBasicForLoopExpression}
'XBasicForLoopExpression'
'{'
('expression' expression=XExpression)?
('eachExpression' eachExpression=XExpression)?
('initExpressions' '{' initExpressions+=XExpression ( "," initExpressions+=XExpression)* '}' )?
('updateExpressions' '{' updateExpressions+=XExpression ( "," updateExpressions+=XExpression)* '}' )?
'}';
XDoWhileExpression returns xbase::XDoWhileExpression:
{xbase::XDoWhileExpression}
'XDoWhileExpression'
'{'
('predicate' predicate=XExpression)?
('body' body=XExpression)?
'}';
XWhileExpression returns xbase::XWhileExpression:
{xbase::XWhileExpression}
'XWhileExpression'
'{'
('predicate' predicate=XExpression)?
('body' body=XExpression)?
'}';
XTypeLiteral returns xbase::XTypeLiteral:
'XTypeLiteral'
'{'
('arrayDimensions' '{' arrayDimensions+=EString ( "," arrayDimensions+=EString)* '}' )?
'type' type=[types::JvmType|EString]
'}';
XInstanceOfExpression returns xbase::XInstanceOfExpression:
'XInstanceOfExpression'
'{'
'type' type=JvmTypeReference
'expression' expression=XExpression
'}';
XThrowExpression returns xbase::XThrowExpression:
{xbase::XThrowExpression}
'XThrowExpression'
'{'
('expression' expression=XExpression)?
'}';
XTryCatchFinallyExpression returns xbase::XTryCatchFinallyExpression:
{xbase::XTryCatchFinallyExpression}
'XTryCatchFinallyExpression'
'{'
('expression' expression=XExpression)?
('finallyExpression' finallyExpression=XExpression)?
('catchClauses' '{' catchClauses+=XCatchClause ( "," catchClauses+=XCatchClause)* '}' )?
'}';
XAssignment returns xbase::XAssignment:
{xbase::XAssignment}
(explicitStatic?='explicitStatic')?
'XAssignment'
'{'
('feature' feature=[types::JvmIdentifiableElement|EString])?
('typeArguments' '{' typeArguments+=JvmTypeReference ( "," typeArguments+=JvmTypeReference)* '}' )?
('assignable' assignable=XExpression)?
('value' value=XExpression)?
'}';
Generator wrongly configured
Using Xbase
Using Xbase
I am missing the Maven part…
https://github.com/holgerschill/XtextCon_Xcore_Maven
A full working example can be found here
Tycho
Xtext Maven Plugin
Exec-Maven-Plugin
Xtend Maven Plugin
Pittfalls
<plugin>
<groupId>org.eclipse.xtext</groupId>
<artifactId>xtext-maven-plugin</artifactId>
<version>${xtext-version}</version>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
<configuration>
<languages>
<language>
<setup>org.eclipse.xtext.ecore.EcoreSupport</setup>
</language>
<language>
<setup>org.eclipse.emf.codegen.ecore.xtext.GenModelSupport</setup>
</language>
<language>
<setup>org.eclipse.emf.ecore.xcore.XcoreStandaloneSetup</setup>
</language>
</languages>
<sourceRoots>
<root>${project.basedir}/model</root>
</sourceRoots>
</configuration>
Register right languages for Xcore
Pittfalls
Right dependencies to generate Java out of Xcore
<dependencies>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.core</artifactId>
<version>4.3.1</version>
</dependency>
<dependency>
<groupId>org.eclipse.core</groupId>
<artifactId>org.eclipse.core.resources</artifactId>
<version>3.7.100</version>
</dependency>
<dependency>
<groupId>org.eclipse.text</groupId>
<artifactId>org.eclipse.text</artifactId>
<version>3.5.101</version>
</dependency>
<dependency>
<groupId>org.eclipse.emf</groupId>
<artifactId>org.eclipse.emf.codegen.ecore.xtext</artifactId>
<version>${ecore-xtext-version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.emf</groupId>
<artifactId>org.eclipse.emf.ecore.xcore.lib</artifactId>
<version>${ecore-xcore-lib-version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.emf</groupId>
<artifactId>org.eclipse.emf.ecore.xcore</artifactId>
<version>${ecore-xcore-version}</version>
</dependency>
</dependencies>
Pittfalls
Set modelDirectory in Xcore files explicitly
@GenModel(modelDirectory="./src-gen")
package org.xtext.example.myfirstdsl
import common.NamedElement
import common.Referenceable
class FirstElement extends NamedElement, Referenceable {
refers Referenceable ref
}
Pittfalls
Don’t use classpath URIs in MWE2
var fileExtensions = "first"
var projectName = "org.xtext.example.firstdsl.lang"
var runtimeProject = "../${projectName}"
var generateXtendStub = true
//var grammarURI = "classpath:/org/xtext/example/firstdsl/Lang.xtext"
var grammarURI = "platform:/resource/${projectName}/src/org/xtext/example/firstdsl/Lang.xtext"
Pittfalls
Explicitly set path to generate Java classes
// generates Java API for the generated EPackages
fragment = ecore.EMFGeneratorFragment auto-inject {
javaModelDirectory = "/${projectName}/src-gen"
}
Questions?

Using Xcore with Xtext

  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
    You will cometo the point… Where you want to take control…
  • 6.
    Problem grammar org.xtext.example.mydsl.MyDsl withorg.eclipse.xtext.common.Terminals generate myDsl "http://www.xtext.org/example/mydsl/MyDsl" Model: elements+=AbstractElement*; AbstractElement: Element | SecondElement | ThirdElement ; Element: 'Element' name=ID ref=[AbstractElement] ; SecondElement: 'SecondElement' name=ID ; ThirdElement: 'ThirdElement' name=ID ; Example
  • 7.
    Problem grammar org.xtext.example.mydsl.MyDsl withorg.eclipse.xtext.common.Terminals generate myDsl "http://www.xtext.org/example/mydsl/MyDsl" Model: elements+=AbstractElement*; AbstractElement: Element | SecondElement | ThirdElement ; Element: 'Element' name=ID ref=[AbstractElement] ; SecondElement: 'SecondElement' name=ID ; ThirdElement: 'ThirdElement' name=ID ; Example
  • 8.
    grammar org.xtext.example.mydsl.MyDsl withorg.eclipse.xtext.common.Terminals generate myDsl "http://www.xtext.org/example/mydsl/MyDsl" Model: elements+=AbstractElement*; AbstractElement: Element | SecondElement | ThirdElement ; Element: 'Element' name=ID ref=[Referenceable] ; SecondElement: 'SecondElement' name=ID ; ThirdElement: 'ThirdElement' name=ID ; Referenceable: SecondElement | ThirdElement ; Never invoked by the parser Example Fake Rules to influence EMF Generator
  • 9.
    For rapid prototypingthe generated model is fine When to stay with the generated model
  • 10.
    For rapid prototypingthe generated model is fine Automatic synchronisation from grammar to model When to stay with the generated model
  • 11.
    For rapid prototypingthe generated model is fine Automatic synchronisation from grammar to model If you do not need to introduce fake rules When to stay with the generated model
  • 12.
    But what if… DSLDSL DSL Order for generating DSLs is important
  • 13.
    But what if… DSLDSL DSL Order for generating DSLs is important Eagerly loaded
  • 14.
    DSL DSL DSLs referenceeach other But what if…
  • 15.
  • 16.
  • 17.
  • 18.
    Still that treeeditor…
  • 19.
    Still that treeeditor… Merging can be difficult
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
    Put code directlyin the model
  • 25.
    Put code directlyin the model
  • 26.
    Load Xcore file NoRegistration needed Workflow configuration
  • 27.
    Don’t forget theXcore dependency
  • 28.
    Don’t forget theXcore dependency Caused by: org.xml.sax.SAXParseExceptionpublicId: platform:/resource/org.xtext.example.mydsl.model/model/MyDsl.xcore; systemId: platform:/resource/org.xtext.example.mydsl.model/model/MyDsl.xcore; lineNumber: 1; columnNumber: 1; Content is not allowed in prolog. at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:203) at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(ErrorHandlerWrapper.java:177) at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:441) at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:368) at com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(XMLScanner.java:1436) at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(XMLDocumentScannerImpl.java:999) at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:606) at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java: 510) at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:848) at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:777) at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141) Invokes XcoreStandaloneSetup to register *.xcore
  • 29.
    There is awizard for that…
  • 30.
    More complex setups Ecore model Xcore model XtextDSL Xcore imports another ecore model Xtext DSL imports Xcore
  • 31.
  • 32.
  • 33.
    Caused by: java.lang.IllegalStateException:Problem parsing 'classpath:/org/xtext/example/ mydsl/MyDsl.xtext': TransformationDiagnostic: null:9 Cannot find compatible feature name in sealed EClass Greeting from imported package http://www.xtext.org/example/mydsl/MyDsl: The type 'Greeting' does not have a feature 'name'. (ErrorCode: CannotCreateTypeInSealedMetamodel) at org.eclipse.xtext.generator.LanguageConfig.setUri(LanguageConfig.java:247) ... 42 more You will face that Exception
  • 34.
    Caused by: java.lang.IllegalStateException:Problem parsing 'classpath:/org/xtext/example/ mydsl/MyDsl.xtext': TransformationDiagnostic: null:9 Cannot find compatible feature name in sealed EClass Greeting from imported package http://www.xtext.org/example/mydsl/MyDsl: The type 'Greeting' does not have a feature 'name'. (ErrorCode: CannotCreateTypeInSealedMetamodel) at org.eclipse.xtext.generator.LanguageConfig.setUri(LanguageConfig.java:247) ... 42 more You will face that Exception Ecore model Xcore model Proxy not resolvable Index is not aware of genmodel that the Xcore model links against Proxy
  • 35.
    But I addedthat stuff in the StandaloneSetup…?
  • 36.
    But I addedthat stuff in the StandaloneSetup…? ResourceSet Resource Resource Resource Resource ResourceSet Resource Resource
  • 37.
    Ecore model Xcore model Proxy What’s happening? ResourceSet Grammar Xcore resource Ecoremodel Genmodel Index ResourceDescription ResourceDescription ResourceDescription ResourceDescription
  • 38.
  • 39.
  • 40.
  • 41.
  • 42.
  • 43.
    More complex example XtextDSL Xtext DSL Languages referencing each other
  • 44.
    More complex example XtextDSL Xtext DSL Languages referencing each other Plugin Xtext DSL 1 Plugin Xtext DSL 1 Problem Circular dependency Buddypolicy
  • 45.
    Introduce a Ecoremodel as a protocol Xtext DSL Xtext DSL Ecore model Generated Model Generated Model
  • 46.
    grammar org.xtext.example.mydsl.MyDsl withorg.eclipse.xtext.common.Terminals generate myDsl "http://www.xtext.org/example/mydsl/MyDsl" import "http://www.xtext.org/common/model" as common PackageDeclaration returns common::PackageDeclaration: 'package' name=FQN content+=Element ; Element returns common::NamedElement: {Element} 'element' name=ID '{' ref=[common::Referenceable | FQN]? '}' ; FQN: ID ('.' ID)* ; Introduce a Ecore model as a protocol
  • 47.
    grammar org.xtext.example.mydsl.MyDsl withorg.eclipse.xtext.common.Terminals generate myDsl "http://www.xtext.org/example/mydsl/MyDsl" import "http://www.xtext.org/common/model" as common PackageDeclaration returns common::PackageDeclaration: 'package' name=FQN content+=Element ; Element returns common::NamedElement: {Element} 'element' name=ID '{' ref=[common::Referenceable | FQN]? '}' ; FQN: ID ('.' ID)* ; Introduce a Ecore model as a protocol
  • 48.
    More complex example XtextDSL Xtext DSL Xcore model Xcore model Imported Model Imported Model
  • 49.
    More complex example XtextDSL Xtext DSL Xcore model Xcore model Imported Model Imported Model Same Plugin
  • 50.
    More complex example XtextDSL Xtext DSL Xcore model Xcore model Imported Model Imported Model Different plugins
  • 51.
    More complex example XtextDSL Xtext DSL Ecore model Xcore model Xcore model Imported Model Imported Model
  • 52.
  • 53.
    grammar org.xtext.example.firstdsl.Lang withorg.eclipse.xtext.common.Terminals import "org.xtext.example.myfirstdsl" import "http://www.eclipse.org/emf/2002/Ecore" as ecore import "http://www.xtext.org/common/model" as common import "org.xtext.example.myseconddsl" as second PackageDeclaration returns common::PackageDeclaration : 'package' name=FQN content+=FirstElement* ; FirstElement : 'element' name=ID '{' ref=[second::SecondElement| FQN]? '}' ; FQN: ID ('.' ID)* ; A lot of imports…
  • 54.
    grammar org.xtext.example.firstdsl.Lang withorg.eclipse.xtext.common.Terminals import "org.xtext.example.myfirstdsl" import "http://www.eclipse.org/emf/2002/Ecore" as ecore import "http://www.xtext.org/common/model" as common import "org.xtext.example.myseconddsl" as second PackageDeclaration returns common::PackageDeclaration : 'package' name=FQN content+=FirstElement* ; FirstElement : 'element' name=ID '{' ref=[second::SecondElement| FQN]? '}' ; FQN: ID ('.' ID)* ; Have same root node…
  • 55.
    grammar org.xtext.example.firstdsl.Lang withorg.eclipse.xtext.common.Terminals import "org.xtext.example.myfirstdsl" import "http://www.eclipse.org/emf/2002/Ecore" as ecore import "http://www.xtext.org/common/model" as common import "org.xtext.example.myseconddsl" as second PackageDeclaration returns common::PackageDeclaration : 'package' name=FQN content+=FirstElement* ; FirstElement : 'element' name=ID '{' ref=[second::SecondElement| FQN]? '}' ; FQN: ID ('.' ID)* ; Use implicitly imported classifier
  • 56.
  • 57.
    grammar org.xtext.example.firstdsl.Lang withorg.eclipse.xtext.common.Terminals import "org.xtext.example.myfirstdsl" import "http://www.eclipse.org/emf/2002/Ecore" as ecore import "http://www.xtext.org/common/model" as common import "org.xtext.example.myseconddsl" as second PackageDeclaration returns common::PackageDeclaration : 'package' name=FQN content+=FirstElement* ; FirstElement : 'element' name=ID '{' ref=[second::SecondElement| FQN]? '}' ; FQN: ID ('.' ID)* ; But there is a small problem
  • 58.
    grammar org.xtext.example.firstdsl.Lang withorg.eclipse.xtext.common.Terminals import "org.xtext.example.myfirstdsl" import "http://www.eclipse.org/emf/2002/Ecore" as ecore import "http://www.xtext.org/common/model" as common import "org.xtext.example.myseconddsl" as second PackageDeclaration returns common::PackageDeclaration : 'package' name=FQN content+=FirstElement* ; FirstElement : 'element' name=ID '{' ref=[second::SecondElement| FQN]? '}' ; FQN: ID ('.' ID)* ; CA is showing both elements?
  • 59.
    grammar org.xtext.example.firstdsl.Lang withorg.eclipse.xtext.common.Terminals import "org.xtext.example.myfirstdsl" import "http://www.eclipse.org/emf/2002/Ecore" as ecore import "http://www.xtext.org/common/model" as common import "org.xtext.example.myseconddsl" as second PackageDeclaration returns common::PackageDeclaration : 'package' name=FQN content+=FirstElement* ; FirstElement : 'element' name=ID '{' ref=[second::SecondElement| FQN]? '}' ; FQN: ID ('.' ID)* ; CA is showing both elements?
  • 60.
    Xtext DSL XtextDSL Ecore model Xcore model Xcore model generated Model generated Model One way to solve that…
  • 61.
    One way tosolve that…
  • 62.
    One way tosolve that… grammar org.xtext.example.seconddsl.Lang with org.eclipse.xtext.common.Terminals generate generatedSecondModel "http://www.xtext.org/generatedSecondModel" import "org.xtext.example.myseconddsl" import "http://www.xtext.org/common/model" as common import "http://www.eclipse.org/emf/2002/Ecore" as ecore import "org.xtext.example.myfirstdsl" as first PackageDeclaration returns common::PackageDeclaration : 'package' name=FQN content+=SecondElement* ; SecondElement returns SecondElement: {CustomSecondElement} 'element' name=ID '{' ref=[first::FirstElement | FQN]? '}' ; FQN: ID ('.' ID)* ;
  • 63.
    One way tosolve that… grammar org.xtext.example.seconddsl.Lang with org.eclipse.xtext.common.Terminals generate generatedSecondModel "http://www.xtext.org/generatedSecondModel" import "org.xtext.example.myseconddsl" import "http://www.xtext.org/common/model" as common import "http://www.eclipse.org/emf/2002/Ecore" as ecore import "org.xtext.example.myfirstdsl" as first PackageDeclaration returns common::PackageDeclaration : 'package' name=FQN content+=SecondElement* ; SecondElement returns SecondElement: {CustomSecondElement} 'element' name=ID '{' ref=[first::FirstElement | FQN]? '}' ; FQN: ID ('.' ID)* ;
  • 64.
    But when Irun it…. [ERROR]: GeneratorException: (Element: -UNKNOWN-; Reported by: Generator) java.lang.RuntimeException: Could not find a GenModel for EPackage 'http://www.xtext.org/ generatedSecondModel' from http://www.xtext.org/generatedSecondModel If the missing GenModel has been generated via EMFGeneratorFragment or EcoreGeneratorFragment make sure to run it first in the workflow. If you have a *.genmodel-file, make sure to register it via StandaloneSetup.registerGenModelFile(String) at org.eclipse.xtext.generator.GenModelAccess.getGenModelResource(GenModelAccess.java:137) at org.eclipse.xtext.generator.GenModelAccess.getGenPackage(GenModelAccess.java:85)
  • 65.
    But when Irun it…. // generates Java API for the generated EPackages fragment = ecore.EMFGeneratorFragment auto-inject {} Don’t forget the EMFGeneratorFragment [ERROR]: GeneratorException: (Element: -UNKNOWN-; Reported by: Generator) java.lang.RuntimeException: Could not find a GenModel for EPackage 'http://www.xtext.org/ generatedSecondModel' from http://www.xtext.org/generatedSecondModel If the missing GenModel has been generated via EMFGeneratorFragment or EcoreGeneratorFragment make sure to run it first in the workflow. If you have a *.genmodel-file, make sure to register it via StandaloneSetup.registerGenModelFile(String) at org.eclipse.xtext.generator.GenModelAccess.getGenModelResource(GenModelAccess.java:137) at org.eclipse.xtext.generator.GenModelAccess.getGenPackage(GenModelAccess.java:85)
  • 66.
    There was nothingabout Xbase so far…
  • 67.
  • 68.
    Wizard does crazythings…// automatically generated by Xtext grammar org.xtext.example.mydsl.MyDsl with org.eclipse.xtext.common.Terminals import "http://www.xtext.org/example/xbase" import "http://www.eclipse.org/xtext/common/JavaVMTypes" as types import "http://www.eclipse.org/xtext/xbase/Xbase" as xbase import "http://www.eclipse.org/emf/2002/Ecore" as ecore MyClass returns MyClass: {MyClass} 'MyClass' '{' ('ref' ref=JvmTypeReference)? ('body' body=XBlockExpression)? '}'; JvmTypeReference returns types::JvmTypeReference: JvmParameterizedTypeReference_Impl | JvmGenericArrayTypeReference | JvmWildcardTypeReference | JvmAnyTypeReference | JvmMultiTypeReference | JvmDelegateTypeReference | JvmSynonymTypeReference | JvmUnknownTypeReference | JvmInnerTypeReference; XExpression returns xbase::XExpression: XIfExpression | XSwitchExpression | XBlockExpression | XVariableDeclaration | XMemberFeatureCall | XFeatureCall | XConstructorCall | XBooleanLiteral | XNullLiteral | XNumberLiteral | XStringLiteral | XListLiteral | XSetLiteral | XClosure | XCastedExpression | XBinaryOperation | XUnaryOperation | XPostfixOperation | XForLoopExpression | XBasicForLoopExpression | XDoWhileExpression | XWhileExpression | XTypeLiteral | XInstanceOfExpression | XThrowExpression | XTryCatchFinallyExpression | XAssignment | XReturnExpression | XSynchronizedExpression; JvmType returns types::JvmType: JvmVoid | JvmPrimitiveType | JvmArrayType | JvmTypeParameter | JvmAnnotationType | JvmEnumerationType | JvmGenericType; JvmTypeConstraint returns types::JvmTypeConstraint: JvmUpperBound | JvmLowerBound; JvmParameterizedTypeReference returns types::JvmParameterizedTypeReference: JvmParameterizedTypeReference_Impl | JvmInnerTypeReference; JvmMember returns types::JvmMember: JvmAnnotationType | JvmEnumerationType | JvmEnumerationLiteral | JvmGenericType | JvmField_Impl | JvmConstructor | JvmOperation; JvmAnnotationValue returns types::JvmAnnotationValue: JvmIntAnnotationValue | JvmBooleanAnnotationValue | JvmByteAnnotationValue | JvmShortAnnotationValue | JvmLongAnnotationValue | JvmDoubleAnnotationValue | JvmFloatAnnotationValue | JvmCharAnnotationValue | JvmStringAnnotationValue | JvmTypeAnnotationValue | JvmAnnotationAnnotationValue | JvmEnumAnnotationValue | JvmCustomAnnotationValue; JvmIdentifiableElement returns types::JvmIdentifiableElement: JvmVoid | JvmPrimitiveType | JvmArrayType | JvmTypeParameter | JvmAnnotationType | JvmEnumerationType | JvmEnumerationLiteral | JvmGenericType | JvmField_Impl | JvmConstructor | JvmOperation | JvmFormalParameter; XBlockExpression returns xbase::XBlockExpression: {xbase::XBlockExpression} 'XBlockExpression' '{' ('expressions' '{' expressions+=XExpression ( "," expressions+=XExpression)* '}' )? '}'; JvmParameterizedTypeReference_Impl returns types::JvmParameterizedTypeReference: {types::JvmParameterizedTypeReference} 'JvmParameterizedTypeReference' '{' ('type' type=[types::JvmType|EString])? ('arguments' '{' arguments+=JvmTypeReference ( "," arguments+=JvmTypeReference)* '}' )? '}'; JvmGenericArrayTypeReference returns types::JvmGenericArrayTypeReference: {types::JvmGenericArrayTypeReference} 'JvmGenericArrayTypeReference' '{' ('componentType' componentType=JvmTypeReference)? '}'; JvmWildcardTypeReference returns types::JvmWildcardTypeReference: {types::JvmWildcardTypeReference} 'JvmWildcardTypeReference' '{' ('constraints' '{' constraints+=JvmTypeConstraint ( "," constraints+=JvmTypeConstraint)* '}' )? '}'; JvmAnyTypeReference returns types::JvmAnyTypeReference: {types::JvmAnyTypeReference} 'JvmAnyTypeReference' '{' ('type' type=[types::JvmType|EString])? '}'; JvmMultiTypeReference returns types::JvmMultiTypeReference: {types::JvmMultiTypeReference} 'JvmMultiTypeReference' '{' ('type' type=[types::JvmType|EString])? ('references' '{' references+=JvmTypeReference ( "," references+=JvmTypeReference)* '}' )? '}'; JvmDelegateTypeReference returns types::JvmDelegateTypeReference: {types::JvmDelegateTypeReference} 'JvmDelegateTypeReference' '{' ('delegate' delegate=[types::JvmTypeReference|EString])? '}'; JvmSynonymTypeReference returns types::JvmSynonymTypeReference: {types::JvmSynonymTypeReference} 'JvmSynonymTypeReference' '{' ('type' type=[types::JvmType|EString])? ('references' '{' references+=JvmTypeReference ( "," references+=JvmTypeReference)* '}' )? '}'; JvmUnknownTypeReference returns types::JvmUnknownTypeReference: {types::JvmUnknownTypeReference} 'JvmUnknownTypeReference' ; JvmInnerTypeReference returns types::JvmInnerTypeReference: {types::JvmInnerTypeReference} 'JvmInnerTypeReference' '{' ('type' type=[types::JvmType|EString])? ('arguments' '{' arguments+=JvmTypeReference ( "," arguments+=JvmTypeReference)* '}' )? ('outer' outer=JvmParameterizedTypeReference)? '}'; JvmVoid returns types::JvmVoid: {types::JvmVoid} 'JvmVoid' ; JvmPrimitiveType returns types::JvmPrimitiveType: {types::JvmPrimitiveType} 'JvmPrimitiveType' '{' ('simpleName' simpleName=EString)? ('arrayType' arrayType=JvmArrayType)? '}'; JvmArrayType returns types::JvmArrayType: {types::JvmArrayType} 'JvmArrayType' '{' ('arrayType' arrayType=JvmArrayType)? '}'; JvmTypeParameter returns types::JvmTypeParameter: {types::JvmTypeParameter} 'JvmTypeParameter' name=EString '{' ('arrayType' arrayType=JvmArrayType)? ('constraints' '{' constraints+=JvmTypeConstraint ( "," constraints+=JvmTypeConstraint)* '}' )? '}'; JvmAnnotationType returns types::JvmAnnotationType: {types::JvmAnnotationType} (deprecated?='deprecated')? (abstract?='abstract')? (static?='static')? (final?='final')? 'JvmAnnotationType' '{' ('visibility' visibility=JvmVisibility)? ('simpleName' simpleName=EString)? ('packageName' packageName=EString)? ('annotations' '{' annotations+=JvmAnnotationReference ( "," annotations+=JvmAnnotationReference)* '}' )? ('arrayType' arrayType=JvmArrayType)? ('superTypes' '{' superTypes+=JvmTypeReference ( "," superTypes+=JvmTypeReference)* '}' )? ('members' '{' members+=JvmMember ( "," members+=JvmMember)* '}' )? '}'; JvmEnumerationType returns types::JvmEnumerationType: {types::JvmEnumerationType} (deprecated?='deprecated')? (abstract?='abstract')? (static?='static')? (final?='final')? 'JvmEnumerationType' '{' ('visibility' visibility=JvmVisibility)? ('simpleName' simpleName=EString)? ('packageName' packageName=EString)? ('annotations' '{' annotations+=JvmAnnotationReference ( "," annotations+=JvmAnnotationReference)* '}' )? ('arrayType' arrayType=JvmArrayType)? ('superTypes' '{' superTypes+=JvmTypeReference ( "," superTypes+=JvmTypeReference)* '}' )? ('members' '{' members+=JvmMember ( "," members+=JvmMember)* '}' )? '}'; JvmGenericType returns types::JvmGenericType: {types::JvmGenericType} (deprecated?='deprecated')? (abstract?='abstract')? (static?='static')? (final?='final')? (interface?='interface')? (strictFloatingPoint?='strictFloatingPoint')? (anonymous?='anonymous')? 'JvmGenericType' '{' ('visibility' visibility=JvmVisibility)? ('simpleName' simpleName=EString)? ('packageName' packageName=EString)? ('annotations' '{' annotations+=JvmAnnotationReference ( "," annotations+=JvmAnnotationReference)* '}' )? ('arrayType' arrayType=JvmArrayType)? ('superTypes' '{' superTypes+=JvmTypeReference ( "," superTypes+=JvmTypeReference)* '}' )? ('members' '{' members+=JvmMember ( "," members+=JvmMember)* '}' )? ('typeParameters' '{' typeParameters+=JvmTypeParameter ( "," typeParameters+=JvmTypeParameter)* '}' )? '}'; EString returns ecore::EString: STRING | ID; JvmAnnotationReference returns types::JvmAnnotationReference: {types::JvmAnnotationReference} 'JvmAnnotationReference' '{' ('annotation' annotation=[types::JvmAnnotationType|EString])? ('explicitValues' '{' explicitValues+=JvmAnnotationValue ( "," explicitValues+=JvmAnnotationValue)* '}' )? '}'; enum JvmVisibility returns types::JvmVisibility: DEFAULT = 'DEFAULT' | PRIVATE = 'PRIVATE' | PROTECTED = 'PROTECTED' | PUBLIC = 'PUBLIC'; EBoolean returns ecore::EBoolean: 'true' | 'false'; JvmOperation returns types::JvmOperation: {types::JvmOperation} (deprecated?='deprecated')? (varArgs?='varArgs')? (static?='static')? (final?='final')? (abstract?='abstract')? (synchronized?='synchronized')? (default?='default')? (native?='native')? (strictFloatingPoint?='strictFloatingPoint')? 'JvmOperation' '{' ('visibility' visibility=JvmVisibility)? ('simpleName' simpleName=EString)? ('annotations' '{' annotations+=JvmAnnotationReference ( "," annotations+=JvmAnnotationReference)* '}' )? ('localClasses' '{' localClasses+=JvmGenericType ( "," localClasses+=JvmGenericType)* '}' )? ('typeParameters' '{' typeParameters+=JvmTypeParameter ( "," typeParameters+=JvmTypeParameter)* '}' )? ('parameters' '{' parameters+=JvmFormalParameter ( "," parameters+=JvmFormalParameter)* '}' )? ('exceptions' '{' exceptions+=JvmTypeReference ( "," exceptions+=JvmTypeReference)* '}' )? ('returnType' returnType=JvmTypeReference)? ('defaultValue' defaultValue=JvmAnnotationValue)? '}'; JvmIntAnnotationValue returns types::JvmIntAnnotationValue: {types::JvmIntAnnotationValue} 'JvmIntAnnotationValue' '{' ('values' '{' values+=EInt ( "," values+=EInt)* '}' )? ('operation' operation=[types::JvmOperation|EString])? '}'; JvmBooleanAnnotationValue returns types::JvmBooleanAnnotationValue: {types::JvmBooleanAnnotationValue} 'JvmBooleanAnnotationValue' '{' ('values' '{' values+=EBoolean ( "," values+=EBoolean)* '}' )? ('operation' operation=[types::JvmOperation|EString])? '}'; JvmByteAnnotationValue returns types::JvmByteAnnotationValue: {types::JvmByteAnnotationValue} 'JvmByteAnnotationValue' '{' ('values' '{' values+=EByte ( "," values+=EByte)* '}' )? ('operation' operation=[types::JvmOperation|EString])? '}'; JvmShortAnnotationValue returns types::JvmShortAnnotationValue: {types::JvmShortAnnotationValue} 'JvmShortAnnotationValue' '{' ('values' '{' values+=EShort ( "," values+=EShort)* '}' )? ('operation' operation=[types::JvmOperation|EString])? '}'; JvmLongAnnotationValue returns types::JvmLongAnnotationValue: {types::JvmLongAnnotationValue} 'JvmLongAnnotationValue' '{' ('values' '{' values+=ELong ( "," values+=ELong)* '}' )? ('operation' operation=[types::JvmOperation|EString])? '}'; JvmDoubleAnnotationValue returns types::JvmDoubleAnnotationValue: {types::JvmDoubleAnnotationValue} 'JvmDoubleAnnotationValue' '{' ('values' '{' values+=EDouble ( "," values+=EDouble)* '}' )? ('operation' operation=[types::JvmOperation|EString])? '}'; JvmFloatAnnotationValue returns types::JvmFloatAnnotationValue: {types::JvmFloatAnnotationValue} 'JvmFloatAnnotationValue' '{' ('values' '{' values+=EFloat ( "," values+=EFloat)* '}' )? ('operation' operation=[types::JvmOperation|EString])? '}'; JvmCharAnnotationValue returns types::JvmCharAnnotationValue: {types::JvmCharAnnotationValue} 'JvmCharAnnotationValue' '{' ('values' '{' values+=EChar ( "," values+=EChar)* '}' )? ('operation' operation=[types::JvmOperation|EString])? '}'; JvmStringAnnotationValue returns types::JvmStringAnnotationValue: {types::JvmStringAnnotationValue} 'JvmStringAnnotationValue' '{' ('values' '{' values+=EString ( "," values+=EString)* '}' )? ('operation' operation=[types::JvmOperation|EString])? '}'; JvmTypeAnnotationValue returns types::JvmTypeAnnotationValue: {types::JvmTypeAnnotationValue} 'JvmTypeAnnotationValue' '{' ('operation' operation=[types::JvmOperation|EString])? ('values' '{' values+=JvmTypeReference ( "," values+=JvmTypeReference)* '}' )? '}'; JvmAnnotationAnnotationValue returns types::JvmAnnotationAnnotationValue: {types::JvmAnnotationAnnotationValue} 'JvmAnnotationAnnotationValue' '{' ('operation' operation=[types::JvmOperation|EString])? ('values' '{' values+=JvmAnnotationReference ( "," values+=JvmAnnotationReference)* '}' )? '}'; JvmEnumAnnotationValue returns types::JvmEnumAnnotationValue: {types::JvmEnumAnnotationValue} 'JvmEnumAnnotationValue' '{' ('operation' operation=[types::JvmOperation|EString])? ('values' '(' values+=[types::JvmEnumerationLiteral|EString] ( "," values+=[types::JvmEnumerationLiteral|EString])* ')' )? '}'; JvmCustomAnnotationValue returns types::JvmCustomAnnotationValue: {types::JvmCustomAnnotationValue} 'JvmCustomAnnotationValue' '{' ('operation' operation=[types::JvmOperation|EString])? ('values' '(' values+=[ecore::EObject|EString] ( "," values+=[ecore::EObject|EString])* ')' )? '}'; JvmFormalParameter returns types::JvmFormalParameter: {types::JvmFormalParameter} 'JvmFormalParameter' name=EString '{' ('annotations' '{' annotations+=JvmAnnotationReference ( "," annotations+=JvmAnnotationReference)* '}' )? ('parameterType' parameterType=JvmTypeReference)? '}'; EInt returns ecore::EInt: '-'? INT; EByte returns ecore::EByte: '-'? INT; EShort returns ecore::EShort: '-'? INT; ELong returns ecore::ELong: '-'? INT; EDouble returns ecore::EDouble: '-'? INT? '.' INT (('E'|'e') '-'? INT)?; EFloat returns ecore::EFloat: '-'? INT? '.' INT (('E'|'e') '-'? INT)?; EChar returns ecore::EChar: '-'? INT; JvmEnumerationLiteral returns types::JvmEnumerationLiteral: {types::JvmEnumerationLiteral} (deprecated?='deprecated')? (static?='static')? (final?='final')? (volatile?='volatile')? (transient?='transient')? (constant?='constant')? 'JvmEnumerationLiteral' '{' ('visibility' visibility=JvmVisibility)? ('simpleName' simpleName=EString)? ('constantValue' constantValue=EJavaObject)? ('annotations' '{' annotations+=JvmAnnotationReference ( "," annotations+=JvmAnnotationReference)* '}' )? ('localClasses' '{' localClasses+=JvmGenericType ( "," localClasses+=JvmGenericType)* '}' )? ('type' type=JvmTypeReference)? '}'; EJavaObject returns ecore::EJavaObject: 'EJavaObject' /* TODO: implement this rule and an appropriate IValueConverter */; EObject returns ecore::EObject: {ecore::EObject} 'EObject' ; JvmField_Impl returns types::JvmField: {types::JvmField} (deprecated?='deprecated')? (static?='static')? (final?='final')? (volatile?='volatile')? (transient?='transient')? (constant?='constant')? 'JvmField' '{' ('visibility' visibility=JvmVisibility)? ('simpleName' simpleName=EString)? ('constantValue' constantValue=EJavaObject)? ('annotations' '{' annotations+=JvmAnnotationReference ( "," annotations+=JvmAnnotationReference)* '}' )? ('localClasses' '{' localClasses+=JvmGenericType ( "," localClasses+=JvmGenericType)* '}' )? ('type' type=JvmTypeReference)? '}'; JvmConstructor returns types::JvmConstructor: {types::JvmConstructor} (deprecated?='deprecated')? (varArgs?='varArgs')? 'JvmConstructor' '{' ('visibility' visibility=JvmVisibility)? ('simpleName' simpleName=EString)? ('annotations' '{' annotations+=JvmAnnotationReference ( "," annotations+=JvmAnnotationReference)* '}' )? ('localClasses' '{' localClasses+=JvmGenericType ( "," localClasses+=JvmGenericType)* '}' )? ('typeParameters' '{' typeParameters+=JvmTypeParameter ( "," typeParameters+=JvmTypeParameter)* '}' )? ('parameters' '{' parameters+=JvmFormalParameter ( "," parameters+=JvmFormalParameter)* '}' )? ('exceptions' '{' exceptions+=JvmTypeReference ( "," exceptions+=JvmTypeReference)* '}' )? '}'; JvmUpperBound returns types::JvmUpperBound: {types::JvmUpperBound} 'JvmUpperBound' '{' ('typeReference' typeReference=JvmTypeReference)? '}'; JvmLowerBound returns types::JvmLowerBound: {types::JvmLowerBound} 'JvmLowerBound' '{' ('typeReference' typeReference=JvmTypeReference)? '}'; XIfExpression returns xbase::XIfExpression: {xbase::XIfExpression} 'XIfExpression' '{' ('if' if=XExpression)? ('then' then=XExpression)? ('else' else=XExpression)? '}'; XSwitchExpression returns xbase::XSwitchExpression: {xbase::XSwitchExpression} 'XSwitchExpression' '{' ('switch' switch=XExpression)? ('cases' '{' cases+=XCasePart ( "," cases+=XCasePart)* '}' )? ('default' default=XExpression)? ('declaredParam' declaredParam=JvmFormalParameter)? '}'; XVariableDeclaration returns xbase::XVariableDeclaration: {xbase::XVariableDeclaration} (writeable?='writeable')? 'XVariableDeclaration' name=EString '{' ('type' type=JvmTypeReference)? ('right' right=XExpression)? '}'; XMemberFeatureCall returns xbase::XMemberFeatureCall: {xbase::XMemberFeatureCall} (explicitOperationCall?='explicitOperationCall')? (explicitStatic?='explicitStatic')? (nullSafe?='nullSafe')? 'XMemberFeatureCall' '{' ('feature' feature=[types::JvmIdentifiableElement|EString])? ('typeArguments' '{' typeArguments+=JvmTypeReference ( "," typeArguments+=JvmTypeReference)* '}' )? ('memberCallTarget' memberCallTarget=XExpression)? ('memberCallArguments' '{' memberCallArguments+=XExpression ( "," memberCallArguments+=XExpression)* '}' )? '}'; XFeatureCall returns xbase::XFeatureCall: {xbase::XFeatureCall} (explicitOperationCall?='explicitOperationCall')? 'XFeatureCall' '{' ('feature' feature=[types::JvmIdentifiableElement|EString])? ('typeArguments' '{' typeArguments+=JvmTypeReference ( "," typeArguments+=JvmTypeReference)* '}' )? ('featureCallArguments' '{' featureCallArguments+=XExpression ( "," featureCallArguments+=XExpression)* '}' )? '}'; XConstructorCall returns xbase::XConstructorCall: {xbase::XConstructorCall} (explicitConstructorCall?='explicitConstructorCall')? 'XConstructorCall' '{' ('constructor' constructor=[types::JvmConstructor|EString])? ('arguments' '{' arguments+=XExpression ( "," arguments+=XExpression)* '}' )? ('typeArguments' '{' typeArguments+=JvmTypeReference ( "," typeArguments+=JvmTypeReference)* '}' )? '}'; XBooleanLiteral returns xbase::XBooleanLiteral: {xbase::XBooleanLiteral} (isTrue?='isTrue')? 'XBooleanLiteral' ; XNullLiteral returns xbase::XNullLiteral: {xbase::XNullLiteral} 'XNullLiteral' ; XNumberLiteral returns xbase::XNumberLiteral: {xbase::XNumberLiteral} 'XNumberLiteral' '{' ('value' value=EString)? '}'; XStringLiteral returns xbase::XStringLiteral: {xbase::XStringLiteral} 'XStringLiteral' '{' ('value' value=EString)? '}'; XListLiteral returns xbase::XListLiteral: {xbase::XListLiteral} 'XListLiteral' '{' ('elements' '{' elements+=XExpression ( "," elements+=XExpression)* '}' )? '}'; XSetLiteral returns xbase::XSetLiteral: {xbase::XSetLiteral} 'XSetLiteral' '{' ('elements' '{' elements+=XExpression ( "," elements+=XExpression)* '}' )? '}'; XClosure returns xbase::XClosure: {xbase::XClosure} (explicitSyntax?='explicitSyntax')? 'XClosure' '{' ('declaredFormalParameters' '{' declaredFormalParameters+=JvmFormalParameter ( "," declaredFormalParameters+=JvmFormalParameter)* '}' )? ('expression' expression=XExpression)? '}'; XCastedExpression returns xbase::XCastedExpression: {xbase::XCastedExpression} 'XCastedExpression' '{' ('type' type=JvmTypeReference)? ('target' target=XExpression)? '}'; XBinaryOperation returns xbase::XBinaryOperation: {xbase::XBinaryOperation} (reassignFirstArgument?='reassignFirstArgument')? 'XBinaryOperation' '{' ('feature' feature=[types::JvmIdentifiableElement|EString])? ('typeArguments' '{' typeArguments+=JvmTypeReference ( "," typeArguments+=JvmTypeReference)* '}' )? ('leftOperand' leftOperand=XExpression)? ('rightOperand' rightOperand=XExpression)? '}'; XUnaryOperation returns xbase::XUnaryOperation: {xbase::XUnaryOperation} 'XUnaryOperation' '{' ('feature' feature=[types::JvmIdentifiableElement|EString])? ('typeArguments' '{' typeArguments+=JvmTypeReference ( "," typeArguments+=JvmTypeReference)* '}' )? ('operand' operand=XExpression)? '}'; XPostfixOperation returns xbase::XPostfixOperation: {xbase::XPostfixOperation} 'XPostfixOperation' '{' ('feature' feature=[types::JvmIdentifiableElement|EString])? ('typeArguments' '{' typeArguments+=JvmTypeReference ( "," typeArguments+=JvmTypeReference)* '}' )? ('operand' operand=XExpression)? '}'; XForLoopExpression returns xbase::XForLoopExpression: {xbase::XForLoopExpression} 'XForLoopExpression' '{' ('forExpression' forExpression=XExpression)? ('eachExpression' eachExpression=XExpression)? ('declaredParam' declaredParam=JvmFormalParameter)? '}'; XBasicForLoopExpression returns xbase::XBasicForLoopExpression: {xbase::XBasicForLoopExpression} 'XBasicForLoopExpression' '{' ('expression' expression=XExpression)? ('eachExpression' eachExpression=XExpression)? ('initExpressions' '{' initExpressions+=XExpression ( "," initExpressions+=XExpression)* '}' )? ('updateExpressions' '{' updateExpressions+=XExpression ( "," updateExpressions+=XExpression)* '}' )? '}'; XDoWhileExpression returns xbase::XDoWhileExpression: {xbase::XDoWhileExpression} 'XDoWhileExpression' '{' ('predicate' predicate=XExpression)? ('body' body=XExpression)? '}'; XWhileExpression returns xbase::XWhileExpression: {xbase::XWhileExpression} 'XWhileExpression' '{' ('predicate' predicate=XExpression)? ('body' body=XExpression)? '}'; XTypeLiteral returns xbase::XTypeLiteral: 'XTypeLiteral' '{' ('arrayDimensions' '{' arrayDimensions+=EString ( "," arrayDimensions+=EString)* '}' )? 'type' type=[types::JvmType|EString] '}'; XInstanceOfExpression returns xbase::XInstanceOfExpression: 'XInstanceOfExpression' '{' 'type' type=JvmTypeReference 'expression' expression=XExpression '}'; XThrowExpression returns xbase::XThrowExpression: {xbase::XThrowExpression} 'XThrowExpression' '{' ('expression' expression=XExpression)? '}'; XTryCatchFinallyExpression returns xbase::XTryCatchFinallyExpression: {xbase::XTryCatchFinallyExpression} 'XTryCatchFinallyExpression' '{' ('expression' expression=XExpression)? ('finallyExpression' finallyExpression=XExpression)? ('catchClauses' '{' catchClauses+=XCatchClause ( "," catchClauses+=XCatchClause)* '}' )? '}'; XAssignment returns xbase::XAssignment: {xbase::XAssignment} (explicitStatic?='explicitStatic')? 'XAssignment' '{' ('feature' feature=[types::JvmIdentifiableElement|EString])? ('typeArguments' '{' typeArguments+=JvmTypeReference ( "," typeArguments+=JvmTypeReference)* '}' )? ('assignable' assignable=XExpression)? ('value' value=XExpression)? '}'; Rebuilds Xbase grammar without reusing it…
  • 69.
    Wizard does crazythings…// automatically generated by Xtext grammar org.xtext.example.mydsl.MyDsl with org.eclipse.xtext.common.Terminals import "http://www.xtext.org/example/xbase" import "http://www.eclipse.org/xtext/common/JavaVMTypes" as types import "http://www.eclipse.org/xtext/xbase/Xbase" as xbase import "http://www.eclipse.org/emf/2002/Ecore" as ecore MyClass returns MyClass: {MyClass} 'MyClass' '{' ('ref' ref=JvmTypeReference)? ('body' body=XBlockExpression)? '}'; JvmTypeReference returns types::JvmTypeReference: JvmParameterizedTypeReference_Impl | JvmGenericArrayTypeReference | JvmWildcardTypeReference | JvmAnyTypeReference | JvmMultiTypeReference | JvmDelegateTypeReference | JvmSynonymTypeReference | JvmUnknownTypeReference | JvmInnerTypeReference; XExpression returns xbase::XExpression: XIfExpression | XSwitchExpression | XBlockExpression | XVariableDeclaration | XMemberFeatureCall | XFeatureCall | XConstructorCall | XBooleanLiteral | XNullLiteral | XNumberLiteral | XStringLiteral | XListLiteral | XSetLiteral | XClosure | XCastedExpression | XBinaryOperation | XUnaryOperation | XPostfixOperation | XForLoopExpression | XBasicForLoopExpression | XDoWhileExpression | XWhileExpression | XTypeLiteral | XInstanceOfExpression | XThrowExpression | XTryCatchFinallyExpression | XAssignment | XReturnExpression | XSynchronizedExpression; JvmType returns types::JvmType: JvmVoid | JvmPrimitiveType | JvmArrayType | JvmTypeParameter | JvmAnnotationType | JvmEnumerationType | JvmGenericType; JvmTypeConstraint returns types::JvmTypeConstraint: JvmUpperBound | JvmLowerBound; JvmParameterizedTypeReference returns types::JvmParameterizedTypeReference: JvmParameterizedTypeReference_Impl | JvmInnerTypeReference; JvmMember returns types::JvmMember: JvmAnnotationType | JvmEnumerationType | JvmEnumerationLiteral | JvmGenericType | JvmField_Impl | JvmConstructor | JvmOperation; JvmAnnotationValue returns types::JvmAnnotationValue: JvmIntAnnotationValue | JvmBooleanAnnotationValue | JvmByteAnnotationValue | JvmShortAnnotationValue | JvmLongAnnotationValue | JvmDoubleAnnotationValue | JvmFloatAnnotationValue | JvmCharAnnotationValue | JvmStringAnnotationValue | JvmTypeAnnotationValue | JvmAnnotationAnnotationValue | JvmEnumAnnotationValue | JvmCustomAnnotationValue; JvmIdentifiableElement returns types::JvmIdentifiableElement: JvmVoid | JvmPrimitiveType | JvmArrayType | JvmTypeParameter | JvmAnnotationType | JvmEnumerationType | JvmEnumerationLiteral | JvmGenericType | JvmField_Impl | JvmConstructor | JvmOperation | JvmFormalParameter; XBlockExpression returns xbase::XBlockExpression: {xbase::XBlockExpression} 'XBlockExpression' '{' ('expressions' '{' expressions+=XExpression ( "," expressions+=XExpression)* '}' )? '}'; JvmParameterizedTypeReference_Impl returns types::JvmParameterizedTypeReference: {types::JvmParameterizedTypeReference} 'JvmParameterizedTypeReference' '{' ('type' type=[types::JvmType|EString])? ('arguments' '{' arguments+=JvmTypeReference ( "," arguments+=JvmTypeReference)* '}' )? '}'; JvmGenericArrayTypeReference returns types::JvmGenericArrayTypeReference: {types::JvmGenericArrayTypeReference} 'JvmGenericArrayTypeReference' '{' ('componentType' componentType=JvmTypeReference)? '}'; JvmWildcardTypeReference returns types::JvmWildcardTypeReference: {types::JvmWildcardTypeReference} 'JvmWildcardTypeReference' '{' ('constraints' '{' constraints+=JvmTypeConstraint ( "," constraints+=JvmTypeConstraint)* '}' )? '}'; JvmAnyTypeReference returns types::JvmAnyTypeReference: {types::JvmAnyTypeReference} 'JvmAnyTypeReference' '{' ('type' type=[types::JvmType|EString])? '}'; JvmMultiTypeReference returns types::JvmMultiTypeReference: {types::JvmMultiTypeReference} 'JvmMultiTypeReference' '{' ('type' type=[types::JvmType|EString])? ('references' '{' references+=JvmTypeReference ( "," references+=JvmTypeReference)* '}' )? '}'; JvmDelegateTypeReference returns types::JvmDelegateTypeReference: {types::JvmDelegateTypeReference} 'JvmDelegateTypeReference' '{' ('delegate' delegate=[types::JvmTypeReference|EString])? '}'; JvmSynonymTypeReference returns types::JvmSynonymTypeReference: {types::JvmSynonymTypeReference} 'JvmSynonymTypeReference' '{' ('type' type=[types::JvmType|EString])? ('references' '{' references+=JvmTypeReference ( "," references+=JvmTypeReference)* '}' )? '}'; JvmUnknownTypeReference returns types::JvmUnknownTypeReference: {types::JvmUnknownTypeReference} 'JvmUnknownTypeReference' ; JvmInnerTypeReference returns types::JvmInnerTypeReference: {types::JvmInnerTypeReference} 'JvmInnerTypeReference' '{' ('type' type=[types::JvmType|EString])? ('arguments' '{' arguments+=JvmTypeReference ( "," arguments+=JvmTypeReference)* '}' )? ('outer' outer=JvmParameterizedTypeReference)? '}'; JvmVoid returns types::JvmVoid: {types::JvmVoid} 'JvmVoid' ; JvmPrimitiveType returns types::JvmPrimitiveType: {types::JvmPrimitiveType} 'JvmPrimitiveType' '{' ('simpleName' simpleName=EString)? ('arrayType' arrayType=JvmArrayType)? '}'; JvmArrayType returns types::JvmArrayType: {types::JvmArrayType} 'JvmArrayType' '{' ('arrayType' arrayType=JvmArrayType)? '}'; JvmTypeParameter returns types::JvmTypeParameter: {types::JvmTypeParameter} 'JvmTypeParameter' name=EString '{' ('arrayType' arrayType=JvmArrayType)? ('constraints' '{' constraints+=JvmTypeConstraint ( "," constraints+=JvmTypeConstraint)* '}' )? '}'; JvmAnnotationType returns types::JvmAnnotationType: {types::JvmAnnotationType} (deprecated?='deprecated')? (abstract?='abstract')? (static?='static')? (final?='final')? 'JvmAnnotationType' '{' ('visibility' visibility=JvmVisibility)? ('simpleName' simpleName=EString)? ('packageName' packageName=EString)? ('annotations' '{' annotations+=JvmAnnotationReference ( "," annotations+=JvmAnnotationReference)* '}' )? ('arrayType' arrayType=JvmArrayType)? ('superTypes' '{' superTypes+=JvmTypeReference ( "," superTypes+=JvmTypeReference)* '}' )? ('members' '{' members+=JvmMember ( "," members+=JvmMember)* '}' )? '}'; JvmEnumerationType returns types::JvmEnumerationType: {types::JvmEnumerationType} (deprecated?='deprecated')? (abstract?='abstract')? (static?='static')? (final?='final')? 'JvmEnumerationType' '{' ('visibility' visibility=JvmVisibility)? ('simpleName' simpleName=EString)? ('packageName' packageName=EString)? ('annotations' '{' annotations+=JvmAnnotationReference ( "," annotations+=JvmAnnotationReference)* '}' )? ('arrayType' arrayType=JvmArrayType)? ('superTypes' '{' superTypes+=JvmTypeReference ( "," superTypes+=JvmTypeReference)* '}' )? ('members' '{' members+=JvmMember ( "," members+=JvmMember)* '}' )? '}'; JvmGenericType returns types::JvmGenericType: {types::JvmGenericType} (deprecated?='deprecated')? (abstract?='abstract')? (static?='static')? (final?='final')? (interface?='interface')? (strictFloatingPoint?='strictFloatingPoint')? (anonymous?='anonymous')? 'JvmGenericType' '{' ('visibility' visibility=JvmVisibility)? ('simpleName' simpleName=EString)? ('packageName' packageName=EString)? ('annotations' '{' annotations+=JvmAnnotationReference ( "," annotations+=JvmAnnotationReference)* '}' )? ('arrayType' arrayType=JvmArrayType)? ('superTypes' '{' superTypes+=JvmTypeReference ( "," superTypes+=JvmTypeReference)* '}' )? ('members' '{' members+=JvmMember ( "," members+=JvmMember)* '}' )? ('typeParameters' '{' typeParameters+=JvmTypeParameter ( "," typeParameters+=JvmTypeParameter)* '}' )? '}'; EString returns ecore::EString: STRING | ID; JvmAnnotationReference returns types::JvmAnnotationReference: {types::JvmAnnotationReference} 'JvmAnnotationReference' '{' ('annotation' annotation=[types::JvmAnnotationType|EString])? ('explicitValues' '{' explicitValues+=JvmAnnotationValue ( "," explicitValues+=JvmAnnotationValue)* '}' )? '}'; enum JvmVisibility returns types::JvmVisibility: DEFAULT = 'DEFAULT' | PRIVATE = 'PRIVATE' | PROTECTED = 'PROTECTED' | PUBLIC = 'PUBLIC'; EBoolean returns ecore::EBoolean: 'true' | 'false'; JvmOperation returns types::JvmOperation: {types::JvmOperation} (deprecated?='deprecated')? (varArgs?='varArgs')? (static?='static')? (final?='final')? (abstract?='abstract')? (synchronized?='synchronized')? (default?='default')? (native?='native')? (strictFloatingPoint?='strictFloatingPoint')? 'JvmOperation' '{' ('visibility' visibility=JvmVisibility)? ('simpleName' simpleName=EString)? ('annotations' '{' annotations+=JvmAnnotationReference ( "," annotations+=JvmAnnotationReference)* '}' )? ('localClasses' '{' localClasses+=JvmGenericType ( "," localClasses+=JvmGenericType)* '}' )? ('typeParameters' '{' typeParameters+=JvmTypeParameter ( "," typeParameters+=JvmTypeParameter)* '}' )? ('parameters' '{' parameters+=JvmFormalParameter ( "," parameters+=JvmFormalParameter)* '}' )? ('exceptions' '{' exceptions+=JvmTypeReference ( "," exceptions+=JvmTypeReference)* '}' )? ('returnType' returnType=JvmTypeReference)? ('defaultValue' defaultValue=JvmAnnotationValue)? '}'; JvmIntAnnotationValue returns types::JvmIntAnnotationValue: {types::JvmIntAnnotationValue} 'JvmIntAnnotationValue' '{' ('values' '{' values+=EInt ( "," values+=EInt)* '}' )? ('operation' operation=[types::JvmOperation|EString])? '}'; JvmBooleanAnnotationValue returns types::JvmBooleanAnnotationValue: {types::JvmBooleanAnnotationValue} 'JvmBooleanAnnotationValue' '{' ('values' '{' values+=EBoolean ( "," values+=EBoolean)* '}' )? ('operation' operation=[types::JvmOperation|EString])? '}'; JvmByteAnnotationValue returns types::JvmByteAnnotationValue: {types::JvmByteAnnotationValue} 'JvmByteAnnotationValue' '{' ('values' '{' values+=EByte ( "," values+=EByte)* '}' )? ('operation' operation=[types::JvmOperation|EString])? '}'; JvmShortAnnotationValue returns types::JvmShortAnnotationValue: {types::JvmShortAnnotationValue} 'JvmShortAnnotationValue' '{' ('values' '{' values+=EShort ( "," values+=EShort)* '}' )? ('operation' operation=[types::JvmOperation|EString])? '}'; JvmLongAnnotationValue returns types::JvmLongAnnotationValue: {types::JvmLongAnnotationValue} 'JvmLongAnnotationValue' '{' ('values' '{' values+=ELong ( "," values+=ELong)* '}' )? ('operation' operation=[types::JvmOperation|EString])? '}'; JvmDoubleAnnotationValue returns types::JvmDoubleAnnotationValue: {types::JvmDoubleAnnotationValue} 'JvmDoubleAnnotationValue' '{' ('values' '{' values+=EDouble ( "," values+=EDouble)* '}' )? ('operation' operation=[types::JvmOperation|EString])? '}'; JvmFloatAnnotationValue returns types::JvmFloatAnnotationValue: {types::JvmFloatAnnotationValue} 'JvmFloatAnnotationValue' '{' ('values' '{' values+=EFloat ( "," values+=EFloat)* '}' )? ('operation' operation=[types::JvmOperation|EString])? '}'; JvmCharAnnotationValue returns types::JvmCharAnnotationValue: {types::JvmCharAnnotationValue} 'JvmCharAnnotationValue' '{' ('values' '{' values+=EChar ( "," values+=EChar)* '}' )? ('operation' operation=[types::JvmOperation|EString])? '}'; JvmStringAnnotationValue returns types::JvmStringAnnotationValue: {types::JvmStringAnnotationValue} 'JvmStringAnnotationValue' '{' ('values' '{' values+=EString ( "," values+=EString)* '}' )? ('operation' operation=[types::JvmOperation|EString])? '}'; JvmTypeAnnotationValue returns types::JvmTypeAnnotationValue: {types::JvmTypeAnnotationValue} 'JvmTypeAnnotationValue' '{' ('operation' operation=[types::JvmOperation|EString])? ('values' '{' values+=JvmTypeReference ( "," values+=JvmTypeReference)* '}' )? '}'; JvmAnnotationAnnotationValue returns types::JvmAnnotationAnnotationValue: {types::JvmAnnotationAnnotationValue} 'JvmAnnotationAnnotationValue' '{' ('operation' operation=[types::JvmOperation|EString])? ('values' '{' values+=JvmAnnotationReference ( "," values+=JvmAnnotationReference)* '}' )? '}'; JvmEnumAnnotationValue returns types::JvmEnumAnnotationValue: {types::JvmEnumAnnotationValue} 'JvmEnumAnnotationValue' '{' ('operation' operation=[types::JvmOperation|EString])? ('values' '(' values+=[types::JvmEnumerationLiteral|EString] ( "," values+=[types::JvmEnumerationLiteral|EString])* ')' )? '}'; JvmCustomAnnotationValue returns types::JvmCustomAnnotationValue: {types::JvmCustomAnnotationValue} 'JvmCustomAnnotationValue' '{' ('operation' operation=[types::JvmOperation|EString])? ('values' '(' values+=[ecore::EObject|EString] ( "," values+=[ecore::EObject|EString])* ')' )? '}'; JvmFormalParameter returns types::JvmFormalParameter: {types::JvmFormalParameter} 'JvmFormalParameter' name=EString '{' ('annotations' '{' annotations+=JvmAnnotationReference ( "," annotations+=JvmAnnotationReference)* '}' )? ('parameterType' parameterType=JvmTypeReference)? '}'; EInt returns ecore::EInt: '-'? INT; EByte returns ecore::EByte: '-'? INT; EShort returns ecore::EShort: '-'? INT; ELong returns ecore::ELong: '-'? INT; EDouble returns ecore::EDouble: '-'? INT? '.' INT (('E'|'e') '-'? INT)?; EFloat returns ecore::EFloat: '-'? INT? '.' INT (('E'|'e') '-'? INT)?; EChar returns ecore::EChar: '-'? INT; JvmEnumerationLiteral returns types::JvmEnumerationLiteral: {types::JvmEnumerationLiteral} (deprecated?='deprecated')? (static?='static')? (final?='final')? (volatile?='volatile')? (transient?='transient')? (constant?='constant')? 'JvmEnumerationLiteral' '{' ('visibility' visibility=JvmVisibility)? ('simpleName' simpleName=EString)? ('constantValue' constantValue=EJavaObject)? ('annotations' '{' annotations+=JvmAnnotationReference ( "," annotations+=JvmAnnotationReference)* '}' )? ('localClasses' '{' localClasses+=JvmGenericType ( "," localClasses+=JvmGenericType)* '}' )? ('type' type=JvmTypeReference)? '}'; EJavaObject returns ecore::EJavaObject: 'EJavaObject' /* TODO: implement this rule and an appropriate IValueConverter */; EObject returns ecore::EObject: {ecore::EObject} 'EObject' ; JvmField_Impl returns types::JvmField: {types::JvmField} (deprecated?='deprecated')? (static?='static')? (final?='final')? (volatile?='volatile')? (transient?='transient')? (constant?='constant')? 'JvmField' '{' ('visibility' visibility=JvmVisibility)? ('simpleName' simpleName=EString)? ('constantValue' constantValue=EJavaObject)? ('annotations' '{' annotations+=JvmAnnotationReference ( "," annotations+=JvmAnnotationReference)* '}' )? ('localClasses' '{' localClasses+=JvmGenericType ( "," localClasses+=JvmGenericType)* '}' )? ('type' type=JvmTypeReference)? '}'; JvmConstructor returns types::JvmConstructor: {types::JvmConstructor} (deprecated?='deprecated')? (varArgs?='varArgs')? 'JvmConstructor' '{' ('visibility' visibility=JvmVisibility)? ('simpleName' simpleName=EString)? ('annotations' '{' annotations+=JvmAnnotationReference ( "," annotations+=JvmAnnotationReference)* '}' )? ('localClasses' '{' localClasses+=JvmGenericType ( "," localClasses+=JvmGenericType)* '}' )? ('typeParameters' '{' typeParameters+=JvmTypeParameter ( "," typeParameters+=JvmTypeParameter)* '}' )? ('parameters' '{' parameters+=JvmFormalParameter ( "," parameters+=JvmFormalParameter)* '}' )? ('exceptions' '{' exceptions+=JvmTypeReference ( "," exceptions+=JvmTypeReference)* '}' )? '}'; JvmUpperBound returns types::JvmUpperBound: {types::JvmUpperBound} 'JvmUpperBound' '{' ('typeReference' typeReference=JvmTypeReference)? '}'; JvmLowerBound returns types::JvmLowerBound: {types::JvmLowerBound} 'JvmLowerBound' '{' ('typeReference' typeReference=JvmTypeReference)? '}'; XIfExpression returns xbase::XIfExpression: {xbase::XIfExpression} 'XIfExpression' '{' ('if' if=XExpression)? ('then' then=XExpression)? ('else' else=XExpression)? '}'; XSwitchExpression returns xbase::XSwitchExpression: {xbase::XSwitchExpression} 'XSwitchExpression' '{' ('switch' switch=XExpression)? ('cases' '{' cases+=XCasePart ( "," cases+=XCasePart)* '}' )? ('default' default=XExpression)? ('declaredParam' declaredParam=JvmFormalParameter)? '}'; XVariableDeclaration returns xbase::XVariableDeclaration: {xbase::XVariableDeclaration} (writeable?='writeable')? 'XVariableDeclaration' name=EString '{' ('type' type=JvmTypeReference)? ('right' right=XExpression)? '}'; XMemberFeatureCall returns xbase::XMemberFeatureCall: {xbase::XMemberFeatureCall} (explicitOperationCall?='explicitOperationCall')? (explicitStatic?='explicitStatic')? (nullSafe?='nullSafe')? 'XMemberFeatureCall' '{' ('feature' feature=[types::JvmIdentifiableElement|EString])? ('typeArguments' '{' typeArguments+=JvmTypeReference ( "," typeArguments+=JvmTypeReference)* '}' )? ('memberCallTarget' memberCallTarget=XExpression)? ('memberCallArguments' '{' memberCallArguments+=XExpression ( "," memberCallArguments+=XExpression)* '}' )? '}'; XFeatureCall returns xbase::XFeatureCall: {xbase::XFeatureCall} (explicitOperationCall?='explicitOperationCall')? 'XFeatureCall' '{' ('feature' feature=[types::JvmIdentifiableElement|EString])? ('typeArguments' '{' typeArguments+=JvmTypeReference ( "," typeArguments+=JvmTypeReference)* '}' )? ('featureCallArguments' '{' featureCallArguments+=XExpression ( "," featureCallArguments+=XExpression)* '}' )? '}'; XConstructorCall returns xbase::XConstructorCall: {xbase::XConstructorCall} (explicitConstructorCall?='explicitConstructorCall')? 'XConstructorCall' '{' ('constructor' constructor=[types::JvmConstructor|EString])? ('arguments' '{' arguments+=XExpression ( "," arguments+=XExpression)* '}' )? ('typeArguments' '{' typeArguments+=JvmTypeReference ( "," typeArguments+=JvmTypeReference)* '}' )? '}'; XBooleanLiteral returns xbase::XBooleanLiteral: {xbase::XBooleanLiteral} (isTrue?='isTrue')? 'XBooleanLiteral' ; XNullLiteral returns xbase::XNullLiteral: {xbase::XNullLiteral} 'XNullLiteral' ; XNumberLiteral returns xbase::XNumberLiteral: {xbase::XNumberLiteral} 'XNumberLiteral' '{' ('value' value=EString)? '}'; XStringLiteral returns xbase::XStringLiteral: {xbase::XStringLiteral} 'XStringLiteral' '{' ('value' value=EString)? '}'; XListLiteral returns xbase::XListLiteral: {xbase::XListLiteral} 'XListLiteral' '{' ('elements' '{' elements+=XExpression ( "," elements+=XExpression)* '}' )? '}'; XSetLiteral returns xbase::XSetLiteral: {xbase::XSetLiteral} 'XSetLiteral' '{' ('elements' '{' elements+=XExpression ( "," elements+=XExpression)* '}' )? '}'; XClosure returns xbase::XClosure: {xbase::XClosure} (explicitSyntax?='explicitSyntax')? 'XClosure' '{' ('declaredFormalParameters' '{' declaredFormalParameters+=JvmFormalParameter ( "," declaredFormalParameters+=JvmFormalParameter)* '}' )? ('expression' expression=XExpression)? '}'; XCastedExpression returns xbase::XCastedExpression: {xbase::XCastedExpression} 'XCastedExpression' '{' ('type' type=JvmTypeReference)? ('target' target=XExpression)? '}'; XBinaryOperation returns xbase::XBinaryOperation: {xbase::XBinaryOperation} (reassignFirstArgument?='reassignFirstArgument')? 'XBinaryOperation' '{' ('feature' feature=[types::JvmIdentifiableElement|EString])? ('typeArguments' '{' typeArguments+=JvmTypeReference ( "," typeArguments+=JvmTypeReference)* '}' )? ('leftOperand' leftOperand=XExpression)? ('rightOperand' rightOperand=XExpression)? '}'; XUnaryOperation returns xbase::XUnaryOperation: {xbase::XUnaryOperation} 'XUnaryOperation' '{' ('feature' feature=[types::JvmIdentifiableElement|EString])? ('typeArguments' '{' typeArguments+=JvmTypeReference ( "," typeArguments+=JvmTypeReference)* '}' )? ('operand' operand=XExpression)? '}'; XPostfixOperation returns xbase::XPostfixOperation: {xbase::XPostfixOperation} 'XPostfixOperation' '{' ('feature' feature=[types::JvmIdentifiableElement|EString])? ('typeArguments' '{' typeArguments+=JvmTypeReference ( "," typeArguments+=JvmTypeReference)* '}' )? ('operand' operand=XExpression)? '}'; XForLoopExpression returns xbase::XForLoopExpression: {xbase::XForLoopExpression} 'XForLoopExpression' '{' ('forExpression' forExpression=XExpression)? ('eachExpression' eachExpression=XExpression)? ('declaredParam' declaredParam=JvmFormalParameter)? '}'; XBasicForLoopExpression returns xbase::XBasicForLoopExpression: {xbase::XBasicForLoopExpression} 'XBasicForLoopExpression' '{' ('expression' expression=XExpression)? ('eachExpression' eachExpression=XExpression)? ('initExpressions' '{' initExpressions+=XExpression ( "," initExpressions+=XExpression)* '}' )? ('updateExpressions' '{' updateExpressions+=XExpression ( "," updateExpressions+=XExpression)* '}' )? '}'; XDoWhileExpression returns xbase::XDoWhileExpression: {xbase::XDoWhileExpression} 'XDoWhileExpression' '{' ('predicate' predicate=XExpression)? ('body' body=XExpression)? '}'; XWhileExpression returns xbase::XWhileExpression: {xbase::XWhileExpression} 'XWhileExpression' '{' ('predicate' predicate=XExpression)? ('body' body=XExpression)? '}'; XTypeLiteral returns xbase::XTypeLiteral: 'XTypeLiteral' '{' ('arrayDimensions' '{' arrayDimensions+=EString ( "," arrayDimensions+=EString)* '}' )? 'type' type=[types::JvmType|EString] '}'; XInstanceOfExpression returns xbase::XInstanceOfExpression: 'XInstanceOfExpression' '{' 'type' type=JvmTypeReference 'expression' expression=XExpression '}'; XThrowExpression returns xbase::XThrowExpression: {xbase::XThrowExpression} 'XThrowExpression' '{' ('expression' expression=XExpression)? '}'; XTryCatchFinallyExpression returns xbase::XTryCatchFinallyExpression: {xbase::XTryCatchFinallyExpression} 'XTryCatchFinallyExpression' '{' ('expression' expression=XExpression)? ('finallyExpression' finallyExpression=XExpression)? ('catchClauses' '{' catchClauses+=XCatchClause ( "," catchClauses+=XCatchClause)* '}' )? '}'; XAssignment returns xbase::XAssignment: {xbase::XAssignment} (explicitStatic?='explicitStatic')? 'XAssignment' '{' ('feature' feature=[types::JvmIdentifiableElement|EString])? ('typeArguments' '{' typeArguments+=JvmTypeReference ( "," typeArguments+=JvmTypeReference)* '}' )? ('assignable' assignable=XExpression)? ('value' value=XExpression)? '}'; Generator wrongly configured
  • 70.
  • 71.
  • 72.
    I am missingthe Maven part…
  • 73.
    https://github.com/holgerschill/XtextCon_Xcore_Maven A full workingexample can be found here Tycho Xtext Maven Plugin Exec-Maven-Plugin Xtend Maven Plugin
  • 74.
  • 75.
    Pittfalls Right dependencies togenerate Java out of Xcore <dependencies> <dependency> <groupId>org.osgi</groupId> <artifactId>org.osgi.core</artifactId> <version>4.3.1</version> </dependency> <dependency> <groupId>org.eclipse.core</groupId> <artifactId>org.eclipse.core.resources</artifactId> <version>3.7.100</version> </dependency> <dependency> <groupId>org.eclipse.text</groupId> <artifactId>org.eclipse.text</artifactId> <version>3.5.101</version> </dependency> <dependency> <groupId>org.eclipse.emf</groupId> <artifactId>org.eclipse.emf.codegen.ecore.xtext</artifactId> <version>${ecore-xtext-version}</version> </dependency> <dependency> <groupId>org.eclipse.emf</groupId> <artifactId>org.eclipse.emf.ecore.xcore.lib</artifactId> <version>${ecore-xcore-lib-version}</version> </dependency> <dependency> <groupId>org.eclipse.emf</groupId> <artifactId>org.eclipse.emf.ecore.xcore</artifactId> <version>${ecore-xcore-version}</version> </dependency> </dependencies>
  • 76.
    Pittfalls Set modelDirectory inXcore files explicitly @GenModel(modelDirectory="./src-gen") package org.xtext.example.myfirstdsl import common.NamedElement import common.Referenceable class FirstElement extends NamedElement, Referenceable { refers Referenceable ref }
  • 77.
    Pittfalls Don’t use classpathURIs in MWE2 var fileExtensions = "first" var projectName = "org.xtext.example.firstdsl.lang" var runtimeProject = "../${projectName}" var generateXtendStub = true //var grammarURI = "classpath:/org/xtext/example/firstdsl/Lang.xtext" var grammarURI = "platform:/resource/${projectName}/src/org/xtext/example/firstdsl/Lang.xtext"
  • 78.
    Pittfalls Explicitly set pathto generate Java classes // generates Java API for the generated EPackages fragment = ecore.EMFGeneratorFragment auto-inject { javaModelDirectory = "/${projectName}/src-gen" }
  • 79.