diff --git a/lib/jsyntaxpane-0.9.5.jar b/lib/jsyntaxpane-0.9.5.jar index 083820ccb..567e90d4d 100644 Binary files a/lib/jsyntaxpane-0.9.5.jar and b/lib/jsyntaxpane-0.9.5.jar differ diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/GetLocal0Ins.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/GetLocal0Ins.java index edf3c0428..9be5031ea 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/GetLocal0Ins.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/GetLocal0Ins.java @@ -15,20 +15,9 @@ * License along with this library. */ package com.jpexs.decompiler.flash.abc.avm2.instructions.localregs; -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool; import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.abc.avm2.model.ClassAVM2Item; -import com.jpexs.decompiler.flash.abc.avm2.model.ScriptAVM2Item; -import com.jpexs.decompiler.flash.abc.avm2.model.ThisAVM2Item; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphTargetItem; -import com.jpexs.decompiler.graph.ScopeStack; -import com.jpexs.decompiler.graph.TranslateStack; -import java.util.HashMap; import java.util.List; public class GetLocal0Ins extends GetLocalTypeIns { @@ -42,19 +31,6 @@ public class GetLocal0Ins extends GetLocalTypeIns { lda.operandStack.push(lda.localRegisters.get(0)); } - @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, AVM2ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { - if ((classIndex >= abc.instance_info.size()) || classIndex < 0) { - stack.push(new ScriptAVM2Item(scriptIndex)); - return; - } - if (isStatic) { - stack.push(new ClassAVM2Item(abc.instance_info.get(classIndex).getName(constants))); - } else { - stack.push(new ThisAVM2Item(abc.instance_info.get(classIndex).getName(constants))); - } - } - @Override public int getRegisterId(AVM2Instruction par0) { return 0; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/GetLocalTypeIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/GetLocalTypeIns.java index b807f0bb2..3d74aabbc 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/GetLocalTypeIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/GetLocalTypeIns.java @@ -20,7 +20,10 @@ import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; +import com.jpexs.decompiler.flash.abc.avm2.model.ClassAVM2Item; import com.jpexs.decompiler.flash.abc.avm2.model.LocalRegAVM2Item; +import com.jpexs.decompiler.flash.abc.avm2.model.ScriptAVM2Item; +import com.jpexs.decompiler.flash.abc.avm2.model.ThisAVM2Item; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.graph.GraphTargetItem; @@ -38,7 +41,22 @@ public abstract class GetLocalTypeIns extends InstructionDefinition { @Override public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, AVM2ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap regAssignCount, int ip, HashMap> refs, AVM2Code code) { + int regId = getRegisterId(ins); + + if(regId == 0){ + if ((classIndex >= abc.instance_info.size()) || classIndex < 0) { + stack.push(new ScriptAVM2Item(scriptIndex)); + return; + } + if (isStatic) { + stack.push(new ClassAVM2Item(abc.instance_info.get(classIndex).getName(constants))); + } else { + stack.push(new ThisAVM2Item(ins, abc.instance_info.get(classIndex).getName(constants))); + } + return; + } + GraphTargetItem computedValue = localRegs.get(regId); int assignCount = 0; if (regAssignCount.containsKey(regId)) { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/AVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/AVM2Item.java index 12306b89f..2539c13da 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/AVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/AVM2Item.java @@ -81,11 +81,11 @@ public abstract class AVM2Item extends GraphTargetItem { } } } - + if (empty) { return propertyName.toString(writer, localData); } - if (propertyName instanceof FullMultinameAVM2Item) { + if (propertyName instanceof FullMultinameAVM2Item) { if (((FullMultinameAVM2Item) propertyName).name != null) { return propertyName.toString(writer, localData); } else { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/FullMultinameAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/FullMultinameAVM2Item.java index 9c4c91aef..4c428231b 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/FullMultinameAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/FullMultinameAVM2Item.java @@ -18,6 +18,7 @@ package com.jpexs.decompiler.flash.abc.avm2.model; import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.abc.types.Multiname; import com.jpexs.decompiler.flash.abc.types.Namespace; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; import com.jpexs.decompiler.graph.GraphTargetItem; @@ -25,13 +26,14 @@ import com.jpexs.decompiler.graph.TypeItem; import com.jpexs.decompiler.graph.model.LocalData; import java.util.HashMap; import java.util.List; +import java.util.Map; public class FullMultinameAVM2Item extends AVM2Item { public int multinameIndex; public GraphTargetItem name; public GraphTargetItem namespace; - + public FullMultinameAVM2Item(AVM2Instruction instruction, int multinameIndex, GraphTargetItem name) { super(instruction, PRECEDENCE_PRIMARY); this.multinameIndex = multinameIndex; @@ -153,10 +155,10 @@ public class FullMultinameAVM2Item extends AVM2Item { return false; } return true; - } - + } + @Override - public GraphTargetItem returnType() { + public GraphTargetItem returnType() { return TypeItem.UNBOUNDED; } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/ThisAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/ThisAVM2Item.java index a777ef2ce..8a82c4b12 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/ThisAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/ThisAVM2Item.java @@ -33,9 +33,10 @@ public class ThisAVM2Item extends AVM2Item { public Multiname className; - public ThisAVM2Item(Multiname className) { - super(null, PRECEDENCE_PRIMARY); + public ThisAVM2Item(GraphSourceItem instruction,Multiname className) { + super(instruction, PRECEDENCE_PRIMARY); this.className = className; + srcData.put("localName", "this"); } @Override @@ -44,7 +45,7 @@ public class ThisAVM2Item extends AVM2Item { } @Override - public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) { + public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) { return writer.append("this"); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/clauses/DeclarationAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/clauses/DeclarationAVM2Item.java index 6006cc7c5..3231ecf86 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/clauses/DeclarationAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/clauses/DeclarationAVM2Item.java @@ -59,6 +59,7 @@ public class DeclarationAVM2Item extends AVM2Item { String localName = localRegName(localData.localRegNames, lti.regIndex); srcData.put("localName",localName); srcData.put("declaration", "true"); + srcData.put("declaredType", "*"); writer.append("var "); writer.append(localName); return writer; @@ -68,6 +69,7 @@ public class DeclarationAVM2Item extends AVM2Item { GetSlotAVM2Item sti=(GetSlotAVM2Item)assignment; srcData.put("localName",sti.getNameAsStr(localData)); srcData.put("declaration", "true"); + srcData.put("declaredType", "*"); writer.append("var "); sti.getName(writer, localData); return writer; @@ -78,6 +80,7 @@ public class DeclarationAVM2Item extends AVM2Item { String localName = localRegName(localData.localRegNames, lti.regIndex); srcData.put("localName",localName); srcData.put("declaration", "true"); + GraphTargetItem coerType = TypeItem.UNBOUNDED; if (lti.value instanceof CoerceAVM2Item) { coerType = ((CoerceAVM2Item) lti.value).typeObj; @@ -85,6 +88,7 @@ public class DeclarationAVM2Item extends AVM2Item { if (lti.value instanceof ConvertAVM2Item) { coerType = ((ConvertAVM2Item) lti.value).type; } + srcData.put("declaredType", (coerType instanceof TypeItem)?((TypeItem)coerType).fullTypeName:"*"); writer.append("var "); writer.append(localName); writer.append(":"); @@ -96,9 +100,10 @@ public class DeclarationAVM2Item extends AVM2Item { SetSlotAVM2Item ssti = (SetSlotAVM2Item) assignment; srcData.put("localName",ssti.getNameAsStr(localData)); srcData.put("declaration", "true"); + srcData.put("declaredType", (type instanceof TypeItem)?((TypeItem)type).fullTypeName:"*"); writer.append("var "); ssti.getName(writer, localData); - writer.append(":"); + writer.append(":"); type.appendTo(writer, localData); writer.append(" = "); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/clauses/TryAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/clauses/TryAVM2Item.java index 7676f9b71..f4874e94e 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/clauses/TryAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/clauses/TryAVM2Item.java @@ -82,6 +82,10 @@ public class TryAVM2Item extends AVM2Item implements Block { Map data=new HashMap<>(); data.put("localName", localName); data.put("declaration", "true"); + + int eti= catchExceptions.get(e).type_index; + + data.put("declaredType", eti<=0?"*":localData.constantsAvm2.constant_multiname.get(eti).getNameWithNamespace(localData.constantsAvm2, true)); writer.hilightSpecial(localName, "try.name",e,data); writer.append(":"); writer.hilightSpecial(catchExceptions.get(e).getTypeName(localData.constantsAvm2, localData.fullyQualifiedNames),"try.type",e); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/InstanceInfo.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/InstanceInfo.java index 19feb5750..26c9a33de 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/InstanceInfo.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/InstanceInfo.java @@ -74,7 +74,9 @@ public class InstanceInfo { if (isInterface()) { objType = "interface "; } - writer.appendNoHilight(modifiers + objType + abc.constants.getMultiname(name_index).getName(abc.constants, new ArrayList()/* No full names here*/, false)); + + writer.appendNoHilight(modifiers + objType); + writer.hilightSpecial(abc.constants.getMultiname(name_index).getName(abc.constants, new ArrayList()/* No full names here*/, false),"classname"); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/MethodInfo.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/MethodInfo.java index 298dc6109..68a5fb0fe 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/MethodInfo.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/MethodInfo.java @@ -278,8 +278,15 @@ public class MethodInfo { if (i > 0) { writer.appendNoHilight(", "); } - pdata=new HashMap<>(); + String ptype = "*"; + if (param_types[i] > 0) { + ptype = constants.getMultiname(param_types[i]).getNameWithNamespace(constants,false); + } + + + pdata=new HashMap<>(); pdata.put("declaration", "true"); + pdata.put("declaredType", ptype); if (!localRegNames.isEmpty()) { pdata.put("localName", localRegNames.get(i + 1)); //assuming it is a slot writer.hilightSpecial(IdentifiersDeobfuscation.printIdentifier(true,localRegNames.get(i + 1)),"paramname",i,pdata); @@ -318,6 +325,7 @@ public class MethodInfo { } pdata=new HashMap<>(); pdata.put("declaration", "true"); + pdata.put("declaredType", "*"); pdata.put("localName",restName); writer.append(restAdd); writer.hilightSpecial(restName, "flag.NEED_REST",0,pdata); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/GraphTargetItem.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/GraphTargetItem.java index d351cfddb..bdf687240 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/GraphTargetItem.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/GraphTargetItem.java @@ -95,7 +95,7 @@ public abstract class GraphTargetItem implements Serializable { writer.startOffset(src, pos, srcData); appendTo(writer, localData); if (needsSemicolon()) { - writer.append(";"); + writer.appendNoHilight(";"); } writer.endOffset(); return writer; diff --git a/libsrc/jsyntaxpane/jsyntaxpane/pom.xml b/libsrc/jsyntaxpane/jsyntaxpane/pom.xml index c0351589b..af2c9acdc 100644 --- a/libsrc/jsyntaxpane/jsyntaxpane/pom.xml +++ b/libsrc/jsyntaxpane/jsyntaxpane/pom.xml @@ -1,84 +1,84 @@ - - - 4.0.0 - jsyntaxpane - jsyntaxpane - jar - 0.9.5 - jsyntaxpane - A very simple to use and extend JEditorKit that supports few languages. The main goal is to make it easy to have nice looking Java Swing Editors with support for Syntax Highlighting. - http://jsyntaxpane.googlecode.com/ - - - - The Apache Software License, Version 2.0 - http://www.apache.org/licenses/LICENSE-2.0 - repo - - - - - http://jsyntaxpane.googlecode.com/svn/ - - - - - jflex - JFlex repository - http://jflex.sourceforge.net/repo/ - - - - - - - maven-compiler-plugin - 2.3 - - - 1.6 - 1.6 - - - - org.apache.maven.plugins - maven-jar-plugin - - ../../../lib - - **/Thumbs.db - - - - jsyntaxpane.SyntaxTester - jsyntaxpane - true - - - - development - ${pom.url} - - - - - - de.jflex - maven-jflex-plugin - - - - - generate - - - - - - - - - UTF-8 - - + + + 4.0.0 + jsyntaxpane + jsyntaxpane + jar + 0.9.5 + jsyntaxpane + A very simple to use and extend JEditorKit that supports few languages. The main goal is to make it easy to have nice looking Java Swing Editors with support for Syntax Highlighting. + http://jsyntaxpane.googlecode.com/ + + + + The Apache Software License, Version 2.0 + http://www.apache.org/licenses/LICENSE-2.0 + repo + + + + + http://jsyntaxpane.googlecode.com/svn/ + + + + + jflex + JFlex repository + http://jflex.sourceforge.net/repo/ + + + + + + + maven-compiler-plugin + 2.3 + + + 1.6 + 1.6 + + + + org.apache.maven.plugins + maven-jar-plugin + + ../../../lib + + **/Thumbs.db + + + + jsyntaxpane.SyntaxTester + jsyntaxpane + true + + + + development + ${pom.url} + + + + + + de.jflex + jflex-maven-plugin + 1.6.0 + + + + generate + + + + + + + + + UTF-8 + + \ No newline at end of file diff --git a/libsrc/jsyntaxpane/jsyntaxpane/src/main/jflex/jsyntaxpane/lexers/actionscript.flex b/libsrc/jsyntaxpane/jsyntaxpane/src/main/jflex/jsyntaxpane/lexers/actionscript.flex index 24bed6ed0..a1760063a 100644 --- a/libsrc/jsyntaxpane/jsyntaxpane/src/main/jflex/jsyntaxpane/lexers/actionscript.flex +++ b/libsrc/jsyntaxpane/jsyntaxpane/src/main/jflex/jsyntaxpane/lexers/actionscript.flex @@ -63,10 +63,14 @@ Comment = {TraditionalComment} | {EndOfLineComment} TraditionalComment = "/*" [^*] ~"*/" | "/*" "*"+ "/" EndOfLineComment = "//" {InputCharacter}* {LineTerminator}? +IdentFirst = [\p{Lu}\p{Ll}\p{Lt}\p{Lm}\p{Lo}_$] +IdentNext = {IdentFirst} | [\p{Nl}\p{Mn}\p{Mc}\p{Nd}\p{Pc}] /* identifiers */ -Identifier = [:jletter:][:jletterdigit:]* +Identifier = {IdentFirst}{IdentNext}* + +/* identifiers */ IdentifierNs = {Identifier} ":" {Identifier} diff --git a/src/com/jpexs/decompiler/flash/gui/TextPanel.java b/src/com/jpexs/decompiler/flash/gui/TextPanel.java index 6ac9f02ef..f150b5b5b 100644 --- a/src/com/jpexs/decompiler/flash/gui/TextPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/TextPanel.java @@ -49,8 +49,7 @@ public class TextPanel extends JPanel implements ActionListener { public TextPanel(MainPanel mainPanel) { super(new BorderLayout()); - - DefaultSyntaxKit.initKit(); + this.mainPanel = mainPanel; textSearchPanel = new SearchPanel<>(new FlowLayout(), mainPanel); diff --git a/src/com/jpexs/decompiler/flash/gui/abc/ABCPanel.java b/src/com/jpexs/decompiler/flash/gui/abc/ABCPanel.java index edaf6a605..7857e15f9 100644 --- a/src/com/jpexs/decompiler/flash/gui/abc/ABCPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/abc/ABCPanel.java @@ -26,6 +26,7 @@ import com.jpexs.decompiler.flash.abc.avm2.instructions.localregs.GetLocal0Ins; import com.jpexs.decompiler.flash.abc.avm2.instructions.other.ReturnVoidIns; import com.jpexs.decompiler.flash.abc.avm2.instructions.stack.PushScopeIns; import com.jpexs.decompiler.flash.abc.avm2.parser.AVM2ParseException; +import com.jpexs.decompiler.flash.abc.avm2.parser.script.Reference; import com.jpexs.decompiler.flash.abc.types.ABCException; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; @@ -37,6 +38,7 @@ import com.jpexs.decompiler.flash.abc.types.traits.TraitMethodGetterSetter; import com.jpexs.decompiler.flash.abc.types.traits.TraitSlotConst; import com.jpexs.decompiler.flash.abc.types.traits.Traits; import com.jpexs.decompiler.flash.abc.usages.MultinameUsage; +import com.jpexs.decompiler.flash.abc.usages.TraitMultinameUsage; import com.jpexs.decompiler.flash.configuration.Configuration; import com.jpexs.decompiler.flash.gui.AppStrings; import com.jpexs.decompiler.flash.gui.HeaderLabel; @@ -112,7 +114,9 @@ import javax.swing.table.TableModel; import javax.swing.text.Highlighter; import javax.swing.tree.TreePath; import jsyntaxpane.DefaultSyntaxKit; +import jsyntaxpane.SyntaxDocument; import jsyntaxpane.Token; +import jsyntaxpane.TokenType; public class ABCPanel extends JPanel implements ItemListener, ActionListener, SearchListener, Freed { @@ -356,9 +360,10 @@ public class ABCPanel extends JPanel implements ItemListener, ActionListener, Se Helper.emptyObject(this); } - public ABCPanel(MainPanel mainPanel) { - DefaultSyntaxKit.initKit(); + public ABCPanel(MainPanel mainPanel) { + DefaultSyntaxKit.initKit(); + this.mainPanel = mainPanel; setLayout(new BorderLayout()); @@ -368,12 +373,12 @@ public class ABCPanel extends JPanel implements ItemListener, ActionListener, Se @Override public boolean isLink(Token token) { - return hasDeclaration(token.start); + return hasDeclaration(token.length==1?token.start:token.start+1); } @Override public void handleLink(Token token) { - gotoDeclaration(token.start); + gotoDeclaration(token.length==1?token.start:token.start+1); } @Override @@ -538,6 +543,22 @@ public class ABCPanel extends JPanel implements ItemListener, ActionListener, Se } private boolean hasDeclaration(int pos) { + + SyntaxDocument sd = (SyntaxDocument)decompiledTextArea.getDocument(); + Token t = sd.getTokenAt(pos); + if(t==null || (t.type != TokenType.IDENTIFIER && t.type!=TokenType.KEYWORD && t.type!=TokenType.REGEX)){ + return false; + } + Reference abcIndex=new Reference<>(0); + Reference classIndex=new Reference<>(0); + Reference traitIndex=new Reference<>(0); + Reference multinameIndexRef=new Reference<>(0); + Reference classTrait=new Reference<>(false); + + + if(decompiledTextArea.getPropertyTypeAtPos(pos, abcIndex, classIndex, traitIndex, classTrait,multinameIndexRef)){ + return true; + } int multinameIndex = decompiledTextArea.getMultinameAtPos(pos); if (multinameIndex > -1) { if(multinameIndex == 0){ @@ -566,10 +587,22 @@ public class ABCPanel extends JPanel implements ItemListener, ActionListener, Se } } - return decompiledTextArea.getLocalDeclarationOfPos(pos) != -1; + return decompiledTextArea.getLocalDeclarationOfPos(pos,new Reference<>("")) != -1; } private void gotoDeclaration(int pos) { + Reference abcIndex=new Reference<>(0); + Reference classIndex=new Reference<>(0); + Reference traitIndex=new Reference<>(0); + Reference classTrait=new Reference<>(false); + Reference multinameIndexRef=new Reference<>(0); + + + if(decompiledTextArea.getPropertyTypeAtPos(pos, abcIndex, classIndex, traitIndex, classTrait,multinameIndexRef)){ + UsageFrame.gotoUsage(ABCPanel.this, new TraitMultinameUsage(swf.abcList, swf.abcList.get(abcIndex.getVal()).getABC(), multinameIndexRef.getVal(),classIndex.getVal(), traitIndex.getVal(), classTrait.getVal(), null, -1) { + }); + return; + } int multinameIndex = decompiledTextArea.getMultinameAtPos(pos); if (multinameIndex > -1) { List usages = abc.findMultinameDefinition(swf.abcList, multinameIndex); @@ -600,7 +633,7 @@ public class ABCPanel extends JPanel implements ItemListener, ActionListener, Se } } - int dpos = decompiledTextArea.getLocalDeclarationOfPos(pos); + int dpos = decompiledTextArea.getLocalDeclarationOfPos(pos,new Reference<>("")); if (dpos > -1) { decompiledTextArea.setCaretPosition(dpos); } @@ -825,11 +858,9 @@ public class ABCPanel extends JPanel implements ItemListener, ActionListener, Se if (oldSp != null) { hilightScript(swf, oldSp); } - //decompiledTextArea.setClassIndex(-1); - //navigator.setClassIndex(-1, oldIndex); setDecompiledEditMode(false); - View.showMessageDialog(this, AppStrings.translate("message.action.saved")); - //reload(); + reload(); + View.showMessageDialog(this, AppStrings.translate("message.action.saved")); } catch (AVM2ParseException ex) { abc.script_info.get(oldIndex).delete(abc, false); decompiledTextArea.gotoLine((int) ex.line); diff --git a/src/com/jpexs/decompiler/flash/gui/abc/DecompiledEditorPane.java b/src/com/jpexs/decompiler/flash/gui/abc/DecompiledEditorPane.java index 918fc7cee..0ee2494f6 100644 --- a/src/com/jpexs/decompiler/flash/gui/abc/DecompiledEditorPane.java +++ b/src/com/jpexs/decompiler/flash/gui/abc/DecompiledEditorPane.java @@ -23,6 +23,9 @@ import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.instructions.construction.ConstructSuperIns; import com.jpexs.decompiler.flash.abc.avm2.instructions.executing.CallSuperIns; import com.jpexs.decompiler.flash.abc.avm2.instructions.executing.CallSuperVoidIns; +import com.jpexs.decompiler.flash.abc.avm2.parser.script.Reference; +import com.jpexs.decompiler.flash.abc.types.ClassInfo; +import com.jpexs.decompiler.flash.abc.types.InstanceInfo; import com.jpexs.decompiler.flash.abc.types.Multiname; import com.jpexs.decompiler.flash.abc.types.ScriptInfo; import com.jpexs.decompiler.flash.abc.types.traits.Trait; @@ -47,6 +50,9 @@ import java.util.TimerTask; import javax.swing.SwingUtilities; import javax.swing.event.CaretEvent; import javax.swing.event.CaretListener; +import jsyntaxpane.SyntaxDocument; +import jsyntaxpane.Token; +import jsyntaxpane.TokenType; public class DecompiledEditorPane extends LineMarkedEditorPane implements CaretListener { @@ -235,25 +241,34 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements CaretL return getMultinameAtPos(getCaretPosition()); } - public int getLocalDeclarationOfPos(int pos) { + public int getLocalDeclarationOfPos(int pos,Reference type) { Highlighting sh = Highlighting.search(specialHighlights, pos); Highlighting h = Highlighting.search(highlights, pos); + if (h == null) { + return -1; + } + List tms = Highlighting.searchAll(methodHighlights, pos, null, null, -1, -1); if (tms.isEmpty()) { return -1; } for (Highlighting tm : tms) { - List tm_tms = Highlighting.searchAll(methodHighlights, -1, "index", tm.getPropertyString("index"), -1, -1); - if (h == null) { - return -1; - } + List tm_tms = Highlighting.searchAll(methodHighlights, -1, "index", tm.getPropertyString("index"), -1, -1); //is it already declaration? if ("true".equals(h.getPropertyString("declaration")) || (sh != null && "true".equals(sh.getPropertyString("declaration")))) { return -1; //no jump } + String lname=h.getPropertyString("localName"); + if("this".equals(lname)){ + Highlighting ch= Highlighting.search(classHighlights, pos); + int cindex=(int)(long)ch.getPropertyLong("index"); + type.setVal(abc.instance_info.get(cindex).getName(abc.constants).getNameWithNamespace(abc.constants, true)); + return ch.startPos; + } + Map search = h.getProperties(); search.remove("index"); search.remove("subtype"); @@ -269,6 +284,7 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements CaretL rh = Highlighting.search(specialHighlights, search, tm1.startPos, tm1.startPos + tm1.len); } if (rh != null) { + type.setVal(rh.getPropertyString("declaredType")); return rh.startPos; } } @@ -277,13 +293,101 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements CaretL return -1; } + public boolean getPropertyTypeAtPos(int pos, Reference abcIndex,Reference classIndex, Reference traitIndex, Reference classTrait, Reference multinameIndex){ + + int m = getMultinameAtPos(pos,true); + if (m <= 0) { + return false; + } + SyntaxDocument sd=(SyntaxDocument)getDocument(); + Token t = sd.getTokenAt(pos+1); + Token lastToken = t; + Token prev = null; + while(t.type == TokenType.IDENTIFIER || t.type == TokenType.KEYWORD){ + prev = sd.getPrevToken(t); + if(prev!=null){ + if(!".".equals(prev.getString(sd))){ + break; + } + t = sd.getPrevToken(prev); + }else{ + break; + } + } + if(t.type != TokenType.IDENTIFIER && t.type != TokenType.KEYWORD){ + return false; + } + Reference locTypeRef = new Reference<>(""); + getLocalDeclarationOfPos(t.start,locTypeRef); + String currentType=locTypeRef.getVal(); + if(currentType.equals("*")){ + return false; + } + boolean found=false; + t = sd.getNextToken(t); + while(t!=lastToken && !currentType.equals("*")){ + t = sd.getNextToken(t); + String ident=t.getString(sd); + found = false; + loopi:for(int i=0;i-1){ + InstanceInfo ii = a.instance_info.get(cindex); + for(int j=0;j(), true))){ + classIndex.setVal(cindex); + abcIndex.setVal(i); + traitIndex.setVal(j); + classTrait.setVal(false); + multinameIndex.setVal(tr.name_index); + currentType = ii.getName(a.constants).getNameWithNamespace(a.constants, true); + found = true; + break loopi; + } + } + + ClassInfo ci = a.class_info.get(cindex); + for(int j=0;j(), true))){ + classIndex.setVal(cindex); + abcIndex.setVal(i); + traitIndex.setVal(j); + classTrait.setVal(true); + multinameIndex.setVal(tr.name_index); + currentType = ii.getName(a.constants).getNameWithNamespace(a.constants, true); + found = true; + break loopi; + } + } + } + } + if(!found){ + return false; + } + + t = sd.getNextToken(t); + if(!".".equals(t.getString(sd))){ + break; + } + } + return true; + } + public int getMultinameAtPos(int pos) { + return getMultinameAtPos(pos, false); + } + + public int getMultinameAtPos(int pos, boolean codeOnly) { Highlighting tm = Highlighting.search(methodHighlights, pos); Trait currentTrait = null; int currentMethod = -1; if (tm != null) { int mi = (int) (long) tm.getPropertyLong("index"); + currentMethod = mi; int bi = abc.findBodyIndex(mi); Highlighting h = Highlighting.search(highlights, pos); if (h != null) { @@ -304,7 +408,7 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements CaretL lastIns = ins; } if (selIns != null) { - if ((selIns.definition instanceof ConstructSuperIns) || (selIns.definition instanceof CallSuperIns)|| (selIns.definition instanceof CallSuperVoidIns)) { + if (!codeOnly && ((selIns.definition instanceof ConstructSuperIns) || (selIns.definition instanceof CallSuperIns)|| (selIns.definition instanceof CallSuperVoidIns))) { Highlighting tc = Highlighting.search(classHighlights, pos); if(tc!=null){ int cindex = (int)(long)tc.getPropertyLong("index"); @@ -321,14 +425,23 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements CaretL } } } - - currentTrait = getCurrentTrait(); - if (currentTrait instanceof TraitMethodGetterSetter) { - currentMethod = ((TraitMethodGetterSetter) currentTrait).method_info; - } - if (currentMethodHighlight != null) { - currentMethod = (int) (long) currentMethodHighlight.getPropertyLong("index"); + + } + if(codeOnly){ + return -1; + } + + Highlighting ch = Highlighting.search(classHighlights, pos); + if(ch!=null){ + Highlighting th = Highlighting.search(traitHighlights, pos); + if (th != null) { + currentTrait = abc.findTraitByTraitId((int) (long) ch.getPropertyLong("index"), (int) (long) th.getPropertyLong("index")); } + } + + + if (currentTrait instanceof TraitMethodGetterSetter) { + currentMethod = ((TraitMethodGetterSetter) currentTrait).method_info; } Highlighting sh = Highlighting.search(specialHighlights, pos); if (sh != null) { diff --git a/src/com/jpexs/decompiler/flash/gui/abc/LineMarkedEditorPane.java b/src/com/jpexs/decompiler/flash/gui/abc/LineMarkedEditorPane.java index a7252e268..0c36d687e 100644 --- a/src/com/jpexs/decompiler/flash/gui/abc/LineMarkedEditorPane.java +++ b/src/com/jpexs/decompiler/flash/gui/abc/LineMarkedEditorPane.java @@ -177,7 +177,7 @@ public class LineMarkedEditorPane extends UndoFixedEditorPane implements LinkHan if (d instanceof SyntaxDocument) { SyntaxDocument sd = (SyntaxDocument) d; int pos = viewToModel(lastPos); - if (pos < 0) { + if (pos <= 0) { return; } Token t = sd.getTokenAt(pos); @@ -211,7 +211,6 @@ public class LineMarkedEditorPane extends UndoFixedEditorPane implements LinkHan setCursor(Cursor.getDefaultCursor()); repaint(); } - } @Override @@ -222,7 +221,7 @@ public class LineMarkedEditorPane extends UndoFixedEditorPane implements LinkHan if (pos < 0) { return; } - Token t = sd.getTokenAt(pos); + Token t = sd.getTokenAt(pos + 1); if (t != null && linkHandler.isLink(t)) { linkHandler.handleLink(t); } diff --git a/src/com/jpexs/decompiler/flash/gui/action/ActionPanel.java b/src/com/jpexs/decompiler/flash/gui/action/ActionPanel.java index 0cb4fbf03..8d4659469 100644 --- a/src/com/jpexs/decompiler/flash/gui/action/ActionPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/action/ActionPanel.java @@ -152,7 +152,7 @@ public class ActionPanel extends JPanel implements ActionListener, SearchListene SyntaxDocument sDoc = ActionUtils.getSyntaxDocument(decompiledEditor); if (sDoc != null) { - Token t = sDoc.getTokenAt(pos); + Token t = sDoc.getTokenAt(pos+1); String ident = null; //It should be identifier or obfuscated identifier if (t != null && (t.type == TokenType.IDENTIFIER || t.type == TokenType.REGEX)) {