grammar xy.domaindsl.DomainDSL with org.eclipse.xtext.common.Terminals hidden(WS, ML_COMMENT, NUM_COMMENT) import "http://www.eclipse.org/framework/v1.0/DomainDSL" // It's of course not eclipse.org :d import "http://www.eclipse.org/emf/2002/Ecore" as ecore import "http://www.eclipse.org/xtext/common/JavaVMTypes" as java DomainModel: 'package' name = QualifiedName ';' imports += TypeImportDeclaration* elements += DomainObject* ; TypeImportDeclaration: 'import' importedNamespace = QualifiedName ';' ; DomainObject: 'bo' name = ID ('extends' superType = [BusinessObject|QualifiedName])? '{' description = MultipleSLComment? (attributes += Attribute)* '}' ; Attribute: ( ReferenceAttribute | ... other alternative attributes ) description = SL_COMMENT? ; ReferenceAttribute: type = ([DomainObject|QualifiedName] | [java::JvmGenericType|QualifiedName]) // That's the kind of thing I'd like to have name = ID ;
ReferenceAttribute: type = [ecore::EObject|QualifiedName] name = ID ;
IScope scope_X_y(EObject ctx, EReference ref) { Predicate<IEObjectDescription> filter = new Predicate<IEObjectDescription>() { @Override public boolean apply(IEObjectDescription arg0) { return TypesPackage.Literals.JVM_GENERIC_TYPE.isSuperTypeOf(arg0.getEClass()) || MydslPackage.Literals.XXX_YYY.isSuperTypeOf(arg0.getEClass()); } }; return new FilteringScope(delegateGetScope(ctx, ref), filter); }
def IScope scope_ReferenceAttribute_type (EObject context, EReference ref) { return new FilteringScope (delegateGetScope (context, ref)) [ return TypesPackage.Literals.JVM_GENERIC_TYPE.isSuperTypeOf (it.EClass) || DomaindslPackage.Literals.DOMAIN_OBJECT.isSuperTypeOf (it.EClass) ] }