[英]I use Acceleo to create Java main method, but "[]" causes trouble because Acceleo redeems this as invocation
I am using Acceleo to create Java main method in my ".mtl", like this我正在使用 Acceleo 在我的“.mtl”中创建 Java 主要方法,就像这样
[template public generateElement(aMiniFamily : MiniFamily)]
[comment @main/]
[file ('CreateMiniFamily.java', false, 'UTF-8')]
public static void main(String[] args) {
}
[/file]
[/template]
But Acceleo gives me error as " The invocation isn't terminated " around " String[] ".但是 Acceleo 给我的错误是“调用未终止”围绕“ String[] ”。
I tried with "\[]" and "/[]", not working.我尝试使用“\[]”和“/[]”,但没有用。
The acceleo template syntax is kind of annoying when you want to print []
, but there's a very simple way to go over this issue, it's to remember that Acceleo will evaluate OCL expressions inside of the [ /]
.当您想打印[]
时,acceleo 模板语法有点烦人,但是有一个非常简单的方法可以解决这个问题 go,请记住,Acceleo 将计算[ /]
内的 OCL 表达式。 Consequently, you can put a string inside of the [/]
and it will be printed as a string in your result file.因此,您可以将一个字符串放在[/]
中,它将作为一个字符串打印在您的结果文件中。 The expression will then be ['[]'/]
and your code:然后表达式将是['[]'/]
和您的代码:
[template public generateElement(aMiniFamily : MiniFamily)]
[comment @main/]
[file ('CreateMiniFamily.java', false, 'UTF-8')]
public static void main(String['[]'/] args) {
}
[/file]
[/template]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.