mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-09-27 12:30:46 +00:00
indent open, indent close fixed
This commit is contained in:
@@ -2155,7 +2155,7 @@ public class Graph {
|
||||
* @param localData
|
||||
* @return String
|
||||
*/
|
||||
public static String graphToString(List<GraphTargetItem> tree, boolean highlight, Object... localData) {
|
||||
public static String graphToString(List<GraphTargetItem> tree, boolean highlight, boolean replaceIndents, Object... localData) {
|
||||
StringBuilder ret = new StringBuilder();
|
||||
List<Object> localDataList = Arrays.asList(localData);
|
||||
for (GraphTargetItem ti : tree) {
|
||||
@@ -2228,23 +2228,20 @@ public class Graph {
|
||||
continue;
|
||||
}
|
||||
strippedP = Highlighting.stripHilights(parts[p]).trim();
|
||||
if (strippedP.equals(INDENTOPEN)) {
|
||||
level++;
|
||||
continue;
|
||||
}
|
||||
if (strippedP.equals(INDENTCLOSE)) {
|
||||
level--;
|
||||
continue;
|
||||
}
|
||||
if (strippedP.startsWith("}")) {
|
||||
level--;
|
||||
|
||||
if (replaceIndents) {
|
||||
if (strippedP.equals(INDENTOPEN)) {
|
||||
level++;
|
||||
continue;
|
||||
}
|
||||
if (strippedP.equals(INDENTCLOSE)) {
|
||||
level--;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
ret.append(tabString(level));
|
||||
ret.append(parts[p].trim());
|
||||
ret.append("\r\n");
|
||||
if (strippedP.equals("{")) {
|
||||
level++;
|
||||
}
|
||||
}
|
||||
return ret.toString();
|
||||
}
|
||||
|
||||
@@ -37,7 +37,9 @@ public class BlockItem extends GraphTargetItem {
|
||||
|
||||
@Override
|
||||
public String toString(boolean highlight, List<Object> localData) {
|
||||
return hilight("{", highlight) + "\r\n" + Graph.graphToString(commands, highlight, localData) + "\r\n" + hilight("}", highlight);
|
||||
return hilight("{", highlight) + "\r\n" + Graph.INDENTOPEN + "\r\n" +
|
||||
Graph.graphToString(commands, highlight, false, localData) + "\r\n" +
|
||||
Graph.INDENTCLOSE + "\r\n" + hilight("}", highlight);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package com.jpexs.decompiler.graph.model;
|
||||
|
||||
import com.jpexs.decompiler.graph.Block;
|
||||
import com.jpexs.decompiler.graph.Graph;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItem;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.Loop;
|
||||
@@ -52,6 +53,7 @@ public class DoWhileItem extends LoopItem implements Block {
|
||||
String ret = "";
|
||||
ret += hilight("loop" + loop.id + ":", highlight) + "\r\n";
|
||||
ret += hilight("do", highlight) + "\r\n" + hilight("{", highlight) + "\r\n";
|
||||
ret += Graph.INDENTOPEN + "\r\n";
|
||||
for (GraphTargetItem ti : commands) {
|
||||
if (!ti.isEmpty()) {
|
||||
ret += ti.toStringSemicoloned(highlight, localData) + "\r\n";
|
||||
@@ -67,6 +69,7 @@ public class DoWhileItem extends LoopItem implements Block {
|
||||
}
|
||||
expStr += expression.get(i).toString(highlight, localData);
|
||||
}
|
||||
ret += Graph.INDENTCLOSE + "\r\n";
|
||||
ret += hilight("}", highlight) + "\r\n" + hilight("while(", highlight) + expStr + hilight(");", highlight) + "\r\n";
|
||||
ret += hilight(":loop" + loop.id, highlight);
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package com.jpexs.decompiler.graph.model;
|
||||
|
||||
import com.jpexs.decompiler.graph.Block;
|
||||
import com.jpexs.decompiler.graph.Graph;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItem;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.Loop;
|
||||
@@ -87,11 +88,13 @@ public class ForItem extends LoopItem implements Block {
|
||||
p++;
|
||||
}
|
||||
ret += hilight(")", highlight) + "\r\n" + hilight("{", highlight) + "\r\n";
|
||||
ret += Graph.INDENTOPEN + "\r\n";
|
||||
for (GraphTargetItem ti : commands) {
|
||||
if (!ti.isEmpty()) {
|
||||
ret += ti.toStringSemicoloned(highlight, localData) + "\r\n";
|
||||
}
|
||||
}
|
||||
ret += Graph.INDENTCLOSE + "\r\n";
|
||||
ret += hilight("}", highlight) + "\r\n";
|
||||
ret += ":loop" + loop.id;
|
||||
return ret;
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package com.jpexs.decompiler.graph.model;
|
||||
|
||||
import com.jpexs.decompiler.graph.Block;
|
||||
import com.jpexs.decompiler.graph.Graph;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItem;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.SourceGenerator;
|
||||
@@ -71,19 +72,23 @@ public class IfItem extends GraphTargetItem implements Block {
|
||||
}
|
||||
}
|
||||
ret = hilight("if(", highlight) + expr.toString(highlight, localData) + hilight(")", highlight) + "\r\n" + hilight("{", highlight) + "\r\n";
|
||||
ret += Graph.INDENTOPEN + "\r\n";
|
||||
for (GraphTargetItem ti : ifBranch) {
|
||||
if (!ti.isEmpty()) {
|
||||
ret += ti.toStringSemicoloned(highlight, localData) + "\r\n";
|
||||
}
|
||||
}
|
||||
ret += Graph.INDENTCLOSE + "\r\n";
|
||||
ret += hilight("}", highlight);
|
||||
if (elseBranch.size() > 0) {
|
||||
ret += "\r\n" + hilight("else", highlight) + "\r\n" + hilight("{", highlight) + "\r\n";
|
||||
ret += Graph.INDENTOPEN + "\r\n";
|
||||
for (GraphTargetItem ti : elseBranch) {
|
||||
if (!ti.isEmpty()) {
|
||||
ret += ti.toStringSemicoloned(highlight, localData) + "\r\n";
|
||||
}
|
||||
}
|
||||
ret += Graph.INDENTCLOSE + "\r\n";
|
||||
ret += hilight("}", highlight);
|
||||
}
|
||||
return ret;
|
||||
|
||||
@@ -55,6 +55,7 @@ public class SwitchItem extends LoopItem implements Block {
|
||||
String ret = "";
|
||||
ret += hilight("loopswitch" + loop.id + ":", highlight) + "\r\n";
|
||||
ret += hilight("switch(", highlight) + switchedObject.toString(highlight, localData) + hilight(")", highlight) + "\r\n" + hilight("{", highlight) + "\r\n";
|
||||
ret += Graph.INDENTOPEN + "\r\n";
|
||||
for (int i = 0; i < caseCommands.size(); i++) {
|
||||
for (int k = 0; k < valuesMapping.size(); k++) {
|
||||
if (valuesMapping.get(k) == i) {
|
||||
@@ -81,6 +82,7 @@ public class SwitchItem extends LoopItem implements Block {
|
||||
ret += Graph.INDENTCLOSE + "\r\n";
|
||||
}
|
||||
}
|
||||
ret += Graph.INDENTCLOSE + "\r\n";
|
||||
ret += hilight("}", highlight) + "\r\n";
|
||||
ret += ":loop" + loop.id;
|
||||
return ret;
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package com.jpexs.decompiler.graph.model;
|
||||
|
||||
import com.jpexs.decompiler.graph.Block;
|
||||
import com.jpexs.decompiler.graph.Graph;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItem;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.Loop;
|
||||
@@ -41,11 +42,13 @@ public class UniversalLoopItem extends LoopItem implements Block {
|
||||
ret += hilight("loop" + loop.id + ":", highlight) + "\r\n";
|
||||
ret += hilight("while(true)", highlight);
|
||||
ret += "\r\n" + hilight("{", highlight) + "\r\n";
|
||||
ret += Graph.INDENTOPEN + "\r\n";
|
||||
for (GraphTargetItem ti : commands) {
|
||||
if (!ti.isEmpty()) {
|
||||
ret += ti.toStringSemicoloned(highlight, localData) + "\r\n";
|
||||
}
|
||||
}
|
||||
ret += Graph.INDENTCLOSE + "\r\n";
|
||||
ret += hilight("}", highlight) + "\r\n";
|
||||
ret += hilight(":loop" + loop.id, highlight);
|
||||
return ret;
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package com.jpexs.decompiler.graph.model;
|
||||
|
||||
import com.jpexs.decompiler.graph.Block;
|
||||
import com.jpexs.decompiler.graph.Graph;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItem;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.Loop;
|
||||
@@ -57,11 +58,13 @@ public class WhileItem extends LoopItem implements Block {
|
||||
expStr += expression.get(i).toString(highlight, localData);
|
||||
}
|
||||
ret += hilight("while(", highlight) + expStr + hilight(")", highlight) + "\r\n" + hilight("{", highlight) + "\r\n";
|
||||
ret += Graph.INDENTOPEN + "\r\n";
|
||||
for (GraphTargetItem ti : commands) {
|
||||
if (!ti.isEmpty()) {
|
||||
ret += ti.toStringSemicoloned(highlight, localData) + "\r\n";
|
||||
}
|
||||
}
|
||||
ret += Graph.INDENTCLOSE + "\r\n";
|
||||
ret += hilight("}", highlight) + "\r\n";
|
||||
ret += hilight(":loop" + loop.id, highlight);
|
||||
return ret;
|
||||
|
||||
Reference in New Issue
Block a user