Split methods

This commit is contained in:
Carlos Galindo 2019-04-04 00:51:10 +02:00
parent 5ea988992a
commit 47bff81942
Signed by untrusted user who does not match committer: kauron
GPG key ID: 83E68706DEE119A3

View file

@ -123,22 +123,21 @@ public class CFG {
return res;
}
private String node2str(Node s) {
if (s == beginNode)
return "Start";
if (s == endNode)
return "Stop";
int index = -1;
for (int i = 0; i < nodes.size(); i++) {
if (nodes.get(i) == s) {
index = i;
break;
}
}
if (index == -1)
throw new RuntimeException("Internal error, can't find node");
return "\"(" + (index + 1) + ", " + s.getRange().get().begin.line + ") "
+ s.toString().replace("\"", "\\\"") + "\"";
private String node2str(Node n) {
if (n == beginNode) return "Start";
if (n == endNode) return "Stop";
return String.format("\"(%d, %d) %s\"", indexOfNode(n) + 1, n.getRange().get().begin.line, escape(n.toString()));
}
private int indexOfNode(Node n) {
for (int i = 0; i < nodes.size(); i++)
if (nodes.get(i) == n)
return i;
throw new RuntimeException("Internal error, can't find node in list");
}
private String escape(String s) {
return s.replace("\"", "\\\"");
}
private static int clusterId = 0;