[英]Custom formatter for Sun Codemodel
I'm using Java Sun Codemodel to generate java classes on the fly, and it works pretty well for me. 我正在使用Java Sun Codemodel即时生成Java类,它对我来说很好用。
Now I have an additional challenge: How do I control how the code is formatted? 现在,我还有一个挑战:如何控制代码的格式? Is there any way at all?
有什么办法吗? In particular, I'd like to have all curly brackets in a new line and would like to extend the line length to let's say 130 chars.
特别是,我想将所有花括号放在换行符中,并希望将行长扩展为130个字符。
Eg, we have a formatter that we use in Eclipse. 例如,我们有一个在Eclipse中使用的格式化程序。 There's no way I can just tell Codemodel to use that somehow, right?
我无法告诉Codemodel以某种方式使用它,对吗?
There's this JFormatter class that kind of looks like it could be useful for something, but it doesn't look like it can do more sophisticated stuff like that. 有一个JFormatter类,它看起来可能对某些东西很有用,但看起来却不能完成类似的工作。
JFormatter declared as final, so not, it isn't possible. JFormatter声明为final,所以不可能。
There's only two ways to solve the problem and continue using codemodel. 只有两种方法可以解决问题并继续使用代码模型。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.