private static boolean containsType(Collection<? extends TypeMirror> collection, TypeMirror type) { for (TypeMirror otherTypeMirror : collection) { if (typeEquals(otherTypeMirror, type)) { return true; } } return false; }
private static boolean containsType(Collection<? extends TypeMirror> collection, TypeMirror type) { for (TypeMirror otherTypeMirror : collection) { if (typeEquals(otherTypeMirror, type)) { return true; } } return false; }
public static boolean isEnclosedIn(Element enclosedIn, Element element) { if (element == null) { return false; } else if (typeEquals(enclosedIn.asType(), element.asType())) { return true; } else { return isEnclosedIn(enclosedIn, element.getEnclosingElement()); } }
private boolean containsOverride(CodeExecutableElement e) { for (AnnotationMirror mirror : e.getAnnotationMirrors()) { if (ElementUtils.typeEquals(overrideType, mirror.getAnnotationType())) { return true; } } return false; }
public static boolean isEnclosedIn(Element enclosedIn, Element element) { if (element == null) { return false; } else if (typeEquals(enclosedIn.asType(), element.asType())) { return true; } else { return isEnclosedIn(enclosedIn, element.getEnclosingElement()); } }
public TypeCastData getCast(TypeMirror targetType) { for (TypeCastData cast : casts) { if (ElementUtils.typeEquals(cast.getTargetType(), targetType)) { return cast; } } return null; }
public TypeCheckData getCheck(TypeMirror type) { for (TypeCheckData check : checks) { if (ElementUtils.typeEquals(check.getCheckedType(), type)) { return check; } } return null; }
private boolean isInstanceHasWrongSignature(String receiverTypeFullClassName) { for (Element elem : this.processingEnv.getElementUtils().getTypeElement(receiverTypeFullClassName).getEnclosedElements()) { if (elem.getKind().equals(ElementKind.METHOD)) { ExecutableElement method = (ExecutableElement) elem; if (method.getSimpleName().toString().equals("isInstance") && method.getParameters().size() == 1 && ElementUtils.typeEquals(method.getParameters().get(0).asType(), Utils.getTypeMirror(processingEnv, TruffleObject.class))) { return false; } } } return true; }
public static int compareByTypeHierarchy(TypeMirror t1, Set<String> t1SuperSet, TypeMirror t2, Set<String> t2SuperSet) { if (typeEquals(t1, t2)) { return 0; } if (t1SuperSet.contains(getQualifiedName(t2))) { return -1; } if (t2SuperSet.contains(getQualifiedName(t1))) { return 1; } return 0; }
public List<ImplicitCastData> lookupByTargetType(TypeMirror targetType) { if (getImplicitCasts() == null) { return Collections.emptyList(); } List<ImplicitCastData> foundCasts = new ArrayList<>(); for (ImplicitCastData cast : getImplicitCasts()) { if (ElementUtils.typeEquals(cast.getTargetType(), targetType)) { foundCasts.add(cast); } } return foundCasts; }
public ExecutableTypeData findExecutableType(TypeMirror primitiveType, int evaluatedCount) { for (ExecutableTypeData type : getExecutableTypes(evaluatedCount)) { if (ElementUtils.typeEquals(type.getReturnType(), primitiveType)) { return type; } } return null; }
public static boolean variableEquals(VariableElement var1, VariableElement var2) { if (!var1.getSimpleName().equals(var2.getSimpleName())) { return false; } if (!ElementUtils.typeEquals(var1.asType(), var2.asType())) { return false; } if (!ElementUtils.elementEquals(var1.getEnclosingElement(), var2.getEnclosingElement())) { return false; } return true; }
public ImplicitCastData lookupCast(TypeMirror sourceType, TypeMirror targetType) { if (getImplicitCasts() == null) { return null; } for (ImplicitCastData cast : getImplicitCasts()) { if (ElementUtils.typeEquals(cast.getSourceType(), sourceType) && ElementUtils.typeEquals(cast.getTargetType(), targetType)) { return cast; } } return null; }
public List<TypeMirror> lookupSourceTypes(TypeMirror targetType) { List<TypeMirror> sourceTypes = new ArrayList<>(); sourceTypes.add(targetType); for (ImplicitCastData cast : getImplicitCasts()) { if (ElementUtils.typeEquals(cast.getTargetType(), targetType)) { sourceTypes.add(cast.getSourceType()); } } return ElementUtils.uniqueSortedTypes(sourceTypes, true); }
public boolean hasImplicitSourceTypes(TypeMirror targetType) { if (getImplicitCasts() == null) { return false; } for (ImplicitCastData cast : getImplicitCasts()) { if (ElementUtils.typeEquals(cast.getTargetType(), targetType)) { return true; } } return false; }
private boolean isPrimitiveWrapper(TypeMirror type) { Types types = context.getEnvironment().getTypeUtils(); for (TypeKind kind : TypeKind.values()) { if (!kind.isPrimitive()) { continue; } if (ElementUtils.typeEquals(type, types.boxedClass(types.getPrimitiveType(kind)).asType())) { return true; } } return false; }
private boolean isPrimitiveWrapper(TypeMirror type) { Types types = context.getEnvironment().getTypeUtils(); for (TypeKind kind : TypeKind.values()) { if (!kind.isPrimitive()) { continue; } if (ElementUtils.typeEquals(type, types.boxedClass(types.getPrimitiveType(kind)).asType())) { return true; } } return false; }
private void verifyTypes(TypeSystemData typeSystem) { for (TypeMirror type : typeSystem.getLegacyTypes()) { if (isPrimitiveWrapper(type)) { typeSystem.addError("Types must not contain primitive wrapper types."); } if (ElementUtils.typeEquals(type, context.getType(Object.class))) { typeSystem.addError("Types must not contain the generic type java.lang.Object."); } } verifyTypeOrder(typeSystem); }
private void verifyTypes(TypeSystemData typeSystem) { for (TypeMirror type : typeSystem.getLegacyTypes()) { if (isPrimitiveWrapper(type)) { typeSystem.addError("Types must not contain primitive wrapper types."); } if (ElementUtils.typeEquals(type, context.getType(Object.class))) { typeSystem.addError("Types must not contain the generic type java.lang.Object."); } } verifyTypeOrder(typeSystem); }
public boolean isCompatibleTo(SpecializationData specialization) { if (isGeneric() && specialization.isFallback()) { return true; } for (Parameter param : getParameters()) { Parameter specializationParam = specialization.findParameter(param.getLocalName()); if (!ElementUtils.typeEquals(param.getType(), specializationParam.getType())) { return false; } } return true; } }