public static List<String> getQualifiedSuperTypeNames(TypeElement element) { List<TypeElement> types = getSuperTypes(element); List<String> qualifiedNames = new ArrayList<>(); for (TypeElement type : types) { qualifiedNames.add(getQualifiedName(type)); } return qualifiedNames; }
public static List<String> getQualifiedSuperTypeNames(TypeElement element) { List<TypeElement> types = getSuperTypes(element); List<String> qualifiedNames = new ArrayList<>(); for (TypeElement type : types) { qualifiedNames.add(getQualifiedName(type)); } return qualifiedNames; }
private static void collectSuperTypeImports(TypeElement e, Set<String> autoImportedTypes) { List<TypeElement> superTypes = getSuperTypes(e); for (TypeElement superType : superTypes) { List<TypeElement> declaredTypes = getDeclaredTypes(superType); for (TypeElement declaredType : declaredTypes) { if (!superTypes.contains(declaredType)) { autoImportedTypes.add(getQualifiedName(declaredType)); } } } }
/** * Gets the methods in the super type hierarchy (excluding interfaces) that are overridden by a * method in a subtype. * * @param declaringElement the subtype element declaring the method * @param name the name of the method * @param params the signature of the method */ public static List<ExecutableElement> getDeclaredMethodsInSuperTypes(TypeElement declaringElement, String name, TypeMirror... params) { List<ExecutableElement> superMethods = new ArrayList<>(); List<TypeElement> superElements = getSuperTypes(declaringElement); for (TypeElement superElement : superElements) { ExecutableElement superMethod = getDeclaredMethod(superElement, name, params); if (superMethod != null) { superMethods.add(superMethod); } } return superMethods; }
/** * Gets the methods in the super type hierarchy (excluding interfaces) that are overridden by a * method in a subtype. * * @param declaringElement the subtype element declaring the method * @param name the name of the method * @param params the signature of the method */ public static List<ExecutableElement> getDeclaredMethodsInSuperTypes(TypeElement declaringElement, String name, TypeMirror... params) { List<ExecutableElement> superMethods = new ArrayList<>(); List<TypeElement> superElements = getSuperTypes(declaringElement); for (TypeElement superElement : superElements) { ExecutableElement superMethod = getDeclaredMethod(superElement, name, params); if (superMethod != null) { superMethods.add(superMethod); } } return superMethods; }
private static void collectSuperTypeImports(TypeElement e, Set<String> autoImportedTypes) { List<TypeElement> superTypes = getSuperTypes(e); for (TypeElement superType : superTypes) { List<TypeElement> declaredTypes = getDeclaredTypes(superType); for (TypeElement declaredType : declaredTypes) { if (!superTypes.contains(declaredType)) { autoImportedTypes.add(getQualifiedName(declaredType)); } } } }
public static List<TypeElement> getSuperTypes(TypeElement element) { List<TypeElement> types = new ArrayList<>(); List<TypeElement> superTypes = null; List<TypeElement> superInterfaces = null; TypeElement superElement = getSuperType(element); if (superElement != null) { types.add(superElement); superTypes = getSuperTypes(superElement); } for (TypeMirror interfaceMirror : element.getInterfaces()) { TypeElement interfaceElement = fromTypeMirror(interfaceMirror); if (interfaceElement != null) { types.add(interfaceElement); if (superInterfaces == null) { superInterfaces = getSuperTypes(interfaceElement); } else { superInterfaces.addAll(getSuperTypes(interfaceElement)); } } } if (superTypes != null) { types.addAll(superTypes); } if (superInterfaces != null) { types.addAll(superInterfaces); } return types; }
public static List<TypeElement> getSuperTypes(TypeElement element) { List<TypeElement> types = new ArrayList<>(); List<TypeElement> superTypes = null; List<TypeElement> superInterfaces = null; TypeElement superElement = getSuperType(element); if (superElement != null) { types.add(superElement); superTypes = getSuperTypes(superElement); } for (TypeMirror interfaceMirror : element.getInterfaces()) { TypeElement interfaceElement = fromTypeMirror(interfaceMirror); if (interfaceElement != null) { types.add(interfaceElement); if (superInterfaces == null) { superInterfaces = getSuperTypes(interfaceElement); } else { superInterfaces.addAll(getSuperTypes(interfaceElement)); } } } if (superTypes != null) { types.addAll(superTypes); } if (superInterfaces != null) { types.addAll(superInterfaces); } return types; }
public static boolean canThrowType(List<? extends TypeMirror> thrownTypes, TypeMirror exceptionType) { if (ElementUtils.containsType(thrownTypes, exceptionType)) { return true; } if (isRuntimeException(exceptionType)) { return true; } // search for any super types for (TypeElement typeElement : getSuperTypes(fromTypeMirror(exceptionType))) { if (ElementUtils.containsType(thrownTypes, typeElement.asType())) { return true; } } return false; }
public static boolean canThrowType(List<? extends TypeMirror> thrownTypes, TypeMirror exceptionType) { if (ElementUtils.containsType(thrownTypes, exceptionType)) { return true; } if (isRuntimeException(exceptionType)) { return true; } // search for any super types for (TypeElement typeElement : getSuperTypes(fromTypeMirror(exceptionType))) { if (ElementUtils.containsType(thrownTypes, typeElement.asType())) { return true; } } return false; }
@Override public Void visitType(CodeTypeElement e, Void p) { List<TypeElement> superTypes = ElementUtils.getSuperTypes(e); for (TypeElement type : superTypes) { String qualifiedName = ElementUtils.getQualifiedName(type); if (qualifiedName.equals(Serializable.class.getCanonicalName())) { if (!e.containsField("serialVersionUID")) { e.add(new CodeVariableElement(modifiers(PRIVATE, STATIC, FINAL), ElementUtils.getType(processingEnv, long.class), "serialVersionUID", "1L")); } break; } } return super.visitType(e, p); }
@Override public Void visitType(CodeTypeElement e, Void p) { List<TypeElement> superTypes = ElementUtils.getSuperTypes(e); for (TypeElement type : superTypes) { String qualifiedName = ElementUtils.getQualifiedName(type); if (qualifiedName.equals(Serializable.class.getCanonicalName())) { if (!e.containsField("serialVersionUID")) { e.add(new CodeVariableElement(modifiers(PRIVATE, STATIC, FINAL), ElementUtils.getType(processingEnv, long.class), "serialVersionUID", "1L")); } break; } } return super.visitType(e, p); }
List<TypeElement> element1Types = getSuperTypes(element1); List<TypeElement> element2Types = getSuperTypes(element2);
List<TypeElement> element1Types = getSuperTypes(element1); List<TypeElement> element2Types = getSuperTypes(element2);
List<TypeElement> superTypes = ElementUtils.getSuperTypes(fromType); for (TypeElement superType : superTypes) { if (ElementUtils.typeEquals(superType.asType(), to)) {
List<TypeElement> superTypes = ElementUtils.getSuperTypes(fromType); for (TypeElement superType : superTypes) { if (ElementUtils.typeEquals(superType.asType(), to)) {