Lombok - v0.10.8

lombok.javac
Class JavacAST

java.lang.Object
  extended by lombok.core.AST<JavacAST,JavacNode,com.sun.tools.javac.tree.JCTree>
      extended by lombok.javac.JavacAST

public class JavacAST
extends AST<JavacAST,JavacNode,com.sun.tools.javac.tree.JCTree>

Wraps around javac's internal AST view to add useful features as well as the ability to visit parents from children, something javac's own AST system does not offer.


Nested Class Summary
 
Nested classes/interfaces inherited from class lombok.core.AST
AST.FieldAccess, AST.Kind
 
Constructor Summary
JavacAST(Messager messager, com.sun.tools.javac.util.Context context, com.sun.tools.javac.tree.JCTree.JCCompilationUnit top)
          Creates a new JavacAST of the provided Compilation Unit.
 
Method Summary
protected  JavacNode buildTree(com.sun.tools.javac.tree.JCTree node, AST.Kind kind)
          Build an AST.Node object for the stated internal (javac/Eclipse) AST Node object.
 com.sun.tools.javac.util.Context getContext()
           
protected  Collection<Class<? extends com.sun.tools.javac.tree.JCTree>> getStatementTypes()
          For javac, both JCExpression and JCStatement are considered as valid children types.
 com.sun.tools.javac.code.Symtab getSymbolTable()
           
 com.sun.tools.javac.tree.TreeMaker getTreeMaker()
           
 com.sun.tools.javac.model.JavacTypes getTypesUtil()
           
protected  void setElementInASTCollection(Field field, Object refField, List<Collection<?>> chain, Collection<?> collection, int idx, com.sun.tools.javac.tree.JCTree newN)
          Override if your AST collection does not support the set method.
 com.sun.tools.javac.util.Name toName(String name)
           
 void traverse(JavacASTVisitor visitor)
          Runs through the entire AST, starting at the compilation unit, calling the provided visitor's visit methods for each node, depth first.
 
Methods inherited from class lombok.core.AST
buildWithField, clearChanged, clearState, fieldsOf, get, getFileName, getImportStatements, getNodeMap, getPackageDeclaration, isChanged, putInMap, replaceStatementInNode, setAndGetAsHandled, setChanged, setTop, top
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JavacAST

public JavacAST(Messager messager,
                com.sun.tools.javac.util.Context context,
                com.sun.tools.javac.tree.JCTree.JCCompilationUnit top)
Creates a new JavacAST of the provided Compilation Unit.

Parameters:
messager - A Messager for warning and error reporting.
context - A Context object for interfacing with the compiler.
top - The compilation unit, which serves as the top level node in the tree to be built.
Method Detail

getContext

public com.sun.tools.javac.util.Context getContext()

traverse

public void traverse(JavacASTVisitor visitor)
Runs through the entire AST, starting at the compilation unit, calling the provided visitor's visit methods for each node, depth first.


toName

public com.sun.tools.javac.util.Name toName(String name)
Returns:
A Name object generated for the proper name table belonging to this AST.

getTreeMaker

public com.sun.tools.javac.tree.TreeMaker getTreeMaker()
Returns:
A TreeMaker instance that you can use to create new AST nodes.

getSymbolTable

public com.sun.tools.javac.code.Symtab getSymbolTable()
Returns:
The symbol table used by this AST for symbols.

getTypesUtil

public com.sun.tools.javac.model.JavacTypes getTypesUtil()
Returns:
The implementation of Types of javac. Contains a few extra methods beyond the ones listed in the official annotation API interface.

buildTree

protected JavacNode buildTree(com.sun.tools.javac.tree.JCTree node,
                              AST.Kind kind)
Build an AST.Node object for the stated internal (javac/Eclipse) AST Node object.

Specified by:
buildTree in class AST<JavacAST,JavacNode,com.sun.tools.javac.tree.JCTree>

getStatementTypes

protected Collection<Class<? extends com.sun.tools.javac.tree.JCTree>> getStatementTypes()
For javac, both JCExpression and JCStatement are considered as valid children types.

Specified by:
getStatementTypes in class AST<JavacAST,JavacNode,com.sun.tools.javac.tree.JCTree>

setElementInASTCollection

protected void setElementInASTCollection(Field field,
                                         Object refField,
                                         List<Collection<?>> chain,
                                         Collection<?> collection,
                                         int idx,
                                         com.sun.tools.javac.tree.JCTree newN)
                                  throws IllegalAccessException
Override if your AST collection does not support the set method. Javac's for example, does not.

Overrides:
setElementInASTCollection in class AST<JavacAST,JavacNode,com.sun.tools.javac.tree.JCTree>
Parameters:
field - The field that contains the array or list of AST nodes.
refField - The object that you can supply to the field's get method.
chain - If the collection is immutable, you need to update the pointer to the collection in each element in the chain.
Throws:
IllegalAccessException - This exception won't happen, but we allow you to throw it so you can avoid having to catch it.

Lombok - v0.10.8

Copyright © 2009-2011 The Project Lombok Authors, licensed under the MIT licence.