Generator

Instance class: org.nasdanika.codegen.Generator

Generator is the base class for model element performing code generation.

Generator final context is constucted in the following order:

  • Iterator is processed
  • If context map is not blank then iterator contexts are mapped
  • If configuration elements are present they are injected into the previously constructed context

Supertypes

Subtypes

Referrers

Uses

Members

  • Attributes
    • contextMap : EString - If context map is not blank then it is parsed as YAML and used to construct a generation context or contexts from the current context.
    • enabled : EBoolean - Generator creates work only if this attribute is true.
    • iterator : EString - Iterator contains context property name and allows to execute generator zero or more times depending on the property type.
  • Operations

Attributes

contextMap : EString

If context map is not blank then it is parsed as YAML and used to construct a generation context or contexts from the current context. If contextMap value is string then it is used as a relative URL to load a YAML resource with context mapping. The resource is processed in the same way as the context map text. If it is a map then then the map is interpolated by the current context and wrapped into a context. If the value is a list then each of its elements is processed as explained here to produce a mapped context. In this case the generator is executed once for each list element for each iterator entry (nested loop).

Type EString
Cardinality 0..1

enabled : EBoolean

Generator creates work only if this attribute is true. The purpose of this attribute is to help with generator model development by disabling model parts which are still work in progress and would fail the generation process, or, on the opposite, already working parts which would create delay and distraction in testing and troubleshooting. Use Iterator for conditional generation.

Type EBoolean
Cardinality 0..1

iterator : EString

Iterator contains context property name and allows to execute generator zero or more times depending on the property type.

  • If iterator is blank then generator is executed once using the current generation context.
  • If iterator is not blank its value is used to get a property from the current generation context. Depending on the property value the generator is executed zero or more times:
    • null - in this case iterator value is used as a prefix to create a sub-context to be used by the generator. E.g. if iterator value is my-component/ then my-property property of the sub-context maps to my-component/my-property property of the parent context.
    • boolean false - generator is not executed.
    • boolean true - generator is executed once with the current context, same as for a blank iterator.
    • single value (scalar) - generator is executed once with the current context and value available via data context property.
    • list - generator is executed once for each list element with element value being processed as explained here.
    • map - the map values are interoplated recursively by the current context. Then the map is wrapped into a context which is used to execute the generator.
    • org.eclipse.emf.common.notify.AdapterFactory - the factory shall be for org.nasdanika.common.ContextIterator.Factory. A context iterator is created by the factory and is used to iterate over the element.
Type EString
Cardinality 0..1

Operations

validate : EBoolean

Validates element.

Type EBoolean
Cardinality 0..1
Parameters
diagnostics : EDiagnosticChain

Diagnostics to add validation messages to.

Type EDiagnosticChain
Cardinality 0..1
context : EMap<EJavaObject, EJavaObject>

Validation context.

Type EMap<EJavaObject,EJavaObject>
Cardinality 0..1