neilcsmith-net commented on code in PR #8484:
URL: https://github.com/apache/netbeans/pull/8484#discussion_r2073080570


##########
java/java.source.base/src/org/netbeans/modules/java/source/save/Reformatter.java:
##########
@@ -2565,7 +2565,39 @@ public Boolean visitIf(final IfTree node, Void p) {
             StatementTree elseStat = node.getElseStatement();
             CodeStyle.BracesGenerationStyle redundantIfBraces = 
cs.redundantIfBraces();
             int eoln = findNewlineAfterStatement(node);
-            if ((elseStat != null && redundantIfBraces == 
CodeStyle.BracesGenerationStyle.ELIMINATE && 
danglingElseChecker.hasDanglingElse(node.getThenStatement())) ||
+            Boolean hasErrThenStatement = 
Optional.ofNullable(node.getThenStatement())
+                    .filter(it-> it instanceof ExpressionStatementTree)
+                    .map(it -> ((ExpressionStatementTree)it).getExpression())
+                    .map(it->  (it instanceof ErroneousTree))
+                    .orElse(false);
+            if (hasErrThenStatement) {
+                if (getCurrentPath().getParentPath().getLeaf() instanceof 
BlockTree parentStTree) {
+                    var isPreviousIfTree = false;
+                    var endPositionOfErrThenStatement = endPos;
+                    for (var statment : parentStTree.getStatements()) {
+                        if (isPreviousIfTree) {
+                            var startPositionOfNextErrorStatement = (int) 
sp.getStartPosition(getCurrentPath().getCompilationUnit(), statment);

Review Comment:
   +1  Also `statment` -> `statement`.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscr...@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscr...@netbeans.apache.org
For additional commands, e-mail: notifications-h...@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists

Reply via email to