From fc7b82b86615933dbf0894775a62e09add8720b7 Mon Sep 17 00:00:00 2001 From: Honfika Date: Mon, 9 Sep 2013 20:46:38 +0200 Subject: [PATCH] indent fix in traitslotconst --- .../src/com/jpexs/decompiler/flash/abc/ABC.java | 6 +++--- .../decompiler/flash/abc/avm2/AVM2Code.java | 2 +- .../flash/abc/types/traits/TraitClass.java | 17 +++++++++-------- .../flash/abc/types/traits/TraitFunction.java | 3 ++- .../types/traits/TraitMethodGetterSetter.java | 3 ++- .../flash/abc/types/traits/TraitSlotConst.java | 11 +++++++---- 6 files changed, 24 insertions(+), 18 deletions(-) diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/ABC.java b/trunk/src/com/jpexs/decompiler/flash/abc/ABC.java index 6f7b6e33d..19e188395 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/ABC.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/ABC.java @@ -32,6 +32,7 @@ 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.*; import com.jpexs.decompiler.flash.helpers.collections.MyEntry; +import com.jpexs.decompiler.graph.Graph; import java.io.*; import java.util.ArrayList; import java.util.HashMap; @@ -58,10 +59,9 @@ public class ABC { public MethodBody[] bodies; private int[] bodyIdxFromMethodIdx; public long[] stringOffsets; - public static final String IDENT_STRING = " "; public static final int MINORwithDECIMAL = 17; protected HashSet listeners = new HashSet<>(); - private static Logger logger = Logger.getLogger(ABC.class.getName()); + private static final Logger logger = Logger.getLogger(ABC.class.getName()); public void addEventListener(EventListener listener) { listeners.add(listener); @@ -608,7 +608,7 @@ public class ABC { StringBuilder ret = new StringBuilder(); for (int i = 0; i < parts.length; i++) { for (int t = 0; t < tabs; t++) { - ret.append(IDENT_STRING); + ret.append(Graph.INDENT_STRING); } ret.append(parts[i]); if (i < parts.length - 1) { diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java index ac8fade16..0e3831c93 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java @@ -1184,7 +1184,7 @@ public class AVM2Code implements Serializable { public String tabString(int len) { StringBuilder ret = new StringBuilder(); for (int i = 0; i < len; i++) { - ret.append(ABC.IDENT_STRING); + ret.append(Graph.INDENT_STRING); } return ret.toString(); } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/TraitClass.java b/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/TraitClass.java index 199fde597..681fac508 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/TraitClass.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/TraitClass.java @@ -33,6 +33,7 @@ import com.jpexs.decompiler.flash.abc.types.NamespaceSet; import com.jpexs.decompiler.flash.abc.types.ScriptInfo; import com.jpexs.decompiler.flash.helpers.Highlighting; import com.jpexs.decompiler.flash.tags.ABCContainerTag; +import com.jpexs.decompiler.graph.Graph; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.helpers.Helper; import java.io.ByteArrayOutputStream; @@ -419,12 +420,12 @@ public class TraitClass extends Trait implements TraitWithSlot { for (String imp : imports) { if (!imp.startsWith(".")) { - out.println(ABC.IDENT_STRING + "import " + imp + ";"); + out.println(Graph.INDENT_STRING + "import " + imp + ";"); } } out.println(); for (String us : uses) { - out.println(ABC.IDENT_STRING + "use namespace " + us + ";"); + out.println(Graph.INDENT_STRING + "use namespace " + us + ";"); } out.println(); @@ -433,8 +434,8 @@ public class TraitClass extends Trait implements TraitWithSlot { if (classHeader.startsWith("private ")) { classHeader = classHeader.substring("private ".length()); } - out.println(ABC.IDENT_STRING + classHeader); - out.println(ABC.IDENT_STRING + "{"); + out.println(Graph.INDENT_STRING + classHeader); + out.println(Graph.INDENT_STRING + "{"); String toPrint; List outTraits = new LinkedList<>(); @@ -449,7 +450,7 @@ public class TraitClass extends Trait implements TraitWithSlot { if (Highlighting.stripHilights(bodyStr).trim().equals("")) { toPrint = ABC.addTabs(bodyStr + "/*classInitializer*/", 3); } else { - toPrint = ABC.IDENT_STRING + ABC.IDENT_STRING + "{\r\n" + ABC.addTabs(bodyStr, 3) + "\r\n" + ABC.IDENT_STRING + ABC.IDENT_STRING + "}"; + toPrint = Graph.INDENT_STRING + Graph.INDENT_STRING + "{\r\n" + ABC.addTabs(bodyStr, 3) + "\r\n" + Graph.INDENT_STRING + Graph.INDENT_STRING + "}"; } if (highlight) { toPrint = Highlighting.hilighTrait(toPrint, abc.class_info[class_info].static_traits.traits.length + abc.instance_info[class_info].instance_traits.traits.length + 1); @@ -483,7 +484,7 @@ public class TraitClass extends Trait implements TraitWithSlot { } else { constructorParams = abc.method_info[abc.instance_info[class_info].iinit_index].getParamStr(abc.constants, null, abc, fullyQualifiedNames); } - toPrint = ABC.IDENT_STRING + ABC.IDENT_STRING + modifier + "function " + abc.constants.constant_multiname[abc.instance_info[class_info].name_index].getName(abc.constants, new ArrayList()/*do not want full names here*/) + "(" + constructorParams + ") {\r\n" + bodyStr + "\r\n" + ABC.IDENT_STRING + ABC.IDENT_STRING + "}"; + toPrint = Graph.INDENT_STRING + Graph.INDENT_STRING + modifier + "function " + abc.constants.constant_multiname[abc.instance_info[class_info].name_index].getName(abc.constants, new ArrayList()/*do not want full names here*/) + "(" + constructorParams + ") {\r\n" + bodyStr + "\r\n" + Graph.INDENT_STRING + Graph.INDENT_STRING + "}"; if (highlight) { toPrint = Highlighting.hilighTrait(toPrint, abc.class_info[class_info].static_traits.traits.length + abc.instance_info[class_info].instance_traits.traits.length); } @@ -514,7 +515,7 @@ public class TraitClass extends Trait implements TraitWithSlot { } } } else { - s = s.replace(ABC.IDENT_STRING, ""); + s = s.replace(Graph.INDENT_STRING, ""); } bui.append(s); } @@ -522,7 +523,7 @@ public class TraitClass extends Trait implements TraitWithSlot { //out.println(Helper.joinStrings(outTraits, "\r\n\r\n")); out.println(bui.toString()); - out.println(ABC.IDENT_STRING + "}");//class + out.println(Graph.INDENT_STRING + "}");//class out.flush(); //Highlighting.doHighlight = true; try { diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/TraitFunction.java b/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/TraitFunction.java index d8dab5f6d..bfc4ffba7 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/TraitFunction.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/TraitFunction.java @@ -19,6 +19,7 @@ package com.jpexs.decompiler.flash.abc.types.traits; import com.jpexs.decompiler.flash.abc.ABC; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.tags.ABCContainerTag; +import com.jpexs.decompiler.graph.Graph; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.helpers.Helper; import java.util.List; @@ -57,7 +58,7 @@ public class TraitFunction extends Trait implements TraitWithSlot { if (bodyIndex != -1) { bodyStr = ABC.addTabs(abc.bodies[bodyIndex].toString(path + "." + abc.constants.constant_multiname[name_index].getName(abc.constants, fullyQualifiedNames), pcode, isStatic, scriptIndex, classIndex, abc, abc.constants, abc.method_info, new Stack(), false, highlight, true, fullyQualifiedNames, null), 3); } - return ABC.IDENT_STRING + ABC.IDENT_STRING + header + (abc.instance_info[classIndex].isInterface() ? ";" : " {\r\n" + bodyStr + "\r\n" + ABC.IDENT_STRING + ABC.IDENT_STRING + "}"); + return Graph.INDENT_STRING + Graph.INDENT_STRING + header + (abc.instance_info[classIndex].isInterface() ? ";" : " {\r\n" + bodyStr + "\r\n" + Graph.INDENT_STRING + Graph.INDENT_STRING + "}"); } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/TraitMethodGetterSetter.java b/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/TraitMethodGetterSetter.java index 8acfaaae9..87f2ac11d 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/TraitMethodGetterSetter.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/TraitMethodGetterSetter.java @@ -19,6 +19,7 @@ package com.jpexs.decompiler.flash.abc.types.traits; import com.jpexs.decompiler.flash.abc.ABC; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.tags.ABCContainerTag; +import com.jpexs.decompiler.graph.Graph; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.helpers.Helper; import java.util.List; @@ -61,7 +62,7 @@ public class TraitMethodGetterSetter extends Trait { if (bodyIndex != -1) { bodyStr = ABC.addTabs(abc.bodies[bodyIndex].toString(path + "." + getName(abc).getName(abc.constants, fullyQualifiedNames), pcode, isStatic, scriptIndex, classIndex, abc, abc.constants, abc.method_info, new Stack(), false, highlight, true, fullyQualifiedNames, null), 3); } - return ABC.IDENT_STRING + ABC.IDENT_STRING + header + ((classIndex != -1 && abc.instance_info[classIndex].isInterface()) ? ";" : " {\r\n" + bodyStr + "\r\n" + ABC.IDENT_STRING + ABC.IDENT_STRING + "}"); + return Graph.INDENT_STRING + Graph.INDENT_STRING + header + ((classIndex != -1 && abc.instance_info[classIndex].isInterface()) ? ";" : " {\r\n" + bodyStr + "\r\n" + Graph.INDENT_STRING + Graph.INDENT_STRING + "}"); } @Override diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/TraitSlotConst.java b/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/TraitSlotConst.java index 17616ccc6..0f3825dd2 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/TraitSlotConst.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/TraitSlotConst.java @@ -130,7 +130,7 @@ public class TraitSlotConst extends Trait implements TraitWithSlot { if (!showModifier) { modifier = ""; } - String ret = ABC.IDENT_STRING + ABC.IDENT_STRING + modifier + getNameStr(abc, fullyQualifiedNames); + String ret = Graph.INDENT_STRING + Graph.INDENT_STRING + modifier + getNameStr(abc, fullyQualifiedNames); String valueStr = getValueStr(abc, fullyQualifiedNames); if (valueStr != null) { ret += " = "; @@ -142,15 +142,18 @@ public class TraitSlotConst extends Trait implements TraitWithSlot { continue; } if (Highlighting.stripHilights(valueStrParts[i]).equals(Graph.INDENTOPEN)) { - //befLen+=ABC.IDENT_STRING.length(); + if (!first) { + befLen += Graph.INDENT_STRING.length(); + } continue; } if (Highlighting.stripHilights(valueStrParts[i]).equals(Graph.INDENTCLOSE)) { - //befLen-=ABC.IDENT_STRING.length(); + if (!first) { + befLen -= Graph.INDENT_STRING.length(); + } continue; } if (!first) { - ret += ABC.IDENT_STRING + ABC.IDENT_STRING; for (int j = 0; j < befLen; j++) { ret += " "; }