Skip to content

Commit

Permalink
some more proceedOnError
Browse files Browse the repository at this point in the history
  • Loading branch information
mickaelistria committed Feb 13, 2025
1 parent dec12bd commit 823f2a2
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,13 @@
import com.sun.tools.javac.tree.JCTree.JCExpressionStatement;
import com.sun.tools.javac.tree.JCTree.JCFieldAccess;
import com.sun.tools.javac.tree.JCTree.JCIdent;
import com.sun.tools.javac.tree.JCTree.JCIf;
import com.sun.tools.javac.tree.JCTree.JCInstanceOf;
import com.sun.tools.javac.tree.JCTree.JCLiteral;
import com.sun.tools.javac.tree.JCTree.JCMethodInvocation;
import com.sun.tools.javac.tree.JCTree.JCNewClass;
import com.sun.tools.javac.tree.JCTree.JCParens;
import com.sun.tools.javac.tree.JCTree.JCReturn;
import com.sun.tools.javac.tree.JCTree.JCThrow;
import com.sun.tools.javac.tree.JCTree.JCVariableDecl;
import com.sun.tools.javac.tree.TreeInfo;
Expand Down Expand Up @@ -194,4 +196,22 @@ public void visitParens(JCParens parens) {
super.visitParens(parens);
}
}

@Override
public void visitReturn(JCReturn tree) {
if (tree == null || !isValid(tree.getExpression())) {
visitErroneous(null);
} else {
super.visitReturn(tree);
}
}

@Override
public void visitIf(JCIf tree) {
if (tree == null || !isValid(tree.getCondition())) {
visitErroneous(null);
} else {
super.visitIf(tree);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import com.sun.tools.javac.tree.JCTree.JCClassDecl;
import com.sun.tools.javac.tree.JCTree.JCMethodInvocation;
import com.sun.tools.javac.tree.JCTree.JCParens;
import com.sun.tools.javac.tree.JCTree.JCReturn;
import com.sun.tools.javac.tree.JCTree.JCTypeCast;
import com.sun.tools.javac.tree.TreeInfo;
import com.sun.tools.javac.util.Context;
Expand Down Expand Up @@ -97,6 +98,14 @@ public void visitParens(JCParens tree) {
super.visitParens(tree);
}

@Override
public void visitReturn(JCReturn tree) {
if (!isValid(tree)) {
return;
}
super.visitReturn(tree);
}

private boolean isValid(JCTree tree) {
return tree != null && tree.type != null && !tree.type.isErroneous();
}
Expand Down

0 comments on commit 823f2a2

Please sign in to comment.