简体   繁体   English

我使用 Acceleo 创建 Java main 方法,但是“[]”引起了麻烦,因为 Acceleo 将其赎回为调用

[英]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.

相关问题 使用 Acceleo 调用 Java 代码 - Invoking Java Code with Acceleo 覆盖或扩展Acceleo模板中的模板 - overwrite or extend a template in an Acceleo template 如何确保 Vue 主模板创建方法在 Router-View 内部模板创建方法开始之前完成 - How To Ensure Vue Main Template Create Method Finishes Before Router-View Inner Template Create Method Starts 模板方法中的迭代器参数出现问题 - Trouble with iterator parameter in template method 当由于模板而无法使用纯虚函数时,简化类设计 - Simplifying class design when I cannot use pure virtual function because of templates 创建一个类方法模板,该模板将使用稍后实现的功能 - Create a class method template, that will use function implemented later 是否可以创建一个可用于创建任何类的“新”实例的泛型方法或类? - Is it possible to create a generic method or class that one can use to create “new” instances of any class? 我如何从主C ++发送模板函数中的模板类中的方法 - how do i send a method in a template class a print function from main c++ 我可以使用模板参数作为非模板方法的参数吗? - Can I use template parameter as argument to non-template method? 如何重构容器以直接使用谓词方法? - how can I refactor a container to use a predicate method directly?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM