[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.modeling.m2m] Re: [ATL]problems with called rules

Hi Migert,

Migert Kapaj a écrit :
Hello all, i have a problem with this ATL code. The scope of this program is to derive the references from one class to all subclasses.
Where is the problem?
Is possible to generate an target model with a helper?

The problem is that you're trying to call a matched rule (which is not callable) from an helper (which is not possible). Indeed, the goal of an helper is to navigate the input model(s) in order to retrieve and/or compute useful information to be used in the rules which build the output model elements. Thus, you cannot create output model element from an helper.


Where is the guide to use lazy-rules?

You can find from http://wiki.eclipse.org/ATL_Language_Troubleshooter#ATL_matched.2C_called_and_lazy_rules:_differences more detailed information on lazy rules and on how to call them.
As lazy rules are also declarative ones, it's recommended using them (if really needed of course).


Best regards,

Hugo


Thanks in advance Migert Kapaj


create OUT : KM3 from IN : KM3;

helper def: relazioni(inp : KM3!Reference) : Set(KM3!Reference) =
thisModule.all_subclasses(inp.owner)->iterate(iter; acc: Set(KM3!Reference)=Set{} |
acc->union(Set{thisModule.creaRelazione(inp,iter,inp.type)})
);


 rule creaRelazione
 {
   from rel: KM3!Reference, owner1: KM3!Class, type1: KM3!Class

  to relazione : KM3!Reference(
      isContainer <- rel.isContainer,
      --opposite <- rel.opposite,
      name <- rel.name,--.concat(type.name),
   location <- rel.location,
      lower <- rel.lower,
      upper <- rel.upper,
      isOrdered <- rel.isOrdered,
      isUnique <- rel.isUnique,
      type <- type1,
   owner <- owner1
   )

 }



rule CopyReference {
from
s : KM3!Reference(if s.opposite.oclIsUndefined() then
true
else
false
endif
)
to
t : distinct KM3!Reference foreach(c in thisModule.relazioni(s))--relazioni(s))
(
isContainer <- s.isContainer,
--opposite <- c.opposite,
name <- s.name,
location <- s.location,
lower <- s.lower,
upper <- s.upper,
isOrdered <- s.isOrdered,
isUnique <- s.isUnique,
type <- s.type,
owner <- c
)
}


... other rules are OK

GRAVE: ****** BEGIN Stack Trace
GRAVE: message: cannot set feature KM3!Reference.owner to value org.eclipse.emf.ecore.impl.DynamicEObjectImpl@1261ef2 (eClass: org.eclipse.emf.ecore.impl.EClassImpl@1b529d6 (name: Reference) (instanceClassName: null) (abstract: false, interface: false))
GRAVE: exception:
GRAVE: The value of type 'org.eclipse.emf.ecore.impl.EClassImpl@1b529d6 (name: Reference) (instanceClassName: null) (abstract: false, interface: false)' must be of type 'org.eclipse.emf.ecore.impl.EClassImpl@7f6155 (name: Class) (instanceClassName: null) (abstract: false, interface: false)'
java.lang.ClassCastException: The value of type 'org.eclipse.emf.ecore.impl.EClassImpl@1b529d6 (name: Reference) (instanceClassName: null) (abstract: false, interface: false)' must be of type 'org.eclipse.emf.ecore.impl.EClassImpl@7f6155 (name: Class) (instanceClassName: null) (abstract: false, interface: false)'
at org.eclipse.emf.ecore.impl.EStructuralFeatureImpl$InternalSettingDelegateSingleContainer.dynamicSet(EStructuralFeatureImpl.java:1824)


at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eDynamicSet(BasicEObjectImpl.java:1116)

at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eSet(BasicEObjectImpl.java:1090)

at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eSet(BasicEObjectImpl.java:1061)

at org.eclipse.m2m.atl.drivers.emf4atl.ASMEMFModelElement.set(ASMEMFModelElement.java:264)

at org.eclipse.m2m.atl.engine.vm.ASMOperation.realExec(ASMOperation.java:292)
at org.eclipse.m2m.atl.engine.vm.ASMOperation.realExec(ASMOperation.java:325)
at org.eclipse.m2m.atl.engine.vm.ASMOperation.exec(ASMOperation.java:161)
at org.eclipse.m2m.atl.engine.vm.nativelib.ASMOclAny.invoke(ASMOclAny.java:133)


at org.eclipse.m2m.atl.engine.vm.nativelib.ASMOclAny.invoke(ASMOclAny.java:91)
at org.eclipse.m2m.atl.engine.vm.ASMOperation.realExec(ASMOperation.java:230)
at org.eclipse.m2m.atl.engine.vm.ASMOperation.realExec(ASMOperation.java:325)
at org.eclipse.m2m.atl.engine.vm.ASMOperation.exec(ASMOperation.java:161)
at org.eclipse.m2m.atl.engine.vm.nativelib.ASMOclAny.invoke(ASMOclAny.java:133)


at org.eclipse.m2m.atl.engine.vm.nativelib.ASMOclAny.invoke(ASMOclAny.java:91)
at org.eclipse.m2m.atl.engine.vm.ASMOperation.realExec(ASMOperation.java:230)
at org.eclipse.m2m.atl.engine.vm.ASMOperation.exec(ASMOperation.java:161)
at org.eclipse.m2m.atl.engine.vm.ASMInterpreter.<init>(ASMInterpreter.java:289)


at org.eclipse.m2m.atl.engine.AtlLauncher.launch(AtlLauncher.java:155)
at org.eclipse.m2m.atl.engine.AtlLauncher.launch(AtlLauncher.java:105)
at org.eclipse.m2m.atl.engine.AtlLauncher.launch(AtlLauncher.java:81)
at org.eclipse.m2m.atl.adt.launching.AtlRegularVM.runAtlLauncher(AtlRegularVM.java:351)


at org.eclipse.m2m.atl.adt.launching.AtlRegularVM.runAtlLauncher(AtlRegularVM.java:453)

at org.eclipse.m2m.atl.adt.launching.AtlRegularVM.launch(AtlRegularVM.java:425)

at org.eclipse.m2m.atl.adt.launching.AtlLaunchConfigurationDelegate.launch(AtlLaunchConfigurationDelegate.java:35)

at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:766)

at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:608)

at org.eclipse.debug.internal.ui.DebugUIPlugin.buildAndLaunch(DebugUIPlugin.java:899)

at org.eclipse.debug.internal.ui.DebugUIPlugin$7.run(DebugUIPlugin.java:1102)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
GRAVE: A.main() : ??#24 null
GRAVE: local variables = {self=KM3Pulito : ASMModule}
GRAVE: local stack = []
GRAVE: A.__exec__() : ??#38 null
GRAVE: local variables = {e=TransientLink {rule = 'CopyReference', sourceElements = {s = IN!literals}, targetElements = {t = Sequence {OUT!literals}}, variables = {}}, self=KM3Pulito : ASMModule}
GRAVE: local stack = []
GRAVE: A.__applyCopyReference(1 : NTransientLink;) : ??#145 182:8-182:18
GRAVE: local variables = {t=Sequence {OUT!literals}, s=IN!literals, link=TransientLink {rule = 'CopyReference', sourceElements = {s = IN!literals}, targetElements = {t = Sequence {OUT!literals}}, variables = {}}, self=KM3Pulito : ASMModule, c=OUT!literals, collection=Sequence {OUT!literals, OUT!literals}, counter=1}
GRAVE: local stack = [OUT!literals]
GRAVE: ****** END Stack Trace
INFO: Execution terminated due to error (see launch configuration to allow continuation after errors).
GRAVE: cannot set feature KM3!Reference.owner to value org.eclipse.emf.ecore.impl.DynamicEObjectImpl@1261ef2 (eClass: org.eclipse.emf.ecore.impl.EClassImpl@1b529d6 (name: Reference) (instanceClassName: null) (abstract: false, interface: false))
java.lang.RuntimeException: cannot set feature KM3!Reference.owner to value org.eclipse.emf.ecore.impl.DynamicEObjectImpl@1261ef2 (eClass: org.eclipse.emf.ecore.impl.EClassImpl@1b529d6 (name: Reference) (instanceClassName: null) (abstract: false, interface: false))
at org.eclipse.m2m.atl.engine.vm.SimpleDebugger.error(SimpleDebugger.java:185)
at org.eclipse.m2m.atl.engine.vm.StackFrame.printStackTrace(StackFrame.java:85)


at org.eclipse.m2m.atl.drivers.emf4atl.ASMEMFModelElement.set(ASMEMFModelElement.java:267)

at org.eclipse.m2m.atl.engine.vm.ASMOperation.realExec(ASMOperation.java:292)
at org.eclipse.m2m.atl.engine.vm.ASMOperation.realExec(ASMOperation.java:325)
at org.eclipse.m2m.atl.engine.vm.ASMOperation.exec(ASMOperation.java:161)
at org.eclipse.m2m.atl.engine.vm.nativelib.ASMOclAny.invoke(ASMOclAny.java:133)


at org.eclipse.m2m.atl.engine.vm.nativelib.ASMOclAny.invoke(ASMOclAny.java:91)
at org.eclipse.m2m.atl.engine.vm.ASMOperation.realExec(ASMOperation.java:230)
at org.eclipse.m2m.atl.engine.vm.ASMOperation.realExec(ASMOperation.java:325)
at org.eclipse.m2m.atl.engine.vm.ASMOperation.exec(ASMOperation.java:161)
at org.eclipse.m2m.atl.engine.vm.nativelib.ASMOclAny.invoke(ASMOclAny.java:133)


at org.eclipse.m2m.atl.engine.vm.nativelib.ASMOclAny.invoke(ASMOclAny.java:91)
at org.eclipse.m2m.atl.engine.vm.ASMOperation.realExec(ASMOperation.java:230)
at org.eclipse.m2m.atl.engine.vm.ASMOperation.exec(ASMOperation.java:161)
at org.eclipse.m2m.atl.engine.vm.ASMInterpreter.<init>(ASMInterpreter.java:289)


at org.eclipse.m2m.atl.engine.AtlLauncher.launch(AtlLauncher.java:155)
at org.eclipse.m2m.atl.engine.AtlLauncher.launch(AtlLauncher.java:105)
at org.eclipse.m2m.atl.engine.AtlLauncher.launch(AtlLauncher.java:81)
at org.eclipse.m2m.atl.adt.launching.AtlRegularVM.runAtlLauncher(AtlRegularVM.java:351)


at org.eclipse.m2m.atl.adt.launching.AtlRegularVM.runAtlLauncher(AtlRegularVM.java:453)

at org.eclipse.m2m.atl.adt.launching.AtlRegularVM.launch(AtlRegularVM.java:425)

at org.eclipse.m2m.atl.adt.launching.AtlLaunchConfigurationDelegate.launch(AtlLaunchConfigurationDelegate.java:35)

at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:766)

at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:608)

at org.eclipse.debug.internal.ui.DebugUIPlugin.buildAndLaunch(DebugUIPlugin.java:899)

at org.eclipse.debug.internal.ui.DebugUIPlugin$7.run(DebugUIPlugin.java:1102)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
Caused by: java.lang.ClassCastException: The value of type 'org.eclipse.emf.ecore.impl.EClassImpl@1b529d6 (name: Reference) (instanceClassName: null) (abstract: false, interface: false)' must be of type 'org.eclipse.emf.ecore.impl.EClassImpl@7f6155 (name: Class) (instanceClassName: null) (abstract: false, interface: false)'
at org.eclipse.emf.ecore.impl.EStructuralFeatureImpl$InternalSettingDelegateSingleContainer.dynamicSet(EStructuralFeatureImpl.java:1824)


at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eDynamicSet(BasicEObjectImpl.java:1116)

at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eSet(BasicEObjectImpl.java:1090)

at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eSet(BasicEObjectImpl.java:1061)

at org.eclipse.m2m.atl.drivers.emf4atl.ASMEMFModelElement.set(ASMEMFModelElement.java:264)

... 25 more



--
--------------------------------------------------------
Hugo Bruneliere - R&D Engineer
ATLAS Group (INRIA & LINA) - University of Nantes
2, rue de la Houssiniere
44322 Nantes Cedex 3 - France
office +33 2 51 12 58 10 /\ cell.+33 6 07 42 45 30
EMail: Hugo.Bruneliere@xxxxxxxxxxxxxx
http://www.sciences.univ-nantes.fr/lina/atl/
--------------------------------------------------------