com.sun.tools.javac.tree
Class JCTree

java.lang.Object
  extended by com.sun.tools.javac.tree.JCTree
All Implemented Interfaces:
JCDiagnostic.DiagnosticPosition, java.lang.Cloneable
Direct Known Subclasses:
JCTree.JCCatch, JCTree.JCCompilationUnit, JCTree.JCExpression, JCTree.JCImport, JCTree.JCMethodDecl, JCTree.JCModifiers, JCTree.JCStatement, JCTree.JCTypeParameter, JCTree.TypeBoundKind

public abstract class JCTree
extends java.lang.Object
implements java.lang.Cloneable, JCDiagnostic.DiagnosticPosition

Root class for abstract syntax tree nodes. It provides definitions for specific tree nodes as subclasses nested inside.

Each subclass is highly standardized. It generally contains only tree fields for the syntactic subcomponents of the node. Some classes that represent identifier uses or definitions also define a Symbol field that denotes the represented identifier. Classes for non-local jumps also carry the jump target as a field. The root class Tree itself defines fields for the tree's type and position. No other fields are kept in a tree node; instead parameters are passed to methods accessing the node.

Except for the methods defined by com.sun.source, the only method defined in subclasses is `visit' which applies a given visitor to the tree. The actual tree processing is done by visitor classes in other packages. The abstract class Visitor, as well as an Factory interface for trees, are defined as inner classes in Tree.

To avoid ambiguities with the Tree API in com.sun.source all sub classes should, by convention, start with JC (javac).

This is NOT part of any API supported by Sun Microsystems. If you write code that depends on this, you do so at your own risk. This code and its internal interfaces are subject to change or deletion without notice.

See Also:
TreeMaker, TreeInfo, TreeTranslator, Pretty

Nested Class Summary
static interface JCTree.Factory
          An interface for tree factories
static class JCTree.JCAnnotation
           
static class JCTree.JCArrayAccess
          An array selection
static class JCTree.JCArrayTypeTree
          An array type, A[]
static class JCTree.JCAssert
          An assert statement.
static class JCTree.JCAssign
          A assignment with "=".
static class JCTree.JCAssignOp
          An assignment with "+=", "|=" ...
static class JCTree.JCBinary
          A binary operation.
static class JCTree.JCBlock
          A statement block.
static class JCTree.JCBracketExpr
          A bracket expression containing an expression.
static class JCTree.JCBracketStat
          A bracket expression containing statements.
static class JCTree.JCBreak
          A break from a loop or switch.
static class JCTree.JCCase
          A "case :" of a switch.
static class JCTree.JCCatch
          A catch block.
static class JCTree.JCClassDecl
          A class definition.
static class JCTree.JCCompilationUnit
          Everything in one source file is kept in a TopLevel structure.
static class JCTree.JCConditional
          A ( ) ? ( ) : ( ) conditional expression
static class JCTree.JCContinue
          A continue of a loop.
static class JCTree.JCDoWhileLoop
          A do loop
static class JCTree.JCEnhancedForLoop
          The enhanced for loop.
static class JCTree.JCErroneous
           
static class JCTree.JCEscapeExpr
          A escape expression
static class JCTree.JCEscapeStat
          An escape statement
static class JCTree.JCExpression
           
static class JCTree.JCExpressionStatement
          an expression statement
static class JCTree.JCFieldAccess
          Selects through packages and classes
static class JCTree.JCForLoop
          A for loop.
static class JCTree.JCIdent
          An identifier
static class JCTree.JCIf
          An "if ( ) { } else { }" block
static class JCTree.JCImport
          An import clause.
static class JCTree.JCInstanceOf
          A type test.
static class JCTree.JCLabeledStatement
          A labelled expression or statement.
static class JCTree.JCLiteral
          A constant value given literally.
static class JCTree.JCMethodDecl
          A method definition.
static class JCTree.JCMethodInvocation
          A method invocation
static class JCTree.JCModifiers
           
static class JCTree.JCNewArray
          A new[...] operation.
static class JCTree.JCNewClass
          A new(...) operation.
static class JCTree.JCParens
          A parenthesized subexpression ( ...
static class JCTree.JCPrimitiveTypeTree
          Identifies a basic type.
static class JCTree.JCReturn
          A return statement.
static class JCTree.JCSkip
          A no-op statement ";".
static class JCTree.JCStatement
           
static class JCTree.JCSwitch
          A "switch ( ) { }" construction.
static class JCTree.JCSynchronized
          A synchronized block.
static class JCTree.JCThrow
          A throw statement.
static class JCTree.JCTry
          A "try { } catch ( ) { } finally { }" block.
static class JCTree.JCTypeApply
          A parameterized type, T<...>
static class JCTree.JCTypeCast
          A type cast.
static class JCTree.JCTypeParameter
          A formal class parameter.
static class JCTree.JCUnary
          A unary operation.
static class JCTree.JCVariableDecl
          A variable definition.
static class JCTree.JCWhileLoop
          A while loop
static class JCTree.JCWildcard
           
static class JCTree.LetExpr
          (let int x = 3; in x+2)
static class JCTree.TypeBoundKind
           
static class JCTree.Visitor
          A generic visitor class for trees.
 
Field Summary
static int AND
           
static int ANNOTATION
          metadata: Annotation.
static int APPLY
          Method invocation expressions, of type Apply.
static int ASGOffset
          The offset between assignment operators and normal operators.
static int ASSERT
          Assert statements, of type Assert.
static int ASSIGN
          Assignment expressions, of type Assign.
static int BITAND
           
static int BITAND_ASG
           
static int BITOR
           
static int BITOR_ASG
          Assignment operators, of type Assignop.
static int BITXOR
           
static int BITXOR_ASG
           
static int BLOCK
          Blocks, of type Block.
static int BRACKET_EXPR
          emw4: staging additions
static int BRACKET_STAT
           
static int BREAK
          Break statements, of type Break.
static int CASE
          Case parts in switch statements, of type Case.
static int CATCH
          Catch clauses in try statements, of type Catch.
static int CLASSDEF
          Class definitions, of type ClassDef.
static int COMPL
           
static int CONDEXPR
          Conditional expressions, of type Conditional.
static int CONTINUE
          Continue statements, of type Continue.
static int DIV
           
static int DIV_ASG
           
static int DOLOOP
          Do-while loops, of type DoLoop.
static int EQ
           
static int ERRONEOUS
          Error trees, of type Erroneous.
static int ESCAPE_EXPR
           
static int ESCAPE_STAT
           
static int EXEC
          Expression statements, of type Exec.
static int FOREACHLOOP
          Foreach-loops, of type ForeachLoop.
static int FORLOOP
          For-loops, of type ForLoop.
static int GE
           
static int GT
           
static int IDENT
          Simple identifiers, of type Ident.
static int IF
          Conditional statements, of type If.
static int IMPORT
          Import clauses, of type Import.
static int INDEXED
          Indexed array expressions, of type Indexed.
static int LABELLED
          Labelled statements, of type Labelled.
static int LE
           
static int LETEXPR
          A synthetic let expression, of type LetExpr.
static int LITERAL
          Literals, of type Literal.
static int LT
           
static int METHODDEF
          Method definitions, of type MethodDef.
static int MINUS
           
static int MINUS_ASG
           
static int MOD
           
static int MOD_ASG
           
static int MODIFIERS
          metadata: Modifiers
static int MUL
           
static int MUL_ASG
           
static int NE
           
static int NEG
           
static int NEWARRAY
          Array creation expressions, of type NewArray.
static int NEWCLASS
          Class instance creation expressions, of type NewClass.
static int NOT
           
static int NULLCHK
          unary operator for null reference checks, only used internally.
static int OR
          Binary operators, of type Binary.
static int PARENS
          Parenthesized subexpressions, of type Parens.
static int PLUS
           
static int PLUS_ASG
           
 int pos
           
static int POS
          Unary operators, of type Unary.
static int POSTDEC
           
static int POSTINC
           
static int PREDEC
           
static int PREINC
           
static int RETURN
          Return statements, of type Return.
static int SELECT
          Selections, of type Select.
static int SKIP
          The no-op statement ";", of type Skip
static int SL
           
static int SL_ASG
           
static int SR
           
static int SR_ASG
           
static int SWITCH
          Switch statements, of type Switch.
static int SYNCHRONIZED
          Synchronized statements, of type Synchonized.
static int THROW
          Throw statements, of type Throw.
static int TOPLEVEL
          Toplevel nodes, of type TopLevel, representing entire source files.
static int TRY
          Try statements, of type Try.
 Type type
           
static int TYPEAPPLY
          Parameterized types, of type TypeApply.
static int TYPEARRAY
          Array types, of type TypeArray.
static int TYPEBOUNDKIND
          Bound kind: extends, super, exact, or unbound
static int TYPECAST
          Type cast expressions, of type TypeCast.
static int TYPEIDENT
          Basic type identifiers, of type TypeIdent.
static int TYPEPARAMETER
          Formal type parameters, of type TypeParameter.
static int TYPETEST
          Type test expressions, of type TypeTest.
static int USR
           
static int USR_ASG
           
static int VARDEF
          Variable definitions, of type VarDef.
static int WHILELOOP
          While-loops, of type WhileLoop.
static int WILDCARD
          Type argument.
 
Constructor Summary
JCTree()
           
 
Method Summary
abstract  void accept(JCTree.Visitor v)
          Visit this tree with a given visitor.
abstract
<R,D> R
accept(TreeVisitor<R,D> v, D d)
           
 java.lang.Object clone()
          Return a shallow copy of this tree.
 int getEndPosition(java.util.Map<JCTree,java.lang.Integer> endPosTable)
          If there is a tree node, and if endPositions are available, get the end position of the tree node.
 int getPreferredPosition()
          Get the position within the file that most accurately defines the location for the diagnostic.
 int getStartPosition()
          If there is a tree node, get the start position of the tree node.
abstract  int getTag()
           
 JCTree getTree()
          Gets the tree node, if any, to which the diagnostic applies.
 JCDiagnostic.DiagnosticPosition pos()
          Get a default position for this tree node.
 JCTree setPos(int pos)
          Set position field and return this tree.
 JCTree setType(Type type)
          Set type field and return this tree.
 java.lang.String toString()
          Convert a tree to a pretty-printed string.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

TOPLEVEL

public static final int TOPLEVEL
Toplevel nodes, of type TopLevel, representing entire source files.

See Also:
Constant Field Values

IMPORT

public static final int IMPORT
Import clauses, of type Import.

See Also:
Constant Field Values

CLASSDEF

public static final int CLASSDEF
Class definitions, of type ClassDef.

See Also:
Constant Field Values

METHODDEF

public static final int METHODDEF
Method definitions, of type MethodDef.

See Also:
Constant Field Values

VARDEF

public static final int VARDEF
Variable definitions, of type VarDef.

See Also:
Constant Field Values

SKIP

public static final int SKIP
The no-op statement ";", of type Skip

See Also:
Constant Field Values

BLOCK

public static final int BLOCK
Blocks, of type Block.

See Also:
Constant Field Values

DOLOOP

public static final int DOLOOP
Do-while loops, of type DoLoop.

See Also:
Constant Field Values

WHILELOOP

public static final int WHILELOOP
While-loops, of type WhileLoop.

See Also:
Constant Field Values

FORLOOP

public static final int FORLOOP
For-loops, of type ForLoop.

See Also:
Constant Field Values

FOREACHLOOP

public static final int FOREACHLOOP
Foreach-loops, of type ForeachLoop.

See Also:
Constant Field Values

LABELLED

public static final int LABELLED
Labelled statements, of type Labelled.

See Also:
Constant Field Values

SWITCH

public static final int SWITCH
Switch statements, of type Switch.

See Also:
Constant Field Values

CASE

public static final int CASE
Case parts in switch statements, of type Case.

See Also:
Constant Field Values

SYNCHRONIZED

public static final int SYNCHRONIZED
Synchronized statements, of type Synchonized.

See Also:
Constant Field Values

TRY

public static final int TRY
Try statements, of type Try.

See Also:
Constant Field Values

CATCH

public static final int CATCH
Catch clauses in try statements, of type Catch.

See Also:
Constant Field Values

CONDEXPR

public static final int CONDEXPR
Conditional expressions, of type Conditional.

See Also:
Constant Field Values

IF

public static final int IF
Conditional statements, of type If.

See Also:
Constant Field Values

EXEC

public static final int EXEC
Expression statements, of type Exec.

See Also:
Constant Field Values

BREAK

public static final int BREAK
Break statements, of type Break.

See Also:
Constant Field Values

CONTINUE

public static final int CONTINUE
Continue statements, of type Continue.

See Also:
Constant Field Values

RETURN

public static final int RETURN
Return statements, of type Return.

See Also:
Constant Field Values

THROW

public static final int THROW
Throw statements, of type Throw.

See Also:
Constant Field Values

ASSERT

public static final int ASSERT
Assert statements, of type Assert.

See Also:
Constant Field Values

APPLY

public static final int APPLY
Method invocation expressions, of type Apply.

See Also:
Constant Field Values

NEWCLASS

public static final int NEWCLASS
Class instance creation expressions, of type NewClass.

See Also:
Constant Field Values

NEWARRAY

public static final int NEWARRAY
Array creation expressions, of type NewArray.

See Also:
Constant Field Values

PARENS

public static final int PARENS
Parenthesized subexpressions, of type Parens.

See Also:
Constant Field Values

ASSIGN

public static final int ASSIGN
Assignment expressions, of type Assign.

See Also:
Constant Field Values

TYPECAST

public static final int TYPECAST
Type cast expressions, of type TypeCast.

See Also:
Constant Field Values

TYPETEST

public static final int TYPETEST
Type test expressions, of type TypeTest.

See Also:
Constant Field Values

INDEXED

public static final int INDEXED
Indexed array expressions, of type Indexed.

See Also:
Constant Field Values

SELECT

public static final int SELECT
Selections, of type Select.

See Also:
Constant Field Values

IDENT

public static final int IDENT
Simple identifiers, of type Ident.

See Also:
Constant Field Values

LITERAL

public static final int LITERAL
Literals, of type Literal.

See Also:
Constant Field Values

TYPEIDENT

public static final int TYPEIDENT
Basic type identifiers, of type TypeIdent.

See Also:
Constant Field Values

TYPEARRAY

public static final int TYPEARRAY
Array types, of type TypeArray.

See Also:
Constant Field Values

TYPEAPPLY

public static final int TYPEAPPLY
Parameterized types, of type TypeApply.

See Also:
Constant Field Values

TYPEPARAMETER

public static final int TYPEPARAMETER
Formal type parameters, of type TypeParameter.

See Also:
Constant Field Values

WILDCARD

public static final int WILDCARD
Type argument.

See Also:
Constant Field Values

TYPEBOUNDKIND

public static final int TYPEBOUNDKIND
Bound kind: extends, super, exact, or unbound

See Also:
Constant Field Values

ANNOTATION

public static final int ANNOTATION
metadata: Annotation.

See Also:
Constant Field Values

MODIFIERS

public static final int MODIFIERS
metadata: Modifiers

See Also:
Constant Field Values

ERRONEOUS

public static final int ERRONEOUS
Error trees, of type Erroneous.

See Also:
Constant Field Values

POS

public static final int POS
Unary operators, of type Unary.

See Also:
Constant Field Values

NEG

public static final int NEG
See Also:
Constant Field Values

NOT

public static final int NOT
See Also:
Constant Field Values

COMPL

public static final int COMPL
See Also:
Constant Field Values

PREINC

public static final int PREINC
See Also:
Constant Field Values

PREDEC

public static final int PREDEC
See Also:
Constant Field Values

POSTINC

public static final int POSTINC
See Also:
Constant Field Values

POSTDEC

public static final int POSTDEC
See Also:
Constant Field Values

NULLCHK

public static final int NULLCHK
unary operator for null reference checks, only used internally.

See Also:
Constant Field Values

OR

public static final int OR
Binary operators, of type Binary.

See Also:
Constant Field Values

AND

public static final int AND
See Also:
Constant Field Values

BITOR

public static final int BITOR
See Also:
Constant Field Values

BITXOR

public static final int BITXOR
See Also:
Constant Field Values

BITAND

public static final int BITAND
See Also:
Constant Field Values

EQ

public static final int EQ
See Also:
Constant Field Values

NE

public static final int NE
See Also:
Constant Field Values

LT

public static final int LT
See Also:
Constant Field Values

GT

public static final int GT
See Also:
Constant Field Values

LE

public static final int LE
See Also:
Constant Field Values

GE

public static final int GE
See Also:
Constant Field Values

SL

public static final int SL
See Also:
Constant Field Values

SR

public static final int SR
See Also:
Constant Field Values

USR

public static final int USR
See Also:
Constant Field Values

PLUS

public static final int PLUS
See Also:
Constant Field Values

MINUS

public static final int MINUS
See Also:
Constant Field Values

MUL

public static final int MUL
See Also:
Constant Field Values

DIV

public static final int DIV
See Also:
Constant Field Values

MOD

public static final int MOD
See Also:
Constant Field Values

BITOR_ASG

public static final int BITOR_ASG
Assignment operators, of type Assignop.

See Also:
Constant Field Values

BITXOR_ASG

public static final int BITXOR_ASG
See Also:
Constant Field Values

BITAND_ASG

public static final int BITAND_ASG
See Also:
Constant Field Values

SL_ASG

public static final int SL_ASG
See Also:
Constant Field Values

SR_ASG

public static final int SR_ASG
See Also:
Constant Field Values

USR_ASG

public static final int USR_ASG
See Also:
Constant Field Values

PLUS_ASG

public static final int PLUS_ASG
See Also:
Constant Field Values

MINUS_ASG

public static final int MINUS_ASG
See Also:
Constant Field Values

MUL_ASG

public static final int MUL_ASG
See Also:
Constant Field Values

DIV_ASG

public static final int DIV_ASG
See Also:
Constant Field Values

MOD_ASG

public static final int MOD_ASG
See Also:
Constant Field Values

BRACKET_EXPR

public static final int BRACKET_EXPR
emw4: staging additions

See Also:
Constant Field Values

BRACKET_STAT

public static final int BRACKET_STAT
See Also:
Constant Field Values

ESCAPE_EXPR

public static final int ESCAPE_EXPR
See Also:
Constant Field Values

ESCAPE_STAT

public static final int ESCAPE_STAT
See Also:
Constant Field Values

LETEXPR

public static final int LETEXPR
A synthetic let expression, of type LetExpr.

See Also:
Constant Field Values

ASGOffset

public static final int ASGOffset
The offset between assignment operators and normal operators.

See Also:
Constant Field Values

pos

public int pos

type

public Type type
Constructor Detail

JCTree

public JCTree()
Method Detail

getTag

public abstract int getTag()

toString

public java.lang.String toString()
Convert a tree to a pretty-printed string.

Overrides:
toString in class java.lang.Object

setPos

public JCTree setPos(int pos)
Set position field and return this tree.


setType

public JCTree setType(Type type)
Set type field and return this tree.


accept

public abstract void accept(JCTree.Visitor v)
Visit this tree with a given visitor.


accept

public abstract <R,D> R accept(TreeVisitor<R,D> v,
                               D d)

clone

public java.lang.Object clone()
Return a shallow copy of this tree.

Overrides:
clone in class java.lang.Object

pos

public JCDiagnostic.DiagnosticPosition pos()
Get a default position for this tree node.


getTree

public JCTree getTree()
Description copied from interface: JCDiagnostic.DiagnosticPosition
Gets the tree node, if any, to which the diagnostic applies.

Specified by:
getTree in interface JCDiagnostic.DiagnosticPosition

getStartPosition

public int getStartPosition()
Description copied from interface: JCDiagnostic.DiagnosticPosition
If there is a tree node, get the start position of the tree node. Otherwise, just returns the same as getPreferredPosition().

Specified by:
getStartPosition in interface JCDiagnostic.DiagnosticPosition

getPreferredPosition

public int getPreferredPosition()
Description copied from interface: JCDiagnostic.DiagnosticPosition
Get the position within the file that most accurately defines the location for the diagnostic.

Specified by:
getPreferredPosition in interface JCDiagnostic.DiagnosticPosition

getEndPosition

public int getEndPosition(java.util.Map<JCTree,java.lang.Integer> endPosTable)
Description copied from interface: JCDiagnostic.DiagnosticPosition
If there is a tree node, and if endPositions are available, get the end position of the tree node. Otherwise, just returns the same as getPreferredPosition().

Specified by:
getEndPosition in interface JCDiagnostic.DiagnosticPosition