You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For me, if a code has errors then we should not format it at all but I can't find any comment on why ignoreErrors was set to true for K_COMPILATION_UNIT in the original code which was introduced in this commit: b0e7530
One possible fix could be to not ignore errors: #1434
But it fails tests and before fixing those tests I would like to confirm this is the expected behavior.
The text was updated successfully, but these errors were encountered:
The idea was that the formatter would only skip AST nodes marked as malformed (see preVisit2() in all of the formatter's ASTVisitors). This in theory should be enough to avoid this kind of problems, while letting us reformat at least fragments that are syntactically correct.
So maybe a good solution with this example would be if the parser/compiler marked the whole TypeDeclaration as malformed? I've already suggested that in https://bugs.eclipse.org/bugs/show_bug.cgi?id=471825#c38
Relates to:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=471825
vi-eclipse/Eclipse-JDT#10
How to reproduce the bug:
The code given in this comment: https://bugs.eclipse.org/bugs/show_bug.cgi?id=471825#c11
or
As far I can understand, it fails because we ignore errors if the kind is K_COMPILATION_UNIT: https://github.com/eclipse-jdt/eclipse.jdt.core/blob/master/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/DefaultCodeFormatter.java#L317
and it proceeds to find the closing bracket.
For me, if a code has errors then we should not format it at all but I can't find any comment on why
ignoreErrors
was set to true for K_COMPILATION_UNIT in the original code which was introduced in this commit: b0e7530One possible fix could be to not ignore errors: #1434
But it fails tests and before fixing those tests I would like to confirm this is the expected behavior.
The text was updated successfully, but these errors were encountered: