Better Searching
Instead of providing the entire path in the search result now we can return only what the user is looking for
This commit is contained in:
parent
e94bee0fb6
commit
f4c0e71475
10 changed files with 114 additions and 111 deletions
|
@ -4,8 +4,8 @@ import org.objectweb.asm.tree.ClassNode;
|
||||||
import the.bytecode.club.bytecodeviewer.BytecodeViewer;
|
import the.bytecode.club.bytecodeviewer.BytecodeViewer;
|
||||||
import the.bytecode.club.bytecodeviewer.searching.BackgroundSearchThread;
|
import the.bytecode.club.bytecodeviewer.searching.BackgroundSearchThread;
|
||||||
import the.bytecode.club.bytecodeviewer.searching.RegexInsnFinder;
|
import the.bytecode.club.bytecodeviewer.searching.RegexInsnFinder;
|
||||||
|
import the.bytecode.club.bytecodeviewer.searching.impl.LDCSearch;
|
||||||
import the.bytecode.club.bytecodeviewer.searching.impl.RegexSearch;
|
import the.bytecode.club.bytecodeviewer.searching.impl.RegexSearch;
|
||||||
import the.bytecode.club.bytecodeviewer.searching.SearchResultNotifier;
|
|
||||||
import the.bytecode.club.bytecodeviewer.translation.TranslatedStrings;
|
import the.bytecode.club.bytecodeviewer.translation.TranslatedStrings;
|
||||||
import the.bytecode.club.bytecodeviewer.resources.ResourceContainer;
|
import the.bytecode.club.bytecodeviewer.resources.ResourceContainer;
|
||||||
|
|
||||||
|
@ -38,12 +38,10 @@ import java.util.regex.PatternSyntaxException;
|
||||||
class PerformSearch extends BackgroundSearchThread
|
class PerformSearch extends BackgroundSearchThread
|
||||||
{
|
{
|
||||||
private final SearchBoxPane searchBoxPane;
|
private final SearchBoxPane searchBoxPane;
|
||||||
private final SearchResultNotifier srn;
|
|
||||||
|
|
||||||
public PerformSearch(SearchBoxPane searchBoxPane, SearchResultNotifier srn)
|
public PerformSearch(SearchBoxPane searchBoxPane)
|
||||||
{
|
{
|
||||||
this.searchBoxPane = searchBoxPane;
|
this.searchBoxPane = searchBoxPane;
|
||||||
this.srn = srn;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -51,6 +49,7 @@ class PerformSearch extends BackgroundSearchThread
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
if(RegexSearch.searchText != null)
|
||||||
Pattern.compile(RegexInsnFinder.processRegex(RegexSearch.searchText.getText()), Pattern.MULTILINE);
|
Pattern.compile(RegexInsnFinder.processRegex(RegexSearch.searchText.getText()), Pattern.MULTILINE);
|
||||||
}
|
}
|
||||||
catch (PatternSyntaxException ex)
|
catch (PatternSyntaxException ex)
|
||||||
|
@ -59,8 +58,9 @@ class PerformSearch extends BackgroundSearchThread
|
||||||
}
|
}
|
||||||
|
|
||||||
for (ResourceContainer container : BytecodeViewer.resourceContainers.values())
|
for (ResourceContainer container : BytecodeViewer.resourceContainers.values())
|
||||||
for (ClassNode c : container.resourceClasses.values())
|
container.resourceClasses.forEach((key,cn)->{
|
||||||
searchBoxPane.searchType.details.search(container, c, srn, searchBoxPane.exact.isSelected());
|
searchBoxPane.searchType.panel.search(container, key, cn, searchBoxPane.exact.isSelected());
|
||||||
|
});
|
||||||
|
|
||||||
BytecodeViewer.viewer.searchBoxPane.search.setEnabled(true);
|
BytecodeViewer.viewer.searchBoxPane.search.setEnabled(true);
|
||||||
BytecodeViewer.viewer.searchBoxPane.search.setText(TranslatedStrings.SEARCH.toString());
|
BytecodeViewer.viewer.searchBoxPane.search.setText(TranslatedStrings.SEARCH.toString());
|
||||||
|
|
|
@ -18,7 +18,7 @@ import org.objectweb.asm.tree.ClassNode;
|
||||||
import the.bytecode.club.bytecodeviewer.BytecodeViewer;
|
import the.bytecode.club.bytecodeviewer.BytecodeViewer;
|
||||||
import the.bytecode.club.bytecodeviewer.gui.resourceviewer.viewer.ResourceViewer;
|
import the.bytecode.club.bytecodeviewer.gui.resourceviewer.viewer.ResourceViewer;
|
||||||
import the.bytecode.club.bytecodeviewer.searching.BackgroundSearchThread;
|
import the.bytecode.club.bytecodeviewer.searching.BackgroundSearchThread;
|
||||||
import the.bytecode.club.bytecodeviewer.searching.SearchResultNotifier;
|
import the.bytecode.club.bytecodeviewer.searching.LDCSearchTreeNodeResult;
|
||||||
import the.bytecode.club.bytecodeviewer.translation.TranslatedStrings;
|
import the.bytecode.club.bytecodeviewer.translation.TranslatedStrings;
|
||||||
import the.bytecode.club.bytecodeviewer.translation.TranslatedComponents;
|
import the.bytecode.club.bytecodeviewer.translation.TranslatedComponents;
|
||||||
import the.bytecode.club.bytecodeviewer.translation.components.*;
|
import the.bytecode.club.bytecodeviewer.translation.components.*;
|
||||||
|
@ -49,8 +49,6 @@ import the.bytecode.club.bytecodeviewer.resources.ResourceContainer;
|
||||||
* @author WaterWolf
|
* @author WaterWolf
|
||||||
* @since 09/29/2011
|
* @since 09/29/2011
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@SuppressWarnings("rawtypes")
|
|
||||||
public class SearchBoxPane extends TranslatedVisibleComponent
|
public class SearchBoxPane extends TranslatedVisibleComponent
|
||||||
{
|
{
|
||||||
public static final SearchRadius[] SEARCH_RADII = SearchRadius.values();
|
public static final SearchRadius[] SEARCH_RADII = SearchRadius.values();
|
||||||
|
@ -59,7 +57,7 @@ public class SearchBoxPane extends TranslatedVisibleComponent
|
||||||
public final JCheckBox exact = new TranslatedJCheckBox("Exact", TranslatedComponents.EXACT);
|
public final JCheckBox exact = new TranslatedJCheckBox("Exact", TranslatedComponents.EXACT);
|
||||||
public final TranslatedDefaultMutableTreeNode treeRoot = new TranslatedDefaultMutableTreeNode("Results", TranslatedComponents.RESULTS);
|
public final TranslatedDefaultMutableTreeNode treeRoot = new TranslatedDefaultMutableTreeNode("Results", TranslatedComponents.RESULTS);
|
||||||
public final JTree tree;
|
public final JTree tree;
|
||||||
public final JComboBox typeBox;
|
public final JComboBox<SearchType> typeBox;
|
||||||
|
|
||||||
public SearchType searchType = null;
|
public SearchType searchType = null;
|
||||||
public final JComboBox searchRadiusBox;
|
public final JComboBox searchRadiusBox;
|
||||||
|
@ -91,13 +89,13 @@ public class SearchBoxPane extends TranslatedVisibleComponent
|
||||||
for (final SearchType st : SEARCH_TYPES)
|
for (final SearchType st : SEARCH_TYPES)
|
||||||
model.addElement(st);
|
model.addElement(st);
|
||||||
|
|
||||||
typeBox = new JComboBox(model);
|
typeBox = new JComboBox<SearchType>(model);
|
||||||
final JPanel searchOptPanel = new JPanel();
|
final JPanel searchOptPanel = new JPanel();
|
||||||
|
|
||||||
final ItemListener il = arg0 -> {
|
final ItemListener il = arg0 -> {
|
||||||
searchOptPanel.removeAll();
|
searchOptPanel.removeAll();
|
||||||
searchType = (SearchType) typeBox.getSelectedItem();
|
searchType = (SearchType) typeBox.getSelectedItem();
|
||||||
searchOptPanel.add(Objects.requireNonNull(searchType).details.getPanel());
|
searchOptPanel.add(Objects.requireNonNull(searchType).panel.getPanel());
|
||||||
|
|
||||||
searchOptPanel.revalidate();
|
searchOptPanel.revalidate();
|
||||||
searchOptPanel.repaint();
|
searchOptPanel.repaint();
|
||||||
|
@ -138,18 +136,11 @@ public class SearchBoxPane extends TranslatedVisibleComponent
|
||||||
if (selectionEvent.getPath().getPathComponent(0).equals(TranslatedStrings.RESULTS))
|
if (selectionEvent.getPath().getPathComponent(0).equals(TranslatedStrings.RESULTS))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
selectionEvent.getPath().getPathComponent(1);
|
LDCSearchTreeNodeResult result = (LDCSearchTreeNodeResult) tree.getLastSelectedPathComponent();
|
||||||
|
|
||||||
String path = selectionEvent.getPath().getPathComponent(1).toString();
|
final String name = result.resourceWorkingName;
|
||||||
|
|
||||||
String containerName = path.split(">", 2)[0];
|
BytecodeViewer.viewer.workPane.addClassResource(result.container, name);
|
||||||
String className = path.split(">", 2)[1].split("\\.")[0];
|
|
||||||
ResourceContainer container = BytecodeViewer.getFileContainer(containerName);
|
|
||||||
|
|
||||||
final ClassNode fN = Objects.requireNonNull(container).getClassNode(className);
|
|
||||||
|
|
||||||
if (fN != null)
|
|
||||||
BytecodeViewer.viewer.workPane.addClassResource(container, className + ".class");
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
@ -166,7 +157,6 @@ public class SearchBoxPane extends TranslatedVisibleComponent
|
||||||
treeRoot.removeAllChildren();
|
treeRoot.removeAllChildren();
|
||||||
searchType = (SearchType) typeBox.getSelectedItem();
|
searchType = (SearchType) typeBox.getSelectedItem();
|
||||||
final SearchRadius radius = (SearchRadius) searchRadiusBox.getSelectedItem();
|
final SearchRadius radius = (SearchRadius) searchRadiusBox.getSelectedItem();
|
||||||
final SearchResultNotifier srn = debug -> treeRoot.add(new DefaultMutableTreeNode(debug));
|
|
||||||
|
|
||||||
if (radius == SearchRadius.All_Classes)
|
if (radius == SearchRadius.All_Classes)
|
||||||
{
|
{
|
||||||
|
@ -175,7 +165,7 @@ public class SearchBoxPane extends TranslatedVisibleComponent
|
||||||
BytecodeViewer.viewer.searchBoxPane.search.setEnabled(false);
|
BytecodeViewer.viewer.searchBoxPane.search.setEnabled(false);
|
||||||
BytecodeViewer.viewer.searchBoxPane.search.setText("Searching, please wait..");
|
BytecodeViewer.viewer.searchBoxPane.search.setText("Searching, please wait..");
|
||||||
|
|
||||||
performSearchThread = new PerformSearch(this, srn);
|
performSearchThread = new PerformSearch(this);
|
||||||
performSearchThread.start();
|
performSearchThread.start();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -188,7 +178,7 @@ public class SearchBoxPane extends TranslatedVisibleComponent
|
||||||
final ResourceViewer cv = BytecodeViewer.getActiveResource();
|
final ResourceViewer cv = BytecodeViewer.getActiveResource();
|
||||||
|
|
||||||
if (cv != null)
|
if (cv != null)
|
||||||
searchType.details.search(cv.resource.container, cv.resource.getResourceClassNode(), srn, exact.isSelected());
|
searchType.panel.search(cv.resource.container, cv.resource.workingName, cv.resource.getResourceClassNode(), exact.isSelected());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package the.bytecode.club.bytecodeviewer.gui.resourcesearch;
|
package the.bytecode.club.bytecodeviewer.gui.resourcesearch;
|
||||||
|
|
||||||
import the.bytecode.club.bytecodeviewer.searching.*;
|
import the.bytecode.club.bytecodeviewer.searching.SearchPanel;
|
||||||
import the.bytecode.club.bytecodeviewer.searching.impl.FieldCallSearch;
|
import the.bytecode.club.bytecodeviewer.searching.impl.FieldCallSearch;
|
||||||
import the.bytecode.club.bytecodeviewer.searching.impl.LDCSearch;
|
import the.bytecode.club.bytecodeviewer.searching.impl.LDCSearch;
|
||||||
import the.bytecode.club.bytecodeviewer.searching.impl.MethodCallSearch;
|
import the.bytecode.club.bytecodeviewer.searching.impl.MethodCallSearch;
|
||||||
|
@ -33,12 +33,13 @@ public enum SearchType
|
||||||
Strings(new LDCSearch()),
|
Strings(new LDCSearch()),
|
||||||
Regex(new RegexSearch()),
|
Regex(new RegexSearch()),
|
||||||
MethodCall(new MethodCallSearch()),
|
MethodCall(new MethodCallSearch()),
|
||||||
FieldCall(new FieldCallSearch());
|
FieldCall(new FieldCallSearch()),
|
||||||
|
;
|
||||||
|
|
||||||
public final SearchTypeDetails details;
|
public final SearchPanel panel;
|
||||||
|
|
||||||
SearchType(final SearchTypeDetails details)
|
SearchType(final SearchPanel panel)
|
||||||
{
|
{
|
||||||
this.details = details;
|
this.panel = panel;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,6 +69,7 @@ public class Workspace extends TranslatedVisibleComponent
|
||||||
if (index != -1)
|
if (index != -1)
|
||||||
tabs.remove(index);
|
tabs.remove(index);
|
||||||
});
|
});
|
||||||
|
|
||||||
closeAllTabs.addActionListener(e ->
|
closeAllTabs.addActionListener(e ->
|
||||||
{
|
{
|
||||||
TabExitButton tabExitButton = (TabExitButton) ((JPopupMenu)((JMenuItem) e.getSource()).getParent()).getInvoker();
|
TabExitButton tabExitButton = (TabExitButton) ((JPopupMenu)((JMenuItem) e.getSource()).getParent()).getInvoker();
|
||||||
|
|
|
@ -1,5 +1,12 @@
|
||||||
package the.bytecode.club.bytecodeviewer.searching;
|
package the.bytecode.club.bytecodeviewer.searching;
|
||||||
|
|
||||||
|
import org.objectweb.asm.tree.ClassNode;
|
||||||
|
import org.objectweb.asm.tree.FieldNode;
|
||||||
|
import org.objectweb.asm.tree.MethodNode;
|
||||||
|
import the.bytecode.club.bytecodeviewer.resources.ResourceContainer;
|
||||||
|
|
||||||
|
import javax.swing.tree.DefaultMutableTreeNode;
|
||||||
|
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
* Bytecode Viewer (BCV) - Java & Android Reverse Engineering Suite *
|
* Bytecode Viewer (BCV) - Java & Android Reverse Engineering Suite *
|
||||||
* Copyright (C) 2014 Kalen 'Konloch' Kinloch - http://bytecodeviewer.com *
|
* Copyright (C) 2014 Kalen 'Konloch' Kinloch - http://bytecodeviewer.com *
|
||||||
|
@ -19,13 +26,24 @@ package the.bytecode.club.bytecodeviewer.searching;
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used to update the search pane that there's been a result found.
|
|
||||||
*
|
|
||||||
* @author Konloch
|
* @author Konloch
|
||||||
* @author WaterWolf
|
* @since 7/29/2021
|
||||||
* @since 09/26/2011
|
|
||||||
*/
|
*/
|
||||||
|
public class LDCSearchTreeNodeResult extends DefaultMutableTreeNode
|
||||||
|
{
|
||||||
|
public final ResourceContainer container;
|
||||||
|
public final String resourceWorkingName;
|
||||||
|
public final String ldc;
|
||||||
|
public final String ldcType;
|
||||||
|
|
||||||
public interface SearchResultNotifier {
|
public LDCSearchTreeNodeResult(ResourceContainer container, String resourceWorkingName,
|
||||||
void notifyOfResult(String debug);
|
ClassNode cn, MethodNode method, FieldNode field,
|
||||||
|
String ldc, String ldcType)
|
||||||
|
{
|
||||||
|
super("'"+ldc+"' -> " + cn.name);
|
||||||
|
this.container = container;
|
||||||
|
this.resourceWorkingName = resourceWorkingName;
|
||||||
|
this.ldc = ldc;
|
||||||
|
this.ldcType = ldcType;
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -1,9 +1,10 @@
|
||||||
package the.bytecode.club.bytecodeviewer.searching;
|
package the.bytecode.club.bytecodeviewer.searching;
|
||||||
|
|
||||||
import javax.swing.JPanel;
|
|
||||||
import org.objectweb.asm.tree.ClassNode;
|
import org.objectweb.asm.tree.ClassNode;
|
||||||
import the.bytecode.club.bytecodeviewer.resources.ResourceContainer;
|
import the.bytecode.club.bytecodeviewer.resources.ResourceContainer;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
* Bytecode Viewer (BCV) - Java & Android Reverse Engineering Suite *
|
* Bytecode Viewer (BCV) - Java & Android Reverse Engineering Suite *
|
||||||
* Copyright (C) 2014 Kalen 'Konloch' Kinloch - http://bytecodeviewer.com *
|
* Copyright (C) 2014 Kalen 'Konloch' Kinloch - http://bytecodeviewer.com *
|
||||||
|
@ -23,16 +24,13 @@ import the.bytecode.club.bytecodeviewer.resources.ResourceContainer;
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Search type details
|
|
||||||
*
|
|
||||||
* @author Konloch
|
* @author Konloch
|
||||||
* @author WaterWolf
|
* @author WaterWolf
|
||||||
* @since 09/26/2011
|
* @since 09/26/2011
|
||||||
*/
|
*/
|
||||||
|
public interface SearchPanel
|
||||||
public interface SearchTypeDetails
|
|
||||||
{
|
{
|
||||||
JPanel getPanel();
|
JPanel getPanel();
|
||||||
|
|
||||||
void search(ResourceContainer container, ClassNode node, SearchResultNotifier srn, boolean exact);
|
void search(ResourceContainer container, String resourceWorkingName, ClassNode node, boolean exact);
|
||||||
}
|
}
|
|
@ -7,7 +7,6 @@ import org.objectweb.asm.tree.ClassNode;
|
||||||
import org.objectweb.asm.tree.FieldInsnNode;
|
import org.objectweb.asm.tree.FieldInsnNode;
|
||||||
import org.objectweb.asm.tree.InsnList;
|
import org.objectweb.asm.tree.InsnList;
|
||||||
import org.objectweb.asm.tree.MethodNode;
|
import org.objectweb.asm.tree.MethodNode;
|
||||||
import the.bytecode.club.bytecodeviewer.searching.SearchResultNotifier;
|
|
||||||
import the.bytecode.club.bytecodeviewer.resources.ResourceContainer;
|
import the.bytecode.club.bytecodeviewer.resources.ResourceContainer;
|
||||||
|
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
|
@ -38,8 +37,7 @@ import the.bytecode.club.bytecodeviewer.resources.ResourceContainer;
|
||||||
public class FieldCallSearch extends MethodCallSearch
|
public class FieldCallSearch extends MethodCallSearch
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public void search(final ResourceContainer container, final ClassNode node, final SearchResultNotifier srn,
|
public void search(ResourceContainer container, String resourceWorkingName, ClassNode node, boolean exact)
|
||||||
boolean exact)
|
|
||||||
{
|
{
|
||||||
final Iterator<MethodNode> methods = node.methods.iterator();
|
final Iterator<MethodNode> methods = node.methods.iterator();
|
||||||
|
|
||||||
|
@ -88,7 +86,7 @@ public class FieldCallSearch extends MethodCallSearch
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
found(container, node, method, insnNode, srn);
|
found(container, resourceWorkingName, node, method, insnNode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,16 +4,17 @@ import java.awt.GridLayout;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
import javax.swing.JTextField;
|
import javax.swing.JTextField;
|
||||||
import org.objectweb.asm.Type;
|
|
||||||
import org.objectweb.asm.tree.AbstractInsnNode;
|
import org.objectweb.asm.tree.AbstractInsnNode;
|
||||||
import org.objectweb.asm.tree.ClassNode;
|
import org.objectweb.asm.tree.ClassNode;
|
||||||
import org.objectweb.asm.tree.FieldNode;
|
import org.objectweb.asm.tree.FieldNode;
|
||||||
import org.objectweb.asm.tree.InsnList;
|
import org.objectweb.asm.tree.InsnList;
|
||||||
import org.objectweb.asm.tree.LdcInsnNode;
|
import org.objectweb.asm.tree.LdcInsnNode;
|
||||||
import org.objectweb.asm.tree.MethodNode;
|
import org.objectweb.asm.tree.MethodNode;
|
||||||
|
import the.bytecode.club.bytecodeviewer.BytecodeViewer;
|
||||||
import the.bytecode.club.bytecodeviewer.searching.EnterKeyEvent;
|
import the.bytecode.club.bytecodeviewer.searching.EnterKeyEvent;
|
||||||
import the.bytecode.club.bytecodeviewer.searching.SearchResultNotifier;
|
import the.bytecode.club.bytecodeviewer.searching.LDCSearchTreeNodeResult;
|
||||||
import the.bytecode.club.bytecodeviewer.searching.SearchTypeDetails;
|
import the.bytecode.club.bytecodeviewer.searching.SearchPanel;
|
||||||
import the.bytecode.club.bytecodeviewer.translation.TranslatedComponents;
|
import the.bytecode.club.bytecodeviewer.translation.TranslatedComponents;
|
||||||
import the.bytecode.club.bytecodeviewer.translation.components.TranslatedJLabel;
|
import the.bytecode.club.bytecodeviewer.translation.components.TranslatedJLabel;
|
||||||
import the.bytecode.club.bytecodeviewer.resources.ResourceContainer;
|
import the.bytecode.club.bytecodeviewer.resources.ResourceContainer;
|
||||||
|
@ -44,7 +45,7 @@ import the.bytecode.club.bytecodeviewer.resources.ResourceContainer;
|
||||||
* @since 09/29/2011
|
* @since 09/29/2011
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class LDCSearch implements SearchTypeDetails
|
public class LDCSearch implements SearchPanel
|
||||||
{
|
{
|
||||||
JTextField searchText;
|
JTextField searchText;
|
||||||
JPanel myPanel = null;
|
JPanel myPanel = null;
|
||||||
|
@ -68,8 +69,7 @@ public class LDCSearch implements SearchTypeDetails
|
||||||
return myPanel;
|
return myPanel;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public void search(final ResourceContainer container, final String resourceWorkingName, final ClassNode node,
|
||||||
public void search(final ResourceContainer container, final ClassNode node, final SearchResultNotifier srn,
|
|
||||||
boolean caseSensitive)
|
boolean caseSensitive)
|
||||||
{
|
{
|
||||||
final Iterator<MethodNode> methods = node.methods.iterator();
|
final Iterator<MethodNode> methods = node.methods.iterator();
|
||||||
|
@ -90,13 +90,6 @@ public class LDCSearch implements SearchTypeDetails
|
||||||
{
|
{
|
||||||
final LdcInsnNode ldcObject = ((LdcInsnNode) insnNode);
|
final LdcInsnNode ldcObject = ((LdcInsnNode) insnNode);
|
||||||
final String ldcString = ldcObject.cst.toString();
|
final String ldcString = ldcObject.cst.toString();
|
||||||
String desc2 = method.desc;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
desc2 = Type.getType(method.desc).toString();
|
|
||||||
if (desc2.equals("null"))
|
|
||||||
desc2 = method.desc;
|
|
||||||
} catch (ArrayIndexOutOfBoundsException ignored) { }
|
|
||||||
|
|
||||||
//TODO re-add this at some point when the search pane is redone
|
//TODO re-add this at some point when the search pane is redone
|
||||||
boolean exact = false;
|
boolean exact = false;
|
||||||
|
@ -107,10 +100,15 @@ public class LDCSearch implements SearchTypeDetails
|
||||||
|
|
||||||
if (anyMatch)
|
if (anyMatch)
|
||||||
{
|
{
|
||||||
srn.notifyOfResult(container.name + ">" + node.name + "." + method.name
|
BytecodeViewer.viewer.searchBoxPane.treeRoot.add(new LDCSearchTreeNodeResult(
|
||||||
+ desc2
|
container,
|
||||||
+ " -> \"" + ldcString + "\" > "
|
resourceWorkingName,
|
||||||
+ ldcObject.cst.getClass().getCanonicalName());
|
node,
|
||||||
|
method,
|
||||||
|
null,
|
||||||
|
ldcString,
|
||||||
|
ldcObject.cst.getClass().getCanonicalName()
|
||||||
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -120,20 +118,17 @@ public class LDCSearch implements SearchTypeDetails
|
||||||
while (methods.hasNext())
|
while (methods.hasNext())
|
||||||
{
|
{
|
||||||
final FieldNode field = fields.next();
|
final FieldNode field = fields.next();
|
||||||
String desc2 = field.desc;
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
desc2 = Type.getType(field.desc).toString();
|
|
||||||
|
|
||||||
if (desc2.equals("null"))
|
|
||||||
desc2 = field.desc;
|
|
||||||
} catch (java.lang.ArrayIndexOutOfBoundsException ignored) { }
|
|
||||||
|
|
||||||
if (field.value instanceof String)
|
if (field.value instanceof String)
|
||||||
{
|
{
|
||||||
srn.notifyOfResult(container.name + ">" + node.name + "." + field.name + desc2
|
BytecodeViewer.viewer.resourcePane.treeRoot.add(new LDCSearchTreeNodeResult(container,
|
||||||
+ " -> \"" + field.value + "\" > field");
|
resourceWorkingName,
|
||||||
|
node,
|
||||||
|
null,
|
||||||
|
field,
|
||||||
|
String.valueOf(field.value),
|
||||||
|
field.value.getClass().getCanonicalName()
|
||||||
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,9 +12,10 @@ import org.objectweb.asm.tree.ClassNode;
|
||||||
import org.objectweb.asm.tree.InsnList;
|
import org.objectweb.asm.tree.InsnList;
|
||||||
import org.objectweb.asm.tree.MethodInsnNode;
|
import org.objectweb.asm.tree.MethodInsnNode;
|
||||||
import org.objectweb.asm.tree.MethodNode;
|
import org.objectweb.asm.tree.MethodNode;
|
||||||
|
import the.bytecode.club.bytecodeviewer.BytecodeViewer;
|
||||||
import the.bytecode.club.bytecodeviewer.searching.EnterKeyEvent;
|
import the.bytecode.club.bytecodeviewer.searching.EnterKeyEvent;
|
||||||
import the.bytecode.club.bytecodeviewer.searching.SearchResultNotifier;
|
import the.bytecode.club.bytecodeviewer.searching.LDCSearchTreeNodeResult;
|
||||||
import the.bytecode.club.bytecodeviewer.searching.SearchTypeDetails;
|
import the.bytecode.club.bytecodeviewer.searching.SearchPanel;
|
||||||
import the.bytecode.club.bytecodeviewer.translation.TranslatedComponents;
|
import the.bytecode.club.bytecodeviewer.translation.TranslatedComponents;
|
||||||
import the.bytecode.club.bytecodeviewer.translation.components.TranslatedJLabel;
|
import the.bytecode.club.bytecodeviewer.translation.components.TranslatedJLabel;
|
||||||
import the.bytecode.club.bytecodeviewer.resources.ResourceContainer;
|
import the.bytecode.club.bytecodeviewer.resources.ResourceContainer;
|
||||||
|
@ -45,7 +46,7 @@ import the.bytecode.club.bytecodeviewer.resources.ResourceContainer;
|
||||||
* @since 09/29/2011
|
* @since 09/29/2011
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class MethodCallSearch implements SearchTypeDetails
|
public class MethodCallSearch implements SearchPanel
|
||||||
{
|
{
|
||||||
JTextField mOwner;
|
JTextField mOwner;
|
||||||
JTextField mName;
|
JTextField mName;
|
||||||
|
@ -62,7 +63,6 @@ public class MethodCallSearch implements SearchTypeDetails
|
||||||
mDesc.addKeyListener(EnterKeyEvent.SINGLETON);
|
mDesc.addKeyListener(EnterKeyEvent.SINGLETON);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public JPanel getPanel()
|
public JPanel getPanel()
|
||||||
{
|
{
|
||||||
if (myPanel == null)
|
if (myPanel == null)
|
||||||
|
@ -80,8 +80,7 @@ public class MethodCallSearch implements SearchTypeDetails
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void search(final ResourceContainer container, final ClassNode node, final SearchResultNotifier srn,
|
public void search(ResourceContainer container, String resourceWorkingName, ClassNode node, boolean exact)
|
||||||
boolean exact)
|
|
||||||
{
|
{
|
||||||
final Iterator<MethodNode> methods = node.methods.iterator();
|
final Iterator<MethodNode> methods = node.methods.iterator();
|
||||||
|
|
||||||
|
@ -130,29 +129,22 @@ public class MethodCallSearch implements SearchTypeDetails
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
found(container, node, method, insnNode, srn);
|
found(container, resourceWorkingName, node, method, insnNode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void found(final ResourceContainer container, final ClassNode node, final MethodNode method, final AbstractInsnNode insnNode, final SearchResultNotifier srn)
|
public void found(final ResourceContainer container, final String resourceWorkingName, final ClassNode node, final MethodNode method, final AbstractInsnNode insnNode)
|
||||||
{
|
{
|
||||||
String desc = method.desc;
|
BytecodeViewer.viewer.searchBoxPane.treeRoot.add(new LDCSearchTreeNodeResult(
|
||||||
try
|
container,
|
||||||
{
|
resourceWorkingName,
|
||||||
desc = Type.getType(method.desc).toString();
|
node,
|
||||||
|
method,
|
||||||
if (desc.equals("null"))
|
null,
|
||||||
desc = method.desc;
|
OpcodeInfo.OPCODES.get(insnNode.getOpcode()).toLowerCase(),
|
||||||
} catch (ArrayIndexOutOfBoundsException ignored) { }
|
""
|
||||||
|
));
|
||||||
srn.notifyOfResult(container.name + ">" + node.name
|
|
||||||
+ "."
|
|
||||||
+ method.name
|
|
||||||
+ desc
|
|
||||||
+ " > "
|
|
||||||
+ OpcodeInfo.OPCODES.get(insnNode.getOpcode())
|
|
||||||
.toLowerCase());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -5,13 +5,16 @@ import java.util.Iterator;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
import javax.swing.JTextField;
|
import javax.swing.JTextField;
|
||||||
|
|
||||||
|
import eu.bibl.banalysis.asm.desc.OpcodeInfo;
|
||||||
import org.objectweb.asm.Type;
|
import org.objectweb.asm.Type;
|
||||||
import org.objectweb.asm.tree.ClassNode;
|
import org.objectweb.asm.tree.ClassNode;
|
||||||
import org.objectweb.asm.tree.MethodNode;
|
import org.objectweb.asm.tree.MethodNode;
|
||||||
|
import the.bytecode.club.bytecodeviewer.BytecodeViewer;
|
||||||
import the.bytecode.club.bytecodeviewer.searching.EnterKeyEvent;
|
import the.bytecode.club.bytecodeviewer.searching.EnterKeyEvent;
|
||||||
|
import the.bytecode.club.bytecodeviewer.searching.LDCSearchTreeNodeResult;
|
||||||
import the.bytecode.club.bytecodeviewer.searching.RegexInsnFinder;
|
import the.bytecode.club.bytecodeviewer.searching.RegexInsnFinder;
|
||||||
import the.bytecode.club.bytecodeviewer.searching.SearchResultNotifier;
|
import the.bytecode.club.bytecodeviewer.searching.SearchPanel;
|
||||||
import the.bytecode.club.bytecodeviewer.searching.SearchTypeDetails;
|
|
||||||
import the.bytecode.club.bytecodeviewer.translation.TranslatedComponents;
|
import the.bytecode.club.bytecodeviewer.translation.TranslatedComponents;
|
||||||
import the.bytecode.club.bytecodeviewer.translation.components.TranslatedJLabel;
|
import the.bytecode.club.bytecodeviewer.translation.components.TranslatedJLabel;
|
||||||
import the.bytecode.club.bytecodeviewer.resources.ResourceContainer;
|
import the.bytecode.club.bytecodeviewer.resources.ResourceContainer;
|
||||||
|
@ -44,7 +47,7 @@ import static the.bytecode.club.bytecodeviewer.searching.RegexInsnFinder.process
|
||||||
* @since 09/29/2011
|
* @since 09/29/2011
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class RegexSearch implements SearchTypeDetails
|
public class RegexSearch implements SearchPanel
|
||||||
{
|
{
|
||||||
public static JTextField searchText;
|
public static JTextField searchText;
|
||||||
JPanel myPanel = null;
|
JPanel myPanel = null;
|
||||||
|
@ -69,8 +72,7 @@ public class RegexSearch implements SearchTypeDetails
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void search(final ResourceContainer container, final ClassNode node, final SearchResultNotifier srn,
|
public void search(final ResourceContainer container, final String resourceWorkingName, final ClassNode node, boolean exact)
|
||||||
boolean exact)
|
|
||||||
{
|
{
|
||||||
final Iterator<MethodNode> methods = node.methods.iterator();
|
final Iterator<MethodNode> methods = node.methods.iterator();
|
||||||
final String srchText = searchText.getText();
|
final String srchText = searchText.getText();
|
||||||
|
@ -94,7 +96,15 @@ public class RegexSearch implements SearchTypeDetails
|
||||||
desc2 = method.desc;
|
desc2 = method.desc;
|
||||||
} catch (java.lang.ArrayIndexOutOfBoundsException ignored) {}
|
} catch (java.lang.ArrayIndexOutOfBoundsException ignored) {}
|
||||||
|
|
||||||
srn.notifyOfResult(container.name + ">" + node.name + "." + method.name + desc2);
|
BytecodeViewer.viewer.searchBoxPane.treeRoot.add(new LDCSearchTreeNodeResult(
|
||||||
|
container,
|
||||||
|
resourceWorkingName,
|
||||||
|
node,
|
||||||
|
method,
|
||||||
|
null,
|
||||||
|
node.name + "." + method.name + desc2,
|
||||||
|
""
|
||||||
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue