From 127f36b0be60fe5818fc7b98b6145b53db0956d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=C5=99=C3=ADk?= Date: Sun, 1 Jun 2025 15:18:37 +0200 Subject: [PATCH] Go to definition fixes --- .../decompiler/flash/gui/abc/ABCPanel.java | 95 +++++++++++-------- .../decompiler/flash/gui/abc/UsageFrame.java | 5 +- .../flash/gui/editor/HighlightsPanel.java | 13 ++- .../flash/gui/editor/UnderlinePainter.java | 4 + .../flash/gui/editor/VariableMarker.java | 5 +- 5 files changed, 75 insertions(+), 47 deletions(-) diff --git a/src/com/jpexs/decompiler/flash/gui/abc/ABCPanel.java b/src/com/jpexs/decompiler/flash/gui/abc/ABCPanel.java index 7e2975acc..1574248dc 100644 --- a/src/com/jpexs/decompiler/flash/gui/abc/ABCPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/abc/ABCPanel.java @@ -91,6 +91,7 @@ import com.jpexs.decompiler.flash.treeitems.AS3ClassTreeItem; import com.jpexs.decompiler.flash.treeitems.Openable; import com.jpexs.decompiler.flash.treeitems.OpenableList; import com.jpexs.decompiler.flash.treeitems.TreeItem; +import com.jpexs.decompiler.graph.DottedChain; import com.jpexs.decompiler.graph.TypeItem; import com.jpexs.helpers.CancellableWorker; import com.jpexs.helpers.Helper; @@ -930,7 +931,19 @@ public class ABCPanel extends JPanel implements ItemListener, SearchListener swfRef = new Reference<>(null); + AbcIndexing.ClassIndex ci = abc.getSwf().getAbcIndex().findClass(new TypeItem(scriptName), abc, decompiledTextArea.getScriptIndex()); if (ci == null) { - return; + AbcIndexing.TraitIndex ti = abc.getSwf().getAbcIndex().findScriptProperty(DottedChain.parseNoSuffix(scriptName)); + if (ti == null) { + return; + } + swfRef.setVal(ti.abc.getSwf()); + } else { + //scriptName = ci.abc.instance_info.get(ci.index).getName(ci.abc.constants).getNameWithNamespace(ci.abc.constants, true).toPrintableString(true); + swfRef.setVal(ci.abc.getSwf()); } - String scriptName = ci.abc.instance_info.get(ci.index).getName(ci.abc.constants).getNameWithNamespace(ci.abc.constants, true).toPrintableString(true); - if (ci.abc.getSwf() == abc.getSwf()) { + + if (swfRef.getVal() == abc.getSwf()) { hilightScript(getOpenable(), scriptName); return; } - Reference swfRef = new Reference<>(null); - Runnable gotoScriptRunnable = new Runnable() { - @Override - public void run() { - hilightScript(swfRef.getVal(), scriptName); - } - }; - OpenableListLoaded afterOpen = new OpenableListLoaded() { - @Override - public void openableListLoaded(OpenableList openableList) { - for (Openable op : openableList.items) { - if (op instanceof SWF) { - SWF swf = (SWF) op; - if ("library.swf".equals(swf.getFileTitle())) { - swfRef.setVal(swf); - gotoScriptRunnable.run(); - return; - } - } - } - } - }; - - SWF swf = ci.abc.getSwf(); - if (swf.getFile() == null && "__playerglobal".equals(swf.getFileTitle())) { - mainPanel.findOrLoadOpanableListByFilePath(Configuration.getPlayerSWC().getAbsolutePath(), afterOpen); - } else if (swf.getFile() == null && "__airglobal".equals(swf.getFileTitle())) { - mainPanel.findOrLoadOpanableListByFilePath(Configuration.getAirSWC().getAbsolutePath(), afterOpen); - } else { - swfRef.setVal(swf); - gotoScriptRunnable.run(); - } + hilightScript(swfRef.getVal(), scriptName); //other file } @@ -1387,7 +1377,7 @@ public class ABCPanel extends JPanel implements ItemListener, SearchListener scriptIndexRef = new Reference<>(-1); Reference usedAbcRef = new Reference<>(null); if (decompiledTextArea.getPropertyTypeAtPos(getSwf().getAbcIndex(), pos, abcIndex, classIndex, traitIndex, classTrait, multinameIndexRef, usedAbcRef, false, scriptIndexRef) != LinkType.NO_LINK) { - UsageFrame.gotoUsage(ABCPanel.this, new TraitMultinameUsage(getAbcList().get(abcIndex.getVal()).getABC(), multinameIndexRef.getVal(), decompiledTextArea.getScriptLeaf().scriptIndex, classIndex.getVal(), traitIndex.getVal(), classTrait.getVal() ? TraitMultinameUsage.TRAITS_TYPE_CLASS : TraitMultinameUsage.TRAITS_TYPE_INSTANCE, null, -1) { + UsageFrame.gotoUsage(ABCPanel.this, new TraitMultinameUsage(usedAbcRef.getVal(), multinameIndexRef.getVal(), scriptIndexRef.getVal(), classIndex.getVal(), traitIndex.getVal(), classTrait.getVal() ? TraitMultinameUsage.TRAITS_TYPE_CLASS : TraitMultinameUsage.TRAITS_TYPE_INSTANCE, null, -1) { }); return; } @@ -1585,7 +1575,32 @@ public class ABCPanel extends JPanel implements ItemListener, SearchListener