private static void printSourceAttributionTree(PrintWriter p, Node parent, Node node, int level) { if (node == null) { return; } if (parent == null) { // Add some preliminary information before starting with the root node final SourceSection sourceSection = node.getSourceSection(); if (sourceSection != null) { final String txt = sourceSection.getSource().getCode(); p.println("Full source len=(" + txt.length() + ") ___" + txt + "___"); p.println("AST source attribution:"); } } final StringBuilder sb = new StringBuilder(); for (int i = 0; i < level; i++) { sb.append("| "); } if (parent != null) { sb.append(getNodeFieldName(parent, node, "")); } sb.append(" (" + node.getClass().getSimpleName() + ") "); sb.append(printSyntaxTags(node)); sb.append(displaySourceAttribution(node)); p.println(sb.toString()); for (Node child : node.getChildren()) { printSourceAttributionTree(p, node, child, level + 1); } p.flush(); }
private static void printSourceAttributionTree(PrintWriter p, Node parent, Node node, int level) { if (node == null) { return; } if (parent == null) { // Add some preliminary information before starting with the root node final SourceSection sourceSection = node.getSourceSection(); if (sourceSection != null) { final String txt = sourceSection.getSource().getCharacters().toString(); p.println("Full source len=(" + txt.length() + ") ___" + txt + "___"); p.println("AST source attribution:"); } } final StringBuilder sb = new StringBuilder(); for (int i = 0; i < level; i++) { sb.append("| "); } if (parent != null) { sb.append(getNodeFieldName(parent, node, "")); } sb.append(" (" + node.getClass().getSimpleName() + ") "); sb.append(printSyntaxTags(node)); sb.append(displaySourceAttribution(node)); p.println(sb.toString()); for (Node child : node.getChildren()) { printSourceAttributionTree(p, node, child, level + 1); } p.flush(); }
private static void printSourceAttributionTree(PrintWriter p, Node parent, Node node, int level) { if (node == null) { return; } if (parent == null) { // Add some preliminary information before starting with the root node final SourceSection sourceSection = node.getSourceSection(); if (sourceSection != null) { final String txt = sourceSection.getSource().getCharacters().toString(); p.println("Full source len=(" + txt.length() + ") ___" + txt + "___"); p.println("AST source attribution:"); } } final StringBuilder sb = new StringBuilder(); for (int i = 0; i < level; i++) { sb.append("| "); } if (parent != null) { sb.append(getNodeFieldName(parent, node, "")); } sb.append(" (" + node.getClass().getSimpleName() + ") "); sb.append(printSyntaxTags(node)); sb.append(displaySourceAttribution(node)); p.println(sb.toString()); for (Node child : node.getChildren()) { printSourceAttributionTree(p, node, child, level + 1); } p.flush(); }
p.print(NodeUtil.printSyntaxTags(node));