mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-09-25 02:30:44 +00:00
Added: AS3 - navigation to definition in other SWF file and also player/airglobal
This commit is contained in:
@@ -1998,7 +1998,13 @@ public class Main {
|
||||
}
|
||||
swfFile = file.getCanonicalPath();
|
||||
OpenableSourceInfo sourceInfo = new OpenableSourceInfo(null, swfFile, fileTitle);
|
||||
OpenFileResult openResult = openFile(sourceInfo);
|
||||
OpenFileResult openResult = openFile(sourceInfo, new OpenableOpened() {
|
||||
@Override
|
||||
public void opened(Openable openable) {
|
||||
executeAfterOpen.run();
|
||||
}
|
||||
}
|
||||
);
|
||||
return openResult;
|
||||
} catch (IOException ex) {
|
||||
ViewMessages.showMessageDialog(getDefaultMessagesComponent(), AppStrings.translate("open.error.cannotOpen"), AppStrings.translate("open.error"), JOptionPane.ERROR_MESSAGE);
|
||||
|
||||
@@ -238,6 +238,7 @@ import java.awt.event.KeyEvent;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
@@ -322,7 +323,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
|
||||
|
||||
private ClipboardPanel resourcesClipboardPanel;
|
||||
private ClipboardPanel tagListClipboardPanel;
|
||||
|
||||
|
||||
private final JPanel contentPanel;
|
||||
|
||||
private final JPanel displayPanel;
|
||||
@@ -435,13 +436,13 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
|
||||
private Map<Openable, ABCExplorerDialog> abcExplorerDialogs = new WeakHashMap<>();
|
||||
|
||||
private Map<SWF, BreakpointListDialog> breakpointsListDialogs = new WeakHashMap<>();
|
||||
|
||||
|
||||
private boolean loadingScrollPosEnabled = true;
|
||||
|
||||
public synchronized void setLoadingScrollPosEnabled(boolean loadingScrollPosEnabled) {
|
||||
this.loadingScrollPosEnabled = loadingScrollPosEnabled;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void savePins() {
|
||||
pinsPanel.save();
|
||||
}
|
||||
@@ -1489,7 +1490,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
|
||||
easyPanel.setSwfs(new ArrayList<>(getAllSwfs()));
|
||||
|
||||
hideWelcomeScreen();
|
||||
|
||||
|
||||
gcClipboard();
|
||||
|
||||
reload(false);
|
||||
@@ -1556,7 +1557,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void hideWelcomeScreen() {
|
||||
if (isWelcomeScreen) {
|
||||
if (currentView == VIEW_EASY) {
|
||||
@@ -1567,9 +1568,9 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
|
||||
isWelcomeScreen = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void updateUi(final Openable openable) {
|
||||
View.checkAccess();
|
||||
View.checkAccess();
|
||||
SWF swf = null;
|
||||
if (openable instanceof SWF) {
|
||||
swf = (SWF) openable;
|
||||
@@ -1602,7 +1603,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
|
||||
Thread t = new Thread() {
|
||||
@Override
|
||||
public void run() {
|
||||
while (!Thread.currentThread().isInterrupted()) {
|
||||
while (!Thread.currentThread().isInterrupted()) {
|
||||
DecompilerPool d = fSwf.getDecompilerPool();
|
||||
statusPanel.setStatus(fSwf.getFileTitle() + " " + d.getStat());
|
||||
try {
|
||||
@@ -1627,14 +1628,14 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
|
||||
isWelcomeScreen = true;
|
||||
quickTagListFindPanel.setVisible(false);
|
||||
quickTreeFindPanel.setVisible(false);
|
||||
doFilter();
|
||||
doFilter();
|
||||
}
|
||||
|
||||
mainFrame.setTitle(ApplicationInfo.applicationVerName);
|
||||
mainMenu.updateComponents(null);
|
||||
|
||||
showView(getCurrentView());
|
||||
|
||||
|
||||
if (taskThread != null) {
|
||||
taskThread.interrupt();
|
||||
taskThread = null;
|
||||
@@ -1736,7 +1737,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
|
||||
mainMenu.updateComponents(null);
|
||||
folderPreviewPanel.clear();
|
||||
folderListPanel.clear();
|
||||
previewPanel.clear();
|
||||
previewPanel.clear();
|
||||
tagInfoPanel.clear();
|
||||
dumpPreviewPanel.clear();
|
||||
|
||||
@@ -1808,45 +1809,44 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
|
||||
if (breakpointsListDialog != null) {
|
||||
breakpointsListDialog.setVisible(false);
|
||||
breakpointsListDialogs.remove(swf);
|
||||
}
|
||||
}
|
||||
int index = easyPanel.indexOf(swf);
|
||||
if (index < minEasyIndex) {
|
||||
minEasyIndex = index;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
minEasyIndex--;
|
||||
if (minEasyIndex < 0) {
|
||||
minEasyIndex = 0;
|
||||
SWF s = easyPanel.getSwfAtIndex(minEasyIndex);
|
||||
while (s != null && swfsToClose.contains(s)) {
|
||||
minEasyIndex++;
|
||||
s = easyPanel.getSwfAtIndex(minEasyIndex);
|
||||
s = easyPanel.getSwfAtIndex(minEasyIndex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
openables.remove(openableList);
|
||||
oldItem = null;
|
||||
clear();
|
||||
|
||||
|
||||
Set<SWF> newSwfs = getAllSwfs();
|
||||
|
||||
|
||||
SWF newEasySwf = null;
|
||||
if (minEasyIndex < newSwfs.size()) {
|
||||
easyPanel.setSwfIndex(minEasyIndex);
|
||||
newEasySwf = easyPanel.getSwf();
|
||||
}
|
||||
|
||||
|
||||
easyPanel.setSwfs(new ArrayList<>(newSwfs));
|
||||
easyPanel.setSwf(newEasySwf);
|
||||
|
||||
if (currentView == VIEW_EASY) {
|
||||
|
||||
if (currentView == VIEW_EASY) {
|
||||
updateUi(newEasySwf);
|
||||
} else {
|
||||
} else {
|
||||
updateUi();
|
||||
}
|
||||
|
||||
|
||||
|
||||
for (SWF swf : swfsToClose) {
|
||||
swf.clearTagSwfs();
|
||||
}
|
||||
@@ -1863,21 +1863,21 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
|
||||
|
||||
folderPreviewPanel.clear();
|
||||
folderListPanel.clear();
|
||||
previewPanel.clear();
|
||||
previewPanel.clear();
|
||||
tagInfoPanel.clear();
|
||||
dumpPreviewPanel.clear();
|
||||
|
||||
|
||||
List<List<String>> nodes;
|
||||
|
||||
|
||||
//To properly clear cached TreePaths
|
||||
nodes = View.getExpandedNodes(tagTree);
|
||||
tagTree.setModel(tagTree.getFullModel());
|
||||
View.expandTreeNodes(tagTree, nodes);
|
||||
|
||||
|
||||
nodes = View.getExpandedNodes(tagListTree);
|
||||
tagListTree.setModel(tagListTree.getFullModel());
|
||||
View.expandTreeNodes(tagListTree, nodes);
|
||||
|
||||
|
||||
doFilter();
|
||||
return true;
|
||||
}
|
||||
@@ -2699,6 +2699,25 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
|
||||
gotoScriptName(swf, scriptName);
|
||||
}
|
||||
|
||||
public void findOrLoadOpanableListByFilePath(String filePath, OpenableListLoaded executeAfterOpen) {
|
||||
for (OpenableList ol : openables) {
|
||||
String existingFilePath = ol.sourceInfo.getFile();
|
||||
if (existingFilePath == null) {
|
||||
continue;
|
||||
}
|
||||
if (new File(filePath).getAbsolutePath().equals(new File(existingFilePath).getAbsolutePath())) {
|
||||
executeAfterOpen.openableListLoaded(ol);
|
||||
return;
|
||||
}
|
||||
}
|
||||
Main.openFile(filePath, null, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
findOrLoadOpanableListByFilePath(filePath, executeAfterOpen);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void gotoScriptLine(SWF swf, String scriptName, int line, int classIndex, int traitIndex, int methodIndex, boolean pcode) {
|
||||
View.checkAccess();
|
||||
|
||||
@@ -5508,9 +5527,8 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
|
||||
} else {
|
||||
/*if (openable == null && openables.get(0) != null) {
|
||||
openable = openables.get(0).get(0);
|
||||
}*/
|
||||
|
||||
/*if (openable != null) {
|
||||
}
|
||||
if (openable != null) {
|
||||
updateUi(openable);
|
||||
}*/
|
||||
updateUi(openable);
|
||||
@@ -5545,7 +5563,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
|
||||
|
||||
@Override
|
||||
public void valueChanged(TreeSelectionEvent e) {
|
||||
JTree source = (JTree) e.getSource();
|
||||
JTree source = (JTree) e.getSource();
|
||||
valueChanged(source, source.getSelectionPath());
|
||||
}
|
||||
|
||||
@@ -5601,7 +5619,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public void clearDebuggerColors() {
|
||||
if (abcPanel != null) {
|
||||
@@ -5612,7 +5630,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
|
||||
actionPanel.decompiledEditor.removeColorMarkerOnAllLines(DecompiledEditorPane.IP_MARKER);
|
||||
actionPanel.editor.removeColorMarkerOnAllLines(DecompiledEditorPane.IP_MARKER);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static final int VIEW_RESOURCES = 0;
|
||||
|
||||
@@ -5869,7 +5887,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
|
||||
|
||||
if (treeItem instanceof SWF) {
|
||||
SWF swf = (SWF) treeItem;
|
||||
previewPanel.showImagePanel(swf, swf, -1, true, Configuration.autoPlaySwfs.get() && Configuration.autoPlayPreviews.get(), !Configuration.animateSubsprites.get(), false, !Configuration.playFrameSounds.get(), true, false, true, false, true);
|
||||
previewPanel.showImagePanel(swf, swf, -1, true, Configuration.autoPlaySwfs.get() && Configuration.autoPlayPreviews.get(), !Configuration.animateSubsprites.get(), false, !Configuration.playFrameSounds.get(), true, false, true, false, true);
|
||||
} else if ((treeItem instanceof PlaceObjectTypeTag)) {
|
||||
previewPanel.showDisplayEditTagPanel((PlaceObjectTypeTag) treeItem, frame);
|
||||
} else if (treeItem instanceof ShapeTag) {
|
||||
@@ -6164,7 +6182,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
|
||||
treeItem = ((TagScript) treeItem).getTag();
|
||||
preferScript = true;
|
||||
}
|
||||
|
||||
|
||||
if (treeItem instanceof FrameScript) {
|
||||
FrameScript fs = (FrameScript) treeItem;
|
||||
DoActionTag doAction = fs.getSingleDoActionTag();
|
||||
@@ -6175,7 +6193,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
|
||||
|
||||
folderPreviewPanel.clear();
|
||||
folderListPanel.clear();
|
||||
previewPanel.clear();
|
||||
previewPanel.clear();
|
||||
tagInfoPanel.clear();
|
||||
|
||||
previewPanel.setImageReplaceButtonVisible(false, false, false, false, false, false, false);
|
||||
@@ -6367,7 +6385,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
|
||||
folderPreviewPanel.setSelectedItems(folderItems);
|
||||
folderPreviewScrollBar.setValue(scrollValue);
|
||||
}
|
||||
|
||||
|
||||
if (loadingScrollPosEnabled) {
|
||||
View.execInEventDispatchLater(new Runnable() {
|
||||
@Override
|
||||
@@ -6378,8 +6396,6 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void repaintTree() {
|
||||
tagTree.repaint();
|
||||
tagListTree.repaint();
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Copyright (C) 2025 JPEXS
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.gui;
|
||||
|
||||
import com.jpexs.decompiler.flash.treeitems.OpenableList;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public interface OpenableListLoaded {
|
||||
public void openableListLoaded(OpenableList openableList);
|
||||
}
|
||||
@@ -20,6 +20,7 @@ import com.jpexs.debugger.flash.Variable;
|
||||
import com.jpexs.debugger.flash.VariableFlags;
|
||||
import com.jpexs.debugger.flash.VariableType;
|
||||
import com.jpexs.debugger.flash.messages.in.InGetVariable;
|
||||
import com.jpexs.decompiler.flash.SWC;
|
||||
import com.jpexs.decompiler.flash.SWF;
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
import com.jpexs.decompiler.flash.abc.ClassPath;
|
||||
@@ -27,6 +28,7 @@ import com.jpexs.decompiler.flash.abc.ScriptPack;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instructions;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.parser.script.AbcIndexing;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.parser.script.ActionScript3SimpleParser;
|
||||
import com.jpexs.decompiler.flash.abc.types.ABCException;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodBody;
|
||||
@@ -58,6 +60,8 @@ import com.jpexs.decompiler.flash.gui.FasterScrollPane;
|
||||
import com.jpexs.decompiler.flash.gui.HeaderLabel;
|
||||
import com.jpexs.decompiler.flash.gui.Main;
|
||||
import com.jpexs.decompiler.flash.gui.MainPanel;
|
||||
import com.jpexs.decompiler.flash.gui.OpenableListLoaded;
|
||||
import com.jpexs.decompiler.flash.gui.OpenableOpened;
|
||||
import com.jpexs.decompiler.flash.gui.PopupButton;
|
||||
import com.jpexs.decompiler.flash.gui.SearchListener;
|
||||
import com.jpexs.decompiler.flash.gui.SearchPanel;
|
||||
@@ -71,6 +75,7 @@ import com.jpexs.decompiler.flash.gui.editor.VariableMarker;
|
||||
import com.jpexs.decompiler.flash.gui.tagtree.AbstractTagTree;
|
||||
import com.jpexs.decompiler.flash.gui.tagtree.AbstractTagTreeModel;
|
||||
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
|
||||
import com.jpexs.decompiler.flash.helpers.hilight.Highlighting;
|
||||
import com.jpexs.decompiler.flash.importers.As3ScriptReplaceException;
|
||||
import com.jpexs.decompiler.flash.importers.As3ScriptReplaceExceptionItem;
|
||||
import com.jpexs.decompiler.flash.importers.As3ScriptReplacerInterface;
|
||||
@@ -86,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.TypeItem;
|
||||
import com.jpexs.helpers.CancellableWorker;
|
||||
import com.jpexs.helpers.Helper;
|
||||
import com.jpexs.helpers.Reference;
|
||||
@@ -207,7 +213,7 @@ public class ABCPanel extends JPanel implements ItemListener, SearchListener<Scr
|
||||
private String lastDecompiled = null;
|
||||
|
||||
private JLabel linksLabel = new JLabel("");
|
||||
|
||||
|
||||
private boolean compound = false;
|
||||
|
||||
public MainPanel getMainPanel() {
|
||||
@@ -219,7 +225,7 @@ public class ABCPanel extends JPanel implements ItemListener, SearchListener<Scr
|
||||
public ScriptPack getPack() {
|
||||
return decompiledTextArea.getScriptLeaf();
|
||||
}
|
||||
|
||||
|
||||
public void setDecompiledEditEnabled(boolean value) {
|
||||
decompiledTextArea.setEnabled(value);
|
||||
editDecompiledButton.setEnabled(value && !compound);
|
||||
@@ -906,7 +912,7 @@ public class ABCPanel extends JPanel implements ItemListener, SearchListener<Scr
|
||||
|
||||
decompiledTextArea.setLinkHandler(new LinkHandler() {
|
||||
@Override
|
||||
public LinkType isLink(Token token) {
|
||||
public LinkType getLinkType(Token token) {
|
||||
return hasDeclaration(token);
|
||||
}
|
||||
|
||||
@@ -919,6 +925,72 @@ public class ABCPanel extends JPanel implements ItemListener, SearchListener<Scr
|
||||
public Highlighter.HighlightPainter linkPainter() {
|
||||
return decompiledTextArea.linkPainter();
|
||||
}
|
||||
|
||||
@Override
|
||||
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;
|
||||
}
|
||||
if (ci.abc.getSwf() == abc.getSwf()) {
|
||||
if (ci.abc == abc
|
||||
&& ci.scriptIndex != null
|
||||
&& ci.scriptIndex == decompiledTextArea.getScriptIndex()) {
|
||||
return LinkType.LINK_THIS_SCRIPT;
|
||||
}
|
||||
|
||||
return LinkType.LINK_OTHER_SCRIPT;
|
||||
}
|
||||
return LinkType.LINK_OTHER_FILE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleExternalTypeLink(String className) {
|
||||
AbcIndexing.ClassIndex ci = abc.getSwf().getAbcIndex().findClass(new TypeItem(className), abc, decompiledTextArea.getScriptIndex());
|
||||
if (ci == null) {
|
||||
return;
|
||||
}
|
||||
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()) {
|
||||
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();
|
||||
}
|
||||
|
||||
//other file
|
||||
}
|
||||
});
|
||||
decompiledTextArea.addScriptListener(new Runnable() {
|
||||
@Override
|
||||
@@ -1180,7 +1252,7 @@ public class ABCPanel extends JPanel implements ItemListener, SearchListener<Scr
|
||||
usageFrame.setVisible(true);
|
||||
}
|
||||
}
|
||||
}, "find-usages", AppStrings.translate("abc.action.find-usages"), "control U");
|
||||
}, "find-usages", AppStrings.translate("abc.action.find-usages"), "control U");
|
||||
|
||||
CtrlClickHandler cch = new CtrlClickHandler();
|
||||
decompiledTextArea.addKeyListener(cch);
|
||||
@@ -1249,13 +1321,17 @@ public class ABCPanel extends JPanel implements ItemListener, SearchListener<Scr
|
||||
Reference<Integer> multinameIndexRef = new Reference<>(0);
|
||||
Reference<Boolean> classTrait = new Reference<>(false);
|
||||
Reference<ABC> usedAbcRef = new Reference<>(null);
|
||||
Reference<Integer> scriptIndexRef = new Reference<>(-1);
|
||||
if (getSwf() == null) {
|
||||
return LinkType.NO_LINK;
|
||||
}
|
||||
LinkType propLinkType = decompiledTextArea.getPropertyTypeAtPos(getSwf().getAbcIndex(), pos, abcIndex, classIndex, traitIndex, classTrait, multinameIndexRef, usedAbcRef, false);
|
||||
LinkType propLinkType = decompiledTextArea.getPropertyTypeAtPos(getSwf().getAbcIndex(), pos, abcIndex, classIndex, traitIndex, classTrait, multinameIndexRef, usedAbcRef, false, scriptIndexRef);
|
||||
if (propLinkType != LinkType.NO_LINK) {
|
||||
return propLinkType;
|
||||
}
|
||||
if (usedAbcRef.getVal() == abc && scriptIndexRef.getVal() == decompiledTextArea.getScriptIndex()) {
|
||||
return LinkType.LINK_THIS_SCRIPT;
|
||||
}
|
||||
return propLinkType;
|
||||
}
|
||||
ABC usedAbc = usedAbcRef.getVal();
|
||||
int multinameIndex = decompiledTextArea.getMultinameAtPos(pos, usedAbcRef);
|
||||
if (multinameIndex > -1) {
|
||||
@@ -1294,7 +1370,10 @@ public class ABCPanel extends JPanel implements ItemListener, SearchListener<Scr
|
||||
}
|
||||
}
|
||||
|
||||
return decompiledTextArea.getLocalDeclarationOfPos(pos, new Reference<>(null)) != -1 ? LinkType.LINK_OTHER_SCRIPT : LinkType.NO_LINK;
|
||||
Reference<LinkType> linkTypeRef = new Reference<>(null);
|
||||
decompiledTextArea.getLocalDeclarationOfPos(pos, new Reference<>(null), linkTypeRef);
|
||||
|
||||
return linkTypeRef.getVal();
|
||||
}
|
||||
|
||||
private void gotoDeclaration(int pos) {
|
||||
@@ -1305,8 +1384,9 @@ public class ABCPanel extends JPanel implements ItemListener, SearchListener<Scr
|
||||
Reference<Integer> traitIndex = new Reference<>(0);
|
||||
Reference<Boolean> classTrait = new Reference<>(false);
|
||||
Reference<Integer> multinameIndexRef = new Reference<>(0);
|
||||
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) != LinkType.NO_LINK) {
|
||||
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) {
|
||||
});
|
||||
return;
|
||||
@@ -1348,7 +1428,7 @@ public class ABCPanel extends JPanel implements ItemListener, SearchListener<Scr
|
||||
}
|
||||
}
|
||||
|
||||
int dpos = decompiledTextArea.getLocalDeclarationOfPos(pos, new Reference<>(null));
|
||||
int dpos = decompiledTextArea.getLocalDeclarationOfPos(pos, new Reference<>(null), new Reference<>(null));
|
||||
if (dpos > -1) {
|
||||
decompiledTextArea.setCaretPosition(dpos);
|
||||
}
|
||||
|
||||
@@ -285,16 +285,18 @@ public class DecompiledEditorPane extends DebuggableEditorPane implements CaretL
|
||||
return getMultinameAtPos(getCaretPosition(), abcUsed);
|
||||
}
|
||||
|
||||
public int getLocalDeclarationOfPos(int pos, Reference<DottedChain> type) {
|
||||
public int getLocalDeclarationOfPos(int pos, Reference<DottedChain> type, Reference<LinkType> linkTypeRef) {
|
||||
Highlighting sh = Highlighting.searchPos(highlightedText.getSpecialHighlights(), pos);
|
||||
Highlighting h = Highlighting.searchPos(highlightedText.getInstructionHighlights(), pos);
|
||||
|
||||
if (h == null) {
|
||||
linkTypeRef.setVal(LinkType.NO_LINK);
|
||||
return -1;
|
||||
}
|
||||
|
||||
List<Highlighting> tms = Highlighting.searchAllPos(highlightedText.getMethodHighlights(), pos);
|
||||
if (tms.isEmpty()) {
|
||||
linkTypeRef.setVal(LinkType.NO_LINK);
|
||||
return -1;
|
||||
}
|
||||
for (Highlighting tm : tms) {
|
||||
@@ -302,6 +304,7 @@ public class DecompiledEditorPane extends DebuggableEditorPane implements CaretL
|
||||
List<Highlighting> tm_tms = Highlighting.searchAllIndexes(highlightedText.getMethodHighlights(), tm.getProperties().index);
|
||||
//is it already declaration?
|
||||
if (h.getProperties().declaration || (sh != null && sh.getProperties().declaration)) {
|
||||
linkTypeRef.setVal(LinkType.NO_LINK);
|
||||
return -1; //no jump
|
||||
}
|
||||
|
||||
@@ -311,6 +314,7 @@ public class DecompiledEditorPane extends DebuggableEditorPane implements CaretL
|
||||
int cindex = (int) ch.getProperties().index;
|
||||
ABC abc = getABC();
|
||||
type.setVal(abc.instance_info.get(cindex).getName(abc.constants).getNameWithNamespace(abc.constants, true));
|
||||
linkTypeRef.setVal(LinkType.LINK_THIS_SCRIPT);
|
||||
return ch.startPos;
|
||||
}
|
||||
|
||||
@@ -321,6 +325,7 @@ public class DecompiledEditorPane extends DebuggableEditorPane implements CaretL
|
||||
search.localName = hData.localName;
|
||||
search.specialValue = hData.specialValue;
|
||||
if (search.isEmpty()) {
|
||||
linkTypeRef.setVal(LinkType.NO_LINK);
|
||||
return -1;
|
||||
}
|
||||
search.declaration = true;
|
||||
@@ -332,15 +337,17 @@ public class DecompiledEditorPane extends DebuggableEditorPane implements CaretL
|
||||
}
|
||||
if (rh != null) {
|
||||
type.setVal(rh.getProperties().declaredType);
|
||||
linkTypeRef.setVal(LinkType.LINK_OTHER_SCRIPT);
|
||||
return rh.startPos;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
linkTypeRef.setVal(LinkType.NO_LINK);
|
||||
return -1;
|
||||
}
|
||||
|
||||
public LinkType getPropertyTypeAtPos(AbcIndexing indexing, int pos, Reference<Integer> abcIndex, Reference<Integer> classIndex, Reference<Integer> traitIndex, Reference<Boolean> classTrait, Reference<Integer> multinameIndex, Reference<ABC> abcUsed, boolean currentSwfOnly) {
|
||||
public LinkType getPropertyTypeAtPos(AbcIndexing indexing, int pos, Reference<Integer> abcIndex, Reference<Integer> classIndex, Reference<Integer> traitIndex, Reference<Boolean> classTrait, Reference<Integer> multinameIndex, Reference<ABC> abcUsed, boolean currentSwfOnly, Reference<Integer> scriptIndexRef) {
|
||||
|
||||
int m = getMultinameAtPos(pos, true, abcUsed);
|
||||
|
||||
@@ -353,7 +360,7 @@ public class DecompiledEditorPane extends DebuggableEditorPane implements CaretL
|
||||
}*/
|
||||
SyntaxDocument sd = (SyntaxDocument) getDocument();
|
||||
Token t = sd.getTokenAt(pos + 1);
|
||||
Token lastToken = t;
|
||||
Token lastToken = t;
|
||||
Token prev;
|
||||
String propName = t.getString(sd);
|
||||
if (!(t.type == TokenType.IDENTIFIER || t.type == TokenType.KEYWORD || t.type == TokenType.REGEX)) {
|
||||
@@ -382,7 +389,8 @@ public class DecompiledEditorPane extends DebuggableEditorPane implements CaretL
|
||||
if (propertyTraitIndex == null) {
|
||||
return LinkType.NO_LINK;
|
||||
}
|
||||
|
||||
scriptIndexRef.setVal(propertyTraitIndex.scriptIndex);
|
||||
|
||||
List<ABCContainerTag> abcs = getABC().getSwf().getAbcList();
|
||||
int index = 0;
|
||||
boolean isCurrentSwf = false;
|
||||
|
||||
@@ -67,13 +67,20 @@ public class LineMarkedEditorPane extends UndoFixedEditorPane implements LinkHan
|
||||
|
||||
private boolean error = false;
|
||||
|
||||
private Token lastUnderlined = null;
|
||||
|
||||
private LinkHandler linkHandler = this;
|
||||
|
||||
private Point lastCursorPos = new Point(0, 0);
|
||||
|
||||
private SimpleParser parser;
|
||||
|
||||
@Override
|
||||
public LinkType getExternalTypeLinkType(String className) {
|
||||
return LinkType.NO_LINK;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleExternalTypeLink(String className) {
|
||||
|
||||
}
|
||||
|
||||
public static class LineMarker implements Comparable<LineMarker> {
|
||||
|
||||
@@ -383,7 +390,7 @@ public class LineMarkedEditorPane extends UndoFixedEditorPane implements LinkHan
|
||||
}
|
||||
|
||||
@Override
|
||||
public LinkType isLink(Token token) {
|
||||
public LinkType getLinkType(Token token) {
|
||||
return LinkType.NO_LINK;
|
||||
}
|
||||
|
||||
|
||||
@@ -24,9 +24,13 @@ import jsyntaxpane.Token;
|
||||
*/
|
||||
public interface LinkHandler {
|
||||
|
||||
public LinkType isLink(Token token);
|
||||
public LinkType getLinkType(Token token);
|
||||
|
||||
public LinkType getExternalTypeLinkType(String className);
|
||||
|
||||
public void handleLink(Token token);
|
||||
|
||||
public void handleExternalTypeLink(String className);
|
||||
|
||||
public Highlighter.HighlightPainter linkPainter();
|
||||
}
|
||||
|
||||
@@ -17,12 +17,21 @@
|
||||
package com.jpexs.decompiler.flash.gui.editor;
|
||||
|
||||
import com.jpexs.decompiler.flash.gui.AppStrings;
|
||||
import com.jpexs.decompiler.flash.gui.Main;
|
||||
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;
|
||||
import java.awt.Cursor;
|
||||
import java.awt.FontMetrics;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.GridBagConstraints;
|
||||
import java.awt.GridBagLayout;
|
||||
import java.awt.Insets;
|
||||
import java.awt.KeyEventPostProcessor;
|
||||
import java.awt.KeyboardFocusManager;
|
||||
import java.awt.Point;
|
||||
@@ -46,7 +55,12 @@ import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
import java.util.logging.Logger;
|
||||
import javax.swing.AbstractAction;
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.BoxLayout;
|
||||
import javax.swing.JCheckBox;
|
||||
import javax.swing.JEditorPane;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JScrollBar;
|
||||
import javax.swing.JScrollPane;
|
||||
@@ -60,6 +74,7 @@ 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;
|
||||
@@ -81,8 +96,6 @@ public class VariableMarker implements SyntaxComponent, CaretListener, PropertyC
|
||||
private static final Color DEFAULT_COLOR = new Color(0xffeedd);
|
||||
private static final Color DEFAULT_ERRORCOLOR = new Color(0xff0000);
|
||||
|
||||
private static final Color SCROLLBAR_VARIABLE_COLOR = new Color(0xb59070);
|
||||
private static final Color SCROLLBAR_ERROR_COLOR = new Color(0xff0000);
|
||||
private JEditorPane pane;
|
||||
private final Set<TokenType> tokenTypes = new HashSet<>();
|
||||
private OccurencesMarker marker;
|
||||
@@ -94,6 +107,9 @@ public class VariableMarker implements SyntaxComponent, CaretListener, PropertyC
|
||||
|
||||
private Map<Integer, List<Integer>> definitionPosToReferences = new LinkedHashMap<>();
|
||||
private Map<Integer, Integer> referenceToDefinition = new LinkedHashMap<>();
|
||||
private List<String> externalTypes = new ArrayList<>();
|
||||
private Map<Integer, Integer> referenceToExternalTypeIndex = new LinkedHashMap<>();
|
||||
private Map<Integer, List<Integer>> externalTypeIndexToReference = new LinkedHashMap<>();
|
||||
|
||||
private MouseMotionAdapter mouseMotionAdapter;
|
||||
|
||||
@@ -109,13 +125,23 @@ public class VariableMarker implements SyntaxComponent, CaretListener, PropertyC
|
||||
|
||||
private Set<Integer> occurencesPositions = new HashSet<>();
|
||||
|
||||
private UnderlinePainter underLinePainter = new UnderlinePainter(new Color(0, 0, 255), null);
|
||||
private UnderlinePainter underLineMarkOccurencesPainter = new UnderlinePainter(new Color(0, 0, 255), DEFAULT_COLOR);
|
||||
private UnderlinePainter underLineExternalPainter = new UnderlinePainter(new Color(0, 255, 0), null);
|
||||
private UnderlinePainter underLineExternalMarkOccurencesPainter = new UnderlinePainter(new Color(0, 255, 0), DEFAULT_COLOR);
|
||||
private Color basicUnderlineColor = new Color(0, 0, 255);
|
||||
private Color otherScriptUnderlineColor = new Color(0, 255, 0);
|
||||
private Color otherFileUnderlineColor = new Color(255, 0, 255);
|
||||
|
||||
private UnderlinePainter underLinePainter = new UnderlinePainter(basicUnderlineColor, null);
|
||||
private UnderlinePainter underLineMarkOccurencesPainter = new UnderlinePainter(basicUnderlineColor, DEFAULT_COLOR);
|
||||
|
||||
private UnderlinePainter underLineOtherScriptPainter = new UnderlinePainter(otherScriptUnderlineColor, null);
|
||||
private UnderlinePainter underLineOtherScriptMarkOccurencesPainter = new UnderlinePainter(otherScriptUnderlineColor, DEFAULT_COLOR);
|
||||
|
||||
private UnderlinePainter underLineOtherFilePainter = new UnderlinePainter(otherFileUnderlineColor, null);
|
||||
private UnderlinePainter underLineOtherFileMarkOccurencesPainter = new UnderlinePainter(otherFileUnderlineColor, DEFAULT_COLOR);
|
||||
|
||||
private Token lastUnderlined;
|
||||
private LinkType lastUnderlinedLinkType = LinkType.NO_LINK;
|
||||
private LinkType lastUnderlinedLinkType = LinkType.NO_LINK;
|
||||
|
||||
private boolean goingOut = false;
|
||||
|
||||
/**
|
||||
* Constructs a new Token highlighter
|
||||
@@ -131,12 +157,6 @@ public class VariableMarker implements SyntaxComponent, CaretListener, PropertyC
|
||||
public void markTokenAt(int pos) {
|
||||
SyntaxDocument doc = ActionUtils.getSyntaxDocument(pane);
|
||||
if (doc != null) {
|
||||
Token everyToken = getNearestTokenAt(doc, pos);
|
||||
if (everyToken != null) {
|
||||
if (errors.containsKey(everyToken.start)) {
|
||||
//System.err.println(errors.get(everyToken.start));
|
||||
}
|
||||
}
|
||||
Token token = getIdentifierTokenAt(doc, pos);
|
||||
removeMarkers();
|
||||
if (token != null && tokenTypes.contains(token.type)) {
|
||||
@@ -153,8 +173,10 @@ public class VariableMarker implements SyntaxComponent, CaretListener, PropertyC
|
||||
Markers.removeMarkers(pane, marker);
|
||||
Markers.removeMarkers(pane, underLinePainter);
|
||||
Markers.removeMarkers(pane, underLineMarkOccurencesPainter);
|
||||
Markers.removeMarkers(pane, underLineExternalPainter);
|
||||
Markers.removeMarkers(pane, underLineExternalMarkOccurencesPainter);
|
||||
Markers.removeMarkers(pane, underLineOtherScriptPainter);
|
||||
Markers.removeMarkers(pane, underLineOtherScriptMarkOccurencesPainter);
|
||||
Markers.removeMarkers(pane, underLineOtherFilePainter);
|
||||
Markers.removeMarkers(pane, underLineOtherFileMarkOccurencesPainter);
|
||||
occurencesPositions.clear();
|
||||
}
|
||||
|
||||
@@ -241,15 +263,38 @@ public class VariableMarker implements SyntaxComponent, CaretListener, PropertyC
|
||||
int definitionPos = tok.start;
|
||||
if (referenceToDefinition.containsKey(tok.start)) {
|
||||
definitionPos = referenceToDefinition.get(tok.start);
|
||||
} else {
|
||||
if (referenceToExternalTypeIndex.containsKey(tok.start)) {
|
||||
int typeIndex = referenceToExternalTypeIndex.get(tok.start);
|
||||
for (int i : externalTypeIndexToReference.get(typeIndex)) {
|
||||
Token referenceToken = getIdentifierTokenAt(sDoc, i);
|
||||
if (referenceToken != null) {
|
||||
Markers.SimpleMarker markerKind = marker;
|
||||
if (lastUnderlined == referenceToken) {
|
||||
if (lastUnderlinedLinkType == LinkType.LINK_OTHER_SCRIPT) {
|
||||
markerKind = underLineOtherScriptMarkOccurencesPainter;
|
||||
} else if (lastUnderlinedLinkType == LinkType.LINK_OTHER_FILE) {
|
||||
markerKind = underLineOtherFileMarkOccurencesPainter;
|
||||
} else {
|
||||
markerKind = underLineMarkOccurencesPainter;
|
||||
}
|
||||
}
|
||||
Markers.markToken(pane, referenceToken, markerKind);
|
||||
occurencesPositions.add(referenceToken.start);
|
||||
}
|
||||
}
|
||||
sDoc.readUnlock();
|
||||
return;
|
||||
}
|
||||
}
|
||||
Token definitionToken = getIdentifierTokenAt(sDoc, definitionPos < 0 ? -(definitionPos + 1) : definitionPos);
|
||||
if (definitionToken != null) {
|
||||
if (definitionPosToReferences.containsKey(definitionPos)) {
|
||||
|
||||
|
||||
Markers.SimpleMarker markerKind = marker;
|
||||
if (lastUnderlined == definitionToken) {
|
||||
if (lastUnderlinedLinkType == LinkType.LINK_OTHER_SCRIPT) {
|
||||
markerKind = underLineExternalMarkOccurencesPainter;
|
||||
markerKind = underLineOtherScriptMarkOccurencesPainter;
|
||||
} else {
|
||||
markerKind = underLineMarkOccurencesPainter;
|
||||
}
|
||||
@@ -264,7 +309,9 @@ public class VariableMarker implements SyntaxComponent, CaretListener, PropertyC
|
||||
markerKind = marker;
|
||||
if (lastUnderlined == referenceToken) {
|
||||
if (lastUnderlinedLinkType == LinkType.LINK_OTHER_SCRIPT) {
|
||||
markerKind = underLineExternalMarkOccurencesPainter;
|
||||
markerKind = underLineOtherScriptMarkOccurencesPainter;
|
||||
} else if (lastUnderlinedLinkType == LinkType.LINK_OTHER_FILE) {
|
||||
markerKind = underLineOtherFileMarkOccurencesPainter;
|
||||
} else {
|
||||
markerKind = underLineMarkOccurencesPainter;
|
||||
}
|
||||
@@ -364,8 +411,7 @@ public class VariableMarker implements SyntaxComponent, CaretListener, PropertyC
|
||||
handleLink(token);
|
||||
}
|
||||
}, "find-declaration", AppStrings.translate("abc.action.find-declaration"), "control B");
|
||||
|
||||
|
||||
|
||||
documentUpdated();
|
||||
markTokenAt(editor.getCaretPosition());
|
||||
status = Status.INSTALLING;
|
||||
@@ -399,6 +445,9 @@ public class VariableMarker implements SyntaxComponent, CaretListener, PropertyC
|
||||
}
|
||||
|
||||
private void update() {
|
||||
if (goingOut) {
|
||||
return;
|
||||
}
|
||||
if (lastCursorPos == null) {
|
||||
return;
|
||||
}
|
||||
@@ -409,9 +458,11 @@ public class VariableMarker implements SyntaxComponent, CaretListener, PropertyC
|
||||
if (t == null || lastUnderlined == null || !t.equals(lastUnderlined)) {
|
||||
MyMarkers.removeMarkers(pane, underLinePainter);
|
||||
MyMarkers.removeMarkers(pane, underLineMarkOccurencesPainter);
|
||||
MyMarkers.removeMarkers(pane, underLineExternalPainter);
|
||||
MyMarkers.removeMarkers(pane, underLineExternalMarkOccurencesPainter);
|
||||
|
||||
MyMarkers.removeMarkers(pane, underLineOtherScriptPainter);
|
||||
MyMarkers.removeMarkers(pane, underLineOtherScriptMarkOccurencesPainter);
|
||||
MyMarkers.removeMarkers(pane, underLineOtherFilePainter);
|
||||
MyMarkers.removeMarkers(pane, underLineOtherFileMarkOccurencesPainter);
|
||||
|
||||
lastUnderlinedLinkType = t == null ? LinkType.NO_LINK : getLinkType(t);
|
||||
if (t != null && lastUnderlinedLinkType != LinkType.NO_LINK) {
|
||||
lastUnderlined = t;
|
||||
@@ -432,7 +483,9 @@ public class VariableMarker implements SyntaxComponent, CaretListener, PropertyC
|
||||
Highlighter.HighlightPainter painter = underLinePainter;
|
||||
if (occurencesPositions.contains(lastUnderlined.start)) {
|
||||
if (lastUnderlinedLinkType == LinkType.LINK_OTHER_SCRIPT) {
|
||||
painter = underLineExternalMarkOccurencesPainter;
|
||||
painter = underLineOtherScriptMarkOccurencesPainter;
|
||||
} else if (lastUnderlinedLinkType == LinkType.LINK_OTHER_FILE) {
|
||||
painter = underLineOtherFileMarkOccurencesPainter;
|
||||
} else {
|
||||
painter = underLineMarkOccurencesPainter;
|
||||
}
|
||||
@@ -440,9 +493,11 @@ public class VariableMarker implements SyntaxComponent, CaretListener, PropertyC
|
||||
markTokenAt(pane.getCaretPosition());
|
||||
} else {
|
||||
if (lastUnderlinedLinkType == LinkType.LINK_OTHER_SCRIPT) {
|
||||
painter = underLineExternalPainter;
|
||||
}
|
||||
MyMarkers.markToken(pane, lastUnderlined, painter);
|
||||
painter = underLineOtherScriptPainter;
|
||||
} else if (lastUnderlinedLinkType == LinkType.LINK_OTHER_FILE) {
|
||||
painter = underLineOtherFilePainter;
|
||||
}
|
||||
MyMarkers.markToken(pane, lastUnderlined, painter);
|
||||
}
|
||||
} else {
|
||||
pane.setCursor(Cursor.getDefaultCursor());
|
||||
@@ -452,10 +507,11 @@ public class VariableMarker implements SyntaxComponent, CaretListener, PropertyC
|
||||
lastUnderlined = null;
|
||||
MyMarkers.removeMarkers(pane, underLinePainter);
|
||||
MyMarkers.removeMarkers(pane, underLineMarkOccurencesPainter);
|
||||
MyMarkers.removeMarkers(pane, underLineExternalPainter);
|
||||
MyMarkers.removeMarkers(pane, underLineExternalMarkOccurencesPainter);
|
||||
|
||||
|
||||
MyMarkers.removeMarkers(pane, underLineOtherScriptPainter);
|
||||
MyMarkers.removeMarkers(pane, underLineOtherScriptMarkOccurencesPainter);
|
||||
MyMarkers.removeMarkers(pane, underLineOtherFilePainter);
|
||||
MyMarkers.removeMarkers(pane, underLineOtherFileMarkOccurencesPainter);
|
||||
|
||||
removeMarkers();
|
||||
markTokenAt(pane.getCaretPosition());
|
||||
}
|
||||
@@ -465,6 +521,9 @@ public class VariableMarker implements SyntaxComponent, CaretListener, PropertyC
|
||||
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
if (lastCursorPos == null) {
|
||||
return;
|
||||
}
|
||||
if (ctrlDown) {
|
||||
Token t = ((LineMarkedEditorPane) pane).tokenAtPos(lastCursorPos);
|
||||
if (t != null && getLinkType(t) != LinkType.NO_LINK) {
|
||||
@@ -476,7 +535,6 @@ public class VariableMarker implements SyntaxComponent, CaretListener, PropertyC
|
||||
|
||||
@Override
|
||||
public void mouseMoved(MouseEvent e) {
|
||||
|
||||
ctrlDown = (e.getModifiersEx() & InputEvent.CTRL_DOWN_MASK) != 0;
|
||||
lastCursorPos = e.getPoint();
|
||||
update();
|
||||
@@ -533,6 +591,7 @@ public class VariableMarker implements SyntaxComponent, CaretListener, PropertyC
|
||||
@Override
|
||||
public void propertyChange(PropertyChangeEvent evt) {
|
||||
if (evt.getPropertyName().equals("document")) {
|
||||
goingOut = false;
|
||||
pane.removeCaretListener(this);
|
||||
pane.getDocument().removeDocumentListener(this);
|
||||
if (status.equals(Status.INSTALLING)) {
|
||||
@@ -564,9 +623,15 @@ public class VariableMarker implements SyntaxComponent, CaretListener, PropertyC
|
||||
Map<Integer, List<Integer>> newDefinitionPosToReferences = new LinkedHashMap<>();
|
||||
Map<Integer, Integer> newReferenceToDefinition = new LinkedHashMap<>();
|
||||
List<SimpleParseException> newErrors = new ArrayList<>();
|
||||
parser.parse(fullText, newDefinitionPosToReferences, newReferenceToDefinition, newErrors);
|
||||
List<String> newExternalTypes = new ArrayList<>();
|
||||
Map<Integer, Integer> newReferenceToExternalTypeIndex = new LinkedHashMap<>();
|
||||
Map<Integer, List<Integer>> newExternalTypeIndexToReference = new LinkedHashMap<>();
|
||||
parser.parse(fullText, newDefinitionPosToReferences, newReferenceToDefinition, newErrors, newExternalTypes, newReferenceToExternalTypeIndex, newExternalTypeIndexToReference);
|
||||
definitionPosToReferences = newDefinitionPosToReferences;
|
||||
referenceToDefinition = newReferenceToDefinition;
|
||||
externalTypes = newExternalTypes;
|
||||
referenceToExternalTypeIndex = newReferenceToExternalTypeIndex;
|
||||
externalTypeIndexToReference = newExternalTypeIndexToReference;
|
||||
for (SimpleParseException ex : newErrors) {
|
||||
errors.put((int) ex.position, ex.getMessage());
|
||||
}
|
||||
@@ -619,10 +684,41 @@ public class VariableMarker implements SyntaxComponent, CaretListener, PropertyC
|
||||
if (linkThisScript) {
|
||||
return LinkType.LINK_THIS_SCRIPT;
|
||||
}
|
||||
|
||||
if (pane.isEditable()) {
|
||||
return LinkType.NO_LINK;
|
||||
}
|
||||
return ((LineMarkedEditorPane) pane).getLinkHandler().isLink(token);
|
||||
if (referenceToExternalTypeIndex.containsKey(token.start)) {
|
||||
String externalType = externalTypes.get(referenceToExternalTypeIndex.get(token.start));
|
||||
return ((LineMarkedEditorPane) pane).getLinkHandler().getExternalTypeLinkType(externalType);
|
||||
}
|
||||
return ((LineMarkedEditorPane) pane).getLinkHandler().getLinkType(token);
|
||||
}
|
||||
|
||||
private class UnderlinedLabel extends JLabel {
|
||||
|
||||
private final Color underlineColor;
|
||||
|
||||
public UnderlinedLabel(String text, Color underlineColor) {
|
||||
super(text);
|
||||
this.underlineColor = underlineColor;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void paintComponent(Graphics g) {
|
||||
super.paintComponent(g);
|
||||
FontMetrics fm = g.getFontMetrics();
|
||||
g.setColor(underlineColor);
|
||||
g.drawLine(0, fm.getHeight() - 3, fm.stringWidth(getText()), fm.getHeight() - 3);
|
||||
}
|
||||
}
|
||||
|
||||
private class CommentLabel extends JLabel {
|
||||
|
||||
public CommentLabel(String text) {
|
||||
super(text);
|
||||
setForeground(new Color(0x339933));
|
||||
}
|
||||
}
|
||||
|
||||
public void handleLink(Token token) {
|
||||
@@ -630,10 +726,94 @@ public class VariableMarker implements SyntaxComponent, CaretListener, PropertyC
|
||||
if (definition != null && definition >= 0) {
|
||||
pane.setCaretPosition(definition);
|
||||
} else if (!pane.isEditable()) {
|
||||
|
||||
if (referenceToExternalTypeIndex.containsKey(token.start)
|
||||
&& com.jpexs.decompiler.flash.configuration.Configuration.warningLinkTypes.get()) {
|
||||
|
||||
String externalType = externalTypes.get(referenceToExternalTypeIndex.get(token.start));
|
||||
LinkType lt = ((LineMarkedEditorPane) pane).getLinkHandler().getExternalTypeLinkType(externalType);
|
||||
|
||||
if (lt == LinkType.LINK_OTHER_FILE) {
|
||||
JPanel msgPanel = new JPanel();
|
||||
msgPanel.setLayout(new BoxLayout(msgPanel, BoxLayout.Y_AXIS));
|
||||
JLabel bewareLabel = new JLabel(AppStrings.translate("message.link.clicked"));
|
||||
bewareLabel.setAlignmentX(Component.CENTER_ALIGNMENT);
|
||||
msgPanel.add(bewareLabel);
|
||||
|
||||
JLabel beware2Label = new JLabel(AppStrings.translate("message.link.bewareTypes"));
|
||||
beware2Label.setAlignmentX(Component.CENTER_ALIGNMENT);
|
||||
msgPanel.add(beware2Label);
|
||||
|
||||
JPanel linksPanel = new JPanel(new GridBagLayout());
|
||||
linksPanel.setBorder(BorderFactory.createLineBorder(Color.BLACK));
|
||||
linksPanel.setBackground(Color.white);
|
||||
GridBagConstraints gbc = new GridBagConstraints();
|
||||
gbc.anchor = GridBagConstraints.FIRST_LINE_START;
|
||||
gbc.insets = new Insets(2, 2, 2, 2);
|
||||
gbc.gridx = 0;
|
||||
gbc.gridy = 0;
|
||||
|
||||
linksPanel.add(new UnderlinedLabel(AppStrings.translate("message.link.type.currentScript.sample"), basicUnderlineColor), gbc);
|
||||
gbc.gridx++;
|
||||
linksPanel.add(new CommentLabel("//" + AppStrings.translate("message.link.type.currentScript")), gbc);
|
||||
gbc.gridx = 0;
|
||||
gbc.gridy++;
|
||||
linksPanel.add(new UnderlinedLabel(AppStrings.translate("message.link.type.otherScript.sample"), otherScriptUnderlineColor), gbc);
|
||||
gbc.gridx++;
|
||||
linksPanel.add(new CommentLabel("//" + AppStrings.translate("message.link.type.otherScript")), gbc);
|
||||
gbc.gridx = 0;
|
||||
gbc.gridy++;
|
||||
linksPanel.add(new UnderlinedLabel(AppStrings.translate("message.link.type.otherFile.sample"), otherFileUnderlineColor), gbc);
|
||||
gbc.gridx++;
|
||||
linksPanel.add(new CommentLabel("//" + AppStrings.translate("message.link.type.otherFile")), gbc);
|
||||
|
||||
gbc.gridx = 2;
|
||||
gbc.gridy = 0;
|
||||
gbc.gridheight = 3;
|
||||
gbc.weightx = 1;
|
||||
gbc.weighty = 1;
|
||||
JPanel finalPanel = new JPanel();
|
||||
finalPanel.setOpaque(false);
|
||||
linksPanel.add(finalPanel);
|
||||
|
||||
linksPanel.setAlignmentX(Component.CENTER_ALIGNMENT);
|
||||
|
||||
msgPanel.add(linksPanel);
|
||||
JLabel reallyLabel = new JLabel(AppStrings.translate("message.link.reallyGo"));
|
||||
reallyLabel.setAlignmentX(Component.CENTER_ALIGNMENT);
|
||||
msgPanel.add(reallyLabel);
|
||||
JCheckBox doNotShowAgainCheckbox = new JCheckBox(AppStrings.translate("message.confirm.donotshowagain"));
|
||||
doNotShowAgainCheckbox.setAlignmentX(Component.CENTER_ALIGNMENT);
|
||||
msgPanel.add(doNotShowAgainCheckbox);
|
||||
|
||||
int result = ViewMessages.showOptionDialog(Main.getDefaultMessagesComponent(),
|
||||
msgPanel,
|
||||
AppStrings.translate("message.warning"),
|
||||
JOptionPane.OK_CANCEL_OPTION,
|
||||
JOptionPane.WARNING_MESSAGE,
|
||||
null, null, null);
|
||||
if (doNotShowAgainCheckbox.isSelected()) {
|
||||
com.jpexs.decompiler.flash.configuration.Configuration.warningLinkTypes.set(false);
|
||||
}
|
||||
if (result != JOptionPane.OK_OPTION) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
lastUnderlined = null;
|
||||
removeErrorMarkers();
|
||||
removeMarkers();
|
||||
pane.repaint();
|
||||
|
||||
if (referenceToExternalTypeIndex.containsKey(token.start)) {
|
||||
goingOut = true;
|
||||
pane.setCursor(Cursor.getDefaultCursor());
|
||||
String externalType = externalTypes.get(referenceToExternalTypeIndex.get(token.start));
|
||||
((LineMarkedEditorPane) pane).getLinkHandler().handleExternalTypeLink(externalType);
|
||||
return;
|
||||
}
|
||||
|
||||
((LineMarkedEditorPane) pane).getLinkHandler().handleLink(token);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -619,3 +619,7 @@ config.description.snapAlignCenterAlignmentHorizontal = Enables snap align of ob
|
||||
|
||||
config.name.snapAlignCenterAlignmentVertical = Snap align vertical center alignment
|
||||
config.description.snapAlignCenterAlignmentVertical = Enables snap align of object center vertically.
|
||||
|
||||
#after 23.0.1
|
||||
config.name.warning.linkTypes = Show warning when clicking external file link
|
||||
config.name.warning.linkTypes = Warn on clicking a link in the script editor which leads to another SWF file.
|
||||
@@ -619,3 +619,8 @@ config.description.snapAlignCenterAlignmentHorizontal = Povol\u00ed p\u0159ichyc
|
||||
|
||||
config.name.snapAlignCenterAlignmentVertical = Vertik\u00e1ln\u00ed zarovn\u00e1n\u00ed st\u0159edu v p\u0159ichycen\u00ed k zarovn\u00e1n\u00ed
|
||||
config.description.snapAlignCenterAlignmentVertical = Povol\u00ed p\u0159ichycen\u00ed k zarovn\u00e1n\u00ed st\u0159edu objektu vertik\u00e1ln\u011b.
|
||||
|
||||
#after 23.0.1
|
||||
config.name.warning.linkTypes = Varovat p\u0159i kliknut\u00ed na link na extern\u00ed soubor
|
||||
config.description.warning.linkTypes = Zobrazovat varov\u00e1n\u00ed p\u0159i kliknut\u00ed na odkaz v editoru skript\u016f, kter\u00fd vede do jin\u00e9ho SWF souboru.
|
||||
|
||||
|
||||
@@ -1061,4 +1061,14 @@ contextmenu.showDetail = Show detail
|
||||
|
||||
highlighter.occurences = Mark occurences
|
||||
highlighter.currentLine = Current line
|
||||
highlighter.error = Error: %error%
|
||||
highlighter.error = Error: %error%
|
||||
|
||||
message.link.clicked = You clicked a link to other SWF file.
|
||||
message.link.bewareTypes = Beware that there are multiple link types:
|
||||
message.link.type.currentScript = Link to current script
|
||||
message.link.type.currentScript.sample = myVar
|
||||
message.link.type.otherScript = Link to other script in this SWF
|
||||
message.link.type.otherScript.sample = OtherClass
|
||||
message.link.type.otherFile = Link to other SWF file (usually playerglobal.swc)
|
||||
message.link.type.otherFile.sample = String
|
||||
message.link.reallyGo = Do you really want to go to another SWF?
|
||||
@@ -1056,4 +1056,18 @@ contextmenu.showInEasy = Zobrazit v Jednoduch\u00e9m editoru
|
||||
work.debugging.start = Spou\u0161t\u00ed se Flash content debugger
|
||||
menu.file.view.alwaysOnTop = V\u017edy navrchu
|
||||
|
||||
contextmenu.showDetail = Zobrazit detail
|
||||
contextmenu.showDetail = Zobrazit detail
|
||||
|
||||
highlighter.occurences = Ozna\u010dit v\u00fdskyty
|
||||
highlighter.currentLine = Aktu\u00e1ln\u00ed \u0159\u00e1dek
|
||||
highlighter.error = Chyba: %error%
|
||||
|
||||
message.link.clicked = Kliknul(a) jste na odkaz do jin\u00e9ho SWF souboru.
|
||||
message.link.bewareTypes = D\u00e1vejte pozor na to, \u017ee existuje v\u00edce druh\u016f odkaz\u016f:
|
||||
message.link.type.currentScript = Odkaz do aktu\u00e1ln\u00edho skriptu
|
||||
message.link.type.currentScript.sample = mojePromenna
|
||||
message.link.type.otherScript = Odkaz na jin\u00fd skript v tomto SWF
|
||||
message.link.type.otherScript.sample = JinaTrida
|
||||
message.link.type.otherFile = Odkaz do jin\u00e9ho SWF souboru (obvykle playerglobal.swc)
|
||||
message.link.type.otherFile.sample = String
|
||||
message.link.reallyGo = Opravdu chcete p\u0159ej\u00edt do jin\u00e9ho SWF?
|
||||
Reference in New Issue
Block a user