将注释移至 IntelliJ IDEA 中的上一行
Move comment to previous line in IntelliJ IDEA
我 "inherited" 一些 Java 代码在语句末尾包含很多注释,例如:
this.apiAccess=apiAccess;// used for reading model
SonarCube 将此标记为次要违规,并声明注释应改为显示在代码上方:
// used for reading model
this.apiAccess=apiAccess;
有没有在 IntelliJ IDEA 中实现这个的简单方法?
您可以在整个项目中使用正则表达式进行搜索和替换,例如:
搜索:
^(.*) (//.*)
替换为:
\n\r
这将替换(作为示例):
<solid android:color="#FFFFFF"/> // Comment
对于
// Comment
<solid android:color="#FFFFFF"/>
我 "inherited" 一些 Java 代码在语句末尾包含很多注释,例如:
this.apiAccess=apiAccess;// used for reading model
SonarCube 将此标记为次要违规,并声明注释应改为显示在代码上方:
// used for reading model
this.apiAccess=apiAccess;
有没有在 IntelliJ IDEA 中实现这个的简单方法?
您可以在整个项目中使用正则表达式进行搜索和替换,例如:
搜索:
^(.*) (//.*)
替换为:
\n\r
这将替换(作为示例):
<solid android:color="#FFFFFF"/> // Comment
对于
// Comment
<solid android:color="#FFFFFF"/>