You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by li...@apache.org on 2022/05/20 07:24:37 UTC
[incubator-doris] branch master updated: [enhancement](community): enhance java style (#9693)
This is an automated email from the ASF dual-hosted git repository.
lingmiao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-doris.git
The following commit(s) were added to refs/heads/master by this push:
new 0c4b47756a [enhancement](community): enhance java style (#9693)
0c4b47756a is described below
commit 0c4b47756ad693db316d311e69ceed03d9f83161
Author: jakevin <30...@users.noreply.github.com>
AuthorDate: Fri May 20 15:24:30 2022 +0800
[enhancement](community): enhance java style (#9693)
Enhance java style.
Now: checkstyle about code order is in this page--Class and Interface Declarations
This pr can make idea auto rearrange code
---
build-support/IntelliJ-code-format.xml | 228 ++++++++++++++++++++-
.../public/images/idea-rearrange-code.png | Bin 0 -> 67359 bytes
docs/en/developer-guide/java-format-code.md | 23 ++-
docs/zh-CN/developer-guide/java-format-code.md | 22 +-
4 files changed, 266 insertions(+), 7 deletions(-)
diff --git a/build-support/IntelliJ-code-format.xml b/build-support/IntelliJ-code-format.xml
index eea3822f66..26886b3541 100644
--- a/build-support/IntelliJ-code-format.xml
+++ b/build-support/IntelliJ-code-format.xml
@@ -32,8 +32,6 @@ under the License.
<emptyLine />
<package name="java" withSubpackages="true" static="false" />
<package name="javax" withSubpackages="true" static="false" />
- <emptyLine />
- <package name="" withSubpackages="true" static="true" />
</value>
</option>
<option name="ALIGN_MULTILINE_RECORDS" value="false" />
@@ -90,6 +88,232 @@ under the License.
<order>KEEP</order>
</group>
</groups>
+ <rules>
+ <section>
+ <rule>
+ <match>
+ <AND>
+ <FIELD>true</FIELD>
+ <FINAL>true</FINAL>
+ <PUBLIC>true</PUBLIC>
+ <STATIC>true</STATIC>
+ </AND>
+ </match>
+ </rule>
+ </section>
+ <section>
+ <rule>
+ <match>
+ <AND>
+ <FIELD>true</FIELD>
+ <PUBLIC>true</PUBLIC>
+ <STATIC>true</STATIC>
+ </AND>
+ </match>
+ </rule>
+ </section>
+ <section>
+ <rule>
+ <match>
+ <AND>
+ <FIELD>true</FIELD>
+ <FINAL>true</FINAL>
+ <PROTECTED>true</PROTECTED>
+ <STATIC>true</STATIC>
+ </AND>
+ </match>
+ </rule>
+ </section>
+ <section>
+ <rule>
+ <match>
+ <AND>
+ <FIELD>true</FIELD>
+ <PROTECTED>true</PROTECTED>
+ <STATIC>true</STATIC>
+ </AND>
+ </match>
+ </rule>
+ </section>
+ <section>
+ <rule>
+ <match>
+ <AND>
+ <FIELD>true</FIELD>
+ <FINAL>true</FINAL>
+ <PACKAGE_PRIVATE>true</PACKAGE_PRIVATE>
+ <STATIC>true</STATIC>
+ </AND>
+ </match>
+ </rule>
+ </section>
+ <section>
+ <rule>
+ <match>
+ <AND>
+ <FIELD>true</FIELD>
+ <PACKAGE_PRIVATE>true</PACKAGE_PRIVATE>
+ <STATIC>true</STATIC>
+ </AND>
+ </match>
+ </rule>
+ </section>
+ <section>
+ <rule>
+ <match>
+ <AND>
+ <FIELD>true</FIELD>
+ <FINAL>true</FINAL>
+ <PRIVATE>true</PRIVATE>
+ <STATIC>true</STATIC>
+ </AND>
+ </match>
+ </rule>
+ </section>
+ <section>
+ <rule>
+ <match>
+ <AND>
+ <FIELD>true</FIELD>
+ <PRIVATE>true</PRIVATE>
+ <STATIC>true</STATIC>
+ </AND>
+ </match>
+ </rule>
+ </section>
+ <section>
+ <rule>
+ <match>
+ <AND>
+ <FIELD>true</FIELD>
+ <FINAL>true</FINAL>
+ <PUBLIC>true</PUBLIC>
+ </AND>
+ </match>
+ </rule>
+ </section>
+ <section>
+ <rule>
+ <match>
+ <AND>
+ <FIELD>true</FIELD>
+ <PUBLIC>true</PUBLIC>
+ </AND>
+ </match>
+ </rule>
+ </section>
+ <section>
+ <rule>
+ <match>
+ <AND>
+ <FIELD>true</FIELD>
+ <FINAL>true</FINAL>
+ <PROTECTED>true</PROTECTED>
+ </AND>
+ </match>
+ </rule>
+ </section>
+ <section>
+ <rule>
+ <match>
+ <AND>
+ <FIELD>true</FIELD>
+ <PROTECTED>true</PROTECTED>
+ </AND>
+ </match>
+ </rule>
+ </section>
+ <section>
+ <rule>
+ <match>
+ <AND>
+ <FIELD>true</FIELD>
+ <FINAL>true</FINAL>
+ <PACKAGE_PRIVATE>true</PACKAGE_PRIVATE>
+ </AND>
+ </match>
+ </rule>
+ </section>
+ <section>
+ <rule>
+ <match>
+ <AND>
+ <FIELD>true</FIELD>
+ <PACKAGE_PRIVATE>true</PACKAGE_PRIVATE>
+ </AND>
+ </match>
+ </rule>
+ </section>
+ <section>
+ <rule>
+ <match>
+ <AND>
+ <FIELD>true</FIELD>
+ <FINAL>true</FINAL>
+ <PRIVATE>true</PRIVATE>
+ </AND>
+ </match>
+ </rule>
+ </section>
+ <section>
+ <rule>
+ <match>
+ <AND>
+ <FIELD>true</FIELD>
+ <PRIVATE>true</PRIVATE>
+ </AND>
+ </match>
+ </rule>
+ </section>
+ <section>
+ <rule>
+ <match>
+ <FIELD>true</FIELD>
+ </match>
+ </rule>
+ </section>
+ <section>
+ <rule>
+ <match>
+ <AND>
+ <INITIALIZER_BLOCK>true</INITIALIZER_BLOCK>
+ <STATIC>true</STATIC>
+ </AND>
+ </match>
+ </rule>
+ </section>
+ <section>
+ <rule>
+ <match>
+ <INITIALIZER_BLOCK>true</INITIALIZER_BLOCK>
+ </match>
+ </rule>
+ </section>
+ <section>
+ <rule>
+ <match>
+ <CONSTRUCTOR>true</CONSTRUCTOR>
+ </match>
+ </rule>
+ </section>
+ <section>
+ <rule>
+ <match>
+ <AND>
+ <METHOD>true</METHOD>
+ <STATIC>true</STATIC>
+ </AND>
+ </match>
+ </rule>
+ </section>
+ <section>
+ <rule>
+ <match>
+ <METHOD>true</METHOD>
+ </match>
+ </rule>
+ </section>
+ </rules>
</arrangement>
</codeStyleSettings>
</code_scheme>
diff --git a/docs/.vuepress/public/images/idea-rearrange-code.png b/docs/.vuepress/public/images/idea-rearrange-code.png
new file mode 100644
index 0000000000..c02e9a4cba
Binary files /dev/null and b/docs/.vuepress/public/images/idea-rearrange-code.png differ
diff --git a/docs/en/developer-guide/java-format-code.md b/docs/en/developer-guide/java-format-code.md
index 5934fbdc38..ef7b4e1fe9 100644
--- a/docs/en/developer-guide/java-format-code.md
+++ b/docs/en/developer-guide/java-format-code.md
@@ -42,18 +42,37 @@ standard java package
* Do not use `import *`
* Do not use `import static`
-## Checkstyle
+## Checkstyle Plugin
Now we have `formatter-check` in `CI` to check the code format.
+### IDEA
+
If you use `IDEA` to develop Java code, please install `Checkstyle-IDEA` plugin.
Setting the `checkstyle.xml` file in `Tools->Checkstyle`.
Click the plus sign under Configuration File, select `Use a local Checkstyle file`, and select the `fe/check/checkstyle/checkstyle.xml` file.
+### VS Code
+
+If you use VS Code to develop Java code, please install `Checkstyle for Java` plugin, and config according to the [document](https://code.visualstudio.com/docs/java/java-linting) and the picture
+
+## IDEA
+
+### Auto format code
+
The automatic formatting function of `IDEA` is also recommended.
Go to `Preferences->Editor->Code Style->Java` click the config sign and select `Import Scheme`,select `IntelliJ IDEA code style XML`,and select the `build-support/IntelliJ-code-format.xml` file.
-If you use VS Code to develop Java code, please install `Checkstyle for Java` plugin, and config according to the [document](https://code.visualstudio.com/docs/java/java-linting) and the picture.
+### Auto rearrange code
+
+Checkstyle will check declarations order according to [Class and Interface Declarations](https://www.oracle.com/java/technologies/javase/codeconventions-fileorganization.html#1852) .
+
+After add the `build-support/IntelliJ-code-format.xml` file. Click `Code/Rearrange Code` to auto rearrange code.
+
+![](/images/idea-rearrange-code.png)
+
+
+
diff --git a/docs/zh-CN/developer-guide/java-format-code.md b/docs/zh-CN/developer-guide/java-format-code.md
index 84e4ece1e5..125e80ac72 100644
--- a/docs/zh-CN/developer-guide/java-format-code.md
+++ b/docs/zh-CN/developer-guide/java-format-code.md
@@ -42,17 +42,33 @@ standard java package
* 禁止使用 `import *`
* 禁止使用 `import static`
-## Checkstyle
+## Checkstyle 插件
现在的 `CI` 之中会有 `formatter-check` 进行代码格式化检测。
+### IDEA
+
如果使用 `IDEA` 进行 Java 开发,请在设置中安装 `Checkstyle-IDEA` 插件。
在 `Tools->Checkstyle` 的 `Configuration File` 里点击 `Use a local Checkstyle file`,选择项目的 `fe/check/checkstyle/checkstyle.xml` 文件。
-同时推荐使用 `IDEA` 的自动格式化功能。
+### VS Code
+
+如果使用 VS Code 进行 Java 开发,请安装 `Checkstyle for Java` 插件,按照[文档](https://code.visualstudio.com/docs/java/java-linting)里的说明和动图进行配置。
+
+## IDEA
+
+### 自动格式化
+
+推荐使用 `IDEA` 的自动格式化功能。
在 `Preferences->Editor->Code Style->Java` 的配置标识点击 `Import Scheme`,点击 `IntelliJ IDEA code style XML`,选择项目的 `build-support/IntelliJ-code-format.xml` 文件。
-如果使用 VS Code 进行 Java 开发,请安装 `Checkstyle for Java` 插件,按照[文档](https://code.visualstudio.com/docs/java/java-linting)里的说明和动图进行配置。
+### Rearrange Code
+
+Checkstyle 会按照 [Class and Interface Declarations](https://www.oracle.com/java/technologies/javase/codeconventions-fileorganization.html#1852) 检测代码的 declarations 顺序。
+
+在导入上面的 `build-support/IntelliJ-code-format.xml` 文件后,使用 `Code/Rearrange Code` 自动完成排序
+
+![](/images/idea-rearrange-code.png)
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org