google / google/google-java-format

Error formatting long string literal that contains "...\\t"

未關閉
#1,186 2 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
主要語言
Java
星號
6.2k
分支
937
平均合併
6 分鐘
30 天內合併 PR
3

描述

In version n1.24.0 of google-java-format_windows-x86-64.exe a long string literal that contains two backslashes followed by 't' results in an error.

Negative example:
```Java
String t =
"0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789\\t";
```

Tool invocation and error message:
```
$ google-java-format_windows-x86-64.exe -r --skip-removing-unused-imports test\Test.java
Test.java:29:7: error: unclosed string literal
"0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789\\t";
```

Positive example. This can be formatted.
```Java
String s = "01234567890123456789012345678901234567890123456789\\t";
```

Update: Using parameter `--skip-reflowing-long-strings` avoids this error!

貢獻指南

開啟貢獻指南

研究方向

使用 google-java-format_windows-x86-64.exe,透過 Test.java 中的長字串字面值重現報告,然後比較使用 --skip-reflowing-long-strings 時的行為。追蹤長字串重新排版路徑,並驗證不使用此替代方案時,有問題的字面值也能成功格式化。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
java
領域
tooling
Issue 類型
缺陷
難度
3/5
預估耗時
1-2 天
活躍度
停滯
描述清晰度
描述清楚
新手友好度
45/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。