mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-07-18 21:48:52 +00:00
Scoped script text search and search across multiple SWFs
This commit is contained in:
@@ -38,7 +38,7 @@ import java.util.logging.Logger;
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class ABCSearchResult implements Serializable {
|
||||
public class ABCSearchResult implements Serializable, ScriptSearchResult {
|
||||
|
||||
public static String STR_INSTANCE_INITIALIZER = AppResources.translate("trait.instanceinitializer");
|
||||
|
||||
|
||||
@@ -43,9 +43,15 @@ import java.util.regex.Pattern;
|
||||
*/
|
||||
public class ActionScriptSearch {
|
||||
|
||||
public List<ActionSearchResult> searchAs2(SWF swf, final String txt, boolean ignoreCase, boolean regexp, boolean pcode, ScriptSearchListener listener) {
|
||||
public List<ActionSearchResult> searchAs2(SWF swf, final String txt, boolean ignoreCase, boolean regexp, boolean pcode, ScriptSearchListener listener, Map<String, ASMSource> scope) {
|
||||
if (txt != null && !txt.isEmpty()) {
|
||||
Map<String, ASMSource> asms = swf.getASMs(false);
|
||||
Map<String, ASMSource> asms;
|
||||
if (scope == null) {
|
||||
asms = swf.getASMs(false);
|
||||
} else {
|
||||
asms = scope;
|
||||
}
|
||||
|
||||
final List<ActionSearchResult> found = new ArrayList<>();
|
||||
Pattern pat = regexp
|
||||
? Pattern.compile(txt, ignoreCase ? (Pattern.CASE_INSENSITIVE | Pattern.UNICODE_CASE) : 0)
|
||||
@@ -107,7 +113,7 @@ public class ActionScriptSearch {
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<ABCSearchResult> searchAs3(final SWF swf, final String txt, boolean ignoreCase, boolean regexp, boolean pcode, ScriptSearchListener listener) {
|
||||
public List<ABCSearchResult> searchAs3(final SWF swf, final String txt, boolean ignoreCase, boolean regexp, boolean pcode, ScriptSearchListener listener, List<ScriptPack> scope) {
|
||||
// todo: pcode seach
|
||||
if (txt != null && !txt.isEmpty()) {
|
||||
List<String> ignoredClasses = new ArrayList<>();
|
||||
@@ -118,7 +124,13 @@ public class ActionScriptSearch {
|
||||
}
|
||||
|
||||
final List<ABCSearchResult> found = Collections.synchronizedList(new ArrayList<>());
|
||||
List<ScriptPack> allpacks = swf.getAS3Packs();
|
||||
final List<ScriptPack> fscope;
|
||||
if (scope == null) {
|
||||
fscope = swf.getAS3Packs();
|
||||
} else {
|
||||
fscope = scope;
|
||||
}
|
||||
|
||||
final Pattern pat = regexp
|
||||
? Pattern.compile(txt, ignoreCase ? (Pattern.CASE_INSENSITIVE | Pattern.UNICODE_CASE) : 0)
|
||||
: Pattern.compile(Pattern.quote(txt), ignoreCase ? (Pattern.CASE_INSENSITIVE | Pattern.UNICODE_CASE) : 0);
|
||||
@@ -127,7 +139,7 @@ public class ActionScriptSearch {
|
||||
List<Future<HighlightedText>> futures = new ArrayList<>();
|
||||
try {
|
||||
loop:
|
||||
for (final ScriptPack pack : allpacks) {
|
||||
for (final ScriptPack pack : fscope) {
|
||||
pos++;
|
||||
if (!pack.isSimple && Configuration.ignoreCLikePackages.get()) {
|
||||
continue;
|
||||
@@ -146,7 +158,7 @@ public class ActionScriptSearch {
|
||||
|
||||
if (pcode) {
|
||||
if (listener != null) {
|
||||
listener.onSearch(pos, allpacks.size(), pack.getClassPath().toString());
|
||||
listener.onSearch(pos, fscope.size(), pack.getClassPath().toString());
|
||||
}
|
||||
|
||||
List<MethodId> methodInfos = new ArrayList<>();
|
||||
@@ -175,7 +187,7 @@ public class ActionScriptSearch {
|
||||
return;
|
||||
}
|
||||
if (listener != null) {
|
||||
listener.onDecompile(fpos, allpacks.size(), pack.getClassPath().toString());
|
||||
listener.onDecompile(fpos, fscope.size(), pack.getClassPath().toString());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -184,7 +196,7 @@ public class ActionScriptSearch {
|
||||
|
||||
if (!Thread.currentThread().isInterrupted()) {
|
||||
if (listener != null) {
|
||||
listener.onSearch(fpos, allpacks.size(), pack.getClassPath().toString());
|
||||
listener.onSearch(fpos, fscope.size(), pack.getClassPath().toString());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ import java.util.Map;
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class ActionSearchResult {
|
||||
public class ActionSearchResult implements ScriptSearchResult {
|
||||
|
||||
private final ASMSource src;
|
||||
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.jpexs.decompiler.flash.search;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public interface ScriptSearchResult {
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user