diff --git a/recaf-core/src/main/java/software/coley/recaf/services/deobfuscation/builtin/StaticValueCollectionTransformer.java b/recaf-core/src/main/java/software/coley/recaf/services/deobfuscation/builtin/StaticValueCollectionTransformer.java index 0a45c8e4c..7cdba862d 100644 --- a/recaf-core/src/main/java/software/coley/recaf/services/deobfuscation/builtin/StaticValueCollectionTransformer.java +++ b/recaf-core/src/main/java/software/coley/recaf/services/deobfuscation/builtin/StaticValueCollectionTransformer.java @@ -71,7 +71,7 @@ public void transform(@Nonnull JvmTransformerContext context, @Nonnull Workspace @Nonnull WorkspaceResource resource, @Nonnull JvmClassBundle bundle, @Nonnull JvmClassInfo classInfo) throws TransformationException { // TODO: Instead of a map, we should make a workspace setup call first - InheritanceGraph graph = graphCache.computeIfAbsent(workspace, w -> w == workspaceManager.getCurrent() ? + InheritanceGraph inheritanceGraph = graphCache.computeIfAbsent(workspace, w -> w == workspaceManager.getCurrent() ? graphService.getCurrentWorkspaceInheritanceGraph() : graphService.newInheritanceGraph(workspace)); @@ -140,7 +140,7 @@ else if (field.hasPrivateModifier()) // Only analyze if we see static setters if (clinit != null && hasStaticSetters(clinit)) { - ReInterpreter interpreter = new ReInterpreter(graph); + ReInterpreter interpreter = new ReInterpreter(inheritanceGraph); ReAnalyzer analyzer = new ReAnalyzer(interpreter); try { Frame[] frames = analyzer.analyze(className, clinit); diff --git a/recaf-core/src/main/java/software/coley/recaf/services/transform/TransformationApplierService.java b/recaf-core/src/main/java/software/coley/recaf/services/transform/TransformationApplierService.java index 0144e8b14..5c9921bce 100644 --- a/recaf-core/src/main/java/software/coley/recaf/services/transform/TransformationApplierService.java +++ b/recaf-core/src/main/java/software/coley/recaf/services/transform/TransformationApplierService.java @@ -54,8 +54,8 @@ public TransformationApplier newApplier(@Nonnull Workspace workspace) { return newApplier(workspace, Objects.requireNonNull(graphService.getCurrentWorkspaceInheritanceGraph(), "Graph not created")); // Need to make a new graph for the given workspace - InheritanceGraph graph = graphService.newInheritanceGraph(workspace); - return newApplier(workspace, graph); + InheritanceGraph inheritanceGraph = graphService.newInheritanceGraph(workspace); + return newApplier(workspace, inheritanceGraph); } /** @@ -67,8 +67,8 @@ public TransformationApplier newApplierForCurrentWorkspace() { Workspace workspace = workspaceManager.getCurrent(); if (workspace == null) return null; - InheritanceGraph graph = Objects.requireNonNull(graphService.getCurrentWorkspaceInheritanceGraph(), "Graph not created"); - return newApplier(workspace, graph); + InheritanceGraph inheritanceGraph = Objects.requireNonNull(graphService.getCurrentWorkspaceInheritanceGraph(), "Graph not created"); + return newApplier(workspace, inheritanceGraph); } /** diff --git a/recaf-core/src/main/java/software/coley/recaf/services/workspace/processors/ThrowablePropertyAssigningProcessor.java b/recaf-core/src/main/java/software/coley/recaf/services/workspace/processors/ThrowablePropertyAssigningProcessor.java index 5813cc4a9..ed7cf3391 100644 --- a/recaf-core/src/main/java/software/coley/recaf/services/workspace/processors/ThrowablePropertyAssigningProcessor.java +++ b/recaf-core/src/main/java/software/coley/recaf/services/workspace/processors/ThrowablePropertyAssigningProcessor.java @@ -31,16 +31,16 @@ @Dependent public class ThrowablePropertyAssigningProcessor implements WorkspaceProcessor, ResourceJvmClassListener, ResourceAndroidClassListener { private static final String THROWABLE = "java/lang/Throwable"; - private final InheritanceGraph graph; + private final InheritanceGraph inheritanceGraph; @Inject public ThrowablePropertyAssigningProcessor(@Nonnull InheritanceGraphService graphService) { - this.graph = Objects.requireNonNull(graphService.getCurrentWorkspaceInheritanceGraph(), "Graph not created"); + this.inheritanceGraph = Objects.requireNonNull(graphService.getCurrentWorkspaceInheritanceGraph(), "Graph not created"); } @Override public void onWorkspaceOpened(@Nonnull Workspace workspace) { - graph.getVertex(THROWABLE).allChildren().forEach(vertex -> { + inheritanceGraph.getVertex(THROWABLE).allChildren().forEach(vertex -> { ClassInfo classInfo = vertex.getValue(); ThrowableProperty.set(classInfo); }); @@ -70,7 +70,7 @@ public String name() { } private void handle(@Nonnull ClassInfo cls) { - InheritanceVertex vertex = graph.getVertex(cls.getName()); + InheritanceVertex vertex = inheritanceGraph.getVertex(cls.getName()); if (vertex != null && vertex.hasParent(THROWABLE)) ThrowableProperty.set(cls); } diff --git a/recaf-core/src/main/java/software/coley/recaf/util/analysis/ReInterpreter.java b/recaf-core/src/main/java/software/coley/recaf/util/analysis/ReInterpreter.java index 83bb82737..1b3be36d6 100644 --- a/recaf-core/src/main/java/software/coley/recaf/util/analysis/ReInterpreter.java +++ b/recaf-core/src/main/java/software/coley/recaf/util/analysis/ReInterpreter.java @@ -48,15 +48,15 @@ */ public class ReInterpreter extends Interpreter implements Opcodes { private static final Logger logger = Logging.get(ReInterpreter.class); - private final InheritanceGraph graph; + private final InheritanceGraph inheritanceGraph; private GetStaticLookup getStaticLookup; private GetFieldLookup getFieldLookup; private InvokeStaticLookup invokeStaticLookup; private InvokeVirtualLookup invokeVirtualLookup; - public ReInterpreter(@Nonnull InheritanceGraph graph) { + public ReInterpreter(@Nonnull InheritanceGraph inheritanceGraph) { super(RecafConstants.getAsmVersion()); - this.graph = graph; + this.inheritanceGraph = inheritanceGraph; } public void setGetStaticLookup(@Nullable GetStaticLookup getStaticLookup) { @@ -627,7 +627,7 @@ public ReValue merge(@Nonnull ReValue value1, @Nonnull ReValue value2) { @Nonnull private Type getSuperClass(@Nonnull Type type) { String name = type.getInternalName(); - InheritanceVertex vertex = graph.getVertex(name); + InheritanceVertex vertex = inheritanceGraph.getVertex(name); if (vertex == null) return Types.OBJECT_TYPE; String superName = vertex.getValue().getSuperName(); @@ -636,7 +636,7 @@ private Type getSuperClass(@Nonnull Type type) { private boolean isInterface(@Nonnull Type type) { String name = type.getInternalName(); - InheritanceVertex vertex = graph.getVertex(name); + InheritanceVertex vertex = inheritanceGraph.getVertex(name); if (vertex == null) return false; return vertex.getValue().hasInterfaceModifier(); @@ -645,6 +645,6 @@ private boolean isInterface(@Nonnull Type type) { private boolean isAssignableFrom(@Nonnull Type type1, @Nonnull Type type2) { String name1 = type1.getInternalName(); String name2 = type2.getInternalName(); - return graph.isAssignableFrom(name1, name2); + return inheritanceGraph.isAssignableFrom(name1, name2); } } diff --git a/recaf-core/src/main/java/software/coley/recaf/util/visitors/WorkspaceClassWriter.java b/recaf-core/src/main/java/software/coley/recaf/util/visitors/WorkspaceClassWriter.java index d68e902f9..7dcdf9972 100644 --- a/recaf-core/src/main/java/software/coley/recaf/util/visitors/WorkspaceClassWriter.java +++ b/recaf-core/src/main/java/software/coley/recaf/util/visitors/WorkspaceClassWriter.java @@ -12,29 +12,29 @@ * @author Matt Coley */ public class WorkspaceClassWriter extends ClassWriter { - private final InheritanceGraph graph; + private final InheritanceGraph inheritanceGraph; /** - * @param graph - * Graph to pull inheritance relations from. + * @param inheritanceGraph + * Inheritance graph to pull inheritance relations from. * @param flags * Writer flags. */ - public WorkspaceClassWriter(@Nonnull InheritanceGraph graph, int flags) { - this(graph, null, flags); + public WorkspaceClassWriter(@Nonnull InheritanceGraph inheritanceGraph, int flags) { + this(inheritanceGraph, null, flags); } /** - * @param graph - * Graph to pull inheritance relations from. + * @param inheritanceGraph + * Inheritance graph to pull inheritance relations from. * @param reader * Reader to pre-populate the constant pool with. Speeds up writing process a bit. * @param flags * Writer flags. */ - public WorkspaceClassWriter(@Nonnull InheritanceGraph graph, @Nullable ClassReader reader, int flags) { + public WorkspaceClassWriter(@Nonnull InheritanceGraph inheritanceGraph, @Nullable ClassReader reader, int flags) { super(reader, flags); - this.graph = graph; + this.inheritanceGraph = inheritanceGraph; } @Override @@ -44,6 +44,6 @@ protected String getCommonSuperClass(String type1, String type2) { return "java/lang/Object"; // Find common parent in workspace - return graph.getCommon(type1, type2); + return inheritanceGraph.getCommon(type1, type2); } } diff --git a/recaf-core/src/test/java/software/coley/recaf/services/callgraph/CallGraphTest.java b/recaf-core/src/test/java/software/coley/recaf/services/callgraph/CallGraphTest.java index 56cb4b6f8..5b92c9804 100644 --- a/recaf-core/src/test/java/software/coley/recaf/services/callgraph/CallGraphTest.java +++ b/recaf-core/src/test/java/software/coley/recaf/services/callgraph/CallGraphTest.java @@ -41,10 +41,10 @@ void testCalleeCallerRelation() throws IOException { JvmClassInfo mainClass = pathUser.getValue().asJvmClass(); JvmClassInfo functionClass = pathFunc.getValue().asJvmClass(); - CallGraph graph = graph(workspace); + CallGraph callGraph = newCallGraph(workspace); - ClassMethodsContainer containerMain = graph.getClassMethodsContainer(mainClass); - ClassMethodsContainer containerFunction = graph.getClassMethodsContainer(functionClass); + ClassMethodsContainer containerMain = callGraph.getClassMethodsContainer(mainClass); + ClassMethodsContainer containerFunction = callGraph.getClassMethodsContainer(functionClass); // Get outbound calls for main. Should just be to 'new StringConsumer()' and 'StringConsumer.accept(String)' MethodVertex mainVertex = containerMain.getVertex("main", "([Ljava/lang/String;)V"); @@ -73,40 +73,40 @@ void testUnresolvedCall() { assertNotNull(pathUser, "Missing FooCaller class"); JvmClassInfo mainClass = pathUser.getValue().asJvmClass(); - CallGraph graph = graph(workspace); + CallGraph callGraph = newCallGraph(workspace); // Get outbound calls for call(Foo). Should just be to 'foo.bar()' which is unresolved - ClassMethodsContainer fooCaller = graph.getClassMethodsContainer(mainClass); + ClassMethodsContainer fooCaller = callGraph.getClassMethodsContainer(mainClass); MethodVertex callVertex = fooCaller.getVertex("call", "(LFoo;)V"); assertNotNull(callVertex, "Missing method vertex for 'call'"); assertEquals(0, callVertex.getCalls().size()); - assertEquals(1, graph.getUnresolvedDeclarations().get("Foo").size(), "Expected to have unresolved call to Foo.bar()"); + assertEquals(1, callGraph.getUnresolvedDeclarations().get("Foo").size(), "Expected to have unresolved call to Foo.bar()"); // Add the missing Foo class to the workspace workspace.getPrimaryResource().getJvmClassBundle().put(new JvmClassInfoBuilder(fooBytes).build()); // The call to Foo.bar() should be resolved now assertEquals(1, callVertex.getCalls().size()); - assertEquals(0, graph.getUnresolvedDeclarations().size(), "Expected to have resolved unresolved call to Foo.bar()"); + assertEquals(0, callGraph.getUnresolvedDeclarations().size(), "Expected to have resolved unresolved call to Foo.bar()"); // TODO: Make a similar test case, but in reverse. // We probably want to prune the call-graph model when things get removed. } @Nonnull - static CallGraph graph(@Nonnull Workspace workspace) { - CallGraph graph = new CallGraph(workspace); - graph.initialize(); + static CallGraph newCallGraph(@Nonnull Workspace workspace) { + CallGraph callGraph = new CallGraph(workspace); + callGraph.initialize(); // Need to wait until async population of graph contents is done. - ObservableBoolean ready = graph.isReady(); + ObservableBoolean ready = callGraph.isReady(); assertDoesNotThrow(() -> { while (!ready.getValue()) { Thread.sleep(100); } }); - return graph; + return callGraph; } static { diff --git a/recaf-core/src/test/java/software/coley/recaf/services/inheritance/InheritanceAndRenamingTest.java b/recaf-core/src/test/java/software/coley/recaf/services/inheritance/InheritanceAndRenamingTest.java index 6def1c867..255a2eaf7 100644 --- a/recaf-core/src/test/java/software/coley/recaf/services/inheritance/InheritanceAndRenamingTest.java +++ b/recaf-core/src/test/java/software/coley/recaf/services/inheritance/InheritanceAndRenamingTest.java @@ -25,7 +25,7 @@ */ class InheritanceAndRenamingTest extends TestBase { static Workspace workspace; - static InheritanceGraph graph; + static InheritanceGraph inheritanceGraph; static MappingApplier mappingApplier; static JvmClassInfo[] generatedClasses; @@ -44,8 +44,8 @@ static void setup() { workspaceManager.setCurrent(workspace); // Get graph - graph = recaf.get(InheritanceGraphService.class).getCurrentWorkspaceInheritanceGraph(); - graph.toString(); // Force immediate init. + inheritanceGraph = recaf.get(InheritanceGraphService.class).getCurrentWorkspaceInheritanceGraph(); + inheritanceGraph.toString(); // Force immediate init. // Get mapping applier mappingApplier = recaf.get(MappingApplier.class); @@ -56,7 +56,7 @@ void test() { // Verify initial state for (int i = 1; i <= 5; i++) { String name = "I" + i; - InheritanceVertex vertex = graph.getVertex(name); + InheritanceVertex vertex = inheritanceGraph.getVertex(name); assertNotNull(vertex, "Graph missing '" + name + "'"); } @@ -70,15 +70,15 @@ void test() { // Very old classes are removed from the graph for (int i = 1; i <= 5; i++) { String name = "I" + i; - InheritanceVertex vertex = graph.getVertex(name); + InheritanceVertex vertex = inheritanceGraph.getVertex(name); assertNull(vertex, "Graph contains pre-mapped '" + name + "'"); } // Verify the new classes are added to the graph - InheritanceVertex objectVertex = graph.getVertex("java/lang/Object"); + InheritanceVertex objectVertex = inheritanceGraph.getVertex("java/lang/Object"); for (int i = 1; i <= 5; i++) { String name = "R" + i; - InheritanceVertex vertex = graph.getVertex(name); + InheritanceVertex vertex = inheritanceGraph.getVertex(name); assertNotNull(vertex, "Graph missing post-mapped '" + name + "'"); if (i > 1) { Set parents = vertex.getParents(); diff --git a/recaf-core/src/test/java/software/coley/recaf/services/inheritance/InheritanceGraphTest.java b/recaf-core/src/test/java/software/coley/recaf/services/inheritance/InheritanceGraphTest.java index 27ad3d4e5..73e0d7b0c 100644 --- a/recaf-core/src/test/java/software/coley/recaf/services/inheritance/InheritanceGraphTest.java +++ b/recaf-core/src/test/java/software/coley/recaf/services/inheritance/InheritanceGraphTest.java @@ -26,7 +26,7 @@ */ class InheritanceGraphTest extends TestBase { static Workspace workspace; - static InheritanceGraph graph; + static InheritanceGraph inheritanceGraph; @BeforeAll static void setup() throws IOException { @@ -38,7 +38,7 @@ static void setup() throws IOException { workspaceManager.setCurrent(workspace); // Get graph - graph = recaf.get(InheritanceGraphService.class).getCurrentWorkspaceInheritanceGraph(); + inheritanceGraph = recaf.get(InheritanceGraphService.class).getCurrentWorkspaceInheritanceGraph(); } @Test @@ -46,7 +46,7 @@ void getVertex() { String appleName = Inheritance.Apple.class.getName().replace('.', '/'); // Check vertex - InheritanceVertex vertex = graph.getVertex(appleName); + InheritanceVertex vertex = inheritanceGraph.getVertex(appleName); assertNotNull(vertex, "Could not get Apple vertex from workspace"); assertEquals(appleName, vertex.getName(), "Vertex should have same name as lookup"); @@ -70,7 +70,7 @@ void getVertex() { "Apple missing parent: Edible"); // Check awareness of library methods - vertex = graph.getVertex(StringConsumer.class.getName().replace('.', '/')); + vertex = inheritanceGraph.getVertex(StringConsumer.class.getName().replace('.', '/')); assertTrue(vertex.hasMethod("accept", "(Ljava/lang/Object;)V")); assertTrue(vertex.hasMethod("accept", "(Ljava/lang/String;)V")); // Redirects to Object method assertTrue(vertex.isLibraryMethod("accept", "(Ljava/lang/Object;)V")); // From Consumer @@ -86,7 +86,7 @@ void getVertexFamily() { appleName.replace("Apple", "Edible"), // parent of apple appleName.replace("Apple", "Grape") // shared parent edible ); - Set family = graph.getVertexFamily(appleName, false); + Set family = inheritanceGraph.getVertexFamily(appleName, false); assertEquals(5, family.size()); assertEquals(names, family.stream().map(InheritanceVertex::getName).collect(Collectors.toSet())); } @@ -98,11 +98,11 @@ void getCommon() { String grapeName = Inheritance.Grape.class.getName().replace('.', '/'); // Compare obvious case --> edible - String commonType = graph.getCommon(appleName, grapeName); + String commonType = inheritanceGraph.getCommon(appleName, grapeName); assertEquals(edibleName, commonType, "Common type of Apple/Grape should be Edible"); // Compare with bogus --> object - commonType = graph.getCommon(appleName, UUID.randomUUID().toString()); + commonType = inheritanceGraph.getCommon(appleName, UUID.randomUUID().toString()); assertEquals(Types.OBJECT_TYPE.getInternalName(), commonType, "Common type of two unrelated classes should be Object"); } @@ -114,12 +114,12 @@ void isAssignableFrom() { String grapeName = Inheritance.Grape.class.getName().replace('.', '/'); // Edible.class.isAssignableFrom(Apple.class) --> true - assertTrue(graph.isAssignableFrom(edibleName, appleName), "Edible should be assignable from Apple"); - assertTrue(graph.isAssignableFrom(edibleName, grapeName), "Edible should be assignable from Grape"); + assertTrue(inheritanceGraph.isAssignableFrom(edibleName, appleName), "Edible should be assignable from Apple"); + assertTrue(inheritanceGraph.isAssignableFrom(edibleName, grapeName), "Edible should be assignable from Grape"); // Apple.class.isAssignableFrom(Edible.class) --> false - assertFalse(graph.isAssignableFrom(appleName, edibleName), "Apple should not be assignable from Edible"); - assertFalse(graph.isAssignableFrom(grapeName, edibleName), "Grape should not be assignable from Edible"); + assertFalse(inheritanceGraph.isAssignableFrom(appleName, edibleName), "Apple should not be assignable from Edible"); + assertFalse(inheritanceGraph.isAssignableFrom(grapeName, edibleName), "Grape should not be assignable from Edible"); } @Test @@ -131,11 +131,11 @@ void getFamilyOfThrowable() { // Assert that looking at child types of throwable finds NotFoodException. // Our class extends Exception, which extends Throwable. So there should be a vertex between Throwable and our type. JvmClassInfo notFoodException = classPath.getValue().asJvmClass(); - List exceptionClasses = graph.getVertex("java/lang/Exception").getAllChildren().stream() + List exceptionClasses = inheritanceGraph.getVertex("java/lang/Exception").getAllChildren().stream() .map(InheritanceVertex::getValue) .toList(); assertTrue(exceptionClasses.contains(notFoodException), "Subtypes of 'Exception' did not yield 'NotFoodException'"); - List throwableClasses = graph.getVertex("java/lang/Throwable").getAllChildren().stream() + List throwableClasses = inheritanceGraph.getVertex("java/lang/Throwable").getAllChildren().stream() .map(InheritanceVertex::getValue) .toList(); assertTrue(throwableClasses.contains(notFoodException), "Subtypes of 'Throwable' did not yield 'NotFoodException'"); diff --git a/recaf-core/src/test/java/software/coley/recaf/services/transform/TransformationApplierTest.java b/recaf-core/src/test/java/software/coley/recaf/services/transform/TransformationApplierTest.java index 99307ada0..e9856c4bc 100644 --- a/recaf-core/src/test/java/software/coley/recaf/services/transform/TransformationApplierTest.java +++ b/recaf-core/src/test/java/software/coley/recaf/services/transform/TransformationApplierTest.java @@ -28,14 +28,14 @@ */ class TransformationApplierTest extends TestBase { private static final TransformationApplierConfig config = new TransformationApplierConfig(); - private static final InheritanceGraph graph; + private static final InheritanceGraph inheritanceGraph; private static final Workspace workspace; static { // Make a dummy workspace. We just need a single class (and any class will work) try { workspace = TestClassUtils.fromBundle(TestClassUtils.fromClasses(HelloWorld.class)); - graph = recaf.get(InheritanceGraphService.class).newInheritanceGraph(workspace); + inheritanceGraph = recaf.get(InheritanceGraphService.class).newInheritanceGraph(workspace); } catch (IOException e) { throw new RuntimeException("Failed to read input class for transformer test", e); } @@ -55,7 +55,7 @@ void independentAB() { // If we transform with "B" we should observe that only "B" is called on sine the two hold no relation TransformationManager manager = new TransformationManager(map); - TransformationApplier applier = new TransformationApplier(manager, graph, workspace); + TransformationApplier applier = new TransformationApplier(manager, inheritanceGraph, workspace); assertDoesNotThrow(() -> applier.transformJvm(Collections.singletonList(JvmTransformerB.class))); // "A" not used @@ -79,7 +79,7 @@ void dependentAB() { // If we transform with "B" we should observe that both "B" and "A" were called on. TransformationManager manager = new TransformationManager(map); - TransformationApplier applier = new TransformationApplier(manager, graph, workspace); + TransformationApplier applier = new TransformationApplier(manager, inheritanceGraph, workspace); assertDoesNotThrow(() -> applier.transformJvm(Collections.singletonList(JvmTransformerDependingOnA.class))); verify(transformerA, times(1)).transform(any(), same(workspace), any(), any(), any()); verify(transformerB, times(1)).transform(any(), same(workspace), any(), any(), any()); @@ -99,7 +99,7 @@ void cycleAB() { // If we transform with "A" or "B" we should observe an exception due to the detected cycle TransformationManager manager = new TransformationManager(map); - TransformationApplier applier = new TransformationApplier(manager, graph, workspace); + TransformationApplier applier = new TransformationApplier(manager, inheritanceGraph, workspace); assertThrows(TransformationException.class, () -> applier.transformJvm(Collections.singletonList(JvmCycleA.class))); assertThrows(TransformationException.class, () -> applier.transformJvm(Collections.singletonList(JvmCycleB.class))); verify(transformerA, never()).transform(any(), same(workspace), any(), any(), any()); @@ -117,7 +117,7 @@ void cycleSingle() { // If we transform with the single transformer we should observe an exception due to the detected cycle TransformationManager manager = new TransformationManager(map); - TransformationApplier applier = new TransformationApplier(manager, graph, workspace); + TransformationApplier applier = new TransformationApplier(manager, inheritanceGraph, workspace); assertThrows(TransformationException.class, () -> applier.transformJvm(Collections.singletonList(JvmCycleSingle.class))); verify(transformer, never()).transform(any(), same(workspace), any(), any(), any()); } @@ -126,7 +126,7 @@ void cycleSingle() { void missingRegistration() { // If we transform with a transformer that is not registered in the manager, the transform should fail TransformationManager manager = new TransformationManager(Collections.emptyMap()); - TransformationApplier applier = new TransformationApplier(manager, graph, workspace); + TransformationApplier applier = new TransformationApplier(manager, inheritanceGraph, workspace); assertThrows(TransformationException.class, () -> applier.transformJvm(Collections.singletonList(JvmCycleSingle.class))); } diff --git a/recaf-ui/src/main/java/software/coley/recaf/services/navigation/Actions.java b/recaf-ui/src/main/java/software/coley/recaf/services/navigation/Actions.java index 4689aa242..9eebf5365 100644 --- a/recaf-ui/src/main/java/software/coley/recaf/services/navigation/Actions.java +++ b/recaf-ui/src/main/java/software/coley/recaf/services/navigation/Actions.java @@ -130,7 +130,7 @@ public class Actions implements Service { private final IconProviderService iconService; private final CellConfigurationService cellConfigurationService; private final PathExportingManager pathExportingManager; - private final Instance graphProvider; + private final Instance inheritanceGraphProvider; private final Instance applierProvider; private final Instance jvmPaneProvider; private final Instance androidPaneProvider; @@ -158,7 +158,7 @@ public Actions(@Nonnull ActionsConfig config, @Nonnull IconProviderService iconService, @Nonnull CellConfigurationService cellConfigurationService, @Nonnull PathExportingManager pathExportingManager, - @Nonnull Instance graphProvider, + @Nonnull Instance inheritanceGraphProvider, @Nonnull Instance applierProvider, @Nonnull Instance jvmPaneProvider, @Nonnull Instance androidPaneProvider, @@ -183,7 +183,7 @@ public Actions(@Nonnull ActionsConfig config, this.iconService = iconService; this.cellConfigurationService = cellConfigurationService; this.pathExportingManager = pathExportingManager; - this.graphProvider = graphProvider; + this.inheritanceGraphProvider = inheritanceGraphProvider; this.applierProvider = applierProvider; this.jvmPaneProvider = jvmPaneProvider; this.androidPaneProvider = androidPaneProvider; @@ -2110,10 +2110,10 @@ public void overrideClassMethod(@Nonnull Workspace workspace, @Nonnull WorkspaceResource resource, @Nonnull JvmClassBundle bundle, @Nonnull JvmClassInfo info) { - InheritanceGraph graph = graphProvider.get(); - if (graph == null) + InheritanceGraph inheritanceGraph = inheritanceGraphProvider.get(); + if (inheritanceGraph == null) return; - new OverrideMethodPopup(this, cellConfigurationService, graph, workspace, info, (methodOwner, method) -> { + new OverrideMethodPopup(this, cellConfigurationService, inheritanceGraph, workspace, info, (methodOwner, method) -> { ClassWriter writer = new ClassWriter(0); info.getClassReader().accept(new MemberStubAddingVisitor(writer, method), 0); JvmClassInfo updatedInfo = info.toJvmClassBuilder() diff --git a/recaf-ui/src/main/java/software/coley/recaf/ui/control/popup/OverrideMethodPopup.java b/recaf-ui/src/main/java/software/coley/recaf/ui/control/popup/OverrideMethodPopup.java index a8c4996e8..4d6915601 100644 --- a/recaf-ui/src/main/java/software/coley/recaf/ui/control/popup/OverrideMethodPopup.java +++ b/recaf-ui/src/main/java/software/coley/recaf/ui/control/popup/OverrideMethodPopup.java @@ -42,7 +42,7 @@ public class OverrideMethodPopup extends RecafStage { private final PathNodeTree tree; public OverrideMethodPopup(@Nonnull Actions actions, @Nonnull CellConfigurationService configurationService, - @Nonnull InheritanceGraph graph, @Nonnull Workspace workspace, + @Nonnull InheritanceGraph inheritanceGraph, @Nonnull Workspace workspace, @Nonnull ClassInfo targetClass, @Nonnull BiConsumer memberConsumer) { WorkspacePathNode rootPath = PathNodes.workspacePath(workspace); TreeItem> rootItem = new TreeItem<>(rootPath); @@ -52,7 +52,7 @@ public OverrideMethodPopup(@Nonnull Actions actions, @Nonnull CellConfigurationS tree.getStyleClass().add("border-muted"); // Setup tree contents - InheritanceVertex vertex = graph.getVertex(targetClass.getName()); + InheritanceVertex vertex = inheritanceGraph.getVertex(targetClass.getName()); if (vertex != null) { vertex.allParents().forEach(parent -> { ClassPathNode parentPath = workspace.findClass(parent.getName()); diff --git a/recaf-ui/src/main/java/software/coley/recaf/ui/control/richtext/suggest/AssemblerTabCompleter.java b/recaf-ui/src/main/java/software/coley/recaf/ui/control/richtext/suggest/AssemblerTabCompleter.java index e19d34cf0..4572270cc 100644 --- a/recaf-ui/src/main/java/software/coley/recaf/ui/control/richtext/suggest/AssemblerTabCompleter.java +++ b/recaf-ui/src/main/java/software/coley/recaf/ui/control/richtext/suggest/AssemblerTabCompleter.java @@ -35,7 +35,7 @@ public class AssemblerTabCompleter implements TabCompleter { private final CompletionPopup completionPopup = new StringCompletionPopup(15); private final Workspace workspace; - private final InheritanceGraph graph; + private final InheritanceGraph inheritanceGraph; private CodeArea area; private List ast; private Context context; @@ -43,12 +43,12 @@ public class AssemblerTabCompleter implements TabCompleter { /** * @param workspace * Workspace to pull class info from. - * @param graph + * @param inheritanceGraph * Graph to pull hierarchies from. */ - public AssemblerTabCompleter(@Nonnull Workspace workspace, @Nonnull InheritanceGraph graph) { + public AssemblerTabCompleter(@Nonnull Workspace workspace, @Nonnull InheritanceGraph inheritanceGraph) { this.workspace = workspace; - this.graph = graph; + this.inheritanceGraph = inheritanceGraph; } /** @@ -286,7 +286,7 @@ public CodeFieldContext(@Nonnull String partialInput, @Nullable String owner, @N @Override public List complete() { boolean isStatic = partialInput.contains("getstatic ") || partialInput.contains("putstatic "); - return complete(workspace, graph, c -> c.fieldStream().filter(m -> isStatic == m.hasStaticModifier())); + return complete(workspace, inheritanceGraph, c -> c.fieldStream().filter(m -> isStatic == m.hasStaticModifier())); } } @@ -315,7 +315,7 @@ class CodeMethodContext extends ReferenceContext { public List complete() { boolean isStatic = partialInput.contains("invokestatic ") || partialInput.contains("invokestaticinterface "); boolean isSpecial = partialInput.contains("invokespecial "); - return complete(workspace, graph, c -> c.methodStream().filter(m -> { + return complete(workspace, inheritanceGraph, c -> c.methodStream().filter(m -> { // Only invokespecial can be used to call constructors. if (m.getName().startsWith("<") && !isSpecial) return false; @@ -360,7 +360,7 @@ public final String partialMatchedText() { public abstract List complete(); @Nonnull - protected List complete(@Nonnull Workspace workspace, @Nonnull InheritanceGraph graph, + protected List complete(@Nonnull Workspace workspace, @Nonnull InheritanceGraph inheritanceGraph, @Nonnull Function> classMemberLookup) { // Skip if no owner type specified. if (owner == null) return Collections.emptyList(); @@ -376,7 +376,7 @@ protected List complete(@Nonnull Workspace workspace, @Nonnull Inheritan ClassPathNode ownerPath = workspace.findClass(owner); if (ownerPath != null) { Set items = new TreeSet<>(); - InheritanceVertex vertex = graph.getVertex(owner); + InheritanceVertex vertex = inheritanceGraph.getVertex(owner); if (vertex != null) for (InheritanceVertex parent : vertex.getAllParents()) items.addAll(collect(classMemberLookup.apply(parent.getValue()))); @@ -398,7 +398,7 @@ protected List complete(@Nonnull Workspace workspace, @Nonnull Inheritan ClassPathNode ownerPath = workspace.findClass(owner); if (ownerPath != null) { Set items = new TreeSet<>(); - InheritanceVertex vertex = graph.getVertex(owner); + InheritanceVertex vertex = inheritanceGraph.getVertex(owner); Predicate filter = member -> member.getName().startsWith(name); if (vertex != null) for (InheritanceVertex parent : vertex.getAllParents()) @@ -413,7 +413,7 @@ protected List complete(@Nonnull Workspace workspace, @Nonnull Inheritan ClassPathNode ownerPath = workspace.findClass(owner); if (ownerPath != null) { Set items = new TreeSet<>(); - InheritanceVertex vertex = graph.getVertex(owner); + InheritanceVertex vertex = inheritanceGraph.getVertex(owner); Predicate filter = member -> member.getName().equals(name) && member.getDescriptor().startsWith(desc); if (vertex != null) for (InheritanceVertex parent : vertex.getAllParents()) diff --git a/recaf-ui/src/main/java/software/coley/recaf/ui/pane/MappingGeneratorPane.java b/recaf-ui/src/main/java/software/coley/recaf/ui/pane/MappingGeneratorPane.java index 08aecc3a0..71ebf7dc5 100644 --- a/recaf-ui/src/main/java/software/coley/recaf/ui/pane/MappingGeneratorPane.java +++ b/recaf-ui/src/main/java/software/coley/recaf/ui/pane/MappingGeneratorPane.java @@ -119,7 +119,7 @@ public class MappingGeneratorPane extends StackPane { private final StringPredicateProvider stringPredicateProvider; private final MappingGenerator mappingGenerator; private final ConfigComponentManager componentManager; - private final InheritanceGraph graph; + private final InheritanceGraph inheritanceGraph; private final ModalPane modal = new ModalPane(); private final MappingApplier mappingApplier; private final Pane previewGroup; @@ -140,7 +140,7 @@ public MappingGeneratorPane(@Nonnull Workspace workspace, this.stringPredicateProvider = stringPredicateProvider; this.mappingGenerator = mappingGenerator; this.componentManager = componentManager; - this.graph = Objects.requireNonNull(graphService.getCurrentWorkspaceInheritanceGraph(), "Graph not created"); + this.inheritanceGraph = Objects.requireNonNull(graphService.getCurrentWorkspaceInheritanceGraph(), "Graph not created"); this.mappingApplier = mappingApplier; // Cache text matchers. @@ -243,7 +243,7 @@ public void generate() { deconflictingGenerator.setWorkspace(workspace); // Generate the mappings - return mappingGenerator.generate(workspace, workspace.getPrimaryResource(), graph, generator, finalFilter); + return mappingGenerator.generate(workspace, workspace.getPrimaryResource(), inheritanceGraph, generator, finalFilter); }).whenCompleteAsync((mappings, error) -> { previewGroup.setDisable(false); if (mappings != null) { diff --git a/recaf-ui/src/main/java/software/coley/recaf/ui/pane/editing/assembler/AssemblerPane.java b/recaf-ui/src/main/java/software/coley/recaf/ui/pane/editing/assembler/AssemblerPane.java index e9b256b4a..9e9ccfcc0 100644 --- a/recaf-ui/src/main/java/software/coley/recaf/ui/pane/editing/assembler/AssemblerPane.java +++ b/recaf-ui/src/main/java/software/coley/recaf/ui/pane/editing/assembler/AssemblerPane.java @@ -99,8 +99,8 @@ public AssemblerPane(@Nonnull AssemblerPipelineManager pipelineManager, int timeToWait = pipelineManager.getServiceConfig().getDisassemblyAstParseDelay().getValue(); - InheritanceGraph graph = Objects.requireNonNull(graphService.getCurrentWorkspaceInheritanceGraph(), "Graph not created"); - tabCompleter = new AssemblerTabCompleter(Objects.requireNonNull(workspaceManager.getCurrent()), graph); + InheritanceGraph inheritanceGraph = Objects.requireNonNull(graphService.getCurrentWorkspaceInheritanceGraph(), "Graph not created"); + tabCompleter = new AssemblerTabCompleter(Objects.requireNonNull(workspaceManager.getCurrent()), inheritanceGraph); editor.setTabCompleter(tabCompleter); editor.getCodeArea().getStylesheets().add(LanguageStylesheets.getJasmStylesheet()); editor.setSelectedBracketTracking(new SelectedBracketTracking());