org.aspectj.org.eclipse.jdt.internal.compiler.classfmt
Class TypeAnnotationWalker

java.lang.Object
  extended by org.aspectj.org.eclipse.jdt.internal.compiler.classfmt.TypeAnnotationWalker
Direct Known Subclasses:
NonNullDefaultAwareTypeAnnotationWalker

public class TypeAnnotationWalker
extends java.lang.Object

A TypeAnnotationWalker is initialized with all type annotations found at a given element. It can be used to walk into the types at the given element and finally answer the actual annotations at any node of the walk. The walker is implemented as immutable objects. During the walk either new instances are created, or the current instance is shared if no difference is encountered.


Field Summary
static TypeAnnotationWalker EMPTY_ANNOTATION_WALKER
          A no-effect annotation walker, all walking methods are implemented as identity-functions.
protected  long matches
           
static IBinaryAnnotation[] NO_ANNOTATIONS
           
protected  int pathPtr
           
protected  IBinaryTypeAnnotation[] typeAnnotations
           
 
Constructor Summary
  TypeAnnotationWalker(IBinaryTypeAnnotation[] typeAnnotations)
           
protected TypeAnnotationWalker(IBinaryTypeAnnotation[] typeAnnotations, long matchBits, int pathPtr)
           
 
Method Summary
 IBinaryAnnotation[] getAnnotationsAtCursor(int currentTypeId)
          Retrieve the type annotations at the current position reached by invocations of toXYZ() methods.
protected  TypeAnnotationWalker restrict(long newMatches, int newPathPtr)
           
 TypeAnnotationWalker toField()
          Walk to a field.
 TypeAnnotationWalker toMethodParameter(short index)
          Walk to the index'th visible formal method parameter (i.e., not counting synthetic args).
 TypeAnnotationWalker toMethodReturn()
          Walk to the return type of a method.
 TypeAnnotationWalker toNextArrayDimension()
          Descend down one level of array dimensions.
protected  TypeAnnotationWalker toNextDetail(int detailKind)
           
 TypeAnnotationWalker toNextNestedType()
          Descend down one level of type nesting.
 TypeAnnotationWalker toReceiver()
          Walk to the receiver type of a method.
 TypeAnnotationWalker toSupertype(short index)
          Walk to the specified supertype: -1 is superclass, else the superinterface at the given index.
protected  TypeAnnotationWalker toTarget(int targetType)
           
 TypeAnnotationWalker toThrows(int index)
          Walk to the throws type at the given index.
 TypeAnnotationWalker toTypeArgument(int rank)
          Walk to the type argument of the given rank.
 TypeAnnotationWalker toTypeBound(short boundIndex)
          Detail of toTypeParameterBounds(boolean, int): walk to the bounds of the previously selected type parameter.
 TypeAnnotationWalker toTypeParameter(boolean isClassTypeParameter, int rank)
          Walk to the type parameter of the given rank.
 TypeAnnotationWalker toTypeParameterBounds(boolean isClassTypeParameter, int parameterRank)
          Walk to the bounds of a type parameter of either a class or a method (signaled by isClassTypeParameter).
 TypeAnnotationWalker toWildcardBound()
          Walk to the bound of a wildcard.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NO_ANNOTATIONS

public static final IBinaryAnnotation[] NO_ANNOTATIONS

EMPTY_ANNOTATION_WALKER

public static final TypeAnnotationWalker EMPTY_ANNOTATION_WALKER
A no-effect annotation walker, all walking methods are implemented as identity-functions. At the end of any walk an empty array of annotations is returned.


typeAnnotations

protected final IBinaryTypeAnnotation[] typeAnnotations

matches

protected final long matches

pathPtr

protected final int pathPtr
Constructor Detail

TypeAnnotationWalker

public TypeAnnotationWalker(IBinaryTypeAnnotation[] typeAnnotations)

TypeAnnotationWalker

protected TypeAnnotationWalker(IBinaryTypeAnnotation[] typeAnnotations,
                               long matchBits,
                               int pathPtr)
Method Detail

restrict

protected TypeAnnotationWalker restrict(long newMatches,
                                        int newPathPtr)

toField

public TypeAnnotationWalker toField()
Walk to a field.


toMethodReturn

public TypeAnnotationWalker toMethodReturn()
Walk to the return type of a method.


toReceiver

public TypeAnnotationWalker toReceiver()
Walk to the receiver type of a method. Note: Type annotations on receiver are not currently used by the compiler.


toTarget

protected TypeAnnotationWalker toTarget(int targetType)

toTypeParameter

public TypeAnnotationWalker toTypeParameter(boolean isClassTypeParameter,
                                            int rank)
Walk to the type parameter of the given rank.

Parameters:
isClassTypeParameter - whether we are looking for a class type parameter (else: method type type parameter)
rank - rank of the type parameter

toTypeParameterBounds

public TypeAnnotationWalker toTypeParameterBounds(boolean isClassTypeParameter,
                                                  int parameterRank)
Walk to the bounds of a type parameter of either a class or a method (signaled by isClassTypeParameter). Clients must then call toTypeBound(short) on the resulting walker.

Parameters:
isClassTypeParameter - whether we are looking at a class type parameter (else: method type type parameter)
parameterRank - rank of the type parameter.

toTypeBound

public TypeAnnotationWalker toTypeBound(short boundIndex)
Detail of toTypeParameterBounds(boolean, int): walk to the bounds of the previously selected type parameter.

Parameters:
boundIndex -

toSupertype

public TypeAnnotationWalker toSupertype(short index)
Walk to the specified supertype: -1 is superclass, else the superinterface at the given index.


toMethodParameter

public TypeAnnotationWalker toMethodParameter(short index)
Walk to the index'th visible formal method parameter (i.e., not counting synthetic args).


toThrows

public TypeAnnotationWalker toThrows(int index)
Walk to the throws type at the given index.


toTypeArgument

public TypeAnnotationWalker toTypeArgument(int rank)
Walk to the type argument of the given rank.


toWildcardBound

public TypeAnnotationWalker toWildcardBound()
Walk to the bound of a wildcard.


toNextArrayDimension

public TypeAnnotationWalker toNextArrayDimension()
Descend down one level of array dimensions.


toNextNestedType

public TypeAnnotationWalker toNextNestedType()
Descend down one level of type nesting.


toNextDetail

protected TypeAnnotationWalker toNextDetail(int detailKind)

getAnnotationsAtCursor

public IBinaryAnnotation[] getAnnotationsAtCursor(int currentTypeId)
Retrieve the type annotations at the current position reached by invocations of toXYZ() methods.