删除JavaDoc注释的工具? [英] Tool to remove JavaDoc comments?
问题描述
有没有可以删除文件中所有JavaDoc注释的工具/ Eclipse插件?
正常(非JavaDoc)注释
尝试这个正则表达式可以在eclipse / sed /您喜欢的编辑器,具有regex支持。
/ \ * \ *(?s :(? * /)/
-
?s
将输入视为单行 - 起始字符串
\ **
- 零或以上
-
的负面前瞻* /
- 空格或非空格字符
-
- 尾随字符串
* /
修改
包含javadoc的字符串,使用此正则表达式
((?<!\\)([^] | ?< = \\) )*)|(/ \ * \ *(S :( ?* \ * /)
并将其替换为第一次捕获组
/ 1
然后,如果你说这不应该匹配
/// ** * /
或更复杂的案例
我建议使用解析器使用
/ \ * \ * (?! \ * /)。)* \ * /
Is there any tool / Eclipse plugin that can remove all JavaDoc comments in a file?
The normal (non-JavaDoc) comments should be intact after running the tool.
Try this regex to search replace either in eclipse / sed / your favorite editor that has regex support.
/\*\*(?s:(?!\*/).)*\*/
?s
treat input as single line- a starting string
\**
- zero or more
- negative lookahead for
*/
- space or non space char
- negative lookahead for
- a trailing string
*/
Edit
To tackle cases where strings containing javadoc, use this regex
((?<!\\)"([^"]|(?<=\\)")*")|(/\*\*(?s:(?!\*/).)*\*/)
and replace it with first capture group
/1
Then if you say this shouldn't match
///** */
or more complex cases
I suggest, using a parser tool like antlr to parse using java grammar for tokens like comments and strings and remove elements that you don't want
Sometime I find my own regex answers cryptic !!
So here is some visual feedback
((?!\\)"([^"]|(?=\\)")*")|(/\*\*(?:(?!\*/).)*\*/)
/\*\*(?:(?!\*/).)*\*/
这篇关于删除JavaDoc注释的工具?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!