public interface AstHelper
KendalHandler.
Helper provides wide spectrum of methods that allow for modification, creation or analysis of AST nodes.
It also contains more specific helpers which deliver more specialized functionalities.| Modifier and Type | Interface and Description |
|---|---|
static class |
AstHelper.Mode
This enum is used for example when adding elements to body of a method or some objects to the declaration of
the class.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addArgToAnnotation(Node<com.sun.tools.javac.tree.JCTree.JCAnnotation> annotationNode,
Node<com.sun.tools.javac.tree.JCTree.JCAssign> arg)
Adds node arg representing assignment to a set of arguments of annotation represented by annotationNode.
|
default void |
addElementToClass(Node<com.sun.tools.javac.tree.JCTree.JCClassDecl> clazz,
Node element)
Does the same as
addElementToClass(Node, Node, Mode, int) but with APPEND mode and offset = 0. |
void |
addElementToClass(Node<com.sun.tools.javac.tree.JCTree.JCClassDecl> clazz,
Node element,
AstHelper.Mode mode,
int offset)
Adds node to a specified class according to the mode and offset.
|
<T extends com.sun.tools.javac.tree.JCTree.JCExpressionStatement> |
addExpressionStatementToConstructor(Node<com.sun.tools.javac.tree.JCTree.JCMethodDecl> method,
Node<T> expressionStatement,
AstHelper.Mode mode,
int offset)
Does the same as
addExpressionStatementToMethod(Node, Node, Mode, int) but takes into account
presence of super() invocation. |
<T extends com.sun.tools.javac.tree.JCTree.JCExpressionStatement> |
addExpressionStatementToMethod(Node<com.sun.tools.javac.tree.JCTree.JCMethodDecl> method,
Node<T> expressionStatement,
AstHelper.Mode mode,
int offset)
Adds node representing expression statement to a specified method according to the mode and offset.
|
Node<com.sun.tools.javac.tree.JCTree.JCVariableDecl> |
findFieldByNameAndType(Node<com.sun.tools.javac.tree.JCTree.JCClassDecl> classDeclNode,
Name name) |
Map<Node,Node> |
getAnnotationSourceMap(Collection<Node> annotationNodes,
String sourceQualifiedName) |
Map<String,Object> |
getAnnotationValues(Node<com.sun.tools.javac.tree.JCTree.JCAnnotation> annotationNode) |
AstNodeBuilder |
getAstNodeBuilder()
Returns Kendal AST Nodes builder which let's you create new AST nodes in easier way.
|
AstUtils |
getAstUtils()
Returns Kendal AST Utils which is a collection of utilities methods.
|
AstValidator |
getAstValidator()
Returns Kendal AST validator which contains some basic validations methods.
|
com.sun.tools.javac.util.Context |
getContext()
Returns context which allows to obtain objects from javac compiler.
|
void |
replaceNode(Node<? extends com.sun.tools.javac.tree.JCTree> parent,
Node<? extends com.sun.tools.javac.tree.JCTree> oldNode,
Node<? extends com.sun.tools.javac.tree.JCTree> newNode)
In the given parent node replaces oldNode node with the newNode.
|
void addElementToClass(Node<com.sun.tools.javac.tree.JCTree.JCClassDecl> clazz, Node element, AstHelper.Mode mode, int offset)
clazz - node representing class that is to be modifiedelement - element to be added to the classmode - either PREPEND or APPEND, defines whether we add from the beginning or the endoffset - number of lines to be skipped before element is addeddefault void addElementToClass(Node<com.sun.tools.javac.tree.JCTree.JCClassDecl> clazz, Node element)
addElementToClass(Node, Node, Mode, int) but with APPEND mode and offset = 0.void addArgToAnnotation(Node<com.sun.tools.javac.tree.JCTree.JCAnnotation> annotationNode, Node<com.sun.tools.javac.tree.JCTree.JCAssign> arg)
<T extends com.sun.tools.javac.tree.JCTree.JCExpressionStatement> void addExpressionStatementToMethod(Node<com.sun.tools.javac.tree.JCTree.JCMethodDecl> method, Node<T> expressionStatement, AstHelper.Mode mode, int offset)
method - node representing method that is to be modifiedexpressionStatement - element to be added to the methodmode - either PREPEND or APPEND, defines whether we add from the beginning or the endoffset - number of lines to be skipped before element is added<T extends com.sun.tools.javac.tree.JCTree.JCExpressionStatement> void addExpressionStatementToConstructor(Node<com.sun.tools.javac.tree.JCTree.JCMethodDecl> method, Node<T> expressionStatement, AstHelper.Mode mode, int offset) throws ImproperNodeTypeException
addExpressionStatementToMethod(Node, Node, Mode, int) but takes into account
presence of super() invocation. If present and PREPEND mode is selected, expression statement is added after it.ImproperNodeTypeExceptionvoid replaceNode(Node<? extends com.sun.tools.javac.tree.JCTree> parent, Node<? extends com.sun.tools.javac.tree.JCTree> oldNode, Node<? extends com.sun.tools.javac.tree.JCTree> newNode)
Node<com.sun.tools.javac.tree.JCTree.JCVariableDecl> findFieldByNameAndType(Node<com.sun.tools.javac.tree.JCTree.JCClassDecl> classDeclNode, Name name)
Map<Node,Node> getAnnotationSourceMap(Collection<Node> annotationNodes, String sourceQualifiedName)
Map<String,Object> getAnnotationValues(Node<com.sun.tools.javac.tree.JCTree.JCAnnotation> annotationNode)
com.sun.tools.javac.util.Context getContext()
AstNodeBuilder getAstNodeBuilder()
AstValidator getAstValidator()
AstUtils getAstUtils()
Copyright © 2019. All rights reserved.