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