mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-19 04:51:24 +07:00
[java-decompiler] Patch 0048 from ForgeFlower.Improve output of loops inside trycatch
GitOrigin-RevId: 44c74aef2d7f6da9c2f7da6f7a53abbc463111cc
This commit is contained in:
committed by
intellij-monorepo-bot
parent
4b2a63b5f4
commit
74e32bae0d
@@ -192,6 +192,26 @@ public final class DecHelper {
|
||||
return setHandlers;
|
||||
}
|
||||
|
||||
public static boolean invalidHeadMerge(Statement head) {
|
||||
// Don't build a trycatch around a loop-head if statement, as we know that DoStatement should be built first.
|
||||
// Since CatchStatement's isHead is run after DoStatement's, we can assume that a loop was not able to be built.
|
||||
Statement ifhead = findIfHead(head);
|
||||
|
||||
return ifhead != null && head.getContinueSet().contains(ifhead.getFirst());
|
||||
}
|
||||
|
||||
private static Statement findIfHead(Statement head) {
|
||||
while (head != null && head.type != Statement.StatementType.IF) {
|
||||
if (head.type != Statement.StatementType.SEQUENCE) {
|
||||
return null;
|
||||
}
|
||||
|
||||
head = head.getFirst();
|
||||
}
|
||||
|
||||
return head;
|
||||
}
|
||||
|
||||
public static List<Exprent> copyExprentList(List<? extends Exprent> lst) {
|
||||
List<Exprent> ret = new ArrayList<>();
|
||||
for (Exprent expr : lst) {
|
||||
@@ -199,4 +219,4 @@ public final class DecHelper {
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,6 +85,10 @@ public final class CatchAllStatement extends Statement {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (DecHelper.invalidHeadMerge(head)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (DecHelper.checkStatementExceptions(Arrays.asList(head, exc))) {
|
||||
return new CatchAllStatement(head, exc);
|
||||
}
|
||||
|
||||
@@ -129,6 +129,10 @@ public final class CatchStatement extends Statement {
|
||||
}
|
||||
}
|
||||
|
||||
if (DecHelper.invalidHeadMerge(head)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (DecHelper.checkStatementExceptions(lst)) {
|
||||
return new CatchStatement(head, next, setHandlers);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user