gpt4 book ai didi

eclipse - 使 Eclipse 的 Java 代码格式化程序忽略 block 注释

转载 作者:行者123 更新时间:2023-12-03 05:17:29 25 4
gpt4 key购买 nike

有没有办法让 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com