PythonTreeMaker { public PrintStatement printStatement(StatementWithSeparator statementWithSeparator) { AstNode astNode = statementWithSeparator.statement(); List<Expression> expressions = expressionsFromTest(astNode); Separators separators = statementWithSeparator.separator(); return new PrintStatementImpl(toPyToken(astNode.getTokens()).get(0), expressions, separators); }  FileInput fileInput(AstNode astNode); void setParents(Tree root); AnnotatedAssignment annotatedAssignment(StatementWithSeparator statementWithSeparator); PrintStatement printStatement(StatementWithSeparator statementWithSeparator); ExecStatement execStatement(StatementWithSeparator statementWithSeparator); AssertStatement assertStatement(StatementWithSeparator statementWithSeparator); PassStatement passStatement(StatementWithSeparator statementWithSeparator); DelStatement delStatement(StatementWithSeparator statementWithSeparator); ReturnStatement returnStatement(StatementWithSeparator statementWithSeparator); YieldStatement yieldStatement(StatementWithSeparator statementWithSeparator); YieldExpression yieldExpression(AstNode astNode); RaiseStatement raiseStatement(StatementWithSeparator statementWithSeparator); BreakStatement breakStatement(StatementWithSeparator statementWithSeparator); ContinueStatement continueStatement(StatementWithSeparator statementWithSeparator); ImportStatement importStatement(StatementWithSeparator statementWithSeparator); GlobalStatement globalStatement(StatementWithSeparator statementWithSeparator); NonlocalStatement nonlocalStatement(StatementWithSeparator statementWithSeparator); IfStatement ifStatement(AstNode astNode); FunctionDef funcDefStatement(AstNode astNode); ClassDef classDefStatement(AstNode astNode); ForStatement forStatement(AstNode astNode); WhileStatementImpl whileStatement(AstNode astNode); ExpressionStatement expressionStatement(StatementWithSeparator statementWithSeparator); AssignmentStatement assignment(StatementWithSeparator statementWithSeparator); CompoundAssignmentStatement compoundAssignment(StatementWithSeparator statementWithSeparator); TryStatement tryStatement(AstNode astNode); WithStatement withStatement(AstNode astNode); Expression expression(AstNode astNode); Argument argument(AstNode astNode); LambdaExpression lambdaExpression(AstNode astNode);  }
@Test public void printStatement() { setRootRule(PythonGrammar.PRINT_STMT); AstNode astNode = p.parse("print 'foo'"); StatementWithSeparator statementWithSeparator = new StatementWithSeparator(astNode, null); PrintStatement printStmt = treeMaker.printStatement(statementWithSeparator); assertThat(printStmt).isNotNull(); assertThat(printStmt.printKeyword().value()).isEqualTo("print"); assertThat(printStmt.expressions()).hasSize(1); assertThat(printStmt.children()).hasSize(2); astNode = p.parse("print 'foo', 'bar'"); statementWithSeparator = new StatementWithSeparator(astNode, null); printStmt = treeMaker.printStatement(statementWithSeparator); assertThat(printStmt).isNotNull(); assertThat(printStmt.printKeyword().value()).isEqualTo("print"); assertThat(printStmt.expressions()).hasSize(2); assertThat(printStmt.children()).hasSize(3); astNode = p.parse("print >> 'foo'"); statementWithSeparator = new StatementWithSeparator(astNode, null); printStmt = treeMaker.printStatement(statementWithSeparator); assertThat(printStmt).isNotNull(); assertThat(printStmt.printKeyword().value()).isEqualTo("print"); assertThat(printStmt.expressions()).hasSize(1); }