diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/ActionScript3SimpleParser.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/ActionScript3SimpleParser.java index a1a2d2004..73451edf6 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/ActionScript3SimpleParser.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/ActionScript3SimpleParser.java @@ -515,6 +515,8 @@ public class ActionScript3SimpleParser implements SimpleParser { Stack cinitLoops = new Stack<>(); Map cinitLoopLabels = new HashMap<>(); + + List traitVariables = new ArrayList<>(); looptraits: while (true) { @@ -660,7 +662,7 @@ public class ActionScript3SimpleParser implements SimpleParser { } else { fname = s.value.toString(); } - classVariables.add(new Variable(true, prefix + fname, fnamePos)); + traitVariables.add(new Variable(true, prefix + fname, fnamePos)); if (fname.equals(classNameStr)) { //constructor if (isStatic) { errors.add(new SimpleParseException("Constructor cannot be static", lexer.yyline(), s.position)); @@ -721,7 +723,7 @@ public class ActionScript3SimpleParser implements SimpleParser { String nname = s.value.toString(); int npos = s.position; - classVariables.add(new Variable(true, prefix + nname, npos)); + traitVariables.add(new Variable(true, prefix + nname, npos)); s = lex(); if (s.type == SymbolType.ASSIGN) { @@ -752,7 +754,7 @@ public class ActionScript3SimpleParser implements SimpleParser { if (!expected(errors, s, lexer.yyline(), SymbolGroup.IDENTIFIER)) { break; } - classVariables.add(new Variable(true, prefix + s.value.toString(), s.position)); + traitVariables.add(new Variable(true, prefix + s.value.toString(), s.position)); s = lex(); if (s.type == SymbolType.NAMESPACESUFFIX) { @@ -789,6 +791,7 @@ public class ActionScript3SimpleParser implements SimpleParser { } } } + classVariables.addAll(0, traitVariables); } private void scriptTraits( diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/parser/script/ActionScript2SimpleParser.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/parser/script/ActionScript2SimpleParser.java index d9eb0a8be..cb11f6079 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/parser/script/ActionScript2SimpleParser.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/parser/script/ActionScript2SimpleParser.java @@ -160,7 +160,7 @@ public class ActionScript2SimpleParser implements SimpleParser { return ret; } - private void function(List errors, boolean withBody, String functionName, int functionNamePosition, boolean isMethod, List variables, boolean inTellTarget, Reference hasEval) throws IOException, InterruptedException, SimpleParseException, ActionParseException { + private FunctionScope function(List errors, boolean withBody, String functionName, int functionNamePosition, boolean isMethod, List variables, boolean inTellTarget, Reference hasEval) throws IOException, InterruptedException, SimpleParseException, ActionParseException { ParsedSymbol s; expectedType(errors, SymbolType.PARENT_OPEN); s = lex(); @@ -192,7 +192,7 @@ public class ActionScript2SimpleParser implements SimpleParser { Reference subHasEval = new Reference<>(false); if (!functionName.isEmpty()) { - variables.add(new Variable(true, functionName, functionNamePosition)); + variables.add(0, new Variable(true, functionName, functionNamePosition)); } for (int i = 0; i < paramNames.size(); i++) { @@ -209,13 +209,15 @@ public class ActionScript2SimpleParser implements SimpleParser { hasEval.setVal(true); } - variables.add(new FunctionScope(subvariables)); + return new FunctionScope(subvariables); } private boolean traits(List errors, boolean isInterface, String className, List variables, boolean inTellTarget, Reference hasEval) throws IOException, InterruptedException, SimpleParseException, ActionParseException { ParsedSymbol s; + List traitVariables = new ArrayList<>(); + looptrait: while (true) { boolean isStatic = false; @@ -238,14 +240,14 @@ public class ActionScript2SimpleParser implements SimpleParser { if (expectedIdentifier(errors, s, lexer.yyline())) { if (!isInterface) { - function(errors, !isInterface, isStatic ? className + "." + s.value.toString() : "this." + s.value.toString(), isStatic ? -1 : s.position, true, variables, inTellTarget, hasEval); + variables.add(function(errors, !isInterface, isStatic ? className + "." + s.value.toString() : "this." + s.value.toString(), isStatic ? -1 : s.position, true, traitVariables, inTellTarget, hasEval)); } } break; case VAR: s = lex(); if (expectedIdentifier(errors, s, lexer.yyline())) { - variables.add(new Variable(true, isStatic ? className + "." + s.value.toString() : "this." + s.value.toString(), s.position)); + traitVariables.add(new Variable(true, isStatic ? className + "." + s.value.toString() : "this." + s.value.toString(), s.position)); } s = lex(); if (s.type == SymbolType.COLON) { @@ -266,6 +268,8 @@ public class ActionScript2SimpleParser implements SimpleParser { } } + + variables.addAll(0, traitVariables); return true; } @@ -799,7 +803,7 @@ public class ActionScript2SimpleParser implements SimpleParser { case FUNCTION: s = lexer.lex(); if (expectedIdentifier(errors, s, lexer.yyline())) { - function(errors, true, s.value.toString(), s.position, false, variables, inTellTarget, hasEval); + variables.add(function(errors, true, s.value.toString(), s.position, false, variables, inTellTarget, hasEval)); } break; case VAR: @@ -1389,7 +1393,7 @@ public class ActionScript2SimpleParser implements SimpleParser { } else { lexer.pushback(s); } - function(errors, true, fname, fnamePos, false, variables, inTellTarget, hasEval); + variables.add(function(errors, true, fname, fnamePos, false, variables, inTellTarget, hasEval)); ret = true; allowMemberOrCall = true; break; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/parser/script/LexBufferer.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/parser/script/LexBufferer.java index b65ff4ed8..c0e3c7138 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/parser/script/LexBufferer.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/parser/script/LexBufferer.java @@ -35,6 +35,9 @@ public class LexBufferer implements LexListener { @Override public void onPushBack(ParsedSymbol s) { + if (items.isEmpty()) { + return; + } if (items.get(items.size() - 1) == s) { items.remove(items.size() - 1); } diff --git a/src/com/jpexs/decompiler/flash/gui/View.java b/src/com/jpexs/decompiler/flash/gui/View.java index 02a444411..e03d6ecab 100644 --- a/src/com/jpexs/decompiler/flash/gui/View.java +++ b/src/com/jpexs/decompiler/flash/gui/View.java @@ -711,16 +711,42 @@ public class View { a.putValue(Action.ACCELERATOR_KEY, ks); a.putValue(Action.NAME, name); - String actionName = key; ActionMap amap = editor.getActionMap(); InputMap imap = editor.getInputMap(JTextComponent.WHEN_FOCUSED); - imap.put(ks, actionName); - amap.put(actionName, a); + imap.put(ks, key); + amap.put(key, a); JPopupMenu pmenu = editor.getComponentPopupMenu(); JMenuItem findUsagesMenu = new JMenuItem(a); pmenu.add(findUsagesMenu); } + + public static void removeEditorAction(JEditorPane editor, String key) { + ActionMap amap = editor.getActionMap(); + InputMap imap = editor.getInputMap(JTextComponent.WHEN_FOCUSED); + for (KeyStroke ks : imap.keys()) { + if (key.equals(imap.get(ks))) { + imap.remove(ks); + break; + } + } + Action a = amap.get(key); + if (a == null) { + return; + } + amap.remove(key); + JPopupMenu menu = editor.getComponentPopupMenu(); + for (int i = 0; i < menu.getComponentCount(); i++) { + Component c = menu.getComponent(i); + if (c instanceof JMenuItem) { + JMenuItem mi = (JMenuItem) c; + if (mi.getAction() == a) { + menu.remove(i); + break; + } + } + } + } public static boolean navigateUrl(String url) { if (Desktop.isDesktopSupported()) { diff --git a/src/com/jpexs/decompiler/flash/gui/abc/ABCPanel.java b/src/com/jpexs/decompiler/flash/gui/abc/ABCPanel.java index 4a30b4a20..886cb88dc 100644 --- a/src/com/jpexs/decompiler/flash/gui/abc/ABCPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/abc/ABCPanel.java @@ -1171,14 +1171,7 @@ public class ABCPanel extends JPanel implements ItemListener, SearchListener