#1308 Search by all P-code files

This commit is contained in:
2016-12-19 22:21:53 +01:00
parent 13db993f13
commit 11088fec36
27 changed files with 237 additions and 352 deletions
@@ -109,7 +109,7 @@ public class SearchDialog extends AppDialog {
searchInPCodeRadioButton.setSelected(false);
searchInTextsRadioButton.setSelected(false);
rbPanel.add(searchInASRadioButton);
// todo: honfika rbPanel.add(searchInPCodeRadioButton);
rbPanel.add(searchInPCodeRadioButton);
rbPanel.add(searchInTextsRadioButton);
cnt.add(rbPanel);
}
@@ -66,7 +66,6 @@ public class SearchResultsDialog<E> extends AppDialog {
buttonsPanel.add(gotoButton);
buttonsPanel.add(closeButton);
resultsList.addKeyListener(new KeyAdapter() {
@Override
public void keyReleased(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_ENTER) {
@@ -76,7 +75,6 @@ public class SearchResultsDialog<E> extends AppDialog {
});
resultsList.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
if (e.getClickCount() == 2) {
@@ -211,7 +211,7 @@ public class TextPanel extends JPanel implements TagEditorPanel {
textValue.requestFocusInWindow();
if (textTag != null && !isModified()) {
HighlightedText text = textTag.getFormattedText(false);
for (Highlighting highlight : text.specialHilights) {
for (Highlighting highlight : text.getSpecialHighlights()) {
if (highlight.getProperties().subtype == HighlightSpecialType.TEXT) {
textValue.select(highlight.startPos, highlight.startPos + highlight.len);
break;
@@ -229,7 +229,7 @@ public class TextPanel extends JPanel implements TagEditorPanel {
HighlightedText text = textTag.getFormattedText(false);
boolean allUpper = true;
for (Highlighting highlight : text.specialHilights) {
for (Highlighting highlight : text.getSpecialHighlights()) {
if (highlight.getProperties().subtype == HighlightSpecialType.TEXT) {
int hStart = highlight.startPos;
int hEnd = highlight.startPos + highlight.len;
@@ -250,7 +250,7 @@ public class TextPanel extends JPanel implements TagEditorPanel {
}
}
for (Highlighting highlight : text.specialHilights) {
for (Highlighting highlight : text.getSpecialHighlights()) {
if (highlight.getProperties().subtype == HighlightSpecialType.TEXT) {
int hStart = highlight.startPos;
int hEnd = highlight.startPos + highlight.len;
@@ -76,9 +76,7 @@ public class ASMSourceEditorPane extends DebuggableEditorPane implements CaretLi
return scriptIndex;
}
private List<Highlighting> disassembledHilights = new ArrayList<>();
private List<Highlighting> specialHilights = new ArrayList<>();
private HighlightedText highlightedText = new HighlightedText();
private final List<DocsListener> docsListeners = new ArrayList<>();
@@ -176,7 +174,7 @@ public class ASMSourceEditorPane extends DebuggableEditorPane implements CaretLi
public void hilighSpecial(HighlightSpecialType type, String specialValue) {
Highlighting h2 = null;
for (Highlighting sh : specialHilights) {
for (Highlighting sh : highlightedText.getSpecialHighlights()) {
if (type.equals(sh.getProperties().subtype)) {
if (sh.getProperties().specialValue.equals(specialValue)) {
h2 = sh;
@@ -198,7 +196,7 @@ public class ASMSourceEditorPane extends DebuggableEditorPane implements CaretLi
if (isEditable()) {
return;
}
Highlighting h2 = Highlighting.searchOffset(disassembledHilights, offset);
Highlighting h2 = Highlighting.searchOffset(highlightedText.getInstructionHighlights(), offset);
if (h2 != null) {
ignoreCarret = true;
if (h2.startPos <= getDocument().getLength()) {
@@ -304,7 +302,6 @@ public class ASMSourceEditorPane extends DebuggableEditorPane implements CaretLi
public boolean missingFloat4(Float4 value) {
return true;
}
}, abc.bodies.get(bodyIndex), abc.method_info.get(abc.bodies.get(bodyIndex).method_info));
//acode.getBytes(abc.bodies.get(bodyIndex).getCodeBytes());
abc.bodies.get(bodyIndex).setCode(acode);
@@ -328,16 +325,13 @@ public class ASMSourceEditorPane extends DebuggableEditorPane implements CaretLi
@Override
public void setText(String t) {
disassembledHilights = new ArrayList<>();
specialHilights = new ArrayList<>();
super.setText(t);
setCaretPosition(0);
setText(new HighlightedText(t));
}
public void setText(HighlightedText highlightedText) {
disassembledHilights = highlightedText.instructionHilights;
if (!disassembledHilights.isEmpty()) {
int firstPos = disassembledHilights.get(0).startPos;
this.highlightedText = highlightedText;
if (!highlightedText.getInstructionHighlights().isEmpty()) {
int firstPos = highlightedText.getInstructionHighlights().get(0).startPos;
String txt = highlightedText.text;
txt = txt.replace("\r", "");
int line = 0;
@@ -348,7 +342,7 @@ public class ASMSourceEditorPane extends DebuggableEditorPane implements CaretLi
}
firstInstrLine = line;
}
specialHilights = highlightedText.specialHilights;
super.setText(highlightedText.text);
setCaretPosition(0);
}
@@ -401,13 +395,13 @@ public class ASMSourceEditorPane extends DebuggableEditorPane implements CaretLi
}
public Highlighting getSelectedSpecial() {
return Highlighting.searchPos(specialHilights, getCaretPosition());
return Highlighting.searchPos(highlightedText.getSpecialHighlights(), getCaretPosition());
}
public long getSelectedOffset() {
int pos = getCaretPosition();
Highlighting lastH = null;
for (Highlighting h : disassembledHilights) {
for (Highlighting h : highlightedText.getInstructionHighlights()) {
if (pos < h.startPos) {
break;
}
@@ -18,7 +18,6 @@ package com.jpexs.decompiler.flash.gui.abc;
import com.jpexs.decompiler.flash.SWF;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.CachedDecompilation;
import com.jpexs.decompiler.flash.abc.ScriptPack;
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
@@ -38,6 +37,7 @@ import com.jpexs.decompiler.flash.gui.AppStrings;
import com.jpexs.decompiler.flash.gui.View;
import com.jpexs.decompiler.flash.gui.editor.DebuggableEditorPane;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.flash.helpers.HighlightedText;
import com.jpexs.decompiler.flash.helpers.hilight.HighlightData;
import com.jpexs.decompiler.flash.helpers.hilight.HighlightSpecialType;
import com.jpexs.decompiler.flash.helpers.hilight.Highlighting;
@@ -60,15 +60,7 @@ import jsyntaxpane.TokenType;
*/
public class DecompiledEditorPane extends DebuggableEditorPane implements CaretListener {
private List<Highlighting> highlights = new ArrayList<>();
private List<Highlighting> specialHighlights = new ArrayList<>();
private List<Highlighting> traitHighlights = new ArrayList<>();
private List<Highlighting> methodHighlights = new ArrayList<>();
private List<Highlighting> classHighlights = new ArrayList<>();
private HighlightedText highlightedText = new HighlightedText();
private Highlighting currentMethodHighlight;
@@ -140,9 +132,9 @@ public class DecompiledEditorPane extends DebuggableEditorPane implements CaretL
}
List<Highlighting> allh = new ArrayList<>();
for (Highlighting h : traitHighlights) {
for (Highlighting h : highlightedText.getTraitHighlights()) {
if (h.getProperties().index == lastTraitIndex) {
for (Highlighting sh : specialHighlights) {
for (Highlighting sh : highlightedText.getSpecialHighlights()) {
if (sh.startPos >= h.startPos && (sh.startPos + sh.len < h.startPos + h.len)) {
allh.add(sh);
}
@@ -150,7 +142,7 @@ public class DecompiledEditorPane extends DebuggableEditorPane implements CaretL
}
}
if (currentMethodHighlight != null) {
for (Highlighting h : specialHighlights) {
for (Highlighting h : highlightedText.getSpecialHighlights()) {
if (h.startPos >= startPos && (h.startPos + h.len < endPos)) {
allh.add(h);
}
@@ -173,9 +165,9 @@ public class DecompiledEditorPane extends DebuggableEditorPane implements CaretL
if (currentMethodHighlight == null) {
return;
}
for (Highlighting h : traitHighlights) {
for (Highlighting h : highlightedText.getTraitHighlights()) {
if (h.getProperties().index == lastTraitIndex) {
Highlighting h2 = Highlighting.searchOffset(highlights, offset, h.startPos, h.startPos + h.len);
Highlighting h2 = Highlighting.searchOffset(highlightedText.getInstructionHighlights(), offset, h.startPos, h.startPos + h.len);
if (h2 != null) {
ignoreCarret = true;
if (h2.startPos <= getDocument().getLength()) {
@@ -224,12 +216,12 @@ public class DecompiledEditorPane extends DebuggableEditorPane implements CaretL
this.isStatic = isStatic;
}
boolean success = false;
Highlighting h = Highlighting.searchPos(highlights, pos);
Highlighting h = Highlighting.searchPos(highlightedText.getInstructionHighlights(), pos);
if (h != null) {
methodCodePanel.hilighOffset(h.getProperties().offset);
success = true;
}
Highlighting sh = Highlighting.searchPos(specialHighlights, pos);
Highlighting sh = Highlighting.searchPos(highlightedText.getSpecialHighlights(), pos);
if (sh != null) {
methodCodePanel.hilighSpecial(sh.getProperties().subtype, sh.getProperties().specialValue);
success = true;
@@ -258,20 +250,20 @@ public class DecompiledEditorPane extends DebuggableEditorPane implements CaretL
}
public int getLocalDeclarationOfPos(int pos, Reference<DottedChain> type) {
Highlighting sh = Highlighting.searchPos(specialHighlights, pos);
Highlighting h = Highlighting.searchPos(highlights, pos);
Highlighting sh = Highlighting.searchPos(highlightedText.getSpecialHighlights(), pos);
Highlighting h = Highlighting.searchPos(highlightedText.getInstructionHighlights(), pos);
if (h == null) {
return -1;
}
List<Highlighting> tms = Highlighting.searchAllPos(methodHighlights, pos);
List<Highlighting> tms = Highlighting.searchAllPos(highlightedText.getMethodHighlights(), pos);
if (tms.isEmpty()) {
return -1;
}
for (Highlighting tm : tms) {
List<Highlighting> tm_tms = Highlighting.searchAllIndexes(methodHighlights, tm.getProperties().index);
List<Highlighting> tm_tms = Highlighting.searchAllIndexes(highlightedText.getMethodHighlights(), tm.getProperties().index);
//is it already declaration?
if (h.getProperties().declaration || (sh != null && sh.getProperties().declaration)) {
return -1; //no jump
@@ -279,7 +271,7 @@ public class DecompiledEditorPane extends DebuggableEditorPane implements CaretL
String lname = h.getProperties().localName;
if ("this".equals(lname)) {
Highlighting ch = Highlighting.searchPos(classHighlights, pos);
Highlighting ch = Highlighting.searchPos(highlightedText.getClassHighlights(), pos);
int cindex = (int) ch.getProperties().index;
ABC abc = getABC();
type.setVal(abc.instance_info.get(cindex).getName(abc.constants).getNameWithNamespace(abc.constants, true));
@@ -298,9 +290,9 @@ public class DecompiledEditorPane extends DebuggableEditorPane implements CaretL
search.declaration = true;
for (Highlighting tm1 : tm_tms) {
Highlighting rh = Highlighting.search(highlights, search, tm1.startPos, tm1.startPos + tm1.len);
Highlighting rh = Highlighting.search(highlightedText.getInstructionHighlights(), search, tm1.startPos, tm1.startPos + tm1.len);
if (rh == null) {
rh = Highlighting.search(specialHighlights, search, tm1.startPos, tm1.startPos + tm1.len);
rh = Highlighting.search(highlightedText.getSpecialHighlights(), search, tm1.startPos, tm1.startPos + tm1.len);
}
if (rh != null) {
type.setVal(rh.getProperties().declaredType);
@@ -414,7 +406,7 @@ public class DecompiledEditorPane extends DebuggableEditorPane implements CaretL
}
public int _getMultinameAtPos(int pos, boolean codeOnly) {
Highlighting tm = Highlighting.searchPos(methodHighlights, pos);
Highlighting tm = Highlighting.searchPos(highlightedText.getMethodHighlights(), pos);
Trait currentTrait = null;
int currentMethod = -1;
ABC abc = getABC();
@@ -423,7 +415,7 @@ public class DecompiledEditorPane extends DebuggableEditorPane implements CaretL
int mi = (int) tm.getProperties().index;
currentMethod = mi;
int bi = abc.findBodyIndex(mi);
Highlighting h = Highlighting.searchPos(highlights, pos);
Highlighting h = Highlighting.searchPos(highlightedText.getInstructionHighlights(), pos);
if (h != null) {
long highlightOffset = h.getProperties().offset;
List<AVM2Instruction> list = abc.bodies.get(bi).getCode().code;
@@ -443,7 +435,7 @@ public class DecompiledEditorPane extends DebuggableEditorPane implements CaretL
if (selIns != null) {
//long inspos = highlightOffset - selIns.offset;
if (!codeOnly && ((selIns.definition instanceof ConstructSuperIns) || (selIns.definition instanceof CallSuperIns) || (selIns.definition instanceof CallSuperVoidIns))) {
Highlighting tc = Highlighting.searchPos(classHighlights, pos);
Highlighting tc = Highlighting.searchPos(highlightedText.getClassHighlights(), pos);
if (tc != null) {
int cindex = (int) tc.getProperties().index;
if (cindex > -1) {
@@ -465,9 +457,9 @@ public class DecompiledEditorPane extends DebuggableEditorPane implements CaretL
return -1;
}
Highlighting ch = Highlighting.searchPos(classHighlights, pos);
Highlighting ch = Highlighting.searchPos(highlightedText.getClassHighlights(), pos);
if (ch != null) {
Highlighting th = Highlighting.searchPos(traitHighlights, pos);
Highlighting th = Highlighting.searchPos(highlightedText.getTraitHighlights(), pos);
if (th != null) {
currentTrait = abc.findTraitByTraitId((int) ch.getProperties().index, (int) th.getProperties().index);
}
@@ -476,7 +468,7 @@ public class DecompiledEditorPane extends DebuggableEditorPane implements CaretL
if (currentTrait instanceof TraitMethodGetterSetter) {
currentMethod = ((TraitMethodGetterSetter) currentTrait).method_info;
}
Highlighting sh = Highlighting.searchPos(specialHighlights, pos);
Highlighting sh = Highlighting.searchPos(highlightedText.getSpecialHighlights(), pos);
if (sh != null) {
switch (sh.getProperties().subtype) {
case TYPE_NAME:
@@ -530,12 +522,12 @@ public class DecompiledEditorPane extends DebuggableEditorPane implements CaretL
abcPanel.detailPanel.methodTraitPanel.methodCodePanel.setIgnoreCarret(true);
try {
classIndex = -1;
Highlighting cm = Highlighting.searchPos(classHighlights, pos);
Highlighting cm = Highlighting.searchPos(highlightedText.getClassHighlights(), pos);
if (cm != null) {
classIndex = (int) cm.getProperties().index;
}
displayClass(classIndex, script.scriptIndex);
Highlighting tm = Highlighting.searchPos(methodHighlights, pos);
Highlighting tm = Highlighting.searchPos(highlightedText.getMethodHighlights(), pos);
if (tm != null) {
String name = "";
if (classIndex > -1) {
@@ -543,7 +535,7 @@ public class DecompiledEditorPane extends DebuggableEditorPane implements CaretL
}
Trait currentTrait = null;
currentTraitHighlight = Highlighting.searchPos(traitHighlights, pos);
currentTraitHighlight = Highlighting.searchPos(highlightedText.getTraitHighlights(), pos);
if (currentTraitHighlight != null) {
lastTraitIndex = (int) currentTraitHighlight.getProperties().index;
if (classIndex != -1) {
@@ -566,7 +558,7 @@ public class DecompiledEditorPane extends DebuggableEditorPane implements CaretL
return;
}
Trait currentTrait;
currentTraitHighlight = Highlighting.searchPos(traitHighlights, pos);
currentTraitHighlight = Highlighting.searchPos(highlightedText.getTraitHighlights(), pos);
if (currentTraitHighlight != null) {
lastTraitIndex = (int) currentTraitHighlight.getProperties().index;
currentTrait = getCurrentTrait();
@@ -581,7 +573,7 @@ public class DecompiledEditorPane extends DebuggableEditorPane implements CaretL
});
abcPanel.detailPanel.setEditMode(false);
currentMethodHighlight = null;
Highlighting spec = Highlighting.searchPos(specialHighlights, pos, currentTraitHighlight.startPos, currentTraitHighlight.startPos + currentTraitHighlight.len);
Highlighting spec = Highlighting.searchPos(highlightedText.getSpecialHighlights(), pos, currentTraitHighlight.startPos, currentTraitHighlight.startPos + currentTraitHighlight.len);
if (spec != null) {
abcPanel.detailPanel.slotConstTraitPanel.hilightSpecial(spec);
}
@@ -614,9 +606,9 @@ public class DecompiledEditorPane extends DebuggableEditorPane implements CaretL
public void gotoTrait(int traitId) {
boolean isScriptInit = traitId == GraphTextWriter.TRAIT_SCRIPT_INITIALIZER;
Highlighting tc = Highlighting.searchIndex(classHighlights, classIndex);
Highlighting tc = Highlighting.searchIndex(highlightedText.getClassHighlights(), classIndex);
if (tc != null || isScriptInit) {
Highlighting th = Highlighting.searchIndex(traitHighlights, traitId, isScriptInit || tc == null ? 0 : tc.startPos, isScriptInit || tc == null ? -1 : tc.startPos + tc.len);
Highlighting th = Highlighting.searchIndex(highlightedText.getTraitHighlights(), traitId, isScriptInit || tc == null ? 0 : tc.startPos, isScriptInit || tc == null ? -1 : tc.startPos + tc.len);
int pos = 0;
if (th != null) {
if (th.len > 1) {
@@ -670,17 +662,14 @@ public class DecompiledEditorPane extends DebuggableEditorPane implements CaretL
nscript = abc.script_info.get(scriptIndex);
}
if (nscript == null) {
highlights = new ArrayList<>();
specialHighlights = new ArrayList<>();
traitHighlights = new ArrayList<>();
methodHighlights = new ArrayList<>();
highlightedText = new HighlightedText();
this.script = scriptLeaf;
return;
}
setText("// " + AppStrings.translate("pleasewait") + "...");
this.script = scriptLeaf;
CachedDecompilation cd = null;
HighlightedText cd = null;
try {
cd = SWF.getCached(scriptLeaf);
} catch (InterruptedException ex) {
@@ -688,16 +677,12 @@ public class DecompiledEditorPane extends DebuggableEditorPane implements CaretL
if (cd != null) {
String hilightedCode = cd.text;
highlights = cd.getInstructionHighlights();
specialHighlights = cd.getSpecialHighligths();
traitHighlights = cd.getTraitHighlights();
methodHighlights = cd.getMethodHighlights();
classHighlights = cd.getClassHighlights();
highlightedText = cd;
setText(hilightedCode);
if (classHighlights.size() > 0) {
if (highlightedText.getClassHighlights().size() > 0) {
try {
setCaretPosition(classHighlights.get(0).startPos);
setCaretPosition(highlightedText.getClassHighlights().get(0).startPos);
} catch (Exception ex) { //sometimes happens
//ignore
}
@@ -21,7 +21,6 @@ import com.jpexs.decompiler.flash.SWF;
import com.jpexs.decompiler.flash.action.Action;
import com.jpexs.decompiler.flash.action.ActionGraph;
import com.jpexs.decompiler.flash.action.ActionList;
import com.jpexs.decompiler.flash.action.CachedScript;
import com.jpexs.decompiler.flash.action.ConstantPoolTooBigException;
import com.jpexs.decompiler.flash.action.parser.ActionParseException;
import com.jpexs.decompiler.flash.action.parser.pcode.ASMParser;
@@ -138,16 +137,6 @@ public class ActionPanel extends JPanel implements SearchListener<ActionSearchRe
public JLabel decLabel = new HeaderLabel(AppStrings.translate("panel.decompiled"));
public List<Highlighting> decompiledHilights = new ArrayList<>();
public List<Highlighting> specialHighlights = new ArrayList<>();
public List<Highlighting> classHighlights = new ArrayList<>();
public List<Highlighting> methodHighlights = new ArrayList<>();
public List<Highlighting> disassembledHilights = new ArrayList<>();
private boolean ignoreCarret = false;
private boolean editMode = false;
@@ -168,7 +157,9 @@ public class ActionPanel extends JPanel implements SearchListener<ActionSearchRe
private HighlightedText srcConstants;
private String lastDecompiled = "";
private HighlightedText disassembledText = new HighlightedText();
private HighlightedText lastDecompiled = new HighlightedText();
private ASMSource lastASM;
@@ -213,7 +204,7 @@ public class ActionPanel extends JPanel implements SearchListener<ActionSearchRe
}
}
if (ident == null) {
Highlighting h = Highlighting.searchPos(decompiledHilights, pos);
Highlighting h = Highlighting.searchPos(lastDecompiled.getInstructionHighlights(), pos);
if (h != null) {
List<Action> list = lastCode;
Action lastIns = null;
@@ -271,14 +262,21 @@ public class ActionPanel extends JPanel implements SearchListener<ActionSearchRe
String workText = AppStrings.translate("work.searching");
String decAdd = "";
ASMSource asm = item.getValue();
if (!SWF.isCached(asm)) {
if (!pcode && !SWF.isCached(asm)) {
decAdd = ", " + AppStrings.translate("work.decompiling");
}
Main.startWork(workText + " \"" + txt + "\"" + decAdd + " - (" + pos + "/" + asms.size() + ") " + item.getKey() + "... ", worker);
try {
if (pat.matcher(SWF.getCached(asm, null).text).find()) {
found.add(new ActionSearchResult(asm, item.getKey()));
if (pcode) {
HighlightedTextWriter writer = new HighlightedTextWriter(Configuration.getCodeFormatting(), true);
asm.getASMSource(ScriptExportMode.PCODE, writer, null);
String text = writer.toString();
if (pat.matcher(text).find()) {
found.add(new ActionSearchResult(asm, pcode, item.getKey()));
}
} else if (pat.matcher(SWF.getCached(asm, null).text).find()) {
found.add(new ActionSearchResult(asm, pcode, item.getKey()));
}
} catch (InterruptedException ex) {
break;
@@ -314,17 +312,16 @@ public class ActionPanel extends JPanel implements SearchListener<ActionSearchRe
View.execInEventDispatch(() -> {
int pos = editor.getCaretPosition();
Highlighting lastH = null;
for (Highlighting h : disassembledHilights) {
for (Highlighting h : disassembledText.getInstructionHighlights()) {
if (pos < h.startPos) {
break;
}
lastH = h;
}
Long offset = lastH == null ? 0 : lastH.getProperties().offset;
disassembledHilights = text.instructionHilights;
String stripped = text.text;
setEditorText(scriptName, stripped, contentType);
Highlighting h = Highlighting.searchOffset(disassembledHilights, offset);
disassembledText = text;
setEditorText(scriptName, text.text, contentType);
Highlighting h = Highlighting.searchOffset(disassembledText.getInstructionHighlights(), offset);
if (h != null) {
if (h.startPos <= editor.getDocument().getLength()) {
editor.setCaretPosition(h.startPos);
@@ -445,19 +442,15 @@ public class ActionPanel extends JPanel implements SearchListener<ActionSearchRe
boolean decompile = Configuration.decompile.get();
if (!decompile) {
lastDecompiled = Helper.getDecompilationSkippedComment();
setDecompiledText(asm.getScriptName(), lastDecompiled);
lastDecompiled = new HighlightedText(Helper.getDecompilationSkippedComment());
setDecompiledText(asm.getScriptName(), lastDecompiled.text);
} else {
CachedScript sc = SWF.getFromCache(asm);
HighlightedText sc = SWF.getFromCache(asm);
if (sc != null) {
decompile = false;
decompiledHilights = sc.hilights;
methodHighlights = sc.methodHilights;
classHighlights = sc.classHilights;
specialHighlights = sc.specialHilights;
lastDecompiled = sc.text;
lastDecompiled = sc;
lastASM = asm;
setDecompiledText(lastASM.getScriptName(), lastDecompiled);
setDecompiledText(lastASM.getScriptName(), lastDecompiled.text);
}
}
@@ -484,14 +477,10 @@ public class ActionPanel extends JPanel implements SearchListener<ActionSearchRe
if (decompileNeeded) {
setDecompiledText("-", "// " + AppStrings.translate("work.decompiling") + "...");
CachedScript sc = SWF.getCached(asm, actions);
decompiledHilights = sc.hilights;
methodHighlights = sc.methodHilights;
classHighlights = sc.classHilights;
specialHighlights = sc.specialHilights;
lastDecompiled = sc.text;
HighlightedText sc = SWF.getCached(asm, actions);
lastDecompiled = sc;
lastASM = asm;
setDecompiledText(lastASM.getScriptName(), lastDecompiled);
setDecompiledText(lastASM.getScriptName(), lastDecompiled.text);
setDecompiledEditMode(false);
}
setEditMode(false);
@@ -528,20 +517,20 @@ public class ActionPanel extends JPanel implements SearchListener<ActionSearchRe
}
public int getLocalDeclarationOfPos(int pos) {
Highlighting sh = Highlighting.searchPos(specialHighlights, pos);
Highlighting h = Highlighting.searchPos(decompiledHilights, pos);
Highlighting sh = Highlighting.searchPos(lastDecompiled.getSpecialHighlights(), pos);
Highlighting h = Highlighting.searchPos(lastDecompiled.getInstructionHighlights(), pos);
if (h == null) {
return -1;
}
List<Highlighting> tms = Highlighting.searchAllPos(methodHighlights, pos);
List<Highlighting> tms = Highlighting.searchAllPos(lastDecompiled.getMethodHighlights(), pos);
if (tms.isEmpty()) {
return -1;
}
for (Highlighting tm : tms) {
List<Highlighting> tm_tms = Highlighting.searchAllLocalNames(methodHighlights, tm.getProperties().localName);
List<Highlighting> tm_tms = Highlighting.searchAllLocalNames(lastDecompiled.getMethodHighlights(), tm.getProperties().localName);
//is it already declaration?
if (h.getProperties().declaration || (sh != null && sh.getProperties().declaration)) {
return -1; //no jump
@@ -549,7 +538,7 @@ public class ActionPanel extends JPanel implements SearchListener<ActionSearchRe
String lname = h.getProperties().localName;
if ("this".equals(lname)) {
Highlighting ch = Highlighting.searchPos(classHighlights, pos);
Highlighting ch = Highlighting.searchPos(lastDecompiled.getClassHighlights(), pos);
// int cindex = (int) ch.getProperties().index;
return ch.startPos;
}
@@ -566,7 +555,7 @@ public class ActionPanel extends JPanel implements SearchListener<ActionSearchRe
search.declaration = true;
for (Highlighting tm1 : tm_tms) {
Highlighting rh = Highlighting.search(decompiledHilights, search, tm1.startPos, tm1.startPos + tm1.len);
Highlighting rh = Highlighting.search(lastDecompiled.getInstructionHighlights(), search, tm1.startPos, tm1.startPos + tm1.len);
if (rh != null) {
return rh.startPos;
}
@@ -586,7 +575,7 @@ public class ActionPanel extends JPanel implements SearchListener<ActionSearchRe
@Override
public boolean isLink(Token token) {
int pos = token.start;
Highlighting h = Highlighting.searchPos(decompiledHilights, pos);
Highlighting h = Highlighting.searchPos(lastDecompiled.getInstructionHighlights(), pos);
if (h != null) {
if (h.getProperties().localName != null && !h.getProperties().declaration) {
return getLocalDeclarationOfPos(pos) != -1;
@@ -778,14 +767,14 @@ public class ActionPanel extends JPanel implements SearchListener<ActionSearchRe
editor.getCaret().setVisible(true);
int pos = editor.getCaretPosition();
Highlighting lastH = null;
for (Highlighting h : disassembledHilights) {
for (Highlighting h : disassembledText.getInstructionHighlights()) {
if (pos < h.startPos) {
break;
}
lastH = h;
}
Long ofs = lastH == null ? 0 : lastH.getProperties().offset;
Highlighting h2 = Highlighting.searchOffset(decompiledHilights, ofs);
Highlighting h2 = Highlighting.searchOffset(lastDecompiled.getInstructionHighlights(), ofs);
if (h2 != null) {
ignoreCarret = true;
if (h2.startPos <= decompiledEditor.getDocument().getLength()) {
@@ -809,9 +798,9 @@ public class ActionPanel extends JPanel implements SearchListener<ActionSearchRe
}
decompiledEditor.getCaret().setVisible(true);
int pos = decompiledEditor.getCaretPosition();
Highlighting h = Highlighting.searchPos(decompiledHilights, pos);
Highlighting h = Highlighting.searchPos(lastDecompiled.getInstructionHighlights(), pos);
if (h != null) {
Highlighting h2 = Highlighting.searchOffset(disassembledHilights, h.getProperties().offset);
Highlighting h2 = Highlighting.searchOffset(disassembledText.getInstructionHighlights(), h.getProperties().offset);
if (h2 != null) {
ignoreCarret = true;
if (h2.startPos > 0 && h2.startPos < editor.getText().length()) {
@@ -888,7 +877,7 @@ public class ActionPanel extends JPanel implements SearchListener<ActionSearchRe
int lastLine = decompiledEditor.getLine();
int prefLines = lastASM.getPrefixLineCount();
if (val) {
String newText = lastASM.removePrefixAndSuffix(lastDecompiled);
String newText = lastASM.removePrefixAndSuffix(lastDecompiled.text);
setDecompiledText(lastASM.getScriptName(), newText);
if (lastLine > -1) {
if (lastLine - prefLines >= 0) {
@@ -896,8 +885,7 @@ public class ActionPanel extends JPanel implements SearchListener<ActionSearchRe
}
}
} else {
String newText = lastDecompiled;
setDecompiledText(lastASM.getScriptName(), newText);
setDecompiledText(lastASM.getScriptName(), lastDecompiled.text);
if (lastLine > -1) {
decompiledEditor.gotoLine(lastLine + prefLines + 1);
}
@@ -1060,7 +1048,11 @@ public class ActionPanel extends JPanel implements SearchListener<ActionSearchRe
decompiledEditor.setCaretPosition(0);
View.execInEventDispatchLater(() -> {
searchPanel.showQuickFindDialog(decompiledEditor);
if (item.isPcode()) {
searchPanel.showQuickFindDialog(editor);
} else {
searchPanel.showQuickFindDialog(decompiledEditor);
}
});
}
@@ -26,10 +26,13 @@ public class ActionSearchResult {
private final ASMSource src;
private final boolean pcode;
private final String path;
public ActionSearchResult(ASMSource src, String path) {
public ActionSearchResult(ASMSource src, boolean pcode, String path) {
this.src = src;
this.pcode = pcode;
this.path = path;
}
@@ -37,6 +40,10 @@ public class ActionSearchResult {
return src;
}
public boolean isPcode() {
return pcode;
}
@Override
public String toString() {
return path;
@@ -213,6 +213,7 @@ public class EnumEditor extends JComboBox<ComboBoxItem<Integer>> implements Gene
@Override
public Object getChangedValue() {
@SuppressWarnings("unchecked")
ComboBoxItem<Integer> item = (ComboBoxItem<Integer>) getSelectedItem();
int value = item.getValue();
return value;