mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-09-24 21:51:32 +00:00
AS3 Highligter - highlight external properties
This commit is contained in:
@@ -20,7 +20,6 @@ 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;
|
||||
@@ -28,6 +27,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.model.ApplyTypeAVM2Item;
|
||||
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;
|
||||
@@ -61,7 +61,6 @@ 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;
|
||||
@@ -69,13 +68,10 @@ import com.jpexs.decompiler.flash.gui.TagEditorPanel;
|
||||
import com.jpexs.decompiler.flash.gui.View;
|
||||
import com.jpexs.decompiler.flash.gui.ViewMessages;
|
||||
import com.jpexs.decompiler.flash.gui.controls.JPersistentSplitPane;
|
||||
import com.jpexs.decompiler.flash.gui.editor.LinkHandler;
|
||||
import com.jpexs.decompiler.flash.gui.editor.LinkType;
|
||||
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;
|
||||
@@ -84,6 +80,8 @@ import com.jpexs.decompiler.flash.search.ABCSearchResult;
|
||||
import com.jpexs.decompiler.flash.search.ActionScriptSearch;
|
||||
import com.jpexs.decompiler.flash.search.ScriptSearchListener;
|
||||
import com.jpexs.decompiler.flash.search.ScriptSearchResult;
|
||||
import com.jpexs.decompiler.flash.simpleparser.LinkHandler;
|
||||
import com.jpexs.decompiler.flash.simpleparser.LinkType;
|
||||
import com.jpexs.decompiler.flash.tags.ABCContainerTag;
|
||||
import com.jpexs.decompiler.flash.tags.Tag;
|
||||
import com.jpexs.decompiler.flash.timeline.AS3Package;
|
||||
@@ -92,6 +90,7 @@ 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.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.TypeItem;
|
||||
import com.jpexs.helpers.CancellableWorker;
|
||||
import com.jpexs.helpers.Helper;
|
||||
@@ -122,6 +121,8 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import javax.swing.AbstractAction;
|
||||
@@ -148,7 +149,6 @@ import javax.swing.event.EventListenerList;
|
||||
import javax.swing.event.TableModelListener;
|
||||
import javax.swing.event.TreeModelEvent;
|
||||
import javax.swing.event.TreeModelListener;
|
||||
import javax.swing.text.Highlighter;
|
||||
import javax.swing.tree.TreePath;
|
||||
import jsyntaxpane.DefaultSyntaxKit;
|
||||
import jsyntaxpane.Token;
|
||||
@@ -903,6 +903,46 @@ public class ABCPanel extends JPanel implements ItemListener, SearchListener<Scr
|
||||
}
|
||||
}
|
||||
|
||||
private void hilightScriptClassTrait(ABC newAbc, int scriptIndex, int classIndex, Integer traitIndex) {
|
||||
Runnable setTrait = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
decompiledTextArea.removeScriptListener(this);
|
||||
decompiledTextArea.setClassIndex(classIndex);
|
||||
if (traitIndex != null) {
|
||||
decompiledTextArea.gotoTrait(traitIndex);
|
||||
} else {
|
||||
decompiledTextArea.gotoClassHeader();
|
||||
}
|
||||
Timer tim = new Timer();
|
||||
tim.schedule(new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
Main.getMainFrame().getPanel().setLoadingScrollPosEnabled(true);
|
||||
}
|
||||
}, 500);
|
||||
}
|
||||
};
|
||||
|
||||
Main.getMainFrame().getPanel().setLoadingScrollPosEnabled(false);
|
||||
if (decompiledTextArea.getScriptIndex() == scriptIndex
|
||||
&& (decompiledTextArea.getClassIndex() == classIndex || classIndex == -1)
|
||||
&& abc == newAbc) {
|
||||
setTrait.run();
|
||||
} else {
|
||||
decompiledTextArea.addScriptListener(setTrait);
|
||||
String scriptName;
|
||||
if (classIndex > -1) {
|
||||
scriptName = newAbc.instance_info.get(classIndex).getName(newAbc.constants).getNameWithNamespace(newAbc.constants, true).toPrintableString(true);
|
||||
} else if (scriptIndex > -1) {
|
||||
scriptName = newAbc.script_info.get(classIndex).getSimplePackName(newAbc).toPrintableString(true);
|
||||
} else {
|
||||
scriptName = "";
|
||||
}
|
||||
hilightScript(newAbc.getOpenable(), scriptName);
|
||||
}
|
||||
}
|
||||
|
||||
public ABCPanel(MainPanel mainPanel) {
|
||||
|
||||
this.mainPanel = mainPanel;
|
||||
@@ -913,22 +953,7 @@ public class ABCPanel extends JPanel implements ItemListener, SearchListener<Scr
|
||||
|
||||
decompiledTextArea.setLinkHandler(new LinkHandler() {
|
||||
@Override
|
||||
public LinkType getLinkType(Token token) {
|
||||
return hasDeclaration(token);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleLink(Token token) {
|
||||
gotoDeclaration(token.start);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Highlighter.HighlightPainter linkPainter() {
|
||||
return decompiledTextArea.linkPainter();
|
||||
}
|
||||
|
||||
@Override
|
||||
public LinkType getExternalTypeLinkType(String className) {
|
||||
public LinkType getClassLinkType(String className) {
|
||||
AbcIndexing.ClassIndex ci = abc.getSwf().getAbcIndex().findClass(new TypeItem(className), abc, decompiledTextArea.getScriptIndex());
|
||||
if (ci == null) {
|
||||
|
||||
@@ -958,7 +983,18 @@ public class ABCPanel extends JPanel implements ItemListener, SearchListener<Scr
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleExternalTypeLink(String scriptName) {
|
||||
public boolean traitExists(String className, String traitName) {
|
||||
Reference<Boolean> foundStatic = new Reference<>(null);
|
||||
AbcIndexing.TraitIndex ti = abc.getSwf().getAbcIndex().findProperty(new AbcIndexing.PropertyDef(traitName, new TypeItem(className), abc, -1),
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
foundStatic);
|
||||
return ti != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleClassLink(String scriptName) {
|
||||
Reference<SWF> swfRef = new Reference<>(null);
|
||||
AbcIndexing.ClassIndex ci = abc.getSwf().getAbcIndex().findClass(new TypeItem(scriptName), abc, decompiledTextArea.getScriptIndex());
|
||||
if (ci == null) {
|
||||
@@ -978,9 +1014,122 @@ public class ABCPanel extends JPanel implements ItemListener, SearchListener<Scr
|
||||
}
|
||||
|
||||
hilightScript(swfRef.getVal(), scriptName);
|
||||
|
||||
//other file
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleTraitLink(String className, String traitName) {
|
||||
Reference<Boolean> foundStatic = new Reference<>(null);
|
||||
AbcIndexing.TraitIndex ti = abc.getSwf().getAbcIndex().findProperty(new AbcIndexing.PropertyDef(traitName, new TypeItem(className), abc, -1),
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
foundStatic);
|
||||
if (ti.objType instanceof TypeItem) {
|
||||
AbcIndexing.ClassIndex ci = abc.getSwf().getAbcIndex().findClass(ti.objType, abc, decompiledTextArea.getScriptIndex());
|
||||
int i = 0;
|
||||
Integer traitIndex = null;
|
||||
for (Trait t : ci.abc.class_info.get(ci.index).static_traits.traits) {
|
||||
if (t == ti.trait) {
|
||||
traitIndex = i;
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
if (traitIndex == null) {
|
||||
for (Trait t : ci.abc.instance_info.get(ci.index).instance_traits.traits) {
|
||||
if (t == ti.trait) {
|
||||
traitIndex = i;
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
if (traitIndex != null) {
|
||||
hilightScriptClassTrait(ti.abc, ti.scriptIndex, ci.index, traitIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTraitType(String className, String traitName) {
|
||||
Reference<Boolean> foundStatic = new Reference<>(null);
|
||||
AbcIndexing.TraitIndex ti = abc.getSwf().getAbcIndex().findProperty(new AbcIndexing.PropertyDef(traitName, new TypeItem(className), abc, -1),
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
foundStatic);
|
||||
if (ti == null) {
|
||||
return null;
|
||||
}
|
||||
if (ti.returnType instanceof ApplyTypeAVM2Item) {
|
||||
ApplyTypeAVM2Item at = (ApplyTypeAVM2Item) ti.returnType;
|
||||
return at.object.toString();
|
||||
}
|
||||
return ti.returnType.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTraitSubType(String className, String traitName, int level) {
|
||||
Reference<Boolean> foundStatic = new Reference<>(null);
|
||||
AbcIndexing.TraitIndex ti = abc.getSwf().getAbcIndex().findProperty(new AbcIndexing.PropertyDef(traitName, new TypeItem(className), abc, -1),
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
foundStatic);
|
||||
if (ti == null) {
|
||||
return null;
|
||||
}
|
||||
GraphTargetItem it = ti.returnType;
|
||||
for (int i = 0; i < level; i++) {
|
||||
if (!(it instanceof ApplyTypeAVM2Item)) {
|
||||
return null;
|
||||
}
|
||||
it = ((ApplyTypeAVM2Item) it).params.get(0);
|
||||
}
|
||||
|
||||
return it.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTraitCallType(String className, String traitName) {
|
||||
Reference<Boolean> foundStatic = new Reference<>(null);
|
||||
AbcIndexing.TraitIndex ti = abc.getSwf().getAbcIndex().findProperty(new AbcIndexing.PropertyDef(traitName, new TypeItem(className), abc, -1),
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
foundStatic);
|
||||
if (ti == null) {
|
||||
return null;
|
||||
}
|
||||
if (ti.callReturnType instanceof ApplyTypeAVM2Item) {
|
||||
ApplyTypeAVM2Item at = (ApplyTypeAVM2Item) ti.callReturnType;
|
||||
return at.object.toString();
|
||||
}
|
||||
return ti.callReturnType.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTraitCallSubType(String className, String traitName, int level) {
|
||||
Reference<Boolean> foundStatic = new Reference<>(null);
|
||||
AbcIndexing.TraitIndex ti = abc.getSwf().getAbcIndex().findProperty(new AbcIndexing.PropertyDef(traitName, new TypeItem(className), abc, -1),
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
foundStatic);
|
||||
if (ti == null) {
|
||||
return null;
|
||||
}
|
||||
GraphTargetItem it = ti.callReturnType;
|
||||
for (int i = 0; i < level; i++) {
|
||||
if (!(it instanceof ApplyTypeAVM2Item)) {
|
||||
return null;
|
||||
}
|
||||
it = ((ApplyTypeAVM2Item) it).params.get(0);
|
||||
}
|
||||
|
||||
return it.toString();
|
||||
}
|
||||
|
||||
});
|
||||
decompiledTextArea.addScriptListener(new Runnable() {
|
||||
@Override
|
||||
@@ -1575,9 +1724,9 @@ 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) {
|
||||
@@ -1600,7 +1749,7 @@ public class ABCPanel extends JPanel implements ItemListener, SearchListener<Scr
|
||||
mainPanel.findOrLoadOpanableListByFilePath(Configuration.getAirSWC().getAbsolutePath(), afterOpen);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (mainPanel.getCurrentView() == MainPanel.VIEW_RESOURCES) {
|
||||
scriptNode = mainPanel.tagTree.getFullModel().getScriptsNode(swf);
|
||||
} else {
|
||||
|
||||
@@ -38,13 +38,13 @@ 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.editor.DebuggableEditorPane;
|
||||
import com.jpexs.decompiler.flash.gui.editor.LinkType;
|
||||
import com.jpexs.decompiler.flash.gui.editor.VariableMarker;
|
||||
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;
|
||||
import com.jpexs.decompiler.flash.simpleparser.LinkType;
|
||||
import com.jpexs.decompiler.flash.tags.ABCContainerTag;
|
||||
import com.jpexs.decompiler.graph.DottedChain;
|
||||
import com.jpexs.decompiler.graph.TypeItem;
|
||||
|
||||
@@ -18,6 +18,8 @@ package com.jpexs.decompiler.flash.gui.editor;
|
||||
|
||||
import com.jpexs.decompiler.flash.configuration.Configuration;
|
||||
import com.jpexs.decompiler.flash.gui.AppStrings;
|
||||
import com.jpexs.decompiler.flash.simpleparser.LinkHandler;
|
||||
import com.jpexs.decompiler.flash.simpleparser.LinkType;
|
||||
import com.jpexs.decompiler.flash.simpleparser.SimpleParser;
|
||||
import com.jpexs.helpers.Reference;
|
||||
import java.awt.Color;
|
||||
@@ -41,7 +43,6 @@ import javax.swing.text.BadLocationException;
|
||||
import javax.swing.text.DefaultHighlighter;
|
||||
import javax.swing.text.Document;
|
||||
import javax.swing.text.Element;
|
||||
import javax.swing.text.Highlighter.HighlightPainter;
|
||||
import javax.swing.text.JTextComponent;
|
||||
import javax.swing.text.Position;
|
||||
import javax.swing.text.Segment;
|
||||
@@ -49,7 +50,6 @@ import javax.swing.text.View;
|
||||
import jsyntaxpane.SyntaxDocument;
|
||||
import jsyntaxpane.SyntaxStyle;
|
||||
import jsyntaxpane.Token;
|
||||
import jsyntaxpane.TokenType;
|
||||
import jsyntaxpane.actions.ActionUtils;
|
||||
|
||||
/**
|
||||
@@ -70,16 +70,44 @@ public class LineMarkedEditorPane extends UndoFixedEditorPane implements LinkHan
|
||||
private LinkHandler linkHandler = this;
|
||||
|
||||
|
||||
private SimpleParser parser;
|
||||
private SimpleParser parser;
|
||||
|
||||
@Override
|
||||
public LinkType getExternalTypeLinkType(String className) {
|
||||
public LinkType getClassLinkType(String className) {
|
||||
return LinkType.NO_LINK;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleExternalTypeLink(String className) {
|
||||
|
||||
public boolean traitExists(String className, String traitName) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleClassLink(String className) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleTraitLink(String className, String traitName) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTraitType(String className, String traitName) {
|
||||
return "*";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTraitSubType(String className, String traitName, int level) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTraitCallType(String className, String traitName) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTraitCallSubType(String className, String traitName, int level) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static class LineMarker implements Comparable<LineMarker> {
|
||||
@@ -384,21 +412,6 @@ public class LineMarkedEditorPane extends UndoFixedEditorPane implements LinkHan
|
||||
return linkHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HighlightPainter linkPainter() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LinkType getLinkType(Token token) {
|
||||
return LinkType.NO_LINK;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleLink(Token token) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setText(String t) {
|
||||
this.lineMarkers = new HashMap<>();
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2010-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.editor;
|
||||
|
||||
import javax.swing.text.Highlighter;
|
||||
import jsyntaxpane.Token;
|
||||
|
||||
/**
|
||||
* @author JPEXS
|
||||
*/
|
||||
public interface LinkHandler {
|
||||
|
||||
public LinkType getLinkType(Token token);
|
||||
|
||||
public LinkType getExternalTypeLinkType(String className);
|
||||
|
||||
public void handleLink(Token token);
|
||||
|
||||
public void handleExternalTypeLink(String className);
|
||||
|
||||
public Highlighter.HighlightPainter linkPainter();
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
/*
|
||||
* 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.editor;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public enum LinkType {
|
||||
NO_LINK,
|
||||
LINK_THIS_SCRIPT,
|
||||
LINK_OTHER_SCRIPT,
|
||||
LINK_OTHER_FILE;
|
||||
}
|
||||
@@ -20,6 +20,7 @@ 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.LinkType;
|
||||
import com.jpexs.decompiler.flash.simpleparser.SimpleParseException;
|
||||
import com.jpexs.decompiler.flash.simpleparser.SimpleParser;
|
||||
import java.awt.BorderLayout;
|
||||
@@ -108,6 +109,9 @@ public class VariableMarker implements SyntaxComponent, CaretListener, PropertyC
|
||||
private List<String> externalTypes = new ArrayList<>();
|
||||
private Map<Integer, Integer> referenceToExternalTypeIndex = new LinkedHashMap<>();
|
||||
private Map<Integer, List<Integer>> externalTypeIndexToReference = new LinkedHashMap<>();
|
||||
private Map<String, String> simpleExternalClassNameToFullClassName = new LinkedHashMap<>();
|
||||
private Map<Integer, String> referenceToExternalTraitKey = new LinkedHashMap<>();
|
||||
private Map<String, List<Integer>> externalTraitKeyToReference = new LinkedHashMap<>();
|
||||
|
||||
private MouseMotionAdapter mouseMotionAdapter;
|
||||
|
||||
@@ -283,6 +287,27 @@ public class VariableMarker implements SyntaxComponent, CaretListener, PropertyC
|
||||
}
|
||||
sDoc.readUnlock();
|
||||
return;
|
||||
} else {
|
||||
if (referenceToExternalTraitKey.containsKey(tok.start)) {
|
||||
String traitKey = referenceToExternalTraitKey.get(tok.start);
|
||||
for (int i : externalTraitKeyToReference.get(traitKey)) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Token definitionToken = getIdentifierTokenAt(sDoc, definitionPos < 0 ? -(definitionPos + 1) : definitionPos);
|
||||
@@ -546,12 +571,32 @@ public class VariableMarker implements SyntaxComponent, CaretListener, PropertyC
|
||||
private void editorMouseMoved(MouseEvent e) {
|
||||
if (pane instanceof LineMarkedEditorPane) {
|
||||
Token token = ((LineMarkedEditorPane) pane).tokenAtPos(e.getPoint());
|
||||
if (token != null) {
|
||||
String err = errors.get(token.start);
|
||||
pane.setToolTipText(err);
|
||||
} else {
|
||||
if (token == null) {
|
||||
pane.setToolTipText(null);
|
||||
return;
|
||||
}
|
||||
String err = errors.get(token.start);
|
||||
if (err != null) {
|
||||
pane.setToolTipText(err);
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
String traitKey = referenceToExternalTraitKey.get(token.start);
|
||||
if (traitKey != null) {
|
||||
pane.setToolTipText(traitKey);
|
||||
return;
|
||||
}
|
||||
|
||||
if (referenceToExternalTypeIndex.containsKey(token.start)) {
|
||||
String externalType = externalTypes.get(referenceToExternalTypeIndex.get(token.start));
|
||||
if (externalType != null) {
|
||||
pane.setToolTipText(externalType);
|
||||
return;
|
||||
}
|
||||
}
|
||||
*/
|
||||
pane.setToolTipText(null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -627,12 +672,34 @@ public class VariableMarker implements SyntaxComponent, CaretListener, PropertyC
|
||||
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);
|
||||
Map<Integer, String> newReferenceToExternalTraitKey = new LinkedHashMap<>();
|
||||
Map<String, List<Integer>> newExternalTraitKeyToReference = new LinkedHashMap<>();
|
||||
parser.parse(
|
||||
fullText,
|
||||
newDefinitionPosToReferences,
|
||||
newReferenceToDefinition,
|
||||
newErrors,
|
||||
newExternalTypes,
|
||||
newReferenceToExternalTypeIndex,
|
||||
newExternalTypeIndexToReference,
|
||||
((LineMarkedEditorPane) pane).getLinkHandler(),
|
||||
newReferenceToExternalTraitKey, newExternalTraitKeyToReference
|
||||
);
|
||||
|
||||
Map<String, String> newSimpleExternalClassNameToFullClassName = new LinkedHashMap<>();
|
||||
for (int i = 0; i < newExternalTypes.size(); i++) {
|
||||
String type = newExternalTypes.get(i);
|
||||
String simpleName = type.contains(".") ? type.substring(type.lastIndexOf(".") + 1) : type;
|
||||
newSimpleExternalClassNameToFullClassName.put(simpleName, type);
|
||||
}
|
||||
definitionPosToReferences = newDefinitionPosToReferences;
|
||||
referenceToDefinition = newReferenceToDefinition;
|
||||
externalTypes = newExternalTypes;
|
||||
referenceToExternalTypeIndex = newReferenceToExternalTypeIndex;
|
||||
externalTypeIndexToReference = newExternalTypeIndexToReference;
|
||||
simpleExternalClassNameToFullClassName = newSimpleExternalClassNameToFullClassName;
|
||||
referenceToExternalTraitKey = newReferenceToExternalTraitKey;
|
||||
externalTraitKeyToReference = newExternalTraitKeyToReference;
|
||||
for (SimpleParseException ex : newErrors) {
|
||||
errors.put((int) ex.position, ex.getMessage());
|
||||
}
|
||||
@@ -691,9 +758,19 @@ public class VariableMarker implements SyntaxComponent, CaretListener, PropertyC
|
||||
}
|
||||
if (referenceToExternalTypeIndex.containsKey(token.start)) {
|
||||
String externalType = externalTypes.get(referenceToExternalTypeIndex.get(token.start));
|
||||
return ((LineMarkedEditorPane) pane).getLinkHandler().getExternalTypeLinkType(externalType);
|
||||
return ((LineMarkedEditorPane) pane).getLinkHandler().getClassLinkType(externalType);
|
||||
}
|
||||
return ((LineMarkedEditorPane) pane).getLinkHandler().getLinkType(token);
|
||||
if (referenceToExternalTraitKey.containsKey(token.start)) {
|
||||
String traitKey = referenceToExternalTraitKey.get(token.start);
|
||||
//String traitName = traitKey.substring(traitKey.lastIndexOf("/") + 1);
|
||||
String className = traitKey.substring(0, traitKey.lastIndexOf("/"));
|
||||
if (simpleExternalClassNameToFullClassName.containsKey(className)) {
|
||||
className = simpleExternalClassNameToFullClassName.get(className);
|
||||
}
|
||||
return ((LineMarkedEditorPane) pane).getLinkHandler().getClassLinkType(className);
|
||||
}
|
||||
|
||||
return LinkType.NO_LINK;
|
||||
}
|
||||
|
||||
private class UnderlinedLabel extends JLabel {
|
||||
@@ -732,7 +809,8 @@ public class VariableMarker implements SyntaxComponent, CaretListener, PropertyC
|
||||
&& com.jpexs.decompiler.flash.configuration.Configuration.warningLinkTypes.get()) {
|
||||
|
||||
String externalType = externalTypes.get(referenceToExternalTypeIndex.get(token.start));
|
||||
LinkType lt = ((LineMarkedEditorPane) pane).getLinkHandler().getExternalTypeLinkType(externalType);
|
||||
|
||||
LinkType lt = ((LineMarkedEditorPane) pane).getLinkHandler().getClassLinkType(externalType);
|
||||
|
||||
if (lt == LinkType.LINK_OTHER_FILE) {
|
||||
JPanel msgPanel = new JPanel();
|
||||
@@ -811,11 +889,19 @@ public class VariableMarker implements SyntaxComponent, CaretListener, PropertyC
|
||||
goingOut = true;
|
||||
pane.setCursor(Cursor.getDefaultCursor());
|
||||
String externalType = externalTypes.get(referenceToExternalTypeIndex.get(token.start));
|
||||
((LineMarkedEditorPane) pane).getLinkHandler().handleExternalTypeLink(externalType);
|
||||
((LineMarkedEditorPane) pane).getLinkHandler().handleClassLink(externalType);
|
||||
return;
|
||||
}
|
||||
if (referenceToExternalTraitKey.containsKey(token.start)) {
|
||||
String traitKey = referenceToExternalTraitKey.get(token.start);
|
||||
String traitName = traitKey.substring(traitKey.lastIndexOf("/") + 1);
|
||||
String className = traitKey.substring(0, traitKey.lastIndexOf("/"));
|
||||
|
||||
((LineMarkedEditorPane) pane).getLinkHandler().handleLink(token);
|
||||
if (simpleExternalClassNameToFullClassName.containsKey(className)) {
|
||||
className = simpleExternalClassNameToFullClassName.get(className);
|
||||
}
|
||||
((LineMarkedEditorPane) pane).getLinkHandler().handleTraitLink(className, traitName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user