We have a field in our dsl,
that's value automatically get a different value if another field is true,
before the output of the dsl is generated.
The source will not be changed.
That field with the condition would be a global configurations field.
If interpretEmptyStringAsNull is true
ProfileSettingsData:
& 'dataobject-metamodel-suffix' '=' metamodelSuffix = STRING
& 'exceptions' '{' exceptions = ExceptionSettings '}'
& interpretEmptyStringAsNull?='interpret-empty-string-submitted-values-as-null'?
// more similar ones left out for better reading
;
All LengthElement should have a minLength with < 0.
LengthElement :
'with-length' '=' '(' ((maxLength = INT) (fixedLength ?= 'fixed')? | (minLength = INT '-' maxLength = INT) ) ')'
;
I tried to use the MyDSLPostProcessor.ext approach, with the following, but nothing happend:
import ecore;
import xtext;
process(xtext::GeneratedMetamodel this) :
process(ePackage)
;
process(ecore::EPackage this) :
this.eClassifiers.typeSelect(ecore::EClass).process()
;
process(EClass this) :
switch (name) {
case "LengthElement": (eAllAttributes.setMinLength(9))
default: null
}
;
EDataType getEcoreDataType(String name) :
org::eclipse::emf::ecore::EcorePackage::eINSTANCE.getEClassifier(name)
;
I did not check for the condition here.
In the end I want to do something like this:
if (interpretEmptyStringAsNull && lengthElementInstance.getMinLength() < 1) {
lengthElementInstance.setMinLengthElement(1);
}
There is only one interpretEmptyStringAsNull
but many LengthElement's.
In other words when the flag is set every length should be at least 1.
Anyone an idea?