org.stjs.generator.javac
Class InternalUtils

java.lang.Object
  extended by org.stjs.generator.javac.InternalUtils

public final class InternalUtils
extends Object

Static utility methods used by annotation abstractions in this package. Some methods in this class depend on the use of Sun javac internals; any procedure in the Checker Framework that uses a non-public API should be placed here.


Method Summary
static ExecutableElement constructor(com.sun.source.tree.NewClassTree tree)
          Determines the symbol for a constructor given an invocation via new.
static com.sun.tools.javac.util.Context getJavacContext(ProcessingEnvironment env)
          Helper function to extract the javac Context from the javac processing environment.
static String getSimpleName(Element element)
           
static TypeMirror greatestLowerBound(ProcessingEnvironment processingEnv, TypeMirror tm1, TypeMirror tm2)
          Returns the greatest lower bound of two TypeMirrors.
static boolean isAnonymousConstructor(com.sun.source.tree.MethodTree method)
          Determines whether or not the node referred to by the given TreePath is an anonymous constructor (the constructor for an anonymous class.
static boolean isClassType(TypeMirror type)
          Returns whether a TypeMirror represents a class type.
static boolean isSynthetic(com.sun.source.tree.Tree tree)
           
static boolean isSyntheticConstructor(com.sun.source.tree.Tree tree)
           
static boolean isVarArg(com.sun.source.tree.Tree tree)
           
static TypeMirror leastUpperBound(ProcessingEnvironment processingEnv, TypeMirror tm1, TypeMirror tm2)
          Returns the least upper bound of two TypeMirrors.
static TypeMirror substituteMethodReturnType(TypeMirror methodType, TypeMirror substitutedReceiverType)
          Returns the return type of a method, where the "raw" return type of that method is given (i.e., the return type might still contain unsubstituted type variables), given the receiver of the method call.
static Element symbol(com.sun.source.tree.Tree tree)
          Gets the Element ("symbol") for the given Tree API node.
static TypeMirror typeOf(com.sun.source.tree.Tree tree)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

symbol

public static Element symbol(com.sun.source.tree.Tree tree)
Gets the Element ("symbol") for the given Tree API node.

Parameters:
tree - the Tree node to get the symbol for
Returns:
the {@link Symbol} for the given tree, or null if one could not be found
Throws:
IllegalArgumentException - if tree is null or is not a valid javac-internal tree (JCTree)

isAnonymousConstructor

public static boolean isAnonymousConstructor(com.sun.source.tree.MethodTree method)
Determines whether or not the node referred to by the given TreePath is an anonymous constructor (the constructor for an anonymous class.

Parameters:
method - the TreePath for a node that may be an anonymous constructor
Returns:
true if the given path points to an anonymous constructor, false if it does not

constructor

public static ExecutableElement constructor(com.sun.source.tree.NewClassTree tree)
Determines the symbol for a constructor given an invocation via new. If the tree is a declaration of an anonymous class, then method returns constructor that gets invoked in the extended class, rather than the anonymous constructor implicitly added by the constructor (JLS 15.9.5.1)

Parameters:
tree - the constructor invocation
Returns:
the ExecutableElement corresponding to the constructor call in tree

typeOf

public static TypeMirror typeOf(com.sun.source.tree.Tree tree)

isClassType

public static boolean isClassType(TypeMirror type)
Returns whether a TypeMirror represents a class type.


leastUpperBound

public static TypeMirror leastUpperBound(ProcessingEnvironment processingEnv,
                                         TypeMirror tm1,
                                         TypeMirror tm2)
Returns the least upper bound of two TypeMirrors.

Parameters:
processingEnv - The ProcessingEnvironment to use.
tm1 - A TypeMirror.
tm2 - A TypeMirror.
Returns:
The least upper bound of tm1 and tm2.

greatestLowerBound

public static TypeMirror greatestLowerBound(ProcessingEnvironment processingEnv,
                                            TypeMirror tm1,
                                            TypeMirror tm2)
Returns the greatest lower bound of two TypeMirrors.

Parameters:
processingEnv - The ProcessingEnvironment to use.
tm1 - A TypeMirror.
tm2 - A TypeMirror.
Returns:
The greatest lower bound of tm1 and tm2.

substituteMethodReturnType

public static TypeMirror substituteMethodReturnType(TypeMirror methodType,
                                                    TypeMirror substitutedReceiverType)
Returns the return type of a method, where the "raw" return type of that method is given (i.e., the return type might still contain unsubstituted type variables), given the receiver of the method call.


getJavacContext

public static com.sun.tools.javac.util.Context getJavacContext(ProcessingEnvironment env)
Helper function to extract the javac Context from the javac processing environment.

Parameters:
env - the processing environment
Returns:
the javac Context

getSimpleName

public static String getSimpleName(Element element)
Parameters:
element -
Returns:
Type$1 for inner types

isVarArg

public static boolean isVarArg(com.sun.source.tree.Tree tree)
Parameters:
tree -
Returns:
true if the node is a vararg

isSynthetic

public static boolean isSynthetic(com.sun.source.tree.Tree tree)

isSyntheticConstructor

public static boolean isSyntheticConstructor(com.sun.source.tree.Tree tree)


Copyright © 2014. All Rights Reserved.