com.togethersoft.sca.ast
Interface AstObject

All Known Subinterfaces:
AstArrayCreationExpression, AstArrayInitializer, AstArrayReference, AstAssertStatement, AstAssignmentExpression, AstBinaryExpression, AstBooleanLiteral, AstBreakStatement, AstCaseLabel, AstCastExpression, AstCatchClause, AstCharLiteral, AstClassFile, AstComment, AstCompilationUnit, AstCompoundStatement, AstConditionalExpression, AstConstructorInvocation, AstContinueStatement, AstDbcResult, AstDeclaration, AstDeclarationStatement, AstDoStatement, AstDoubleLiteral, AstElement, AstEmptyStatement, AstExpression, AstExpressionStatement, AstField, AstFieldReference, AstFinallyClause, AstFloatLiteral, AstForStatement, AstIfStatement, AstImport, AstInitializer, AstIntLiteral, AstJavadocTag, AstLiteral, AstLongLiteral, AstMember, AstMethod, AstMethodCallExpression, AstModifier, AstNullLiteral, AstObjectCreationExpression, AstPackage, AstParenthesizedExpression, AstReference, AstReturnStatement, AstSimpleReference, AstStatement, AstStringLiteral, AstSuperExpression, AstSwitchGroup, AstSwitchStatement, AstSynchronizedStatement, AstThisExpression, AstThrowSpecifier, AstThrowStatement, AstTryStatement, AstType, AstTypeExpression, AstUnaryExpression, AstVarDeclaration, AstVariable, AstWhileStatement

public interface AstObject

Represents an abstract syntax tree (AST) node which is the basic building block of the AST model. The AST objects are basically declarations, statements and expressions organized in a hierarchical tree structure.


Field Summary
static int ARRAY_CREATION
          Constant representing a new array creation expression.
static int ARRAY_INITIALIZER
          Constant representing an array initializer.
static int ARRAY_REFERENCE
          Constant representing an array access expression.
static int ASSERT_STATEMENT
          Constant representing an assertion statement.
static int ASSIGNMENT_EXPRESSION
          Constant representing an assignment expression.
static int BINARY_EXPRESSION
          Constant representing a binary expression.
static int BREAK_STATEMENT
          Constant representing a break statement.
static int CASE_LABEL
          Constant representing a case label.
static int CAST_EXPRESSION
          Constant representing a type cast expression.
static int CATCH_CLAUSE
          Constant representing a catch clause of a try statement.
static int CLASS_FILE
          Constant representing a class file.
static int COMMENT
          Constant representing a comment.
static int COMPILATION_UNIT
          Constant representing a compilation unit.
static int COMPOUND_STATEMENT
          Constant representing a compound statement.
static int CONDITIONAL_EXPRESSION
          Constant representing a conditional expression.
static int CONSTRUCTOR_INVOCATION
          Constant representing an explicit constructor invocation.
static int CONTINUE_STATEMENT
          Constant representing a continue statement.
static int DBC_RESULT
          Constant representing a reference to a returned value.
static int DECLARATION_STATEMENT
          Constant representing a declaration statement.
static int DO_STATEMENT
          Constant representing a do statement.
static int EMPTY_STATEMENT
          Constant representing an empty statement.
static int EXPRESSION_STATEMENT
          Constant representing an expression statement.
static int FIELD_REFERENCE
          Constant representing a field access expression.
static int FINALLY_CLAUSE
          Constant representing a finally clause of a try statement.
static int FOR_STATEMENT
          Constant representing a for statement.
static int IF_STATEMENT
          Constant representing an if statement.
static int IMPORT
          Constant representing an import declaration.
static int INITIALIZER
          Constant representing a class initializer.
static int JAVADOC_TAG
          Constant representing a Javadoc tag.
static int LITERAL
          Constant representing a literal.
static int METHOD
          Constant representing a method declaration.
static int METHOD_CALL_EXPRESSION
          Constant representing a method invocation expression.
static int N_A
          Constant representing an object that does not fit into this model.
static int OBJECT_CREATION_EXPRESSION
          Constant representing a new object instantiation expression.
static int PACKAGE
          Constant representing a package.
static int PARENTHESIZED_EXPRESSION
          Constant representing a parenthesized expression.
static int RETURN_STATEMENT
          Constant representing a return statement.
static int SIMPLE_REFERENCE
          Constant representing a single identifier expression.
static int SUPER_EXPRESSION
          Constant representing a superclass access expression.
static int SWITCH_GROUP
          Constant representing a switch group statement.
static int SWITCH_STATEMENT
          Constant representing a switch statement.
static int SYNCHRONIZED_STATEMENT
          Constant representing a synchronized statement.
static int THIS_EXPRESSION
          Constant representing a this class access expression.
static int THROW_SPECIFIER
          Constant representing an exception type specified in a method's throw clause.
static int THROW_STATEMENT
          Constant representing a throw statement.
static int TRY_STATEMENT
          Constant representing a try statement.
static int TYPE
          Constant representing a class or an interface.
static int TYPE_EXPRESSION
          Constant representing a type expression.
static int UNARY_EXPRESSION
          Constant representing a unary expression.
static int VARIABLE
          Constant representing a declaration a field, local variable, or method parameter.
static int VARIABLE_DECLARATION
          Constant representing a variable declaration.
static int WHILE_STATEMENT
          Constant representing a while statement.
 
Method Summary
 void addComment(AstComment comment)
          Add new comment to the statement
 AstObject[] getChildren()
          Returns the AST objects directly enclosed by this object.
 AstComment[] getComments()
          Returns a list of comments associated with this object.
 AstCompilationUnit getCompilationUnit()
          Returns the compilation unit in which this object is declared, or null if this type is not declared in a compilation unit (for example, it is contained in a binary type or a compilation unit itself).
 AstMethod getDeclaringMethod()
          Returns the method in which this object is declared, or null if this object is not declared in a method (for example, a field initializer).
 AstType getDeclaringType()
          Returns the type in which this object is declared, or null if this object is not declared in a type (for example, a top-level type).
 int getObjectKind()
          Returns this object's kind, encoded as an integer.
 AstPackage getPackage()
          Returns the package in which this object is declared, or null if this object is not declared in a package (for example, a top-level package).
 AstObject getParent()
          Returns the object directly containing this object, or null if this element has no parent.
 AstSourcePosition getPosition()
          Returns the source range associated with this object, or null if this object has no associated source code.
 boolean isDeleted()
          Check if AST node is deleted by autofix/
 void remove()
          Remove this object from abstract syntax tree
 void replaceWith(AstObject obj)
          Replace object
 void replaceWith(AstObject obj, AstObject parent)
          Replace object
 void setPosition(AstSourcePosition position)
          Set source poistion for object
 void setPositionAfter(AstSourcePosition position)
          Set source poistion after location of specfied object
 void visitExpressions(AstExpressionVisitor visitor)
          Visit all the expressions contained in this AST object including this object.
 void visitStatements(AstStatementVisitor visitor)
          Visit all the statements contained in this AST object including this object.
 

Field Detail

ARRAY_CREATION

public static final int ARRAY_CREATION
Constant representing a new array creation expression.

ARRAY_INITIALIZER

public static final int ARRAY_INITIALIZER
Constant representing an array initializer.

ARRAY_REFERENCE

public static final int ARRAY_REFERENCE
Constant representing an array access expression.

ASSERT_STATEMENT

public static final int ASSERT_STATEMENT
Constant representing an assertion statement.

ASSIGNMENT_EXPRESSION

public static final int ASSIGNMENT_EXPRESSION
Constant representing an assignment expression.

BINARY_EXPRESSION

public static final int BINARY_EXPRESSION
Constant representing a binary expression.

BREAK_STATEMENT

public static final int BREAK_STATEMENT
Constant representing a break statement.

CASE_LABEL

public static final int CASE_LABEL
Constant representing a case label.

CAST_EXPRESSION

public static final int CAST_EXPRESSION
Constant representing a type cast expression.

CATCH_CLAUSE

public static final int CATCH_CLAUSE
Constant representing a catch clause of a try statement.

CLASS_FILE

public static final int CLASS_FILE
Constant representing a class file.

COMMENT

public static final int COMMENT
Constant representing a comment.

COMPILATION_UNIT

public static final int COMPILATION_UNIT
Constant representing a compilation unit.

COMPOUND_STATEMENT

public static final int COMPOUND_STATEMENT
Constant representing a compound statement.

CONDITIONAL_EXPRESSION

public static final int CONDITIONAL_EXPRESSION
Constant representing a conditional expression.

CONSTRUCTOR_INVOCATION

public static final int CONSTRUCTOR_INVOCATION
Constant representing an explicit constructor invocation.

CONTINUE_STATEMENT

public static final int CONTINUE_STATEMENT
Constant representing a continue statement.

DBC_RESULT

public static final int DBC_RESULT
Constant representing a reference to a returned value.

DECLARATION_STATEMENT

public static final int DECLARATION_STATEMENT
Constant representing a declaration statement.

DO_STATEMENT

public static final int DO_STATEMENT
Constant representing a do statement.

EMPTY_STATEMENT

public static final int EMPTY_STATEMENT
Constant representing an empty statement.

EXPRESSION_STATEMENT

public static final int EXPRESSION_STATEMENT
Constant representing an expression statement.

FIELD_REFERENCE

public static final int FIELD_REFERENCE
Constant representing a field access expression.

FINALLY_CLAUSE

public static final int FINALLY_CLAUSE
Constant representing a finally clause of a try statement.

FOR_STATEMENT

public static final int FOR_STATEMENT
Constant representing a for statement.

IF_STATEMENT

public static final int IF_STATEMENT
Constant representing an if statement.

IMPORT

public static final int IMPORT
Constant representing an import declaration.

INITIALIZER

public static final int INITIALIZER
Constant representing a class initializer.

JAVADOC_TAG

public static final int JAVADOC_TAG
Constant representing a Javadoc tag.

LITERAL

public static final int LITERAL
Constant representing a literal.

METHOD

public static final int METHOD
Constant representing a method declaration.

METHOD_CALL_EXPRESSION

public static final int METHOD_CALL_EXPRESSION
Constant representing a method invocation expression.

N_A

public static final int N_A
Constant representing an object that does not fit into this model.

OBJECT_CREATION_EXPRESSION

public static final int OBJECT_CREATION_EXPRESSION
Constant representing a new object instantiation expression.

PACKAGE

public static final int PACKAGE
Constant representing a package.

PARENTHESIZED_EXPRESSION

public static final int PARENTHESIZED_EXPRESSION
Constant representing a parenthesized expression.

RETURN_STATEMENT

public static final int RETURN_STATEMENT
Constant representing a return statement.

SIMPLE_REFERENCE

public static final int SIMPLE_REFERENCE
Constant representing a single identifier expression.

SUPER_EXPRESSION

public static final int SUPER_EXPRESSION
Constant representing a superclass access expression.

SWITCH_GROUP

public static final int SWITCH_GROUP
Constant representing a switch group statement.

SWITCH_STATEMENT

public static final int SWITCH_STATEMENT
Constant representing a switch statement.

SYNCHRONIZED_STATEMENT

public static final int SYNCHRONIZED_STATEMENT
Constant representing a synchronized statement.

THIS_EXPRESSION

public static final int THIS_EXPRESSION
Constant representing a this class access expression.

THROW_SPECIFIER

public static final int THROW_SPECIFIER
Constant representing an exception type specified in a method's throw clause.

THROW_STATEMENT

public static final int THROW_STATEMENT
Constant representing a throw statement.

TRY_STATEMENT

public static final int TRY_STATEMENT
Constant representing a try statement.

TYPE

public static final int TYPE
Constant representing a class or an interface.

TYPE_EXPRESSION

public static final int TYPE_EXPRESSION
Constant representing a type expression.

UNARY_EXPRESSION

public static final int UNARY_EXPRESSION
Constant representing a unary expression.

VARIABLE

public static final int VARIABLE
Constant representing a declaration a field, local variable, or method parameter.

VARIABLE_DECLARATION

public static final int VARIABLE_DECLARATION
Constant representing a variable declaration.

WHILE_STATEMENT

public static final int WHILE_STATEMENT
Constant representing a while statement.
Method Detail

addComment

public void addComment(AstComment comment)
Add new comment to the statement

getChildren

public AstObject[] getChildren()
Returns the AST objects directly enclosed by this object. Returns an empty array if this AST object contains no child objects.
Returns:
the AST objects enclosed by this object.

getComments

public AstComment[] getComments()
Returns a list of comments associated with this object. Returns an empty array if this object has no comments.

getCompilationUnit

public AstCompilationUnit getCompilationUnit()
Returns the compilation unit in which this object is declared, or null if this type is not declared in a compilation unit (for example, it is contained in a binary type or a compilation unit itself).

getDeclaringMethod

public AstMethod getDeclaringMethod()
Returns the method in which this object is declared, or null if this object is not declared in a method (for example, a field initializer).

getDeclaringType

public AstType getDeclaringType()
Returns the type in which this object is declared, or null if this object is not declared in a type (for example, a top-level type).

getObjectKind

public int getObjectKind()
Returns this object's kind, encoded as an integer.

getPackage

public AstPackage getPackage()
Returns the package in which this object is declared, or null if this object is not declared in a package (for example, a top-level package).

getParent

public AstObject getParent()
Returns the object directly containing this object, or null if this element has no parent.

getPosition

public AstSourcePosition getPosition()
Returns the source range associated with this object, or null if this object has no associated source code.

isDeleted

public boolean isDeleted()
Check if AST node is deleted by autofix/
Returns:
boolean

remove

public void remove()
Remove this object from abstract syntax tree

replaceWith

public void replaceWith(AstObject obj)
Replace object
Parameters:
obj - object with which this object will be replaces

replaceWith

public void replaceWith(AstObject obj,
                        AstObject parent)
Replace object
Parameters:
obj - object with which this object will be replaces
parent - parent for the replaced object

setPosition

public void setPosition(AstSourcePosition position)
Set source poistion for object
Parameters:
position - specified source position

setPositionAfter

public void setPositionAfter(AstSourcePosition position)
Set source poistion after location of specfied object
Parameters:
position - specified source position

visitExpressions

public void visitExpressions(AstExpressionVisitor visitor)
Visit all the expressions contained in this AST object including this object. The expressions are visited in a postorder manner (the children are visited before the parent).

visitStatements

public void visitStatements(AstStatementVisitor visitor)
Visit all the statements contained in this AST object including this object. The statements are visited in a postorder manner (the children are visited before the parent).