Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » [Acceleo] eliminate warnings([Acceleo] eliminate warnings)
[Acceleo] eliminate warnings [message #654809] Thu, 17 February 2011 09:24 Go to next message
olafo987  is currently offline olafo987 Friend
Messages: 13
Registered: November 2010
Junior Member
Hello
First, I apologize for my poor Inglish.

I'm working at one project with "Acceleo" and I have the need of eliminate multiples "warnings" that I have. I have very code as this:

[query public hasParameterTypeByName(c : Class, parameterName : String) : Boolean = (c.ownedOperation->asSequence()->collect(ownedParameter)->select(p : Parameter | p.type.name.equalsIgnoreCase(parameterName))->size() > 0) /]

[template public templateImportsSpecialsParameters(c : Class) post (trim())]
[if (c.hasParameterTypeByName('BigDecimal'))]
import java.math.BigDecimal;
[/if]
[if (hasParameterTypeByName(c, 'DataHandler'))]
import javax.activation.DataHandler;
[/if]
[if (hasParameterTypeByName(c, 'Document'))]
import org.w3c.dom.Document;
[/if]
[if (hasParameterTypeByName(c, 'Timestamp'))]
import java.sql.Timestamp;
[/if]
[if (hasParameterTypeByName(c, 'Calendar'))]
import java.util.Calendar;
[/if]
[if (hasParameterTypeByName(c, 'Date'))]
import java.util.Date;
[/if]
[if (hasParameterTypeByName(c, 'EmptyBean'))]
import gnf.ada.core.service.EmptyBean;
[/if]
[if (hasParameterTypeByName(c, 'Map'))]
import java.util.HashMap;
[/if]
[if (hasParameterList(c) or hasOperationReturnLis(c))]
import java.util.ArrayList;
[/if]
[if (hasSerializable(c))]
import java.io.Serializable;
[/if]
[/template]


And the warning that leaving is:
Invalid result for expression c.ownedOperation->asSequence()->collect(temp2 : Operation | temp2.ownedParameter)->select(p : Parameter | p.type.name.equalsIgnoreCase(parameterName))->size().>(0) at line 57 in Module common for query hasParameterTypeByName(Class,String). Last recorded value of self was org.eclipse.uml2.uml.internal.impl.ClassImpl@179a5d (name: MantPropertyTypeService, visibility: <unset>) (isLeaf: false, isAbstract: false) (isActive: false).

That strategy I can use to eliminate this warnings?, I can do defensive programming with "Acceleo"?

Thank in advance for you reply
Juan Carlos
Re: [Acceleo] eliminate warnings [message #655095 is a reply to message #654809] Fri, 18 February 2011 10:09 Go to previous message
Stephane Begaudeau is currently offline Stephane BegaudeauFriend
Messages: 454
Registered: April 2010
Location: Nantes (France)
Senior Member

Hi,

First of all this "warning" during the generation means that during your generation we found what would be considered as an error but it is not critical and we succeeded in continuing the generation. those type of "warning" have to be handle.

The problem here is coming from the fact that during this expression, you have an OclInvalid value.

"(c.ownedOperation->asSequence()->collect(ownedParameter)- >select(p : Parameter | p.type.name.equalsIgnoreCase(parameterName))->size() > 0)"

It can come from:
- "c" begin invalid.
- "c.ownedOperation" being invalid (unlikely)
- "p.type" (a parameter without any type)
- "p.type.name" (the type of the parameter does not have a name)
- etc... (I think that I've covered most of the cases here)

>> "That strategy I can use to eliminate this warnings?, I can do defensive programming with "Acceleo"?"

You can use a defensive approach with Acceleo by checking for ".oclIsInvalid()" and/or "oclIsUndefined()" but I would say that your model may contains a parameter of an operation with an undefined type or something like that.

I would advise you to check your model first anyway.


Stephane Begaudeau, Obeo

--
Twitter: @sbegaudeau
Acceleo wiki: http://wiki.eclipse.org/Acceleo
Blogs: http://stephanebegaudeau.tumblr.com & http://sbegaudeau.tumblr.com
Previous Topic:[Acceleo] Problems about queries
Next Topic:[Acceleo 3] Problems with the 'automatically build' : false errors
Goto Forum:
  


Current Time: Sat Apr 10 12:48:05 GMT 2021

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

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

Back to the top