mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-06-14 22:32:07 +00:00
indent fix in traitslotconst
This commit is contained in:
@@ -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<EventListener> 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) {
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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<String> 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<String>()/*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<String>()/*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 {
|
||||
|
||||
@@ -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<GraphTargetItem>(), 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 + "}");
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -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<GraphTargetItem>(), 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
|
||||
|
||||
@@ -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 += " ";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user