diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetLexIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetLexIns.java index c12453f0b..7e63e2b1b 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetLexIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetLexIns.java @@ -80,7 +80,8 @@ public class GetLexIns extends InstructionDefinition { if (localData.abcIndex != null) { String currentClassName = localData.classIndex == -1 ? null : localData.abc.instance_info.get(localData.classIndex).getName(localData.abc.constants).getNameWithNamespace(localData.abc.constants, true).toRawString(); if (currentClassName != null) { - localData.abcIndex.findPropertyTypeOrCallType(localData.abc, new TypeItem(currentClassName), multinameStr, localData.abc.constants.getMultiname(multinameIndex).namespace_index, true, true, true, type, callType); + Reference foundStatic = new Reference<>(null); + localData.abcIndex.findPropertyTypeOrCallType(localData.abc, new TypeItem(currentClassName), multinameStr, localData.abc.constants.getMultiname(multinameIndex).namespace_index, true, true, true, type, callType, foundStatic); } if (type.getVal().equals(TypeItem.UNKNOWN)) { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetPropertyIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetPropertyIns.java index 6115681f8..f03e088b6 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetPropertyIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetPropertyIns.java @@ -178,7 +178,8 @@ public class GetPropertyIns extends InstructionDefinition { if (localData.abcIndex != null) { String currentClassName = localData.classIndex == -1 ? null : localData.abc.instance_info.get(localData.classIndex).getName(localData.abc.constants).getNameWithNamespace(localData.abc.constants, true).toRawString(); if (currentClassName != null) { - localData.abcIndex.findPropertyTypeOrCallType(localData.abc, new TypeItem(currentClassName), multinameStr, localData.abc.constants.getMultiname(multiname.multinameIndex).namespace_index, true, true, true, type, callType); + Reference foundStatic = new Reference<>(null); + localData.abcIndex.findPropertyTypeOrCallType(localData.abc, new TypeItem(currentClassName), multinameStr, localData.abc.constants.getMultiname(multiname.multinameIndex).namespace_index, true, true, true, type, callType, foundStatic); } if (type.getVal().equals(TypeItem.UNKNOWN)) { GraphTargetItem ti = AbcIndexing.multinameToType(multiname.multinameIndex, localData.abc.constants); @@ -256,7 +257,8 @@ public class GetPropertyIns extends InstructionDefinition { return; } } - localData.abcIndex.findPropertyTypeOrCallType(localData.abc, receiverType, multiname.resolvedMultinameName, localData.abc.constants.getMultiname(multiname.multinameIndex).namespace_index, parentStatic, !parentStatic, false, type, callType); + Reference foundStatic = new Reference<>(null); + localData.abcIndex.findPropertyTypeOrCallType(localData.abc, receiverType, multiname.resolvedMultinameName, localData.abc.constants.getMultiname(multiname.multinameIndex).namespace_index, parentStatic, !parentStatic, false, type, callType, foundStatic); if (receiverType.equals(new TypeItem("XML")) && !type.getVal().equals(new TypeItem("Function"))) { type.setVal(new TypeItem("XMLList")); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/AVM2SourceGenerator.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/AVM2SourceGenerator.java index e95b65e1c..3c1684cb2 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/AVM2SourceGenerator.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/AVM2SourceGenerator.java @@ -2520,7 +2520,8 @@ public class AVM2SourceGenerator implements SourceGenerator { isType.setVal(false); AbcIndexing.TraitIndex sp = abc.findScriptProperty(pkg.addWithSuffix(propertyName)); if (sp == null) { - sp = abc.findProperty(new AbcIndexing.PropertyDef(propertyName, new TypeItem(pkg.addWithSuffix(obj)), abc.getSelectedAbc(), selectedNs), !instanceOnly, true, true); + Reference foundStatic = new Reference<>(null); + sp = abc.findProperty(new AbcIndexing.PropertyDef(propertyName, new TypeItem(pkg.addWithSuffix(obj)), abc.getSelectedAbc(), selectedNs), !instanceOnly, true, true, foundStatic); } if (sp != null) { if (sp.trait instanceof TraitClass) { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/AbcIndexing.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/AbcIndexing.java index d0d080158..f1553a623 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/AbcIndexing.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/AbcIndexing.java @@ -644,8 +644,8 @@ public final class AbcIndexing { * @param type Property type * @param callType Call type */ - public void findPropertyTypeOrCallType(ABC abc, GraphTargetItem cls, String propName, int ns, boolean findStatic, boolean findInstance, boolean findProtected, Reference type, Reference callType) { - TraitIndex traitIndex = findProperty(new PropertyDef(propName, cls, abc, ns), findStatic, findInstance, findProtected); + public void findPropertyTypeOrCallType(ABC abc, GraphTargetItem cls, String propName, int ns, boolean findStatic, boolean findInstance, boolean findProtected, Reference type, Reference callType, Reference foundStatic) { + TraitIndex traitIndex = findProperty(new PropertyDef(propName, cls, abc, ns), findStatic, findInstance, findProtected, foundStatic); if (traitIndex == null) { type.setVal(TypeItem.UNKNOWN); callType.setVal(TypeItem.UNKNOWN); @@ -666,8 +666,8 @@ public final class AbcIndexing { * @param findProtected Find protected namespace properties * @return Trait index or null */ - public GraphTargetItem findPropertyType(ABC abc, GraphTargetItem cls, String propName, int ns, boolean findStatic, boolean findInstance, boolean findProtected) { - TraitIndex traitIndex = findProperty(new PropertyDef(propName, cls, abc, ns), findStatic, findInstance, findProtected); + public GraphTargetItem findPropertyType(ABC abc, GraphTargetItem cls, String propName, int ns, boolean findStatic, boolean findInstance, boolean findProtected, Reference foundStatic) { + TraitIndex traitIndex = findProperty(new PropertyDef(propName, cls, abc, ns), findStatic, findInstance, findProtected, foundStatic); if (traitIndex == null) { return TypeItem.UNBOUNDED; } @@ -685,8 +685,8 @@ public final class AbcIndexing { * @param findProtected Find protected namespace properties * @return Trait index or null */ - public GraphTargetItem findPropertyCallType(ABC abc, GraphTargetItem cls, String propName, int ns, boolean findStatic, boolean findInstance, boolean findProtected) { - TraitIndex traitIndex = findProperty(new PropertyDef(propName, cls, abc, ns), findStatic, findInstance, findProtected); + public GraphTargetItem findPropertyCallType(ABC abc, GraphTargetItem cls, String propName, int ns, boolean findStatic, boolean findInstance, boolean findProtected, Reference foundStatic) { + TraitIndex traitIndex = findProperty(new PropertyDef(propName, cls, abc, ns), findStatic, findInstance, findProtected, foundStatic); if (traitIndex == null) { return TypeItem.UNBOUNDED; } @@ -761,9 +761,10 @@ public final class AbcIndexing { * @param findStatic Find static properties * @param findInstance Find instance properties * @param findProtected Find protected namespace properties + * @param foundStatic Whether result is static * @return Trait index or null */ - public TraitIndex findProperty(PropertyDef prop, boolean findStatic, boolean findInstance, boolean findProtected) { + public TraitIndex findProperty(PropertyDef prop, boolean findStatic, boolean findInstance, boolean findProtected, Reference foundStatic) { /*System.out.println("searching " + prop); for (PropertyDef p : instanceProperties.keySet()) { if (p.parent.equals(new TypeItem("tests_classes.TestConvertParent"))) { @@ -776,11 +777,12 @@ public final class AbcIndexing { if (findStatic && classProperties.containsKey(prop)) { TraitIndex ti = classProperties.get(prop); if (ti != null) { + foundStatic.setVal(true); return ti; } if (parent != null) { - TraitIndex ret = parent.findProperty(prop, findStatic, findInstance, findProtected); - if (ret != null) { + TraitIndex ret = parent.findProperty(prop, findStatic, findInstance, findProtected, foundStatic); + if (ret != null) { return ret; } } @@ -790,11 +792,12 @@ public final class AbcIndexing { if (findInstance && instanceProperties.containsKey(prop)) { TraitIndex ti = instanceProperties.get(prop); if (ti != null) { + foundStatic.setVal(false); return ti; } if (parent != null) { - TraitIndex ret = parent.findProperty(prop, findStatic, findInstance, findProtected); - if (ret != null) { + TraitIndex ret = parent.findProperty(prop, findStatic, findInstance, findProtected, foundStatic); + if (ret != null) { return ret; } } @@ -805,7 +808,7 @@ public final class AbcIndexing { if (ci != null && ci.parent != null && (prop.abc == null || prop.propNsIndex == 0)) { AbcIndexing.ClassIndex ciParent = ci.parent; DottedChain parentClass = ciParent.abc.instance_info.get(ciParent.index).getName(ciParent.abc.constants).getNameWithNamespace(ciParent.abc.constants, true); - TraitIndex pti = findProperty(new PropertyDef(prop.propName, new TypeItem(parentClass), prop.getPropNsString()), findStatic, findInstance, findProtected); + TraitIndex pti = findProperty(new PropertyDef(prop.propName, new TypeItem(parentClass), prop.getPropNsString()), findStatic, findInstance, findProtected, foundStatic); if (pti != null) { return pti; } @@ -815,14 +818,14 @@ public final class AbcIndexing { if (ci != null) { int protNs = ci.abc.instance_info.get(ci.index).protectedNS; PropertyDef prop2 = new PropertyDef(prop.propName, prop.parent, ci.abc, protNs); - TraitIndex pti = findProperty(prop2, findStatic, findInstance, false); + TraitIndex pti = findProperty(prop2, findStatic, findInstance, false, foundStatic); if (pti != null) { return pti; } } } if (parent != null) { - TraitIndex pti = parent.findProperty(prop, findStatic, findInstance, findProtected); + TraitIndex pti = parent.findProperty(prop, findStatic, findInstance, findProtected, foundStatic); if (pti != null) { return pti; } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/PropertyAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/PropertyAVM2Item.java index abdae2938..fc366c2b1 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/PropertyAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/PropertyAVM2Item.java @@ -258,7 +258,8 @@ public class PropertyAVM2Item extends AssignableAVM2Item { // however this namespace is in the ABC of the super class and not in abcIndex.getSelectedAbc() AbcIndexing.ClassIndex ci = abcIndex.findClass(objType, null, null/*FIXME?*/); int superProtectedNs = ci.abc.instance_info.get(ci.index).protectedNS; - AbcIndexing.TraitIndex sp = abcIndex.findProperty(new AbcIndexing.PropertyDef(propertyName, objType, ci.abc, superProtectedNs), false, true, true); + Reference foundStatic = new Reference<>(null); + AbcIndexing.TraitIndex sp = abcIndex.findProperty(new AbcIndexing.PropertyDef(propertyName, objType, ci.abc, superProtectedNs), false, true, true, foundStatic); if (sp != null) { objType = sp.objType; Namespace ns = sp.trait.getName(sp.abc).getNamespace(sp.abc.constants); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/TraitClass.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/TraitClass.java index 375ef643e..d500663f6 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/TraitClass.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/TraitClass.java @@ -381,7 +381,8 @@ public class TraitClass extends Trait implements TraitWithSlot { if (sIndex > -1) { int nsIndex = abc.constants.getNamespaceId(Namespace.KIND_PACKAGE, DottedChain.TOPLEVEL, sIndex, false); if (nsIndex > -1) { - convertData.thisHasDefaultToPrimitive = null == index.findProperty(new AbcIndexing.PropertyDef("toString", new TypeItem(instanceInfo.getName(abc.constants).getNameWithNamespace(abc.constants, true)), abc, nsIndex), false, true, false); + Reference foundStatic = new Reference<>(null); + convertData.thisHasDefaultToPrimitive = null == index.findProperty(new AbcIndexing.PropertyDef("toString", new TypeItem(instanceInfo.getName(abc.constants).getNameWithNamespace(abc.constants, true)), abc, nsIndex), false, true, false, foundStatic); } else { convertData.thisHasDefaultToPrimitive = true; } diff --git a/src/com/jpexs/decompiler/flash/gui/abc/ABCPanel.java b/src/com/jpexs/decompiler/flash/gui/abc/ABCPanel.java index 29dceb05b..9068e849e 100644 --- a/src/com/jpexs/decompiler/flash/gui/abc/ABCPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/abc/ABCPanel.java @@ -66,6 +66,7 @@ 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; @@ -905,7 +906,7 @@ public class ABCPanel extends JPanel implements ItemListener, SearchListener abcIndex = new Reference<>(0); @@ -1249,21 +1250,22 @@ public class ABCPanel extends JPanel implements ItemListener, SearchListener classTrait = new Reference<>(false); Reference usedAbcRef = new Reference<>(null); if (getSwf() == null) { - return false; - } - if (decompiledTextArea.getPropertyTypeAtPos(getSwf().getAbcIndex(), pos, abcIndex, classIndex, traitIndex, classTrait, multinameIndexRef, usedAbcRef)) { - return true; + return LinkType.NO_LINK; } + LinkType propLinkType = decompiledTextArea.getPropertyTypeAtPos(getSwf().getAbcIndex(), pos, abcIndex, classIndex, traitIndex, classTrait, multinameIndexRef, usedAbcRef, false); + if (propLinkType != LinkType.NO_LINK) { + return propLinkType; + } ABC usedAbc = usedAbcRef.getVal(); int multinameIndex = decompiledTextArea.getMultinameAtPos(pos, usedAbcRef); if (multinameIndex > -1) { if (multinameIndex == 0) { - return false; + return LinkType.NO_LINK; } Multiname m = usedAbc.constants.getMultiname(multinameIndex); if (m == null) { - return false; + return LinkType.NO_LINK; } if (m.kind == Multiname.TYPENAME) { //Assuming it's a Vector with single parameter multinameIndex = m.params[0]; @@ -1288,11 +1290,11 @@ public class ABCPanel extends JPanel implements ItemListener, SearchListener(null)) != -1; + return decompiledTextArea.getLocalDeclarationOfPos(pos, new Reference<>(null)) != -1 ? LinkType.LINK_OTHER_SCRIPT : LinkType.NO_LINK; } private void gotoDeclaration(int pos) { @@ -1304,7 +1306,7 @@ public class ABCPanel extends JPanel implements ItemListener, SearchListener classTrait = new Reference<>(false); Reference multinameIndexRef = new Reference<>(0); Reference usedAbcRef = new Reference<>(null); - if (decompiledTextArea.getPropertyTypeAtPos(getSwf().getAbcIndex(), pos, abcIndex, classIndex, traitIndex, classTrait, multinameIndexRef, usedAbcRef)) { + if (decompiledTextArea.getPropertyTypeAtPos(getSwf().getAbcIndex(), pos, abcIndex, classIndex, traitIndex, classTrait, multinameIndexRef, usedAbcRef, false) != 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; diff --git a/src/com/jpexs/decompiler/flash/gui/abc/DecompiledEditorPane.java b/src/com/jpexs/decompiler/flash/gui/abc/DecompiledEditorPane.java index bdd99e982..1cd3c45c7 100644 --- a/src/com/jpexs/decompiler/flash/gui/abc/DecompiledEditorPane.java +++ b/src/com/jpexs/decompiler/flash/gui/abc/DecompiledEditorPane.java @@ -38,6 +38,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.editor.DebuggableEditorPane; +import com.jpexs.decompiler.flash.gui.editor.LinkType; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; import com.jpexs.decompiler.flash.helpers.HighlightedText; import com.jpexs.decompiler.flash.helpers.hilight.HighlightData; @@ -337,14 +338,14 @@ public class DecompiledEditorPane extends DebuggableEditorPane implements CaretL } return -1; - } - - public boolean getPropertyTypeAtPos(AbcIndexing indexing, int pos, Reference abcIndex, Reference classIndex, Reference traitIndex, Reference classTrait, Reference multinameIndex, Reference abcUsed) { + } + + public LinkType getPropertyTypeAtPos(AbcIndexing indexing, int pos, Reference abcIndex, Reference classIndex, Reference traitIndex, Reference classTrait, Reference multinameIndex, Reference abcUsed, boolean currentSwfOnly) { int m = getMultinameAtPos(pos, true, abcUsed); if (indexing == null) { - return false; + return LinkType.NO_LINK; } /*int m = getMultinameAtPos(pos, true, abcUsed); if (m <= 0) { @@ -356,64 +357,68 @@ public class DecompiledEditorPane extends DebuggableEditorPane implements CaretL Token prev; String propName = t.getString(sd); if (!(t.type == TokenType.IDENTIFIER || t.type == TokenType.KEYWORD || t.type == TokenType.REGEX)) { - return false; + return LinkType.NO_LINK; } prev = sd.getPrevToken(t); if (prev == null) { - return false; + return LinkType.NO_LINK; } if (!".".equals(prev.getString(sd))) { - return false; + return LinkType.NO_LINK; } Highlighting sh = Highlighting.search(highlightedText.getSpecialHighlights(), new HighlightData(), prev.start, prev.start); if (sh == null) { - return false; + return LinkType.NO_LINK; } HighlightData data = sh.getProperties(); String parentType = data.propertyType; if (parentType.equals("*")) { - return false; + return LinkType.NO_LINK; } - AbcIndexing.TraitIndex propertyTraitIndex = indexing.findProperty(new AbcIndexing.PropertyDef(propName, new TypeItem(parentType), getABC(), data.namespaceIndex), data.isStatic, !data.isStatic, true); + Reference foundStatic = new Reference<>(null); + AbcIndexing.TraitIndex propertyTraitIndex = indexing.findProperty(new AbcIndexing.PropertyDef(propName, new TypeItem(parentType), getABC(), data.namespaceIndex), true, !data.isStatic, true, foundStatic); if (propertyTraitIndex == null) { - return false; + return LinkType.NO_LINK; } List abcs = getABC().getSwf().getAbcList(); int index = 0; - boolean found = false; + boolean isCurrentSwf = false; for (ABCContainerTag cnt : abcs) { if (cnt.getABC() == propertyTraitIndex.abc) { abcIndex.setVal(index); - found = true; + isCurrentSwf = true; break; } index++; } - if (!found) { - return false; + + if (currentSwfOnly) { + if (!isCurrentSwf) { + return LinkType.NO_LINK; + } } abcUsed.setVal(propertyTraitIndex.abc); index = propertyTraitIndex.abc.findClassByName(propertyTraitIndex.objType.toString()); if (index == -1) { - return false; + return LinkType.NO_LINK; } classIndex.setVal(index); - classTrait.setVal(data.isStatic); + classTrait.setVal(foundStatic.getVal()); Traits ts; - if (data.isStatic) { + if (foundStatic.getVal()) { ts = propertyTraitIndex.abc.class_info.get(index).static_traits; } else { ts = propertyTraitIndex.abc.instance_info.get(index).instance_traits; } - - found = false; + + boolean found = false; for (int i = 0; i < ts.traits.size(); i++) { if (ts.traits.get(i) == propertyTraitIndex.trait) { traitIndex.setVal(i); @@ -422,12 +427,12 @@ public class DecompiledEditorPane extends DebuggableEditorPane implements CaretL } } if (!found) { - return false; + return LinkType.NO_LINK; } multinameIndex.setVal(propertyTraitIndex.trait.name_index); - return true; + return isCurrentSwf ? LinkType.LINK_OTHER_SCRIPT : LinkType.LINK_OTHER_FILE; /* if (t.type != TokenType.IDENTIFIER && t.type != TokenType.KEYWORD && t.type != TokenType.REGEX) { return false; diff --git a/src/com/jpexs/decompiler/flash/gui/editor/LineMarkedEditorPane.java b/src/com/jpexs/decompiler/flash/gui/editor/LineMarkedEditorPane.java index b14201166..cc836204f 100644 --- a/src/com/jpexs/decompiler/flash/gui/editor/LineMarkedEditorPane.java +++ b/src/com/jpexs/decompiler/flash/gui/editor/LineMarkedEditorPane.java @@ -49,6 +49,7 @@ import javax.swing.text.View; import jsyntaxpane.SyntaxDocument; import jsyntaxpane.SyntaxStyle; import jsyntaxpane.Token; +import jsyntaxpane.TokenType; import jsyntaxpane.actions.ActionUtils; /** @@ -382,8 +383,8 @@ public class LineMarkedEditorPane extends UndoFixedEditorPane implements LinkHan } @Override - public boolean isLink(Token token) { - return false; + public LinkType isLink(Token token) { + return LinkType.NO_LINK; } @Override diff --git a/src/com/jpexs/decompiler/flash/gui/editor/LinkHandler.java b/src/com/jpexs/decompiler/flash/gui/editor/LinkHandler.java index 7a15a8aeb..100f8ddf4 100644 --- a/src/com/jpexs/decompiler/flash/gui/editor/LinkHandler.java +++ b/src/com/jpexs/decompiler/flash/gui/editor/LinkHandler.java @@ -24,7 +24,7 @@ import jsyntaxpane.Token; */ public interface LinkHandler { - public boolean isLink(Token token); + public LinkType isLink(Token token); public void handleLink(Token token); diff --git a/src/com/jpexs/decompiler/flash/gui/editor/LinkType.java b/src/com/jpexs/decompiler/flash/gui/editor/LinkType.java new file mode 100644 index 000000000..57b791a9c --- /dev/null +++ b/src/com/jpexs/decompiler/flash/gui/editor/LinkType.java @@ -0,0 +1,28 @@ +/* + * 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 . + */ +package com.jpexs.decompiler.flash.gui.editor; + +/** + * + * @author JPEXS + */ +public enum LinkType { + NO_LINK, + LINK_THIS_SCRIPT, + LINK_OTHER_SCRIPT, + LINK_OTHER_FILE; +} diff --git a/src/com/jpexs/decompiler/flash/gui/editor/VariableMarker.java b/src/com/jpexs/decompiler/flash/gui/editor/VariableMarker.java index 4d69fb853..c524d5839 100644 --- a/src/com/jpexs/decompiler/flash/gui/editor/VariableMarker.java +++ b/src/com/jpexs/decompiler/flash/gui/editor/VariableMarker.java @@ -115,14 +115,7 @@ public class VariableMarker implements SyntaxComponent, CaretListener, PropertyC private UnderlinePainter underLineExternalMarkOccurencesPainter = new UnderlinePainter(new Color(0, 255, 0), DEFAULT_COLOR); private Token lastUnderlined; - private LinkType lastUnderlinedLinkType = LinkType.NO_LINK; - - - public static enum LinkType { - NO_LINK, - LINK_THIS_SCRIPT, - LINK_OTHER_SCRIPT; - } + private LinkType lastUnderlinedLinkType = LinkType.NO_LINK; /** * Constructs a new Token highlighter @@ -629,10 +622,7 @@ public class VariableMarker implements SyntaxComponent, CaretListener, PropertyC if (pane.isEditable()) { return LinkType.NO_LINK; } - if (((LineMarkedEditorPane) pane).getLinkHandler().isLink(token)) { - return LinkType.LINK_OTHER_SCRIPT; - } - return LinkType.NO_LINK; + return ((LineMarkedEditorPane) pane).getLinkHandler().isLink(token); } public void handleLink(Token token) {