Home » Modeling » M2T (model-to-text transformation) » [Acceleo] Warning in query implemented in Java
[Acceleo] Warning in query implemented in Java [message #1096513] |
Wed, 28 August 2013 13:38  |
Eclipse User |
|
|
|
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 13:38] by Moderator Report message to a moderator
|
|
|
Re: [Acceleo] [message #1096574 is a reply to message #1096513] |
Wed, 28 August 2013 15:26   |
Eclipse User |
|
|
|
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 18:34  |
Eclipse User |
|
|
|
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;
|
|
|
Goto Forum:
Current Time: Thu Feb 13 14:04:56 GMT 2025
Powered by FUDForum. Page generated in 0.03732 seconds
|