0
我已經創建了自定義java代碼樣式格式化程序。 但是當我嘗試使用source->格式時,它沒有格式化文件。 此外,我嘗試使用源代碼 - >清理,我創建了一個自定義清理和應用格式源代碼選項。但仍然沒有格式化文件。日食格式化程序不工作
有時eclipse會顯示格式化的進度,但是如果我檢查代碼,只有幾個文件(也就是xml)被更改。
編輯 - 我已經嘗試從根項目以及源文件夾中單擊和格式化。 另外,源文件夾在構建路徑中。
我檢查錯誤日誌,發現以下異常 -
java.lang.ArrayIndexOutOfBoundsException: -1
at org.eclipse.jdt.internal.formatter.Scribe.getNewLineString(Scribe.java:1137)
at org.eclipse.jdt.internal.formatter.Scribe.getEmptyLines(Scribe.java:1062)
at org.eclipse.jdt.internal.formatter.Scribe.printEmptyLines(Scribe.java:3050)
at org.eclipse.jdt.internal.formatter.Scribe.preserveEmptyLines(Scribe.java:1584)
at org.eclipse.jdt.internal.formatter.Scribe.printComment(Scribe.java:2584)
at org.eclipse.jdt.internal.formatter.Scribe.printComment(Scribe.java:2414)
at org.eclipse.jdt.internal.formatter.CodeFormatterVisitor.format(CodeFormatterVisitor.java:714)
at org.eclipse.jdt.internal.formatter.CodeFormatterVisitor.visit(CodeFormatterVisitor.java:3294)
at org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.traverse(CompilationUnitDeclaration.java:679)
編輯2 找到根本原因。這是由於空白行和註釋導入語句
import org.hibernate.validator.HibernateValidator;
import org.hibernate.validator.HibernateValidatorConfiguration;
//import javax.validation.*;
import javax.validation.Configuration;
尋找可疑的錯誤信息點擊幫助 - >關於eclipse->安裝詳細信息 - >配置 - >查看錯誤日誌 – Leo
您是否正在根據Java項目的'源文件夾'格式化Java源文件到項目'Java Build Path'? – nitind