Package org.codehaus.janino
Class UnparseVisitor
- java.lang.Object
-
- org.codehaus.janino.UnparseVisitor
-
- All Implemented Interfaces:
Visitor.AnnotationVisitor
,Visitor.AtomVisitor
,Visitor.BlockStatementVisitor
,Visitor.ComprehensiveVisitor
,Visitor.ElementValueArrayInitializerVisitor
,Visitor.ElementValueVisitor
,Visitor.ImportVisitor
,Visitor.LvalueVisitor
,Visitor.RvalueVisitor
,Visitor.TypeBodyDeclarationVisitor
,Visitor.TypeDeclarationVisitor
,Visitor.TypeVisitor
public class UnparseVisitor extends java.lang.Object implements Visitor.ComprehensiveVisitor
A visitor that unparses (un-compiles) an AST to aWriter
. Seemain(String[])
for a usage example.
-
-
Constructor Summary
Constructors Constructor Description UnparseVisitor(java.io.Writer w)
-
Method Summary
-
-
-
Method Detail
-
main
public static void main(java.lang.String[] args) throws java.lang.Exception
Testing of parsing/unparsing.Reads compilation units from the files named on the command line and unparses them to
System.out
.- Throws:
java.lang.Exception
-
unparse
public static void unparse(Java.CompilationUnit cu, java.io.Writer w)
Unparse the givenJava.CompilationUnit
to the givenWriter
.
-
close
public void close()
Flushes all generated code.
-
unparseCompilationUnit
public void unparseCompilationUnit(Java.CompilationUnit cu)
-
visitSingleTypeImportDeclaration
public void visitSingleTypeImportDeclaration(Java.CompilationUnit.SingleTypeImportDeclaration stid)
Description copied from interface:Visitor.ImportVisitor
E.g. 'import pkg.Type
'.- Specified by:
visitSingleTypeImportDeclaration
in interfaceVisitor.ImportVisitor
-
visitTypeImportOnDemandDeclaration
public void visitTypeImportOnDemandDeclaration(Java.CompilationUnit.TypeImportOnDemandDeclaration tiodd)
Description copied from interface:Visitor.ImportVisitor
E.g. 'import pkg.*
'.- Specified by:
visitTypeImportOnDemandDeclaration
in interfaceVisitor.ImportVisitor
-
visitSingleStaticImportDeclaration
public void visitSingleStaticImportDeclaration(Java.CompilationUnit.SingleStaticImportDeclaration ssid)
Description copied from interface:Visitor.ImportVisitor
E.g. 'import static pkg.Type.member
'.- Specified by:
visitSingleStaticImportDeclaration
in interfaceVisitor.ImportVisitor
-
visitStaticImportOnDemandDeclaration
public void visitStaticImportOnDemandDeclaration(Java.CompilationUnit.StaticImportOnDemandDeclaration siodd)
Description copied from interface:Visitor.ImportVisitor
E.g. 'import static pkg.Type.*
'.- Specified by:
visitStaticImportOnDemandDeclaration
in interfaceVisitor.ImportVisitor
-
visitLocalClassDeclaration
public void visitLocalClassDeclaration(Java.LocalClassDeclaration lcd)
Description copied from interface:Visitor.TypeDeclarationVisitor
E.g. 'class LocalClass { ... }'.- Specified by:
visitLocalClassDeclaration
in interfaceVisitor.TypeDeclarationVisitor
-
visitMemberClassDeclaration
public void visitMemberClassDeclaration(Java.MemberClassDeclaration mcd)
Description copied from interface:Visitor.TypeDeclarationVisitor
E.g. 'public class TopLevelClass { public class MemberClass { ... } }'.- Specified by:
visitMemberClassDeclaration
in interfaceVisitor.TypeBodyDeclarationVisitor
- Specified by:
visitMemberClassDeclaration
in interfaceVisitor.TypeDeclarationVisitor
-
visitMemberInterfaceDeclaration
public void visitMemberInterfaceDeclaration(Java.MemberInterfaceDeclaration mid)
Description copied from interface:Visitor.TypeDeclarationVisitor
E.g. 'public class TopLevelClass { public interface MemberInterface { ... } }'.- Specified by:
visitMemberInterfaceDeclaration
in interfaceVisitor.TypeBodyDeclarationVisitor
- Specified by:
visitMemberInterfaceDeclaration
in interfaceVisitor.TypeDeclarationVisitor
-
visitPackageMemberClassDeclaration
public void visitPackageMemberClassDeclaration(Java.PackageMemberClassDeclaration pmcd)
Description copied from interface:Visitor.TypeDeclarationVisitor
E.g. 'public class TopLevelClass { ... }'.- Specified by:
visitPackageMemberClassDeclaration
in interfaceVisitor.TypeDeclarationVisitor
-
visitPackageMemberInterfaceDeclaration
public void visitPackageMemberInterfaceDeclaration(Java.PackageMemberInterfaceDeclaration pmid)
Description copied from interface:Visitor.TypeDeclarationVisitor
E.g. 'public TopLevelInterface { ... }'.- Specified by:
visitPackageMemberInterfaceDeclaration
in interfaceVisitor.TypeDeclarationVisitor
-
visitConstructorDeclarator
public void visitConstructorDeclarator(Java.ConstructorDeclarator cd)
Description copied from interface:Visitor.TypeBodyDeclarationVisitor
E.g. 'public MyClass(...) { ... }'.- Specified by:
visitConstructorDeclarator
in interfaceVisitor.TypeBodyDeclarationVisitor
-
visitMethodDeclarator
public void visitMethodDeclarator(Java.MethodDeclarator md)
Description copied from interface:Visitor.TypeBodyDeclarationVisitor
E.g. 'public void meth(...) { ... }'.- Specified by:
visitMethodDeclarator
in interfaceVisitor.TypeBodyDeclarationVisitor
-
visitFieldDeclaration
public void visitFieldDeclaration(Java.FieldDeclaration fd)
Description copied from interface:Visitor.TypeBodyDeclarationVisitor
E.g. 'public int field;'.- Specified by:
visitFieldDeclaration
in interfaceVisitor.BlockStatementVisitor
- Specified by:
visitFieldDeclaration
in interfaceVisitor.TypeBodyDeclarationVisitor
-
visitInitializer
public void visitInitializer(Java.Initializer i)
Description copied from interface:Visitor.TypeBodyDeclarationVisitor
E.g. 'public class MyClass { static { ... } }'.- Specified by:
visitInitializer
in interfaceVisitor.BlockStatementVisitor
- Specified by:
visitInitializer
in interfaceVisitor.TypeBodyDeclarationVisitor
-
visitBlock
public void visitBlock(Java.Block b)
- Specified by:
visitBlock
in interfaceVisitor.BlockStatementVisitor
-
visitBreakStatement
public void visitBreakStatement(Java.BreakStatement bs)
- Specified by:
visitBreakStatement
in interfaceVisitor.BlockStatementVisitor
-
visitContinueStatement
public void visitContinueStatement(Java.ContinueStatement cs)
- Specified by:
visitContinueStatement
in interfaceVisitor.BlockStatementVisitor
-
visitAssertStatement
public void visitAssertStatement(Java.AssertStatement as)
- Specified by:
visitAssertStatement
in interfaceVisitor.BlockStatementVisitor
-
visitDoStatement
public void visitDoStatement(Java.DoStatement ds)
- Specified by:
visitDoStatement
in interfaceVisitor.BlockStatementVisitor
-
visitEmptyStatement
public void visitEmptyStatement(Java.EmptyStatement es)
- Specified by:
visitEmptyStatement
in interfaceVisitor.BlockStatementVisitor
-
visitExpressionStatement
public void visitExpressionStatement(Java.ExpressionStatement es)
- Specified by:
visitExpressionStatement
in interfaceVisitor.BlockStatementVisitor
-
visitForStatement
public void visitForStatement(Java.ForStatement fs)
- Specified by:
visitForStatement
in interfaceVisitor.BlockStatementVisitor
-
visitIfStatement
public void visitIfStatement(Java.IfStatement is)
- Specified by:
visitIfStatement
in interfaceVisitor.BlockStatementVisitor
-
visitLabeledStatement
public void visitLabeledStatement(Java.LabeledStatement ls)
- Specified by:
visitLabeledStatement
in interfaceVisitor.BlockStatementVisitor
-
visitLocalClassDeclarationStatement
public void visitLocalClassDeclarationStatement(Java.LocalClassDeclarationStatement lcds)
- Specified by:
visitLocalClassDeclarationStatement
in interfaceVisitor.BlockStatementVisitor
-
visitLocalVariableDeclarationStatement
public void visitLocalVariableDeclarationStatement(Java.LocalVariableDeclarationStatement lvds)
- Specified by:
visitLocalVariableDeclarationStatement
in interfaceVisitor.BlockStatementVisitor
-
visitReturnStatement
public void visitReturnStatement(Java.ReturnStatement rs)
- Specified by:
visitReturnStatement
in interfaceVisitor.BlockStatementVisitor
-
visitSwitchStatement
public void visitSwitchStatement(Java.SwitchStatement ss)
- Specified by:
visitSwitchStatement
in interfaceVisitor.BlockStatementVisitor
-
visitSynchronizedStatement
public void visitSynchronizedStatement(Java.SynchronizedStatement ss)
- Specified by:
visitSynchronizedStatement
in interfaceVisitor.BlockStatementVisitor
-
visitThrowStatement
public void visitThrowStatement(Java.ThrowStatement ts)
- Specified by:
visitThrowStatement
in interfaceVisitor.BlockStatementVisitor
-
visitTryStatement
public void visitTryStatement(Java.TryStatement ts)
- Specified by:
visitTryStatement
in interfaceVisitor.BlockStatementVisitor
-
visitWhileStatement
public void visitWhileStatement(Java.WhileStatement ws)
- Specified by:
visitWhileStatement
in interfaceVisitor.BlockStatementVisitor
-
unparseVariableDeclarator
public void unparseVariableDeclarator(Java.VariableDeclarator vd)
-
unparseFormalParameter
public void unparseFormalParameter(Java.FunctionDeclarator.FormalParameter fp)
-
visitMethodInvocation
public void visitMethodInvocation(Java.MethodInvocation mi)
- Specified by:
visitMethodInvocation
in interfaceVisitor.RvalueVisitor
-
visitAlternateConstructorInvocation
public void visitAlternateConstructorInvocation(Java.AlternateConstructorInvocation aci)
- Specified by:
visitAlternateConstructorInvocation
in interfaceVisitor.BlockStatementVisitor
-
visitSuperConstructorInvocation
public void visitSuperConstructorInvocation(Java.SuperConstructorInvocation sci)
- Specified by:
visitSuperConstructorInvocation
in interfaceVisitor.BlockStatementVisitor
-
visitNewClassInstance
public void visitNewClassInstance(Java.NewClassInstance nci)
- Specified by:
visitNewClassInstance
in interfaceVisitor.RvalueVisitor
-
visitAssignment
public void visitAssignment(Java.Assignment a)
- Specified by:
visitAssignment
in interfaceVisitor.RvalueVisitor
-
visitAmbiguousName
public void visitAmbiguousName(Java.AmbiguousName an)
- Specified by:
visitAmbiguousName
in interfaceVisitor.LvalueVisitor
-
visitArrayAccessExpression
public void visitArrayAccessExpression(Java.ArrayAccessExpression aae)
- Specified by:
visitArrayAccessExpression
in interfaceVisitor.LvalueVisitor
-
visitArrayLength
public void visitArrayLength(Java.ArrayLength al)
- Specified by:
visitArrayLength
in interfaceVisitor.RvalueVisitor
-
visitArrayType
public void visitArrayType(Java.ArrayType at)
- Specified by:
visitArrayType
in interfaceVisitor.TypeVisitor
-
visitBasicType
public void visitBasicType(Java.BasicType bt)
- Specified by:
visitBasicType
in interfaceVisitor.TypeVisitor
-
visitBinaryOperation
public void visitBinaryOperation(Java.BinaryOperation bo)
- Specified by:
visitBinaryOperation
in interfaceVisitor.RvalueVisitor
-
visitCast
public void visitCast(Java.Cast c)
- Specified by:
visitCast
in interfaceVisitor.RvalueVisitor
-
visitClassLiteral
public void visitClassLiteral(Java.ClassLiteral cl)
- Specified by:
visitClassLiteral
in interfaceVisitor.RvalueVisitor
-
visitConditionalExpression
public void visitConditionalExpression(Java.ConditionalExpression ce)
- Specified by:
visitConditionalExpression
in interfaceVisitor.RvalueVisitor
-
visitCrement
public void visitCrement(Java.Crement c)
- Specified by:
visitCrement
in interfaceVisitor.RvalueVisitor
-
visitFieldAccess
public void visitFieldAccess(Java.FieldAccess fa)
- Specified by:
visitFieldAccess
in interfaceVisitor.LvalueVisitor
-
visitFieldAccessExpression
public void visitFieldAccessExpression(Java.FieldAccessExpression fae)
- Specified by:
visitFieldAccessExpression
in interfaceVisitor.LvalueVisitor
-
visitSuperclassFieldAccessExpression
public void visitSuperclassFieldAccessExpression(Java.SuperclassFieldAccessExpression scfae)
- Specified by:
visitSuperclassFieldAccessExpression
in interfaceVisitor.LvalueVisitor
-
visitInstanceof
public void visitInstanceof(Java.Instanceof io)
- Specified by:
visitInstanceof
in interfaceVisitor.RvalueVisitor
-
visitIntegerLiteral
public void visitIntegerLiteral(Java.IntegerLiteral il)
- Specified by:
visitIntegerLiteral
in interfaceVisitor.RvalueVisitor
-
visitFloatingPointLiteral
public void visitFloatingPointLiteral(Java.FloatingPointLiteral fpl)
- Specified by:
visitFloatingPointLiteral
in interfaceVisitor.RvalueVisitor
-
visitBooleanLiteral
public void visitBooleanLiteral(Java.BooleanLiteral bl)
- Specified by:
visitBooleanLiteral
in interfaceVisitor.RvalueVisitor
-
visitCharacterLiteral
public void visitCharacterLiteral(Java.CharacterLiteral cl)
- Specified by:
visitCharacterLiteral
in interfaceVisitor.RvalueVisitor
-
visitStringLiteral
public void visitStringLiteral(Java.StringLiteral sl)
- Specified by:
visitStringLiteral
in interfaceVisitor.RvalueVisitor
-
visitNullLiteral
public void visitNullLiteral(Java.NullLiteral nl)
- Specified by:
visitNullLiteral
in interfaceVisitor.RvalueVisitor
-
visitLocalVariableAccess
public void visitLocalVariableAccess(Java.LocalVariableAccess lva)
- Specified by:
visitLocalVariableAccess
in interfaceVisitor.LvalueVisitor
-
visitNewArray
public void visitNewArray(Java.NewArray na)
- Specified by:
visitNewArray
in interfaceVisitor.RvalueVisitor
-
visitNewInitializedArray
public void visitNewInitializedArray(Java.NewInitializedArray nai)
- Specified by:
visitNewInitializedArray
in interfaceVisitor.RvalueVisitor
-
visitPackage
public void visitPackage(Java.Package p)
- Specified by:
visitPackage
in interfaceVisitor.AtomVisitor
-
visitParameterAccess
public void visitParameterAccess(Java.ParameterAccess pa)
- Specified by:
visitParameterAccess
in interfaceVisitor.RvalueVisitor
-
visitQualifiedThisReference
public void visitQualifiedThisReference(Java.QualifiedThisReference qtr)
- Specified by:
visitQualifiedThisReference
in interfaceVisitor.RvalueVisitor
-
visitReferenceType
public void visitReferenceType(Java.ReferenceType rt)
- Specified by:
visitReferenceType
in interfaceVisitor.TypeVisitor
-
visitRvalueMemberType
public void visitRvalueMemberType(Java.RvalueMemberType rmt)
- Specified by:
visitRvalueMemberType
in interfaceVisitor.TypeVisitor
-
visitSimpleType
public void visitSimpleType(Java.SimpleType st)
- Specified by:
visitSimpleType
in interfaceVisitor.TypeVisitor
-
visitSuperclassMethodInvocation
public void visitSuperclassMethodInvocation(Java.SuperclassMethodInvocation smi)
- Specified by:
visitSuperclassMethodInvocation
in interfaceVisitor.RvalueVisitor
-
visitThisReference
public void visitThisReference(Java.ThisReference tr)
- Specified by:
visitThisReference
in interfaceVisitor.RvalueVisitor
-
visitUnaryOperation
public void visitUnaryOperation(Java.UnaryOperation uo)
- Specified by:
visitUnaryOperation
in interfaceVisitor.RvalueVisitor
-
visitParenthesizedExpression
public void visitParenthesizedExpression(Java.ParenthesizedExpression pe)
- Specified by:
visitParenthesizedExpression
in interfaceVisitor.LvalueVisitor
-
visitAnonymousClassDeclaration
public void visitAnonymousClassDeclaration(Java.AnonymousClassDeclaration acd)
Description copied from interface:Visitor.TypeDeclarationVisitor
E.g. 'new Superclass() { ... }'.- Specified by:
visitAnonymousClassDeclaration
in interfaceVisitor.TypeDeclarationVisitor
-
visitNewAnonymousClassInstance
public void visitNewAnonymousClassInstance(Java.NewAnonymousClassInstance naci)
- Specified by:
visitNewAnonymousClassInstance
in interfaceVisitor.RvalueVisitor
-
visitMarkerAnnotation
public void visitMarkerAnnotation(Java.MarkerAnnotation ma)
- Specified by:
visitMarkerAnnotation
in interfaceVisitor.AnnotationVisitor
-
visitNormalAnnotation
public void visitNormalAnnotation(Java.NormalAnnotation na)
- Specified by:
visitNormalAnnotation
in interfaceVisitor.AnnotationVisitor
-
visitSingleElementAnnotation
public void visitSingleElementAnnotation(Java.SingleElementAnnotation sea)
- Specified by:
visitSingleElementAnnotation
in interfaceVisitor.AnnotationVisitor
-
visitElementValueArrayInitializer
public void visitElementValueArrayInitializer(Java.ElementValueArrayInitializer evai)
- Specified by:
visitElementValueArrayInitializer
in interfaceVisitor.ElementValueArrayInitializerVisitor
-
-