Merge pull request #399 from GraxCode/search
Various search fixes and additions
This commit is contained in:
commit
8b61fa2e7b
8 changed files with 211 additions and 139 deletions
|
@ -117,7 +117,7 @@ public class InstructionPrinter {
|
||||||
info.add("}");
|
info.add("}");
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String printInstruction(AbstractInsnNode ain)
|
public String printInstruction(AbstractInsnNode ain)
|
||||||
{
|
{
|
||||||
String line = "";
|
String line = "";
|
||||||
|
@ -136,15 +136,15 @@ public class InstructionPrinter {
|
||||||
} else if (ain instanceof JumpInsnNode) {
|
} else if (ain instanceof JumpInsnNode) {
|
||||||
line = printJumpInsnNode((JumpInsnNode) ain);
|
line = printJumpInsnNode((JumpInsnNode) ain);
|
||||||
} else if (ain instanceof LineNumberNode) {
|
} else if (ain instanceof LineNumberNode) {
|
||||||
line = printLineNumberNode();
|
line = printLineNumberNode((LineNumberNode) ain);
|
||||||
} else if (ain instanceof LabelNode) {
|
} else if (ain instanceof LabelNode) {
|
||||||
if (firstLabel
|
if (firstLabel
|
||||||
&& BytecodeViewer.viewer.appendBracketsToLabels
|
&& BytecodeViewer.viewer.appendBracketsToLabels
|
||||||
.isSelected())
|
.isSelected())
|
||||||
info.add("}");
|
info.add("}");
|
||||||
|
|
||||||
line = printLabelnode((LabelNode) ain);
|
line = printLabelnode((LabelNode) ain);
|
||||||
|
|
||||||
if (BytecodeViewer.viewer.appendBracketsToLabels.isSelected()) {
|
if (BytecodeViewer.viewer.appendBracketsToLabels.isSelected()) {
|
||||||
if (!firstLabel)
|
if (!firstLabel)
|
||||||
firstLabel = true;
|
firstLabel = true;
|
||||||
|
@ -168,7 +168,7 @@ public class InstructionPrinter {
|
||||||
line += "UNADDED OPCODE: " + nameOpcode(ain.getOpcode()) + " "
|
line += "UNADDED OPCODE: " + nameOpcode(ain.getOpcode()) + " "
|
||||||
+ ain;
|
+ ain;
|
||||||
}
|
}
|
||||||
|
|
||||||
return line;
|
return line;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -245,8 +245,8 @@ public class InstructionPrinter {
|
||||||
+ resolveLabel(jin.label);
|
+ resolveLabel(jin.label);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String printLineNumberNode() {
|
protected String printLineNumberNode(LineNumberNode lnn) {
|
||||||
return "";
|
return "// line " + lnn.line;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String printLabelnode(LabelNode label) {
|
protected String printLabelnode(LabelNode label) {
|
||||||
|
|
|
@ -50,7 +50,7 @@ public class SearchableJTextArea extends JTextArea
|
||||||
private final JScrollPane scrollPane = new JScrollPane();
|
private final JScrollPane scrollPane = new JScrollPane();
|
||||||
private final JPanel searchPanel = new JPanel(new BorderLayout());
|
private final JPanel searchPanel = new JPanel(new BorderLayout());
|
||||||
private final JTextField searchInput = new JTextField();
|
private final JTextField searchInput = new JTextField();
|
||||||
private final JCheckBox caseSensitiveSearch = new TranslatedJCheckBox("Exact", TranslatedComponents.EXACT);
|
private final JCheckBox caseSensitiveSearch = new TranslatedJCheckBox("Match case", TranslatedComponents.MATCH_CASE);
|
||||||
|
|
||||||
public SearchableJTextArea()
|
public SearchableJTextArea()
|
||||||
{
|
{
|
||||||
|
|
|
@ -55,7 +55,7 @@ public class SearchableRSyntaxTextArea extends RSyntaxTextArea
|
||||||
private final RTextScrollPane scrollPane = new RTextScrollPane(this);
|
private final RTextScrollPane scrollPane = new RTextScrollPane(this);
|
||||||
private final JPanel searchPanel = new JPanel(new BorderLayout());
|
private final JPanel searchPanel = new JPanel(new BorderLayout());
|
||||||
private final JTextField searchInput = new JTextField();
|
private final JTextField searchInput = new JTextField();
|
||||||
private final JCheckBox caseSensitiveSearch = new TranslatedJCheckBox("Exact", TranslatedComponents.EXACT);
|
private final JCheckBox caseSensitiveSearch = new TranslatedJCheckBox("Match case", TranslatedComponents.MATCH_CASE);
|
||||||
private final JLabel titleHeader = new JLabel("");
|
private final JLabel titleHeader = new JLabel("");
|
||||||
private final Color darkScrollBackground = new Color(0x3c3f41);
|
private final Color darkScrollBackground = new Color(0x3c3f41);
|
||||||
private final Color darkScrollForeground = new Color(0x575859);
|
private final Color darkScrollForeground = new Color(0x575859);
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package the.bytecode.club.bytecodeviewer.gui.resourcelist;
|
package the.bytecode.club.bytecodeviewer.gui.resourcelist;
|
||||||
|
|
||||||
import java.awt.BorderLayout;
|
import java.awt.*;
|
||||||
import java.awt.Color;
|
|
||||||
import java.awt.event.FocusEvent;
|
import java.awt.event.FocusEvent;
|
||||||
import java.awt.event.FocusListener;
|
import java.awt.event.FocusListener;
|
||||||
import java.awt.event.KeyAdapter;
|
import java.awt.event.KeyAdapter;
|
||||||
|
@ -71,7 +70,8 @@ import static the.bytecode.club.bytecodeviewer.Constants.tempDirectory;
|
||||||
public class ResourceListPane extends TranslatedVisibleComponent implements FileDrop.Listener
|
public class ResourceListPane extends TranslatedVisibleComponent implements FileDrop.Listener
|
||||||
{
|
{
|
||||||
public final JPopupMenu rightClickMenu = new JPopupMenu();
|
public final JPopupMenu rightClickMenu = new JPopupMenu();
|
||||||
public final JCheckBox exact = new TranslatedJCheckBox("Exact", TranslatedComponents.EXACT);
|
public final JCheckBox exact = new TranslatedJCheckBox("Exact path", TranslatedComponents.EXACT_PATH);
|
||||||
|
public final JCheckBox caseSensitive = new TranslatedJCheckBox("Match case", TranslatedComponents.MATCH_CASE);
|
||||||
public final JButton open = new JButton("+");
|
public final JButton open = new JButton("+");
|
||||||
public final JButton close = new JButton("-");
|
public final JButton close = new JButton("-");
|
||||||
public final ResourceTreeNode treeRoot = new ResourceTreeNode("Loaded Files:");
|
public final ResourceTreeNode treeRoot = new ResourceTreeNode("Loaded Files:");
|
||||||
|
@ -104,7 +104,7 @@ public class ResourceListPane extends TranslatedVisibleComponent implements File
|
||||||
|
|
||||||
tree.setRootVisible(false);
|
tree.setRootVisible(false);
|
||||||
tree.setShowsRootHandles(true);
|
tree.setShowsRootHandles(true);
|
||||||
quickSearch.setForeground(Color.gray);
|
quickSearch.setForeground(quickSearch.getDisabledTextColor());
|
||||||
|
|
||||||
attachTreeListeners();
|
attachTreeListeners();
|
||||||
attachQuickSearchListeners();
|
attachQuickSearchListeners();
|
||||||
|
@ -118,7 +118,12 @@ public class ResourceListPane extends TranslatedVisibleComponent implements File
|
||||||
|
|
||||||
quickSearchPanel.setLayout(new BorderLayout());
|
quickSearchPanel.setLayout(new BorderLayout());
|
||||||
quickSearchPanel.add(quickSearch, BorderLayout.NORTH);
|
quickSearchPanel.add(quickSearch, BorderLayout.NORTH);
|
||||||
exactPanel.add(exact, BorderLayout.WEST);
|
|
||||||
|
JPanel btns = new JPanel(new FlowLayout());
|
||||||
|
btns.add(exact);
|
||||||
|
btns.add(caseSensitive);
|
||||||
|
exactPanel.add(btns, BorderLayout.WEST);
|
||||||
|
|
||||||
buttonPanel.add(open, BorderLayout.EAST);
|
buttonPanel.add(open, BorderLayout.EAST);
|
||||||
buttonPanel.add(close, BorderLayout.WEST);
|
buttonPanel.add(close, BorderLayout.WEST);
|
||||||
exactPanel.add(buttonPanel, BorderLayout.EAST);
|
exactPanel.add(buttonPanel, BorderLayout.EAST);
|
||||||
|
@ -519,7 +524,7 @@ public class ResourceListPane extends TranslatedVisibleComponent implements File
|
||||||
if (quickSearch.getText().equals(TranslatedStrings.QUICK_FILE_SEARCH_NO_FILE_EXTENSION.toString()))
|
if (quickSearch.getText().equals(TranslatedStrings.QUICK_FILE_SEARCH_NO_FILE_EXTENSION.toString()))
|
||||||
{
|
{
|
||||||
quickSearch.setText("");
|
quickSearch.setText("");
|
||||||
quickSearch.setForeground(Color.black);
|
quickSearch.setForeground(quickSearch.getSelectedTextColor());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -529,7 +534,7 @@ public class ResourceListPane extends TranslatedVisibleComponent implements File
|
||||||
if (quickSearch.getText().isEmpty())
|
if (quickSearch.getText().isEmpty())
|
||||||
{
|
{
|
||||||
quickSearch.setText(TranslatedStrings.QUICK_FILE_SEARCH_NO_FILE_EXTENSION.toString());
|
quickSearch.setText(TranslatedStrings.QUICK_FILE_SEARCH_NO_FILE_EXTENSION.toString());
|
||||||
quickSearch.setForeground(Color.gray);
|
quickSearch.setForeground(quickSearch.getDisabledTextColor());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
package the.bytecode.club.bytecodeviewer.gui.resourcelist;
|
package the.bytecode.club.bytecodeviewer.gui.resourcelist;
|
||||||
|
|
||||||
|
import javax.swing.tree.TreeNode;
|
||||||
|
import javax.swing.tree.TreePath;
|
||||||
|
import java.awt.*;
|
||||||
import java.awt.event.KeyAdapter;
|
import java.awt.event.KeyAdapter;
|
||||||
import java.awt.event.KeyEvent;
|
import java.awt.event.KeyEvent;
|
||||||
import java.util.Enumeration;
|
import java.util.Enumeration;
|
||||||
import javax.swing.tree.TreeNode;
|
|
||||||
import javax.swing.tree.TreePath;
|
|
||||||
import the.bytecode.club.bytecodeviewer.BytecodeViewer;
|
|
||||||
|
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
* Bytecode Viewer (BCV) - Java & Android Reverse Engineering Suite *
|
* Bytecode Viewer (BCV) - Java & Android Reverse Engineering Suite *
|
||||||
|
@ -29,118 +29,103 @@ import the.bytecode.club.bytecodeviewer.BytecodeViewer;
|
||||||
* @author Konloch
|
* @author Konloch
|
||||||
* @since 6/22/2021
|
* @since 6/22/2021
|
||||||
*/
|
*/
|
||||||
public class SearchKeyAdapter extends KeyAdapter
|
public class SearchKeyAdapter extends KeyAdapter {
|
||||||
{
|
private final ResourceListPane resourceListPane;
|
||||||
private final ResourceListPane resourceListPane;
|
|
||||||
|
public SearchKeyAdapter(ResourceListPane resourceListPane) {
|
||||||
public SearchKeyAdapter(ResourceListPane resourceListPane) {this.resourceListPane = resourceListPane;}
|
this.resourceListPane = resourceListPane;
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public void keyPressed(final KeyEvent ke)
|
@Override
|
||||||
{
|
public void keyPressed(final KeyEvent ke) {
|
||||||
//only trigger on enter
|
//only trigger on enter
|
||||||
if (ke.getKeyCode() != KeyEvent.VK_ENTER)
|
if (ke.getKeyCode() != KeyEvent.VK_ENTER)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
final String qt = resourceListPane.quickSearch.getText();
|
final String qt = resourceListPane.quickSearch.getText();
|
||||||
resourceListPane.quickSearch.setText("");
|
|
||||||
|
if (qt.trim().isEmpty()) //NOPE
|
||||||
if (qt.isEmpty()) //NOPE
|
return;
|
||||||
return;
|
|
||||||
|
String[] path;
|
||||||
String[] path;
|
if (qt.contains(".")) {
|
||||||
int found = 0;
|
path = qt.split("\\.");
|
||||||
|
} else {
|
||||||
if (qt.contains("."))
|
path = new String[]{qt};
|
||||||
{
|
}
|
||||||
path = qt.split("\\.");
|
|
||||||
}
|
ResourceTreeNode curNode = resourceListPane.treeRoot;
|
||||||
else
|
boolean caseSensitive = resourceListPane.caseSensitive.isSelected();
|
||||||
{
|
|
||||||
path = new String[]{qt};
|
boolean success = false;
|
||||||
}
|
if (resourceListPane.exact.isSelected()) {
|
||||||
|
pathLoop:
|
||||||
ResourceTreeNode curNode = resourceListPane.treeRoot;
|
for (int i = 0; i < path.length; i++) {
|
||||||
if (resourceListPane.exact.isSelected())
|
final String pathName = path[i];
|
||||||
{
|
final boolean isLast = i == path.length - 1;
|
||||||
pathLoop:
|
|
||||||
for (int i = 0; i < path.length; i++)
|
for (int c = 0; c < curNode.getChildCount(); c++) {
|
||||||
{
|
final ResourceTreeNode child = (ResourceTreeNode) curNode.getChildAt(c);
|
||||||
final String pathName = path[i];
|
Object userObject = child.getUserObject();
|
||||||
final boolean isLast = i == path.length - 1;
|
if (caseSensitive ? userObject.equals(pathName) : userObject.toString().equalsIgnoreCase(pathName)) {
|
||||||
|
curNode = child;
|
||||||
for (int c = 0; c < curNode.getChildCount(); c++)
|
if (isLast) {
|
||||||
{
|
final TreePath pathn = new TreePath(curNode.getPath());
|
||||||
final ResourceTreeNode child = (ResourceTreeNode) curNode.getChildAt(c);
|
resourceListPane.tree.setSelectionPath(pathn);
|
||||||
System.out.println(pathName + ":" + child.getUserObject());
|
resourceListPane.tree.makeVisible(pathn);
|
||||||
|
resourceListPane.tree.scrollPathToVisible(pathn);
|
||||||
if (child.getUserObject().equals(pathName))
|
resourceListPane.openPath(pathn); //auto open
|
||||||
{
|
success = true;
|
||||||
curNode = child;
|
break pathLoop;
|
||||||
if (isLast)
|
}
|
||||||
{
|
continue pathLoop;
|
||||||
System.out.println("Found! " + curNode);
|
}
|
||||||
found++;
|
}
|
||||||
final TreePath pathn = new TreePath(curNode.getPath());
|
|
||||||
resourceListPane.tree.setSelectionPath(pathn);
|
System.out.println("Could not find " + pathName);
|
||||||
resourceListPane.tree.makeVisible(pathn);
|
break;
|
||||||
resourceListPane.tree.scrollPathToVisible(pathn);
|
}
|
||||||
resourceListPane.openPath(pathn); //auto open
|
} else {
|
||||||
break pathLoop;
|
@SuppressWarnings("unchecked")
|
||||||
}
|
Enumeration<TreeNode> enums = curNode.depthFirstEnumeration();
|
||||||
continue pathLoop;
|
while (enums != null && enums.hasMoreElements()) {
|
||||||
}
|
ResourceTreeNode node = (ResourceTreeNode) enums.nextElement();
|
||||||
}
|
if (node.isLeaf()) {
|
||||||
|
String userObject = (String) (node.getUserObject());
|
||||||
System.out.println("Could not find " + pathName);
|
String lastElem = path[path.length - 1];
|
||||||
break;
|
|
||||||
}
|
if (caseSensitive ? userObject.contains(lastElem) : userObject.toLowerCase().contains(lastElem.toLowerCase())) {
|
||||||
}
|
TreeNode[] pathArray = node.getPath();
|
||||||
else
|
int k = 0;
|
||||||
{
|
StringBuilder fullPath = new StringBuilder();
|
||||||
@SuppressWarnings("unchecked")
|
while (pathArray != null
|
||||||
Enumeration<TreeNode> enums = curNode.depthFirstEnumeration();
|
&& k < pathArray.length) {
|
||||||
while (enums != null && enums.hasMoreElements())
|
ResourceTreeNode n = (ResourceTreeNode) pathArray[k];
|
||||||
{
|
String s = (String) (n.getUserObject());
|
||||||
ResourceTreeNode node = (ResourceTreeNode) enums.nextElement();
|
fullPath.append(s);
|
||||||
if (node.isLeaf())
|
if (k++ != pathArray.length - 1) {
|
||||||
{
|
fullPath.append(".");
|
||||||
if (((String) (node.getUserObject())).toLowerCase().contains(path[path.length - 1].toLowerCase()))
|
}
|
||||||
{
|
}
|
||||||
TreeNode[] pathArray = node.getPath();
|
String fullPathString = fullPath.toString();
|
||||||
int k = 0;
|
|
||||||
StringBuilder fullPath = new StringBuilder();
|
if (caseSensitive ? fullPathString.contains(qt) : fullPathString.toLowerCase().contains(qt.toLowerCase())) {
|
||||||
while (pathArray != null
|
final TreePath pathn = new TreePath(node.getPath());
|
||||||
&& k < pathArray.length)
|
resourceListPane.tree.setSelectionPath(pathn.getParentPath());
|
||||||
{
|
resourceListPane.tree.setSelectionPath(pathn);
|
||||||
ResourceTreeNode n = (ResourceTreeNode) pathArray[k];
|
resourceListPane.tree.makeVisible(pathn);
|
||||||
String s = (String) (n.getUserObject());
|
resourceListPane.tree.scrollPathToVisible(pathn);
|
||||||
fullPath.append(s);
|
success = true;
|
||||||
if (k++ != pathArray.length - 1)
|
break;
|
||||||
{
|
}
|
||||||
fullPath.append(".");
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
String fullPathString = fullPath.toString();
|
|
||||||
if (fullPathString.toLowerCase().contains(qt.toLowerCase()))
|
}
|
||||||
{
|
|
||||||
System.out.println("Found! " + node);
|
if (!success) {
|
||||||
found++;
|
Toolkit.getDefaultToolkit().beep();
|
||||||
if (found >= 30)
|
}
|
||||||
{ //TODO probably make this a setting, no real reason it's 30
|
}
|
||||||
BytecodeViewer.showMessage("Uh oh, there could be more results but you've"
|
|
||||||
+ " triggered the 30 classes at once limit. Try refining your search.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
final TreePath pathn = new TreePath(node.getPath());
|
|
||||||
resourceListPane.tree.setSelectionPath(pathn.getParentPath());
|
|
||||||
resourceListPane.tree.setSelectionPath(pathn);
|
|
||||||
resourceListPane.tree.makeVisible(pathn);
|
|
||||||
resourceListPane.tree.scrollPathToVisible(pathn);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,7 @@
|
||||||
package the.bytecode.club.bytecodeviewer.gui.resourcesearch;
|
package the.bytecode.club.bytecodeviewer.gui.resourcesearch;
|
||||||
|
|
||||||
import the.bytecode.club.bytecodeviewer.searching.SearchPanel;
|
import the.bytecode.club.bytecodeviewer.searching.SearchPanel;
|
||||||
import the.bytecode.club.bytecodeviewer.searching.impl.FieldCallSearch;
|
import the.bytecode.club.bytecodeviewer.searching.impl.*;
|
||||||
import the.bytecode.club.bytecodeviewer.searching.impl.LDCSearch;
|
|
||||||
import the.bytecode.club.bytecodeviewer.searching.impl.MethodCallSearch;
|
|
||||||
import the.bytecode.club.bytecodeviewer.searching.impl.RegexSearch;
|
|
||||||
|
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
* Bytecode Viewer (BCV) - Java & Android Reverse Engineering Suite *
|
* Bytecode Viewer (BCV) - Java & Android Reverse Engineering Suite *
|
||||||
|
@ -34,6 +31,7 @@ public enum SearchType
|
||||||
Regex(new RegexSearch()),
|
Regex(new RegexSearch()),
|
||||||
MethodCall(new MethodCallSearch()),
|
MethodCall(new MethodCallSearch()),
|
||||||
FieldCall(new FieldCallSearch()),
|
FieldCall(new FieldCallSearch()),
|
||||||
|
MemberWithAnnotation(new MemberWithAnnotationSearch())
|
||||||
;
|
;
|
||||||
|
|
||||||
public final SearchPanel panel;
|
public final SearchPanel panel;
|
||||||
|
|
|
@ -0,0 +1,83 @@
|
||||||
|
package the.bytecode.club.bytecodeviewer.searching.impl;
|
||||||
|
|
||||||
|
import org.objectweb.asm.Type;
|
||||||
|
import org.objectweb.asm.tree.AnnotationNode;
|
||||||
|
import org.objectweb.asm.tree.ClassNode;
|
||||||
|
import the.bytecode.club.bytecodeviewer.BytecodeViewer;
|
||||||
|
import the.bytecode.club.bytecodeviewer.resources.ResourceContainer;
|
||||||
|
import the.bytecode.club.bytecodeviewer.searching.EnterKeyEvent;
|
||||||
|
import the.bytecode.club.bytecodeviewer.searching.LDCSearchTreeNodeResult;
|
||||||
|
import the.bytecode.club.bytecodeviewer.searching.SearchPanel;
|
||||||
|
import the.bytecode.club.bytecodeviewer.translation.TranslatedComponents;
|
||||||
|
import the.bytecode.club.bytecodeviewer.translation.components.TranslatedJLabel;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.awt.*;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
* Bytecode Viewer (BCV) - Java & Android Reverse Engineering Suite *
|
||||||
|
* Copyright (C) 2014 Kalen 'Konloch' Kinloch - http://bytecodeviewer.com *
|
||||||
|
* *
|
||||||
|
* This program is free software: you can redistribute it and/or modify *
|
||||||
|
* it under the terms of the GNU General Public License as published by *
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or *
|
||||||
|
* (at your option) any later version. *
|
||||||
|
* *
|
||||||
|
* This program is distributed in the hope that it will be useful, *
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||||
|
* GNU General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* You should have received a copy of the GNU General Public License *
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Annotation Searching
|
||||||
|
*
|
||||||
|
* @author GraxCode
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class MemberWithAnnotationSearch implements SearchPanel {
|
||||||
|
JTextField annotation;
|
||||||
|
JPanel myPanel = null;
|
||||||
|
|
||||||
|
public MemberWithAnnotationSearch() {
|
||||||
|
annotation = new JTextField("");
|
||||||
|
annotation.addKeyListener(EnterKeyEvent.SINGLETON);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public JPanel getPanel() {
|
||||||
|
if (myPanel == null) {
|
||||||
|
myPanel = new JPanel(new GridLayout(1, 2));
|
||||||
|
myPanel.add(new TranslatedJLabel("Annotation name: ", TranslatedComponents.ANNOTATION_NAME));
|
||||||
|
myPanel.add(annotation);
|
||||||
|
}
|
||||||
|
|
||||||
|
return myPanel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void search(final ResourceContainer container, final String resourceWorkingName, final ClassNode node, boolean caseSensitive) {
|
||||||
|
final String srchText = annotation.getText().trim();
|
||||||
|
|
||||||
|
if (srchText.isEmpty()) return;
|
||||||
|
|
||||||
|
node.fields.stream().filter(fn -> hasAnnotation(srchText, fn.invisibleAnnotations, fn.visibleAnnotations)).forEach(fn -> BytecodeViewer.viewer.searchBoxPane.treeRoot.add(new LDCSearchTreeNodeResult(container, resourceWorkingName, node, null, fn, fn.name + " " + fn.desc, "")));
|
||||||
|
node.methods.stream().filter(mn -> hasAnnotation(srchText, mn.invisibleAnnotations, mn.visibleAnnotations)).forEach(mn -> BytecodeViewer.viewer.searchBoxPane.treeRoot.add(new LDCSearchTreeNodeResult(container, resourceWorkingName, node, mn, null, mn.name + mn.desc, "")));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean hasAnnotation(String annotation, List<AnnotationNode>... annoLists) {
|
||||||
|
if (annoLists == null) return false;
|
||||||
|
for (List<AnnotationNode> annos : annoLists) {
|
||||||
|
if (annos == null) continue;
|
||||||
|
if (annos.stream().anyMatch(ant -> {
|
||||||
|
String internalName = Type.getType(ant.desc).getInternalName();
|
||||||
|
return internalName.equals(annotation) || internalName.endsWith('/' + annotation) || ant.desc.endsWith('/' + annotation.replace('.', '$'));
|
||||||
|
// in case dot is used for inner class annotations
|
||||||
|
})) return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
|
@ -251,8 +251,9 @@ public enum TranslatedComponents
|
||||||
RESULTS,
|
RESULTS,
|
||||||
REFRESH,
|
REFRESH,
|
||||||
MIN_SDK_VERSION,
|
MIN_SDK_VERSION,
|
||||||
|
ANNOTATION_NAME,
|
||||||
;
|
MATCH_CASE,
|
||||||
|
EXACT_PATH;
|
||||||
|
|
||||||
private final TranslatedComponentReference componentReference;
|
private final TranslatedComponentReference componentReference;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue