mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-19 04:51:24 +07:00
[java-decompiler] IDEA-346312 adapt patches
- add comments with examples GitOrigin-RevId: 22a84867e417c1a326f78c19d1146b3580f583a4
This commit is contained in:
committed by
intellij-monorepo-bot
parent
041ae74f7e
commit
cdb57601a8
@@ -268,6 +268,26 @@ public class MethodProcessorRunnable implements Runnable {
|
||||
return finished;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clean monitor of synchronizer: <p>
|
||||
* Simple synthetic example:<p>
|
||||
* before: <pre>
|
||||
* {@code
|
||||
* var a = b; // a is not used anywhere
|
||||
* synchronized (b){
|
||||
* doSomething();
|
||||
* }
|
||||
* }
|
||||
* </pre>
|
||||
* after:
|
||||
* <pre>
|
||||
* {@code
|
||||
* synchronized (b){
|
||||
* doSomething();
|
||||
* }
|
||||
* }
|
||||
* </pre>
|
||||
*/
|
||||
public static void cleanSynchronizedVar(Statement stat) {
|
||||
for (Statement st : stat.getStats()) {
|
||||
cleanSynchronizedVar(st);
|
||||
|
||||
@@ -12,6 +12,30 @@ import java.util.*;
|
||||
|
||||
public final class EliminateLoopsHelper {
|
||||
|
||||
/**
|
||||
* Remove loops from the given root statement. <p>
|
||||
* Simple synthetic example:<p>
|
||||
* before: <pre>
|
||||
* {@code
|
||||
* LABEL:
|
||||
* while(true){
|
||||
* while(true){
|
||||
* doSomething();
|
||||
* break LABEL;
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
* </pre>
|
||||
* after:
|
||||
* <pre>
|
||||
* {@code
|
||||
* while(true){
|
||||
* doSomething();
|
||||
* break;
|
||||
* }
|
||||
* }
|
||||
* </pre>
|
||||
*/
|
||||
public static boolean eliminateLoops(RootStatement root, StructMethod mt, StructClass cl) {
|
||||
|
||||
boolean ret = eliminateLoopsRec(root);
|
||||
|
||||
@@ -19,7 +19,29 @@ import java.util.Set;
|
||||
|
||||
public final class LoopExtractHelper {
|
||||
|
||||
|
||||
/**
|
||||
* Analyzes the provided statement structure to identify and extract loop constructs.
|
||||
* If any loops are successfully extracted, the statement sequences are condensed.<p>
|
||||
* Simple synthetic example:<p>
|
||||
* before: <pre>
|
||||
* {@code
|
||||
* while(true){
|
||||
* if (var1 >= 10){
|
||||
* break
|
||||
* }
|
||||
* doSomething();
|
||||
* }
|
||||
* }
|
||||
* </pre>
|
||||
* after:
|
||||
* <pre>
|
||||
* {@code
|
||||
* while(var1 >= 10){
|
||||
* doSomething();
|
||||
* }
|
||||
* }
|
||||
* </pre>
|
||||
*/
|
||||
public static boolean extractLoops(Statement root) {
|
||||
|
||||
boolean res = (extractLoopsRec(root) != 0);
|
||||
|
||||
@@ -17,6 +17,26 @@ import java.util.Set;
|
||||
import static org.jetbrains.java.decompiler.modules.decompiler.StatEdge.EdgeDirection;
|
||||
|
||||
public final class MergeHelper {
|
||||
/**
|
||||
* Enhances the loops in the provided statement tree.
|
||||
* Simple example:<p>
|
||||
* before: <pre>
|
||||
* {@code
|
||||
* Iterator var6 = a.iterator();
|
||||
* while(true) {
|
||||
* if (!var6.hasNext()) {
|
||||
* break;
|
||||
* }
|
||||
* A<String> s = (A)var6.next();
|
||||
* }
|
||||
* }
|
||||
* </pre>
|
||||
* after:
|
||||
* <pre>
|
||||
* {@code
|
||||
* for(A<String> s : a) {}
|
||||
* </pre>
|
||||
*/
|
||||
public static void enhanceLoops(Statement root) {
|
||||
while (enhanceLoopsRec(root)) /**/;
|
||||
SequenceHelper.condenseSequences(root);
|
||||
@@ -714,6 +734,28 @@ public final class MergeHelper {
|
||||
return inv.isUnboxingCall() && isNextCall(inv.getInstance());
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert `while` to `do-while`.
|
||||
* Simple synthetic example:<p>
|
||||
* before: <pre>
|
||||
* {@code
|
||||
* while(true){
|
||||
* doSomething();
|
||||
* if (i >= 10) {
|
||||
* break;,
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
* </pre>
|
||||
* after:
|
||||
* <pre>
|
||||
* {@code
|
||||
* do {
|
||||
* doSomething();
|
||||
* } while(i < 10);
|
||||
* }
|
||||
* </pre>
|
||||
*/
|
||||
public static boolean makeDoWhileLoops(RootStatement root) {
|
||||
if (makeDoWhileRec(root)) {
|
||||
SequenceHelper.condenseSequences(root);
|
||||
|
||||
@@ -20,6 +20,9 @@ import java.util.stream.Collectors;
|
||||
|
||||
public final class TryHelper
|
||||
{
|
||||
/**
|
||||
* Tries to convert `try` statement to `try-with-resource`
|
||||
*/
|
||||
public static boolean enhanceTryStats(RootStatement root, StructMethod mt) {
|
||||
boolean ret = makeTryWithResourceRec(root, mt, root.getDummyExit(), new ArrayList<>());
|
||||
if (ret) {
|
||||
|
||||
Reference in New Issue
Block a user