Go to definition fixes

This commit is contained in:
Jindra Petřík
2025-06-01 15:18:37 +02:00
parent c9216538be
commit 127f36b0be
5 changed files with 75 additions and 47 deletions
@@ -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<Scr
public LinkType getExternalTypeLinkType(String className) {
AbcIndexing.ClassIndex ci = abc.getSwf().getAbcIndex().findClass(new TypeItem(className), abc, decompiledTextArea.getScriptIndex());
if (ci == null) {
return LinkType.NO_LINK;
AbcIndexing.TraitIndex ti = abc.getSwf().getAbcIndex().findScriptProperty(DottedChain.parseNoSuffix(className));
if (ti == null) {
return LinkType.NO_LINK;
}
if (ti.abc.getSwf() == abc.getSwf()) {
if (ti.abc == abc
&& ti.scriptIndex == decompiledTextArea.getScriptIndex()) {
return LinkType.LINK_THIS_SCRIPT;
}
return LinkType.LINK_OTHER_SCRIPT;
}
return LinkType.LINK_OTHER_FILE;
}
if (ci.abc.getSwf() == abc.getSwf()) {
if (ci.abc == abc
@@ -945,49 +958,26 @@ public class ABCPanel extends JPanel implements ItemListener, SearchListener<Scr
}
@Override
public void handleExternalTypeLink(String className) {
AbcIndexing.ClassIndex ci = abc.getSwf().getAbcIndex().findClass(new TypeItem(className), abc, decompiledTextArea.getScriptIndex());
public void handleExternalTypeLink(String scriptName) {
Reference<SWF> 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<SWF> 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<Scr
Reference<Integer> scriptIndexRef = new Reference<>(-1);
Reference<ABC> 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<Scr
TreeItem scriptNode = null;
if (openable instanceof SWF) {
SWF swf = (SWF) openable;
SWF swf = (SWF) openable;
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())) {
hilightScript(swf, name);
return;
}
}
}
}
};
if (swf.getFile() == null && "__playerglobal".equals(swf.getFileTitle())) {
mainPanel.findOrLoadOpanableListByFilePath(Configuration.getPlayerSWC().getAbsolutePath(), afterOpen);
return;
} else if (swf.getFile() == null && "__airglobal".equals(swf.getFileTitle())) {
mainPanel.findOrLoadOpanableListByFilePath(Configuration.getAirSWC().getAbsolutePath(), afterOpen);
return;
}
if (mainPanel.getCurrentView() == MainPanel.VIEW_RESOURCES) {
scriptNode = mainPanel.tagTree.getFullModel().getScriptsNode(swf);
} else {
@@ -157,7 +157,8 @@ public class UsageFrame extends AppDialog implements MouseListener {
Main.getMainFrame().getPanel().setLoadingScrollPosEnabled(false);
if (decompiledTextArea.getScriptIndex() == icu.getScriptIndex()
&& (decompiledTextArea.getClassIndex() == icu.getClassIndex() || icu.getClassIndex() == -1) && abcPanel.abc == newAbc) {
&& (decompiledTextArea.getClassIndex() == icu.getClassIndex() || icu.getClassIndex() == -1)
&& abcPanel.abc == newAbc) {
setTrait.run();
} else {
decompiledTextArea.addScriptListener(setTrait);
@@ -169,7 +170,7 @@ public class UsageFrame extends AppDialog implements MouseListener {
} else {
scriptName = "";
}
abcPanel.hilightScript(abcPanel.getOpenable(), scriptName);
abcPanel.hilightScript(icu.getAbc().getOpenable(), scriptName);
}
}
}
@@ -32,7 +32,6 @@ import javax.swing.JPanel;
import javax.swing.JScrollBar;
import javax.swing.JScrollPane;
import javax.swing.SwingUtilities;
import javax.swing.plaf.ScrollBarUI;
import javax.swing.text.BadLocationException;
import javax.swing.text.Highlighter;
import jsyntaxpane.actions.ActionUtils;
@@ -75,6 +74,9 @@ public class HighlightsPanel extends JPanel {
for (Highlighter.Highlight highlight : editorPane.getHighlighter().getHighlights()) {
Highlighter.HighlightPainter painter = highlight.getPainter();
if ((painter instanceof UnderlinePainter) && ((UnderlinePainter) painter).getColor() == null) {
continue;
}
if (painter instanceof Markers.SimpleMarker) {
try {
int lineNum = ActionUtils.getLineNumber(editorPane, highlight.getStartOffset());
@@ -116,6 +118,9 @@ public class HighlightsPanel extends JPanel {
for (Highlighter.Highlight highlight : editorPane.getHighlighter().getHighlights()) {
Highlighter.HighlightPainter painter = highlight.getPainter();
if ((painter instanceof UnderlinePainter) && ((UnderlinePainter) painter).getColor() == null) {
continue;
}
if (painter instanceof Markers.SimpleMarker) {
try {
int lineNum = ActionUtils.getLineNumber(editorPane, highlight.getStartOffset());
@@ -175,10 +180,12 @@ public class HighlightsPanel extends JPanel {
for (Highlighter.Highlight highlight : highlights) {
Highlighter.HighlightPainter painter = highlight.getPainter();
if ((painter instanceof UnderlinePainter) && ((UnderlinePainter) painter).getColor() == null) {
continue;
}
if (painter instanceof Markers.SimpleMarker) {
Markers.SimpleMarker simpleMarker = (Markers.SimpleMarker) painter;
g.setColor(simpleMarker.getColor());
g.setColor(simpleMarker.getColor());
try {
int line = ActionUtils.getLineNumber(editorPane, highlight.getStartOffset());
@@ -41,6 +41,10 @@ public class UnderlinePainter extends OccurencesMarker {
this.underlineColor = underLineColor;
}
public Color getUnderlineColor() {
return underlineColor;
}
@Override
public void paint(Graphics g, int offs0, int offs1, Shape bounds, JTextComponent c) {
if (getColor() != null) {
@@ -22,7 +22,6 @@ import com.jpexs.decompiler.flash.gui.View;
import com.jpexs.decompiler.flash.gui.ViewMessages;
import com.jpexs.decompiler.flash.simpleparser.SimpleParseException;
import com.jpexs.decompiler.flash.simpleparser.SimpleParser;
import com.sun.java.swing.action.ViewMenu;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
@@ -74,7 +73,6 @@ import javax.swing.plaf.ScrollPaneUI;
import javax.swing.plaf.basic.BasicScrollPaneUI;
import javax.swing.text.BadLocationException;
import javax.swing.text.Highlighter;
import javax.swing.text.Segment;
import jsyntaxpane.SyntaxDocument;
import jsyntaxpane.Token;
import jsyntaxpane.TokenType;
@@ -295,6 +293,8 @@ public class VariableMarker implements SyntaxComponent, CaretListener, PropertyC
if (lastUnderlined == definitionToken) {
if (lastUnderlinedLinkType == LinkType.LINK_OTHER_SCRIPT) {
markerKind = underLineOtherScriptMarkOccurencesPainter;
} else if (lastUnderlinedLinkType == LinkType.LINK_OTHER_FILE) {
markerKind = underLineOtherFileMarkOccurencesPainter;
} else {
markerKind = underLineMarkOccurencesPainter;
}
@@ -502,6 +502,7 @@ public class VariableMarker implements SyntaxComponent, CaretListener, PropertyC
} else {
pane.setCursor(Cursor.getDefaultCursor());
}
highlightsPanel.repaint();
} else {
if (lastUnderlined != null) {
lastUnderlined = null;