有没有办法让 Eclipse 的内置 Java 代码格式化程序忽略注释?每当我运行它时,它就会变成这样:
/*
* PSEUDOCODE
* Read in user's string/paragraph
*
* Three cases are possible
* Case 1: foobar
* do case 1 things
* Case 2: fred hacker
* do case 2 things
* Case 3: cowboyneal
* do case 3 things
*
* In all cases, do some other thing
*/
进入此:
/*
* PSEUDOCODE Read in user's string/paragraph
*
* Three cases are possible Case 1: foobar do case 1 things Case 2: fred
* hacker do case 2 things Case 3: cowboyneal do case 3 things
*
* In all cases, do some other thing
*/
我已经尝试过 Windows > 首选项 > Java > 代码样式 > 格式化程序设置,但找不到用于保留注释格式的设置。我使用的是 Eclipse 3.4.0。
最佳答案
还有另一种解决方案可用于抑制特定 block 注释的格式。在 block 注释的开头使用 /*-
(注意连字符),并格式化
如果您格式化文件的其余部分,则不会受到影响。
/*- * Here is a block comment with some very special * formatting that I want indent(1) to ignore. * * one * two * three */
来源:http://www.oracle.com/technetwork/java/javase/documentation/codeconventions-141999.html#350
关于eclipse - 使 Eclipse 的 Java 代码格式化程序忽略 block 注释,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1024886/