Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » MOFScript » Recursive import?
Recursive import? [message #469069] Fri, 05 December 2008 01:46 Go to next message
No real name is currently offline No real nameFriend
Messages: 4
Registered: July 2009
Junior Member
Hi,

I have a big transformation and I want to split it into different files.
For example assume the following two transformation files:

// Start of contents of file test1.m2t
import "test2.m2t"

texttransformation test1 (in uml:"http://www.eclipse.org/uml2/2.1.0/UML") {
uml.Class::main () {
self.ownedAttribute->forEach(p:uml.Property) {
p.privateProperty()
}
}
uml.Type::mapType(){
stdout.println ("Mapping types");
}
}
// End of contents of file test1.m2t


// Start of contents of file test2.m2t
import "test1.m2t"
texttransformation test2 (in uml:"http://www.eclipse.org/uml2/2.1.0/UML") {
uml.Property::privateProperty () {
self.type.mapType()
}
}
// End of contents of file test2.m2t


This compiles fine, but if I execute the transformation on a model with
class attributes I get the following runtime exception:

## Starting transformation: "test1"
#Runtime Error in FunctionCallEvaluator:# Unknown function mapType for
type org.eclipse.uml2.uml.internal.impl.PrimitiveTypeImpl(line: 10)
( - Context:
test2::privateProperty::org.eclipse.mofscript.MOFScriptModel.impl.FunctionCallImpl@167e563
(line: 10, column: 4) (specification: ) (name: self.type.mapType,
isSuperCall: false)


It seems that the mapType operation cannot be found even though test1.m2t
has been imported in test2.m2t. Does the problem happen because there are
recursive imports in this example (i.e. test1.m2t imports test2.m2t and
test2.m2t imports test1.mt2)? If I put the contents of test2.m2t inside
test1.m2t the transformation works fine.

I was wondering if I am doing something wrong, or if there is any other
way to achieve what I am trying to do.

Many thanks,
Kyriakos
Re: Recursive import? [message #469072 is a reply to message #469069] Fri, 05 December 2008 13:32 Go to previous messageGo to next message
Gøran K. Olsen is currently offline Gøran K. OlsenFriend
Messages: 184
Registered: July 2009
Senior Member
Hello Kyriakos,

Yes, currently this does not work.

I haven't had the use for it earlier, so never tested it. But I guess it
should be easy to fix for the next version (if it should be possible at all
doing that, have to think about that ;-)).

To solve it "as-is" I would suggest that you make a file (or more based on
e.g. context or functionality etc..) ".....Util.m2t" and gather all your
rules that are used by more than one ".m2t" unit in that file and imports it
to all the other. I also thinks this is a cleaner approach than
"cross-importing" specifications.

Best Regards,
G
Re: Recursive import? [message #469075 is a reply to message #469072] Fri, 05 December 2008 16:14 Go to previous message
No real name is currently offline No real nameFriend
Messages: 4
Registered: July 2009
Junior Member
Hi Goran,

Thank you for the fast response. Yes, I should be able to split the
transformation so as to have a transformation file with the commonly used
rules to avoid recursive imports.

Regards,
Kyriakos
Re: Recursive import? [message #566132 is a reply to message #469069] Fri, 05 December 2008 13:32 Go to previous message
Gøran K. Olsen is currently offline Gøran K. OlsenFriend
Messages: 184
Registered: July 2009
Senior Member
Hello Kyriakos,

Yes, currently this does not work.

I haven't had the use for it earlier, so never tested it. But I guess it
should be easy to fix for the next version (if it should be possible at all
doing that, have to think about that ;-)).

To solve it "as-is" I would suggest that you make a file (or more based on
e.g. context or functionality etc..) ".....Util.m2t" and gather all your
rules that are used by more than one ".m2t" unit in that file and imports it
to all the other. I also thinks this is a cleaner approach than
"cross-importing" specifications.

Best Regards,
G
Re: Recursive import? [message #566146 is a reply to message #469072] Fri, 05 December 2008 16:14 Go to previous message
No real name is currently offline No real nameFriend
Messages: 4
Registered: July 2009
Junior Member
Hi Goran,

Thank you for the fast response. Yes, I should be able to split the
transformation so as to have a transformation file with the commonly used
rules to avoid recursive imports.

Regards,
Kyriakos
Previous Topic:Recursive import?
Next Topic:Bug located when calling a java class from a transformation
Goto Forum:
  


Current Time: Sat Jul 04 10:21:22 GMT 2015

Powered by FUDForum. Page generated in 0.03920 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software