Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » [Acceleo] Warning in query implemented in Java
icon4.gif  [Acceleo] Warning in query implemented in Java [message #1096513] Wed, 28 August 2013 09:38 Go to next message
Johan Hardy is currently offline Johan Hardy
Messages: 32
Registered: December 2012
Member
Dear All,

I'm facing at repetitive warnings wrt a simple Acceleo query. The problem is that the warnings are listed in the error log view of Eclipse. And the list becomes longer and longer each time I perform a new generation.

Here is the simple query I use to format comments in C:

[query public formatComment(arg0 : String, arg1 : String, arg2 : String, arg3 : Integer) : String
	= invoke('com.spacebel.acceleo.uml.to.c.services.commonServices', 'formatComment(java.lang.String, java.lang.String, java.lang.String, int)', Sequence{arg0, arg1, arg2, arg3}) /]


The associated java method is the following:

public String formatComment(String comment, String tagLine, String startLine, int lineSize)
	{
		String result = tagLine;
		String[] yy = comment.replaceAll("\\r","").split("\n");
		for (int i=0; i<yy.length; i++)
		{
			String line = yy[i];
			if (i!=0) 
			{
				result = result + "\n" + startLine;
			}
			if ((line.indexOf("@image") >= 0) || (line.length() <= lineSize))
			{
				result = result + line;
			}
			else
			{
				int size = 0;
				String[] tokens = line.split(" ");
				for (int x=0; x<tokens.length; x++)
				{
					String self = tokens[x];
					if ((self.length() + size) < lineSize)
					{
						size = size + 1 + self.length();
						result = result + self;
					}
					else
					{
						size = self.length() + 1;
						result = result + "\n" + startLine + self;
					}
					if ((self.length() == 0) || (!self.endsWith("\n"))) 
					{
						result = result + " ";
					}
				}
			}			
		}
		result = result + "\n" + startLine; 
		return result;
	}


The warning I have is: "It is strongly recommended not to return directly a String from a Java service in a query taking a primitive as its first parameter in order to ensure the precision of the traceability of each text region generated."

Does anyone know how to eliminate (kill) it ?

Regards;

[Updated on: Wed, 28 August 2013 09:38]

Report message to a moderator

Re: [Acceleo] [message #1096574 is a reply to message #1096513] Wed, 28 August 2013 11:26 Go to previous messageGo to next message
Ed Willink is currently offline Ed Willink
Messages: 4035
Registered: July 2009
Senior Member
Hi

Add an extra argument to your query so that it has on EObject to hang on to.

Just delete the irritations in the Problem View.

Regards

Ed Willink

On 28/08/2013 14:38, Johan Hardy wrote:
> Dear All,
>
> I'm facing at repetitive warnings wrt a simple Acceleo query. The
> problem is that the warnings are listed in the error log view of
> Eclipse. And the list becomes longer and longer each time I perform a
> new generation.
>
> Here is the simple query I use to format comments in C:
>
>
> [query public formatComment(arg0 : String, arg1 : String, arg2 :
> String, arg3 : Integer) : String
> = invoke('com.spacebel.acceleo.uml.to.c.services.commonServices',
> 'formatComment(java.lang.String, java.lang.String, java.lang.String,
> int)', Sequence{arg0, arg1, arg2, arg3}) /]
>
>
> The associated java method is the following:
>
>
> public String formatComment(String comment, String tagLine, String
> startLine, int lineSize)
> {
> String result = tagLine;
> String[] yy = comment.replaceAll("\\r","").split("\n");
> for (int i=0; i<yy.length; i++)
> {
> String line = yy[i];
> if (i!=0) {
> result = result + "\n" + startLine;
> }
> if ((line.indexOf("@image") >= 0) || (line.length() <=
> lineSize))
> {
> result = result + line;
> }
> else
> {
> int size = 0;
> String[] tokens = line.split(" ");
> for (int x=0; x<tokens.length; x++)
> {
> String self = tokens[x];
> if ((self.length() + size) < lineSize)
> {
> size = size + 1 + self.length();
> result = result + self;
> }
> else
> {
> size = self.length() + 1;
> result = result + "\n" + startLine + self;
> }
> if ((self.length() == 0) ||
> (!self.endsWith("\n"))) {
> result = result + " ";
> }
> }
> }
> }
> result = result + "\n" + startLine; return result;
> }
>
>
> The warning I have is: "It is strongly recommended not to return
> directly a String from a Java service in a query taking a primitive as
> its first parameter in order to ensure the precision of the
> traceability of each text region generated."
>
> Does anyone know how to eliminate (kill) it ?
>
> Regards;
Re: [Acceleo] [message #1096691 is a reply to message #1096574] Wed, 28 August 2013 14:34 Go to previous message
Johan Hardy is currently offline Johan Hardy
Messages: 32
Registered: December 2012
Member
Hi Ed,

Many thanks for your prompt answer. I used en EObject and it works !

[query public formatComment(arg0 : uml::Comment, arg1 : String, arg2 : String, arg3 : Integer) : String
	= invoke('com.spacebel.acceleo.uml.to.c.services.commonServices', 'formatComment(org.eclipse.uml2.uml.Comment, java.lang.String, java.lang.String, int)', Sequence{arg0, arg1, arg2, arg3}) /]


Regards;
Previous Topic:[Acceleo] How to get the value of a property (tagged value)
Next Topic:[Xpand] Hiding Xpand template from user
Goto Forum:
  


Current Time: Sat Aug 30 10:32:27 EDT 2014

Powered by FUDForum. Page generated in 0.01584 seconds