diff --git a/.gitignore b/.gitignore index e5b99a4..568c8be 100644 --- a/.gitignore +++ b/.gitignore @@ -38,9 +38,13 @@ build/ /JNotepad/ /src/main/JNotepad.java /.idea/ +!.idea/codeStyles/ +!.idea/fileTemplates/ +!.idea/encodings.xml /project.txt logs/ /ch_language_pack.txt /en_language_pack.txt /jnotepadConfig.json /qodana.yaml +.mvn/ \ No newline at end of file diff --git a/.mvn/wrapper/maven-wrapper.jar b/.mvn/wrapper/maven-wrapper.jar deleted file mode 100644 index c1dd12f..0000000 Binary files a/.mvn/wrapper/maven-wrapper.jar and /dev/null differ diff --git a/.mvn/wrapper/maven-wrapper.properties b/.mvn/wrapper/maven-wrapper.properties deleted file mode 100644 index 40ca015..0000000 --- a/.mvn/wrapper/maven-wrapper.properties +++ /dev/null @@ -1,2 +0,0 @@ -distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.5/apache-maven-3.8.5-bin.zip -wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar \ No newline at end of file diff --git a/docs/images/codeTemplate.png b/docs/images/codeTemplate.png new file mode 100644 index 0000000..4ba79dc Binary files /dev/null and b/docs/images/codeTemplate.png differ diff --git a/docs/代码规范.md b/docs/代码规范.md new file mode 100644 index 0000000..ec66561 --- /dev/null +++ b/docs/代码规范.md @@ -0,0 +1,247 @@ +# 代码规范 + +## 1. 排版规则 + +### 1.1 编码 + +**规 则:IDE的text file encoding设置为UTF-8。** +**规 则:IDE中文件的换行符使用Unix格式,不要使用windows格式。** + +**补 充:** +本项目中`.idea/encodings.xml`已定义src、resource目录为UTF-8编码,禁止修改。 + +### 1.2 页宽 + +**规 则:编辑器列宽应设置为120** +**说 明:** +当一行代码的长度过长时,为了阅读方便,应该换行展示。但因为每个人的字体设置,屏幕大小有所不同,因此需要统一列宽为120。 +**补 充:** +IDEA默认列宽为120。本项目的.idea/codeStyles目录中应用的即为IDEA默认配置。 + +### 1.3 换行 + +**规 则:第二行相对第一行缩进4个空格,从第三行开始,不再缩进,而是与第二行保持同级。** +**规 则:运算符、方法调用的点符号与下文一起换行。** +**规 则:在多个参数超长时,逗号后换行。** +**示 例:** + +```java +//符合规范 +StringBuffer sb=new StringBuffer(); +//超过100个字符的时候,换行缩进4个空格,并且方法钱的点符号一起换行 + sb.append("wan").append("fang")... + .append("shu")... + .append("ju")... + .append("gu"); +//在逗号后换行 + method(arg1,arg2,arg3,...argx, + argx1) +``` + +### 1.4 缩进 + +**规 则:程序块需要采用缩进风格编写,缩进为4个空格。** +**说 明:** 不同的编辑工具会导致Tab字符的宽度不统一,在编码时应注意其可能造成的问题。 +**补 充:** +本项目的.idea/codeStyles目录中应用的即为IDEA默认配置。 + +### 1.5 空行 + +**规则:独立的程序块与变量声明之间加空行分割** +**示 例:** + +```java +//不符合规范 +if(log.getLevel()Editor->File and Code Templates,可进行修改。 +⚠️注意:确保schema选择的是project。 +![codeTemplate.png](images/codeTemplate.png) \ No newline at end of file