Jump to: navigation, search

Difference between revisions of "ATL Language Troubleshooter"

('''Trouble''' '''Cause''' '''Solution(s)''')
m (UML2 Profiles)
Line 64: Line 64:
  
 
===UML2 Profiles===
 
===UML2 Profiles===
 +
 +
''N.B.: The following text concerns Eclipse 3.1 / UML2 v1.1. It does not apply to Eclipse 3.2 / UML2 v2.0 or later.''
  
 
Eclipse UML2 Profiles and Stereotypes cannot be applied directly via ATL, but must use the native Java methods of the UML2 plug-in. See also [http://groups.yahoo.com/group/atl_discussion/message/1202?l=1 atl_discussion message 1202].
 
Eclipse UML2 Profiles and Stereotypes cannot be applied directly via ATL, but must use the native Java methods of the UML2 plug-in. See also [http://groups.yahoo.com/group/atl_discussion/message/1202?l=1 atl_discussion message 1202].

Revision as of 07:14, 6 February 2007

< To: ATL

Trouble Cause Solution(s)

ATL Virtual Machine Troubles

  • Trouble: NativeOperation public static org.atl.engine.vm.nativelib.ASMNumber org.atl.engine.vm.nativelib.ASMInteger.operatorMinus(org.atl.engine.vm.StackFrame,org.atl.engine.vm.nativelib.ASMInteger,org.atl.engine.vm.nativelib.ASMNumber)
    Cause: You use negative integer to compare
    e.g. if self.upper = -1 ...
    Solutions: Use (0-x) operation
    e.g. if self.upper = (0-1) ... or change your comparaison if it is possible: e.g. if self.upper < 0 ...


ATL Called Rules Troubles

  • Trouble: ERROR: could not find operation including on Module having supertypes: [OclAny]) on a called rule
    Cause: Your called rule doesn't return the good type (problably any)
    Solution: Add a return type on your called rule by adding the do clause
    e.g.
rule myCalledRule() {
 to
   out : XML!Element -- ...
 do {
   out;
 }
}


ATL matched, called and lazy rules: differences

  • a matched rule is a declarative rule whose "from" pattern is automatically matched by the ATL engine
  • a lazy Rule is a declarative rule which is explicitely called
  • a called Rule is a imperative rule which is explicitely called

As ATL prefered coding style is declarative, you should better use matched and lazy rule.

How to call lazy rules ?

Let a simple lazy rule:

 lazy rule getCross {
   from
     i: ecore!EObject
   to 
     rel: metamodel!Relationship (
     )
 }

We can call it from a matched rule as follows:

 rule Example {
   from 
     s : ecore!EObject
   to 
     t : metamodel!Node (
       name <- s.toString(),
       edges <- thisModule.getCross(s)
 }

If we want to call lazy rule multiple times:

 rule Example {
   from 
     s : ecore!EObject
   to 
     t : metamodel!Node (
       name <- s.toString(),
       edges <- ecore!EClass.allInstancesFrom('yourmodel')->collect(e | thisModule.getCross(e))
  }

UML2 Profiles

N.B.: The following text concerns Eclipse 3.1 / UML2 v1.1. It does not apply to Eclipse 3.2 / UML2 v2.0 or later.

Eclipse UML2 Profiles and Stereotypes cannot be applied directly via ATL, but must use the native Java methods of the UML2 plug-in. See also atl_discussion message 1202.

The reason is that UML2 Profiles contain a small Ecore meta-model, with an EClass for each Stereotype defined. When a Profile is applied, this small meta-model is added to the set of available meta-models. Whenever a Stereotype is applied, an EAnnotation "appliedStereotypes" is created (or modified) and an instance of the EClass for that stereotype is added to the contents of the EAnnotation.

This can create problems with ATL, since ATL rules are intended to be confluent (i.e. execution order of rules does not matter). A Profile application basically changes the meta-model at run-time. Any Stereotype application can only happen after the Profile has been applied. Things become even more complex when unapplying Profiles/Stereotypes.