@Test public void testDoc() { assertEquals("", print(new Doc("PrinterTest", EMPTY_PKG, NO_IMPORTS, Util.<DataType> list()))); assertEquals("package some.package\n\n", print(new Doc("PrinterTest", Pkg._Pkg(NO_COMMENTS, "some.package"), NO_IMPORTS, Util.<DataType> list()))); assertEquals("import number.one\nimport number.two\n\n", print(new Doc("PrinterTest", EMPTY_PKG, list(Imprt._Imprt(NO_COMMENTS, "number.one"), Imprt._Imprt(NO_COMMENTS,"number.two")), Util.<DataType> list()))); assertEquals("package some.package\n\nimport number.one\nimport number.two\n\n", print(new Doc( "PrinterTest", Pkg._Pkg(NO_COMMENTS, "some.package"), list(Imprt._Imprt(NO_COMMENTS, "number.one"), Imprt._Imprt(NO_COMMENTS,"number.two")), Util.<DataType> list()))); assertEquals("package some.package\n\nimport number.one\nimport number.two\n\nFoo =\n Bar\n", print(new Doc( "PrinterTest", Pkg._Pkg(NO_COMMENTS, "some.package"), list(Imprt._Imprt(NO_COMMENTS, "number.one"), Imprt._Imprt(NO_COMMENTS,"number.two")), list(new DataType(NO_COMMENTS, NO_ANNOTATIONS, "Foo", Util.<String>list(), NO_EXTENDS, NO_IMPLEMENTS, list(new Constructor(NO_COMMENTS, "Bar", Util.<Arg> list()))))))); }
public static String print(Doc doc) { final StringBuilder builder = new StringBuilder(doc.pkg.name.isEmpty() ? "" : ("package " + doc.pkg.name + "\n\n")); if (!doc.imports.isEmpty()) { for (Imprt imp : doc.imports) { builder.append("import " + imp.name + "\n"); } builder.append("\n"); } for (DataType dataType : doc.dataTypes) { builder.append(print(dataType)); builder.append("\n"); } return builder.toString(); }
ASTPrinter { public static String print(Doc doc) { final StringBuilder builder = new StringBuilder(doc.pkg.name.isEmpty() ? "" : ("package " + doc.pkg.name + "\n\n")); if (!doc.imports.isEmpty()) { for (Imprt imp : doc.imports) { builder.append("import " + imp.name + "\n"); } builder.append("\n"); } for (DataType dataType : doc.dataTypes) { builder.append(print(dataType)); builder.append("\n"); } return builder.toString(); } }
ASTPrinter { public static String print(Doc doc) { final StringBuilder builder = new StringBuilder(doc.pkg.name.isEmpty() ? "" : ("package " + doc.pkg.name + "\n\n")); if (!doc.imports.isEmpty()) { for (Imprt imp : doc.imports) { builder.append("import " + imp.name + "\n"); } builder.append("\n"); } for (DataType dataType : doc.dataTypes) { builder.append(print(dataType)); builder.append("\n"); } return builder.toString(); }  }
ASTPrinter { public static String print(Doc doc) { final StringBuilder builder = new StringBuilder(doc.pkg.name.isEmpty() ? "" : ("package " + doc.pkg.name + "\n\n")); if (!doc.imports.isEmpty()) { for (Imprt imp : doc.imports) { builder.append("import " + imp.name + "\n"); } builder.append("\n"); } for (DataType dataType : doc.dataTypes) { builder.append(print(dataType)); builder.append("\n"); } return builder.toString(); }  static String print(Doc doc); static String printComments(String indent, List<JavaComment> comments); static String print(final String indent, JavaComment comment); static String print(DataType dataType); static String print(Constructor constructor); static String print(Arg arg); static String printArgModifiers(List<ArgModifier> modifiers); static String print(Type type); static String print(RefType type); static String print(PrimitiveType type); static String print(ArgModifier modifier); static String print(final Literal literal); static String print(Expression expression); static String print(Annotation annotation); static String print(AnnotationElement value); static String print(AnnotationValue value); static String print(BinaryOperator op); }
ASTPrinter { public static String print(Doc doc) { final StringBuilder builder = new StringBuilder(doc.pkg.name.isEmpty() ? "" : ("package " + doc.pkg.name + "\n\n")); if (!doc.imports.isEmpty()) { for (Imprt imp : doc.imports) { builder.append("import " + imp.name + "\n"); } builder.append("\n"); } for (DataType dataType : doc.dataTypes) { builder.append(print(dataType)); builder.append("\n"); } return builder.toString(); }  static String print(Doc doc); static String printComments(String indent, List<JavaComment> comments); static String print(final String indent, JavaComment comment); static String print(DataType dataType); static String print(Constructor constructor); static String print(Arg arg); static String printArgModifiers(List<ArgModifier> modifiers); static String print(Type type); static String print(RefType type); static String print(PrimitiveType type); static String print(ArgModifier modifier); static String print(final Literal literal); static String print(Expression expression); static String print(Annotation annotation); static String print(AnnotationElement value); static String print(AnnotationValue value); static String print(BinaryOperator op);  }