Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Using Xcore with Xtext

3,333 views

Published on

Xcore is a textual format to define ecore models. This not only makes editing and reading much more convenient but has other cool advantages as well. Xcore, for instance, allows to embed Xbase expressions to define logic within EOperations and the like.
In this session you will learn, why and when using Xcore is a good idea and how to use it with Xtext languages. I will explain talk about which URIs to use, and how to properly configure the MWE2 file as well as more complicated setups, with multiple languages and mixtures of ecore, xcore and generated models.

  • Be the first to comment

Using Xcore with Xtext

  1. 1. modelsUsing with Holger Schill
  2. 2. Generated model
  3. 3. Generated model
  4. 4. Generated model
  5. 5. You will come to the point… Where you want to take control…
  6. 6. 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
  7. 7. 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
  8. 8. 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
  9. 9. For rapid prototyping the generated model is fine When to stay with the generated model
  10. 10. For rapid prototyping the generated model is fine Automatic synchronisation from grammar to model When to stay with the generated model
  11. 11. 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
  12. 12. But what if… DSL DSL DSL Order for generating DSLs is important
  13. 13. But what if… DSL DSL DSL Order for generating DSLs is important Eagerly loaded
  14. 14. DSL DSL DSLs reference each other But what if…
  15. 15. Imported Model
  16. 16. Imported Model
  17. 17. Imported Model Xtext Nature !
  18. 18. Still that tree editor…
  19. 19. Still that tree editor… Merging can be difficult
  20. 20. Generation Gap Pattern…
  21. 21. What is Xcore?
  22. 22. The MyDSL example in Xcore
  23. 23. Derives ecore and genmodel
  24. 24. Put code directly in the model
  25. 25. Put code directly in the model
  26. 26. Load Xcore file No Registration needed Workflow configuration
  27. 27. Don’t forget the Xcore dependency
  28. 28. 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
  29. 29. There is a wizard for that…
  30. 30. More complex setups Ecore model Xcore model Xtext DSL Xcore imports another ecore model Xtext DSL imports Xcore
  31. 31. Ecore model Xcore model
  32. 32. Ecore model Xcore model Xtext DSL
  33. 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. 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. 35. But I added that stuff in the StandaloneSetup…?
  36. 36. But I added that stuff in the StandaloneSetup…? ResourceSet Resource Resource Resource Resource ResourceSet Resource Resource
  37. 37. Ecore model Xcore model Proxy What’s happening? ResourceSet Grammar Xcore resource Ecore model Genmodel Index ResourceDescription ResourceDescription ResourceDescription ResourceDescription
  38. 38. Ecore model Xcore model Proxy What’s happening? Name Index ResourceDescription ResourceDescription ResourceDescription ResourceDescription
  39. 39. Ecore model Xcore model Proxy What’s happening? URI Index ResourceDescription ResourceDescription ResourceDescription ResourceDescription
  40. 40. Ecore model Xcore model What’s happening? resolved Index ResourceDescription ResourceDescription ResourceDescription ResourceDescription
  41. 41. Force same ResourceSet
  42. 42. More elegant
  43. 43. More complex example Xtext DSL Xtext DSL Languages referencing each other
  44. 44. More complex example Xtext DSL Xtext DSL Languages referencing each other Plugin Xtext DSL 1 Plugin Xtext DSL 1 Problem Circular dependency Buddypolicy
  45. 45. Introduce a Ecore model as a protocol Xtext DSL Xtext DSL Ecore model Generated Model Generated Model
  46. 46. 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
  47. 47. 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
  48. 48. More complex example Xtext DSL Xtext DSL Xcore model Xcore model Imported Model Imported Model
  49. 49. More complex example Xtext DSL Xtext DSL Xcore model Xcore model Imported Model Imported Model Same Plugin
  50. 50. More complex example Xtext DSL Xtext DSL Xcore model Xcore model Imported Model Imported Model Different plugins
  51. 51. More complex example Xtext DSL Xtext DSL Ecore model Xcore model Xcore model Imported Model Imported Model
  52. 52. Ecore model Xcore model Xcore model
  53. 53. 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…
  54. 54. 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…
  55. 55. 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
  56. 56. MWE2 configuration Same for both languages
  57. 57. 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
  58. 58. 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?
  59. 59. 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?
  60. 60. Xtext DSL Xtext DSL Ecore model Xcore model Xcore model generated Model generated Model One way to solve that…
  61. 61. One way to solve that…
  62. 62. 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)* ;
  63. 63. 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)* ;
  64. 64. 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)
  65. 65. 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)
  66. 66. There was nothing about Xbase so far…
  67. 67. Using Xbase
  68. 68. 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…
  69. 69. 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
  70. 70. Using Xbase
  71. 71. Using Xbase
  72. 72. I am missing the Maven part…
  73. 73. 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
  74. 74. 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
  75. 75. 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>
  76. 76. 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 }
  77. 77. 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"
  78. 78. Pittfalls Explicitly set path to generate Java classes // generates Java API for the generated EPackages fragment = ecore.EMFGeneratorFragment auto-inject { javaModelDirectory = "/${projectName}/src-gen" }
  79. 79. Questions?

×