MCBasicTypesPrettyPrinter implements MCBasicTypesVisitor { public String prettyprint(ASTMCBasicTypesNode a) { getPrinter().clearBuffer(); a.accept(getRealThis()); return getPrinter().getContent(); } MCBasicTypesPrettyPrinter(IndentPrinter printer); IndentPrinter getPrinter(); void setPrinter(IndentPrinter printer); @Override void handle(ASTMCQualifiedName a); @Override void handle(ASTMCVoidType a); @Override void handle(ASTMCPrimitiveType a); @Override void handle(ASTMCImportStatement a); String prettyprint(ASTMCBasicTypesNode a); void setRealThis(MCBasicTypesVisitor realThis); @Override MCBasicTypesVisitor getRealThis();  }
@Test public void testMCQualifiedName() throws IOException { MCBasicTypesTestParser parser = new MCBasicTypesTestParser(); Optional<ASTMCQualifiedName> ast = parser.parse_StringMCQualifiedName("Name1.Name2.Name3"); assertTrue(ast.isPresent()); assertFalse(parser.hasErrors()); ASTMCQualifiedName qualifiedName = ast.get(); MCBasicTypesPrettyPrinter printer = new MCBasicTypesPrettyPrinter(new IndentPrinter()); String output = printer.prettyprint(ast.get()); ast = parser.parse_StringMCQualifiedName(output); assertFalse(parser.hasErrors()); assertTrue(ast.isPresent()); assertTrue(qualifiedName.deepEquals(ast.get())); }
@Test public void testMcImportStatement() throws IOException { MCBasicTypesTestParser parser = new MCBasicTypesTestParser(); Optional<ASTMCImportStatement> ast = parser.parse_StringMCImportStatement("import de.monticore.types.*;"); assertTrue(ast.isPresent()); assertFalse(parser.hasErrors()); ASTMCImportStatement importStatement = ast.get(); MCBasicTypesPrettyPrinter printer = new MCBasicTypesPrettyPrinter(new IndentPrinter()); String output = printer.prettyprint(ast.get()); ast = parser.parse_StringMCImportStatement(output); assertFalse(parser.hasErrors()); assertTrue(ast.isPresent()); assertTrue(importStatement.deepEquals(ast.get())); }
@Test public void testMcPrimitiveType() throws IOException { MCBasicTypesTestParser parser = new MCBasicTypesTestParser(); Optional<ASTMCPrimitiveType> ast = parser.parse_StringMCPrimitiveType("long"); assertTrue(ast.isPresent()); assertFalse(parser.hasErrors()); ASTMCPrimitiveType primitiveType = ast.get(); MCBasicTypesPrettyPrinter printer = new MCBasicTypesPrettyPrinter(new IndentPrinter()); String output = printer.prettyprint(ast.get()); ast = parser.parse_StringMCPrimitiveType(output); assertFalse(parser.hasErrors()); assertTrue(ast.isPresent()); assertTrue(primitiveType.deepEquals(ast.get())); }
@Test public void testMCVoidType() throws IOException { MCBasicTypesTestParser parser = new MCBasicTypesTestParser(); Optional<ASTMCVoidType> ast = parser.parse_StringMCVoidType("void"); assertTrue(ast.isPresent()); assertFalse(parser.hasErrors()); ASTMCVoidType voidType = ast.get(); MCBasicTypesPrettyPrinter printer = new MCBasicTypesPrettyPrinter(new IndentPrinter()); String output = printer.prettyprint(ast.get()); ast = parser.parse_StringMCVoidType(output); assertFalse(parser.hasErrors()); assertTrue(ast.isPresent()); assertTrue(voidType.deepEquals(ast.get())); }
@Test public void testMCReturnTypeVoid() throws IOException { MCBasicTypesTestParser parser = new MCBasicTypesTestParser(); Optional<ASTMCReturnType> ast = parser.parse_StringMCReturnType("void"); assertTrue(ast.isPresent()); assertFalse(parser.hasErrors()); ASTMCReturnType voidType = ast.get(); MCBasicTypesPrettyPrinter printer = new MCBasicTypesPrettyPrinter(new IndentPrinter()); String output = printer.prettyprint(ast.get()); ast = parser.parse_StringMCReturnType(output); assertFalse(parser.hasErrors()); assertTrue(ast.isPresent()); assertTrue(voidType.deepEquals(ast.get())); }
@Test public void testMCReturnType() throws IOException { MCBasicTypesTestParser parser = new MCBasicTypesTestParser(); Optional<ASTMCReturnType> ast = parser.parse_StringMCReturnType("boolean"); assertTrue(ast.isPresent()); assertFalse(parser.hasErrors()); ASTMCReturnType voidType = ast.get(); MCBasicTypesPrettyPrinter printer = new MCBasicTypesPrettyPrinter(new IndentPrinter()); String output = printer.prettyprint(ast.get()); ast = parser.parse_StringMCReturnType(output); assertFalse(parser.hasErrors()); assertTrue(ast.isPresent()); assertTrue(voidType.deepEquals(ast.get())); }
@Test public void testMCQualifiedType() throws IOException { MCBasicTypesTestParser parser = new MCBasicTypesTestParser(); Optional<ASTMCQualifiedType> ast = parser.parse_StringMCQualifiedType("a.b.c.d"); assertTrue(ast.isPresent()); assertFalse(parser.hasErrors()); ASTMCQualifiedType qualifiedReferenceType = ast.get(); MCBasicTypesPrettyPrinter printer = new MCBasicTypesPrettyPrinter(new IndentPrinter()); String output = printer.prettyprint(ast.get()); ast = parser.parse_StringMCQualifiedType(output); assertFalse(parser.hasErrors()); assertTrue(ast.isPresent()); assertTrue(qualifiedReferenceType.deepEquals(ast.get())); }