Formatting code with intellij plugin and using the jar gives different results
維護者通常 1 天內回覆
@plumpy 已經在處理了。
開始於 2021年2月23日。
評估
這個 Issue 還沒有評估資料。
描述
If I format the following file using the intellij plugin (IDE version: Ultimate 2020.2.4 / plugin version: google-java-format 1.9.0.0. ) I get different result when compared to using the jar on the command line.
original example file:
package x;
public class test2 {
static final String LONG_STRING = "This is a long string that makes the total line length for this line over 100 characters";
static final String ANOTHER_LONG_STRING =
"This is another long string but this line is under 100 characters "
+ "and this line is also under 100 characters "
+ "but this line is over 100 characters and will not be reformatted to under 100 characters using the intellij plugin but will be reformatted to under 100 characters using the jar.";
public test2() {
int x=1;if(x==1){x=2;}else{x=3;}
}
}
after formatting using intellij plugin (using menu code / reformat code) I get this:
package x;
public class test2 {
static final String LONG_STRING =
"This is a long string that makes the total line length for this line over 100 characters";
static final String ANOTHER_LONG_STRING =
"This is another long string but this line is under 100 characters "
+ "and this line is also under 100 characters "
+ "but this line is over 100 characters and will not be reformatted to under 100 characters using the intellij plugin but will be reformatted to under 100 characters using the jar.";
public test2() {
int x = 1;
if (x == 1) {
x = 2;
} else {
x = 3;
}
}
}
And after formatting on the command line:
/tmp $ java -version
openjdk version "11.0.9" 2020-10-20
OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.9+11)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.9+11, mixed mode)
/tmp $ cksum ~/lib/google-java-format-1.9-all-deps.jar
2002751029 3404610 ~/lib/google-java-format-1.9-all-deps.jar
/tmp $ java -jar ~/lib/google-java-format-1.9-all-deps.jar ./test2.java
I get this:
package x;
public class test2 {
static final String LONG_STRING =
"This is a long string that makes the total line length for this line over 100 characters";
static final String ANOTHER_LONG_STRING =
"This is another long string but this line is under 100 characters and this line is also"
+ " under 100 characters but this line is over 100 characters and will not be"
+ " reformatted to under 100 characters using the intellij plugin but will be"
+ " reformatted to under 100 characters using the jar.";
public test2() {
int x = 1;
if (x == 1) {
x = 2;
} else {
x = 3;
}
}
}
- 主要語言
- Java
- 星號
- 6.2k
- 分支
- 936
- 平均合併
- 6 分鐘
- 30 天內合併 PR
- 3
環境準備
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
google/google-java-format 的其他 Issue
-
難度 2/5 1-3 小時 新手友好度 72/100
google/google-java-format#1094 · 1 則留言 ·
維護者通常 1 天內回覆
-
難度 5/5 一週以上 新手友好度 15/100
google/google-java-format#1450 · 1 個 reaction ·
維護者通常 1 天內回覆
-
難度 4/5 3-5 天 新手友好度 55/100
google/google-java-format#1439 · 1 則留言 ·
維護者通常 1 天內回覆
-
難度 3/5 1-2 天 新手友好度 62/100
google/google-java-format#1436 · 2 則留言 ·
維護者通常 1 天內回覆
-
難度 3/5 1-2 天 新手友好度 48/100
google/google-java-format#1428 · 4 則留言 ·
維護者通常 1 天內回覆
查看 google/google-java-format 的全部 Issue
相似的 Issue
-
bug
難度 2/5 1-3 小時 新手友好度 84/100
維護者通常 1 天內回覆
-
ci-failure-cause test-failure
難度 2/5 1-3 小時 新手友好度 72/100
維護者通常 1 天內回覆
-
enhancement
難度 2/5 1-3 小時 新手友好度 65/100
nextcloud/notes-android#3367 ·
維護者通常 1 天內回覆
-
Feature
難度 2/5 1-3 小時 新手友好度 68/100
MuntashirAkon/AppManager#2058 ·
-
SarifLogger: artifactLocation.uri is not properly encoded for file names containing '#', '?', or '%' 未關閉
難度 2/5 1-3 小時 新手友好度 76/100
checkstyle/checkstyle#21721 ·
維護者通常 1 天內回覆