japa.parser

## Class ASTHelper

- java.lang.Object
- - japa.parser.ASTHelper

    public final class ASTHelper
    extends Object

This class helps to construct new nodes.

Author:
  Júlio Vilmar Gesser

### Field Summary

Fields
`static PrimitiveType` `BOOLEAN_TYPE`
`static PrimitiveType` `BYTE_TYPE`
`static PrimitiveType` `CHAR_TYPE`
`static PrimitiveType` `DOUBLE_TYPE`
`static PrimitiveType` `FLOAT_TYPE`
`static PrimitiveType` `INT_TYPE`
`static PrimitiveType` `LONG_TYPE`
`static PrimitiveType` `SHORT_TYPE`
`static VoidType` `VOID_TYPE`

### Method Summary

All Methods Static Methods Concrete Methods
`static void` `addArgument(MethodCallExpr call, Expression arg)` Adds the given argument to the method call.
`static void` `addMember(TypeDeclaration type, BodyDeclaration decl)` Adds the given declaration to the specified type.
`static void` `addParameter(MethodDeclaration method, Parameter parameter)` Adds the given parameter to the method.
`static void` `addStmt(BlockStmt block, Expression expr)` Adds the given expression to the specified block.
`static void` `addStmt(BlockStmt block, Statement stmt)` Adds the given statement to the specified block.
`static void` `addTypeDeclaration(CompilationUnit cu, TypeDeclaration type)` Adds the given type declaration to the compilation unit.
`static FieldDeclaration` `createFieldDeclaration(int modifiers, Type type, String name)` Creates a `FieldDeclaration`.
`static FieldDeclaration` `createFieldDeclaration(int modifiers, Type type, VariableDeclarator variable)` Creates a `FieldDeclaration`.
`static NameExpr` `createNameExpr(String qualifiedName)` Creates a new `NameExpr` from a qualified name. The qualified name can contains "." (dot) characters.
`static Parameter` `createParameter(Type type, String name)` Creates a new `Parameter`.
`static ReferenceType` `createReferenceType(PrimitiveType type, int arrayCount)` Creates a new `ReferenceType` for the given primitive type.
`static ReferenceType` `createReferenceType(String name, int arrayCount)` Creates a new `ReferenceType` for a class or interface.
`static VariableDeclarationExpr` `createVariableDeclarationExpr(Type type, String name)` Creates a `VariableDeclarationExpr`.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Field Detail

#### BYTE_TYPE

    public static final PrimitiveType BYTE_TYPE

#### SHORT_TYPE

    public static final PrimitiveType SHORT_TYPE

#### INT_TYPE

    public static final PrimitiveType INT_TYPE

#### LONG_TYPE

    public static final PrimitiveType LONG_TYPE

#### FLOAT_TYPE

    public static final PrimitiveType FLOAT_TYPE

#### DOUBLE_TYPE

    public static final PrimitiveType DOUBLE_TYPE

#### BOOLEAN_TYPE

    public static final PrimitiveType BOOLEAN_TYPE

#### CHAR_TYPE

    public static final PrimitiveType CHAR_TYPE

#### VOID_TYPE

    public static final VoidType VOID_TYPE

### Method Detail

#### createNameExpr

    public static NameExpr createNameExpr(String qualifiedName)

Creates a new `NameExpr` from a qualified name.
The qualified name can contains "." (dot) characters.

Parameters:
  `qualifiedName` - qualified name
Returns:
  instanceof `NameExpr`

#### createParameter

    public static Parameter createParameter(Type type,
                                            String name)

Creates a new `Parameter`.

Parameters:
  `type` - type of the parameter
  `name` - name of the parameter
Returns:
  instance of `Parameter`

#### createFieldDeclaration

    public static FieldDeclaration createFieldDeclaration(int modifiers,
                                                          Type type,
                                                          VariableDeclarator variable)

Creates a `FieldDeclaration`.

Parameters:
  `modifiers` - modifiers
  `type` - type
  `variable` - variable declarator
Returns:
  instance of `FieldDeclaration`

#### createFieldDeclaration

    public static FieldDeclaration createFieldDeclaration(int modifiers,
                                                          Type type,
                                                          String name)

Creates a `FieldDeclaration`.

Parameters:
  `modifiers` - modifiers
  `type` - type
  `name` - field name
Returns:
  instance of `FieldDeclaration`

#### createVariableDeclarationExpr

    public static VariableDeclarationExpr createVariableDeclarationExpr(Type type,
                                                                        String name)

Creates a `VariableDeclarationExpr`.

Parameters:
  `type` - type
  `name` - name
Returns:
  instance of `VariableDeclarationExpr`

#### addParameter

    public static void addParameter(MethodDeclaration method,
                                    Parameter parameter)

Adds the given parameter to the method. The list of parameters will be initialized if it is `null`.

Parameters:
  `method` - method
  `parameter` - parameter

#### addArgument

    public static void addArgument(MethodCallExpr call,
                                   Expression arg)

Adds the given argument to the method call. The list of arguments will be initialized if it is `null`.

Parameters:
  `call` - method call
  `arg` - argument value

#### addTypeDeclaration

    public static void addTypeDeclaration(CompilationUnit cu,
                                          TypeDeclaration type)

Adds the given type declaration to the compilation unit. The list of types will be initialized if it is `null`.

Parameters:
  `cu` - compilation unit
  `type` - type declaration

#### createReferenceType

    public static ReferenceType createReferenceType(String name,
                                                    int arrayCount)

Creates a new `ReferenceType` for a class or interface.

Parameters:
  `name` - name of the class or interface
  `arrayCount` - number os arrays or `0` if is not a array.
Returns:
  instanceof `ReferenceType`

#### createReferenceType

    public static ReferenceType createReferenceType(PrimitiveType type,
                                                    int arrayCount)

Creates a new `ReferenceType` for the given primitive type.

Parameters:
  `type` - primitive type
  `arrayCount` - number os arrays or `0` if is not a array.
Returns:
  instanceof `ReferenceType`

#### addStmt

    public static void addStmt(BlockStmt block,
                               Statement stmt)

Adds the given statement to the specified block. The list of statements will be initialized if it is `null`.

Parameters:
  `block` -
  `stmt` -

#### addStmt

    public static void addStmt(BlockStmt block,
                               Expression expr)

Adds the given expression to the specified block. The list of statements will be initialized if it is `null`.

Parameters:
  `block` -
  `stmt` -

#### addMember

    public static void addMember(TypeDeclaration type,
                                 BodyDeclaration decl)

Adds the given declaration to the specified type. The list of members will be initialized if it is `null`.

Parameters:
  `type` - type declaration
  `decl` - member declaration