Skip to content

Commit

Permalink
Fix decompile-all not targeting selected bundle
Browse files Browse the repository at this point in the history
  • Loading branch information
Col-E committed Jan 23, 2024
1 parent 19f0518 commit 784af62
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,11 @@ public ContextMenuProvider getBundleContextMenuProvider(@Nonnull ContextSource s
var edit = builder.submenu("menu.edit", EDIT);
edit.item("misc.clear", TRASH_CAN, bundle::clear);

if (bundle instanceof JvmClassBundle) {
if (bundle instanceof JvmClassBundle jvmBundle) {
builder.item("menu.file.decompileall", DOCUMENT_EXPORT, () -> {
DecompileAllPopup pane = decompileAllPaneProvider.get();
pane.show();
DecompileAllPopup popup = decompileAllPaneProvider.get();
popup.setTargetBundle(jvmBundle);
popup.show();
});
}
return menu;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import software.coley.recaf.util.Lang;
import software.coley.recaf.util.ZipCreationUtils;
import software.coley.recaf.workspace.model.Workspace;
import software.coley.recaf.workspace.model.bundle.JvmClassBundle;

import java.io.File;
import java.io.IOException;
Expand All @@ -54,13 +55,14 @@ public class DecompileAllPopup extends RecafStage {
private final ObjectProperty<Path> pathProperty = new SimpleObjectProperty<>();
private final ObservableObject<JvmDecompiler> decompilerProperty;
private final BooleanProperty inProgressProperty = new SimpleBooleanProperty();
private JvmClassBundle targetBundle;

@Inject
public DecompileAllPopup(@Nonnull DecompilerManager decompilerManager,
@Nonnull RecentFilesConfig recentFilesConfig,
@Nonnull DecompilerPaneConfig decompilerPaneConfig,
@Nonnull Workspace workspace) {

targetBundle = workspace.getPrimaryResource().getJvmClassBundle();
decompilerProperty = new ObservableObject<>(decompilerManager.getTargetJvmDecompiler());
pathProperty.setValue(Paths.get(recentFilesConfig.getLastWorkspaceExportDirectory().getValue()).resolve("decompiled.zip"));

Expand All @@ -87,7 +89,7 @@ public DecompileAllPopup(@Nonnull DecompilerManager decompilerManager,
progress.setProgress(0);

// Determine which classes to decompile
List<JvmClassInfo> targetClasses = workspace.getPrimaryResource().getJvmClassBundle().stream().filter(cls -> {
List<JvmClassInfo> targetClasses = targetBundle.stream().filter(cls -> {
// Skip inner classes
if (cls.isInnerClass())
return false;
Expand Down Expand Up @@ -168,4 +170,11 @@ public DecompileAllPopup(@Nonnull DecompilerManager decompilerManager,
setTitle(Lang.get("menu.file.decompileall"));
setScene(new RecafScene(layout, 400, 150));
}

/**
* @param targetBundle Bundle to target for decompilation.
*/
public void setTargetBundle(@Nonnull JvmClassBundle targetBundle) {
this.targetBundle = targetBundle;
}
}

0 comments on commit 784af62

Please sign in to comment.