Class ElementUtils
java.lang.Object
com.oracle.truffle.dsl.processor.java.ElementUtils
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanareTypesCompatible(TypeMirror type1, TypeMirror type2) static StringbasicTypeId(TypeMirror type) static TypeMirrorboxType(ProcessorContext context, TypeMirror primitiveType) static booleancanThrowType(List<? extends TypeMirror> thrownTypes, TypeMirror exceptionType) static booleancanThrowTypeExact(List<? extends TypeMirror> thrownTypes, TypeMirror exceptionType) static TypeElementcastTypeElement(TypeMirror mirror) static List<AnnotationMirror> collectAnnotations(AnnotationMirror markerAnnotation, String elementName, Element element, DeclaredType annotationClass) static intcompareByTypeHierarchy(TypeMirror t1, Set<String> t1SuperSet, TypeMirror t2, Set<String> t2SuperSet) static intstatic intcompareMethod(ExecutableElement method1, ExecutableElement method2) static intcompareType(TypeMirror signature1, TypeMirror signature2) static StringcreateConstantName(String simpleName) static StringcreateReferenceName(ExecutableElement method) static StringdefaultValue(TypeMirror mirror) static booleanelementEquals(Element element1, Element element2) static TypeMirroreraseGenericTypes(TypeMirror type) static booleanstatic TypeMirrorstatic List<ExecutableElement> findAllPublicMethods(DeclaredType type, String methodName) static AnnotationMirrorfindAnnotationMirror(List<? extends AnnotationMirror> mirrors, TypeMirror expectedAnnotationType) static AnnotationMirrorfindAnnotationMirror(Element element, Class<?> expectedAnnotationType) static AnnotationMirrorfindAnnotationMirror(Element element, TypeMirror annotationType) static ExecutableElementfindExecutableElement(DeclaredType type, String name) static ExecutableElementfindExecutableElement(DeclaredType type, String name, int argumentCount) static ExecutableElementfindMethod(Class<?> type, String methodName) static ExecutableElementfindMethod(DeclaredType type, String methodName) static ExecutableElementfindMethod(DeclaredType type, String methodName, int parameterCount) static Optional<TypeElement> static PackageElementstatic Optional<TypeElement> findParentEnclosingType(Element element) static Optional<TypeElement> findRootEnclosingType(Element element) static ExecutableElementfindStaticMethod(TypeElement type, String methodName) static VariableElementfindVariableElement(Element element, String name) static VariableElementfindVariableElement(DeclaredType type, String name) static StringfirstLetterLowerCase(String name) static StringfirstLetterUpperCase(String name) static StringfixECJBinaryNameIssue(String name) static TypeElementfromTypeMirror(TypeMirror mirror) static <T> TgetAnnotationValue(Class<T> expectedType, AnnotationMirror mirror, String name) static <T> TgetAnnotationValue(Class<T> expectedType, AnnotationMirror mirror, String name, boolean resolveDefault) static AnnotationValuegetAnnotationValue(AnnotationMirror mirror, String name) Temporary local implementation ofgetAnnotationValue(javax.lang.model.element.AnnotationMirror, java.lang.String).static AnnotationValuegetAnnotationValue(AnnotationMirror mirror, String name, boolean resolveDefault) Temporary local implementation ofgetAnnotationValue(javax.lang.model.element.AnnotationMirror, java.lang.String, boolean).static <T> List<T> getAnnotationValueList(Class<T> expectedListType, AnnotationMirror mirror, String name) static StringgetBinaryName(TypeElement provider) static Stringstatic TypeMirrorgetCommonSuperType(ProcessorContext context, Collection<TypeMirror> types) static intgetCompressedReferenceSize(TypeMirror mirror) static List<ExecutableElement> getDeclaredMethodsInSuperTypes(TypeElement declaringElement, String name, TypeMirror... params) Gets the methods in the super type hierarchy (excluding interfaces) that are overridden by a method in a subtype.static StringgetDeclaredName(DeclaredType element, boolean includeTypeVariables) static DeclaredTypegetDeclaredType(TypeElement typeElem, TypeMirror... typeArgs) static List<TypeElement> getDeclaredTypes(TypeElement element) static List<TypeElement> getDirectSuperTypes(TypeElement element) static StringgetEnclosedQualifiedName(DeclaredType mirror) getEnumValues(TypeElement type) getIdempotent(ExecutableElement method) static StringgetPackageName(Element element) static StringgetPackageName(TypeMirror mirror) static StringgetQualifiedName(TypeElement element) static StringgetQualifiedName(TypeMirror mirror) getQualifiedSuperTypeNames(TypeElement element) static StringgetReadableReference(Element relativeTo, Element element) static Stringstatic StringgetReadableSignature(ExecutableElement method, int highlightParameter) static List<AnnotationMirror> getRepeatedAnnotation(List<? extends AnnotationMirror> mirrors, DeclaredType base) static StringgetSimpleName(TypeElement element) static StringgetSimpleName(TypeMirror mirror) static TypeElementgetSuperType(TypeElement element) Gets the element representing the super class of a given type element.static List<TypeElement> getSuperTypes(TypeElement element) static TypeElementgetTypeElement(CharSequence typeName) static StringgetTypeSimpleId(TypeMirror mirror) static StringgetUniqueIdentifier(TypeMirror typeMirror) getUniqueIdentifiers(List<TypeMirror> typeMirror) static ModifiergetVisibility(Set<Modifier> modifier) static booleanhasError(TypeMirror mirror) static booleanhasGenericTypes(TypeMirror type) static booleanhasOverloads(TypeElement enclosingType, ExecutableElement e) static booleanisAssignable(TypeMirror from, TypeMirror to) static booleanisDeclaredIn(Element search, Element elementHierarchy) static booleanisDeclaredMethodInSuperType(TypeElement element, String name, TypeMirror[] params) static booleanisDefaultMethodOverridden(TypeElement declaringElement, String name, TypeMirror... params) Determines whetherdeclaringElementor any of its direct super types override a default interface method.static booleanisDeprecated(Element baseType) static booleanisDeprecated(TypeMirror baseType) static booleanisEnclosedIn(Element enclosedIn, Element element) static booleanisFinal(TypeMirror mirror) static booleanisNone(TypeMirror mirror) static booleanisObject(TypeMirror actualType) static booleanisPackageDeprecated(TypeElement baseType) static booleanisPrimitive(TypeMirror mirror) static booleanisSubtype(TypeMirror type1, TypeMirror type2) static booleanisSubtypeBoxed(ProcessorContext context, TypeMirror from, TypeMirror to) static booleanstatic booleanisVoid(TypeMirror mirror) static booleanneedsCastTo(TypeMirror sourceType, TypeMirror targetType) static Stringstatic <T> TresolveAnnotationValue(Class<T> expectedType, AnnotationValue value) static voidstatic voidsetVisibility(Set<Modifier> modifiers, Modifier visibility) static booleanstatic List<TypeMirror> sortTypes(List<TypeMirror> list, boolean reverse) static booleantypeEquals(TypeMirror type1, TypeMirror type2) static Objectstatic List<TypeMirror> uniqueSortedTypes(Collection<TypeMirror> types, boolean reverse) static Collection<TypeMirror> uniqueTypes(Collection<TypeMirror> types) static booleanvariableEquals(VariableElement var1, VariableElement var2)
-
Field Details
-
COMPRESSED_POINTER_SIZE
public static final int COMPRESSED_POINTER_SIZE- See Also:
-
COMPRESSED_HEADER_SIZE
public static final int COMPRESSED_HEADER_SIZE- See Also:
-
-
Constructor Details
-
ElementUtils
public ElementUtils()
-
-
Method Details
-
findMethod
-
findMethod
-
findAllPublicMethods
-
getEnumValues
-
findMethod
public static ExecutableElement findMethod(DeclaredType type, String methodName, int parameterCount) -
findStaticMethod
-
defaultValue
-
getTypeElement
-
findExecutableElement
-
findExecutableElement
public static ExecutableElement findExecutableElement(DeclaredType type, String name, int argumentCount) -
findVariableElement
-
findVariableElement
-
needsCastTo
-
createReferenceName
-
boxType
-
getDeclaredType
-
collectAnnotations
public static List<AnnotationMirror> collectAnnotations(AnnotationMirror markerAnnotation, String elementName, Element element, DeclaredType annotationClass) -
getCommonSuperType
-
getReadableSignature
-
hasOverloads
-
getReadableSignature
-
hasError
-
isSubtypeBoxed
-
isSubtype
-
isAssignable
-
modifiers
-
getTypeSimpleId
-
getSimpleName
-
getSimpleName
-
getDeclaredName
-
fixECJBinaryNameIssue
-
getClassQualifiedName
-
getQualifiedName
-
getQualifiedName
-
isNone
-
isVoid
-
isPrimitive
-
isFinal
-
getQualifiedSuperTypeNames
-
getDeclaredTypes
-
isEnclosedIn
-
getElementHierarchy
-
findRootEnclosingType
-
findParentEnclosingType
-
findNearestEnclosingType
-
getDirectSuperTypes
-
getSuperType
Gets the element representing the super class of a given type element. -
isDeprecated
-
isDeprecated
-
isPackageDeprecated
-
getSuperTypes
-
getPackageName
-
getEnclosedQualifiedName
-
getPackageName
-
createConstantName
-
fromTypeMirror
-
getAnnotationValue
Temporary local implementation ofgetAnnotationValue(javax.lang.model.element.AnnotationMirror, java.lang.String). TheElementUtils.getAnnotationValuedoes not work on Eclipse JDT compiler when an annotation type is nested in a generic type, see issue: https://bugs.eclipse.org/bugs/show_bug.cgi?id=544940 -
getAnnotationValue
public static AnnotationValue getAnnotationValue(AnnotationMirror mirror, String name, boolean resolveDefault) Temporary local implementation ofgetAnnotationValue(javax.lang.model.element.AnnotationMirror, java.lang.String, boolean). TheElementUtils.getAnnotationValuedoes not work on Eclipse JDT compiler when an annotation type is nested in a generic type, see issue: https://bugs.eclipse.org/bugs/show_bug.cgi?id=544940 -
getAnnotationValueList
public static <T> List<T> getAnnotationValueList(Class<T> expectedListType, AnnotationMirror mirror, String name) -
getAnnotationValue
-
getAnnotationValue
public static <T> T getAnnotationValue(Class<T> expectedType, AnnotationMirror mirror, String name, boolean resolveDefault) -
resolveAnnotationValue
-
unboxAnnotationValue
-
printException
-
findAnnotationMirror
public static AnnotationMirror findAnnotationMirror(Element element, Class<?> expectedAnnotationType) -
findAnnotationMirror
public static AnnotationMirror findAnnotationMirror(List<? extends AnnotationMirror> mirrors, TypeMirror expectedAnnotationType) -
findAnnotationMirror
-
findPackageElement
-
firstLetterUpperCase
-
firstLetterLowerCase
-
isDeclaredMethodInSuperType
public static boolean isDeclaredMethodInSuperType(TypeElement element, String name, TypeMirror[] params) -
getDeclaredMethodsInSuperTypes
public static List<ExecutableElement> getDeclaredMethodsInSuperTypes(TypeElement declaringElement, String name, TypeMirror... params) Gets the methods in the super type hierarchy (excluding interfaces) that are overridden by a method in a subtype.- Parameters:
declaringElement- the subtype element declaring the methodname- the name of the methodparams- the signature of the method
-
isDefaultMethodOverridden
public static boolean isDefaultMethodOverridden(TypeElement declaringElement, String name, TypeMirror... params) Determines whetherdeclaringElementor any of its direct super types override a default interface method.Any declaration of the given method and signature in the direct super type hierarchy - even if it is abstract - is considered to override the default method.
- Parameters:
declaringElement- the type to checkname- the name of the default interface methodparams- the signature of the method- Returns:
- true if any the default method is overridden
-
typeEquals
-
areTypesCompatible
-
getUniqueIdentifiers
-
getUniqueIdentifier
-
compareByTypeHierarchy
-
compareByTypeHierarchy
public static int compareByTypeHierarchy(TypeMirror t1, Set<String> t1SuperSet, TypeMirror t2, Set<String> t2SuperSet) -
canThrowTypeExact
public static boolean canThrowTypeExact(List<? extends TypeMirror> thrownTypes, TypeMirror exceptionType) -
canThrowType
public static boolean canThrowType(List<? extends TypeMirror> thrownTypes, TypeMirror exceptionType) -
setFinal
-
setVisibility
-
getVisibility
-
isObject
-
fillInGenericWildcards
-
hasGenericTypes
-
eraseGenericTypes
-
variableEquals
-
signatureEquals
-
executableEquals
-
elementEquals
-
sortTypes
-
compareType
-
uniqueSortedTypes
-
uniqueTypes
-
compareMethod
-
getRepeatedAnnotation
public static List<AnnotationMirror> getRepeatedAnnotation(List<? extends AnnotationMirror> mirrors, DeclaredType base) -
isVisible
-
castTypeElement
-
getReadableReference
-
isDeclaredIn
-
getBinaryName
-
basicTypeId
-
getCompressedReferenceSize
-
getIdempotent
-