use of the.bytecode.club.bytecodeviewer.searching.LDCSearchTreeNodeResult in project bytecode-viewer by Konloch.
the class LDCSearch method search.
public void search(final ResourceContainer container, final String resourceWorkingName, final ClassNode node, boolean caseSensitive) {
final Iterator<MethodNode> methods = node.methods.iterator();
final String srchText = searchText.getText();
final String srchTextLowerCase = searchText.getText().toLowerCase();
if (srchText.isEmpty())
return;
while (methods.hasNext()) {
final MethodNode method = methods.next();
final InsnList insnlist = method.instructions;
for (AbstractInsnNode insnNode : insnlist) {
if (insnNode instanceof LdcInsnNode) {
final LdcInsnNode ldcObject = ((LdcInsnNode) insnNode);
final String ldcString = ldcObject.cst.toString();
// TODO re-add this at some point when the search pane is redone
boolean exact = false;
final boolean exactMatch = exact && ldcString.equals(srchText);
final boolean caseInsensitiveMatch = !exact && caseSensitive && ldcString.contains(srchText);
final boolean caseSensitiveMatch = !exact && !caseSensitive && ldcString.toLowerCase().contains(srchTextLowerCase);
final boolean anyMatch = exactMatch || caseInsensitiveMatch || caseSensitiveMatch;
if (anyMatch) {
BytecodeViewer.viewer.searchBoxPane.treeRoot.add(new LDCSearchTreeNodeResult(container, resourceWorkingName, node, method, null, ldcString, ldcObject.cst.getClass().getCanonicalName()));
}
}
}
}
final Iterator<FieldNode> fields = node.fields.iterator();
while (methods.hasNext()) {
final FieldNode field = fields.next();
if (field.value instanceof String) {
BytecodeViewer.viewer.resourcePane.treeRoot.add(new LDCSearchTreeNodeResult(container, resourceWorkingName, node, null, field, String.valueOf(field.value), field.value.getClass().getCanonicalName()));
}
}
}
use of the.bytecode.club.bytecodeviewer.searching.LDCSearchTreeNodeResult in project bytecode-viewer by Konloch.
the class RegexSearch method search.
@Override
public void search(final ResourceContainer container, final String resourceWorkingName, final ClassNode node, boolean exact) {
final Iterator<MethodNode> methods = node.methods.iterator();
final String srchText = searchText.getText();
if (srchText.isEmpty())
return;
Pattern pattern = Pattern.compile(processRegex(srchText), Pattern.MULTILINE);
while (methods.hasNext()) {
final MethodNode method = methods.next();
if (RegexInsnFinder.staticScan(node, method, pattern)) {
String desc2 = method.desc;
try {
desc2 = Type.getType(method.desc).toString();
if (desc2.equals("null"))
desc2 = method.desc;
} catch (java.lang.ArrayIndexOutOfBoundsException ignored) {
}
BytecodeViewer.viewer.searchBoxPane.treeRoot.add(new LDCSearchTreeNodeResult(container, resourceWorkingName, node, method, null, node.name + "." + method.name + desc2, ""));
}
}
}
Aggregations