mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
refactoring: moving OriginAnalysis and CFG into asm package
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.intellij.codeInspection.bytecodeAnalysis;
|
||||
|
||||
import com.intellij.codeInspection.bytecodeAnalysis.asm.ControlFlowGraph;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.org.objectweb.asm.Opcodes;
|
||||
import org.jetbrains.org.objectweb.asm.Type;
|
||||
|
||||
+2
@@ -16,6 +16,8 @@
|
||||
package com.intellij.codeInspection.bytecodeAnalysis;
|
||||
|
||||
import com.intellij.codeInspection.bytecodeAnalysis.asm.ASMUtils;
|
||||
import com.intellij.codeInspection.bytecodeAnalysis.asm.ControlFlowGraph;
|
||||
import com.intellij.codeInspection.bytecodeAnalysis.asm.OriginsAnalysis;
|
||||
import com.intellij.openapi.progress.ProcessCanceledException;
|
||||
import com.intellij.openapi.progress.ProgressManager;
|
||||
import com.intellij.openapi.util.NotNullLazyValue;
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
package com.intellij.codeInspection.bytecodeAnalysis;
|
||||
|
||||
import com.intellij.codeInspection.bytecodeAnalysis.asm.ASMUtils;
|
||||
import com.intellij.codeInspection.bytecodeAnalysis.asm.ControlFlowGraph;
|
||||
import com.intellij.util.SingletonSet;
|
||||
import com.intellij.util.containers.HashSet;
|
||||
import org.jetbrains.org.objectweb.asm.Handle;
|
||||
|
||||
+5
-1
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.intellij.codeInspection.bytecodeAnalysis;
|
||||
|
||||
import com.intellij.codeInspection.bytecodeAnalysis.asm.ControlFlowGraph.Edge;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.org.objectweb.asm.Handle;
|
||||
import org.jetbrains.org.objectweb.asm.Type;
|
||||
@@ -24,7 +25,10 @@ import org.jetbrains.org.objectweb.asm.tree.analysis.BasicInterpreter;
|
||||
import org.jetbrains.org.objectweb.asm.tree.analysis.BasicValue;
|
||||
import org.jetbrains.org.objectweb.asm.tree.analysis.Frame;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import static com.intellij.codeInspection.bytecodeAnalysis.AbstractValues.*;
|
||||
import static org.jetbrains.org.objectweb.asm.Opcodes.*;
|
||||
|
||||
+7
-57
@@ -16,6 +16,8 @@
|
||||
package com.intellij.codeInspection.bytecodeAnalysis;
|
||||
|
||||
import com.intellij.codeInspection.bytecodeAnalysis.asm.ASMUtils;
|
||||
import com.intellij.codeInspection.bytecodeAnalysis.asm.ControlFlowGraph;
|
||||
import com.intellij.codeInspection.bytecodeAnalysis.asm.ControlFlowGraph.Edge;
|
||||
import com.intellij.codeInspection.bytecodeAnalysis.asm.FramelessAnalyzer;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import gnu.trove.TIntArrayList;
|
||||
@@ -27,7 +29,10 @@ import org.jetbrains.org.objectweb.asm.tree.*;
|
||||
import org.jetbrains.org.objectweb.asm.tree.analysis.*;
|
||||
import org.jetbrains.org.objectweb.asm.tree.analysis.Value;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.jetbrains.org.objectweb.asm.Opcodes.*;
|
||||
|
||||
@@ -223,61 +228,6 @@ final class cfg {
|
||||
|
||||
}
|
||||
|
||||
final class Edge {
|
||||
final int from, to;
|
||||
|
||||
Edge(int from, int to) {
|
||||
this.from = from;
|
||||
this.to = to;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (!(o instanceof Edge)) {
|
||||
return false;
|
||||
}
|
||||
Edge edge = (Edge) o;
|
||||
return from == edge.from && to == edge.to;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return 31 * from + to;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "(" + from + "," + to + ")";
|
||||
}
|
||||
}
|
||||
|
||||
final class ControlFlowGraph {
|
||||
final String className;
|
||||
final MethodNode methodNode;
|
||||
final int[][] transitions;
|
||||
final int edgeCount;
|
||||
final boolean[] errors;
|
||||
final Set<Edge> errorTransitions;
|
||||
|
||||
ControlFlowGraph(String className, MethodNode methodNode, int[][] transitions, int edgeCount, boolean[] errors, Set<Edge> errorTransitions) {
|
||||
this.className = className;
|
||||
this.methodNode = methodNode;
|
||||
this.transitions = transitions;
|
||||
this.edgeCount = edgeCount;
|
||||
this.errors = errors;
|
||||
this.errorTransitions = errorTransitions;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CFG(" +
|
||||
Arrays.toString(transitions) + "," +
|
||||
errorTransitions +
|
||||
')';
|
||||
}
|
||||
}
|
||||
|
||||
final class RichControlFlow {
|
||||
final ControlFlowGraph controlFlow;
|
||||
final DFSTree dfsTree;
|
||||
@@ -292,7 +242,7 @@ final class ControlFlowBuilder extends FramelessAnalyzer {
|
||||
final String className;
|
||||
final MethodNode methodNode;
|
||||
final TIntArrayList[] transitions;
|
||||
final Set<Edge> errorTransitions;
|
||||
final Set<ControlFlowGraph.Edge> errorTransitions;
|
||||
private final boolean[] errors;
|
||||
private int edgeCount;
|
||||
|
||||
|
||||
+4
-1
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.intellij.codeInspection.bytecodeAnalysis;
|
||||
|
||||
import com.intellij.codeInspection.bytecodeAnalysis.asm.ControlFlowGraph.Edge;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.org.objectweb.asm.Type;
|
||||
import org.jetbrains.org.objectweb.asm.tree.AbstractInsnNode;
|
||||
@@ -26,7 +27,9 @@ import org.jetbrains.org.objectweb.asm.tree.analysis.BasicInterpreter;
|
||||
import org.jetbrains.org.objectweb.asm.tree.analysis.BasicValue;
|
||||
import org.jetbrains.org.objectweb.asm.tree.analysis.Frame;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import static com.intellij.codeInspection.bytecodeAnalysis.AbstractValues.InstanceOfCheckValue;
|
||||
import static com.intellij.codeInspection.bytecodeAnalysis.AbstractValues.ParamValue;
|
||||
|
||||
+65
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.codeInspection.bytecodeAnalysis.asm;
|
||||
|
||||
import org.jetbrains.org.objectweb.asm.tree.MethodNode;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author lambdamix
|
||||
*/
|
||||
public final class ControlFlowGraph {
|
||||
public static final class Edge {
|
||||
public final int from, to;
|
||||
|
||||
public Edge(int from, int to) {
|
||||
this.from = from;
|
||||
this.to = to;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (!(o instanceof Edge)) {
|
||||
return false;
|
||||
}
|
||||
Edge edge = (Edge) o;
|
||||
return from == edge.from && to == edge.to;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return 31 * from + to;
|
||||
}
|
||||
}
|
||||
|
||||
public final String className;
|
||||
public final MethodNode methodNode;
|
||||
public final int[][] transitions;
|
||||
public final int edgeCount;
|
||||
public final boolean[] errors;
|
||||
public final Set<Edge> errorTransitions;
|
||||
|
||||
public ControlFlowGraph(String className, MethodNode methodNode, int[][] transitions, int edgeCount, boolean[] errors, Set<Edge> errorTransitions) {
|
||||
this.className = className;
|
||||
this.methodNode = methodNode;
|
||||
this.transitions = transitions;
|
||||
this.edgeCount = edgeCount;
|
||||
this.errors = errors;
|
||||
this.errorTransitions = errorTransitions;
|
||||
}
|
||||
}
|
||||
+1
-2
@@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.codeInspection.bytecodeAnalysis;
|
||||
package com.intellij.codeInspection.bytecodeAnalysis.asm;
|
||||
|
||||
import gnu.trove.TIntArrayList;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -21,7 +21,6 @@ import org.jetbrains.org.objectweb.asm.Opcodes;
|
||||
import org.jetbrains.org.objectweb.asm.tree.AbstractInsnNode;
|
||||
import org.jetbrains.org.objectweb.asm.tree.InsnList;
|
||||
import org.jetbrains.org.objectweb.asm.tree.analysis.*;
|
||||
import org.jetbrains.org.objectweb.asm.tree.analysis.Value;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedList;
|
||||
Reference in New Issue
Block a user