public Set<String> collectSuperTypeNames(JvmType type) { return collectSuperTypeNames(newRef(type)); }
public Set<JvmTypeReference> collectSuperTypes(JvmType type) { return collectSuperTypes(newRef(type)); }
public boolean isSuperType(JvmDeclaredType subType, JvmDeclaredType superType) { if (subType==null || superType == null) return false; return collectSuperTypesAsRawTypes(newRef(subType)).contains(superType); }
public void collectSuperTypes(JvmTypeReference type, SuperTypeAcceptor acceptor) { doCollectSupertypeData(type, acceptor); }
public boolean isInstanceOf(JvmTypeReference reference, Class<?> clazz) { if (isNullOrProxy(reference)) return false; if (is(reference, clazz)) { return true; } Set<JvmTypeReference> types = superTypeCollector.collectSuperTypes(reference); for (JvmTypeReference jvmTypeReference : types) { if (is(jvmTypeReference, clazz)) return true; } return false; }
protected boolean isInheritanceRelation(JvmMember overriding, JvmMember overridden) { return superTypeCollector.isSuperType(overriding.getDeclaringType(), overridden.getDeclaringType()); }
protected JvmTypeReference newRef(JvmType type) { if (type instanceof JvmArrayType) { JvmTypeReference componentType = newRef(((JvmArrayType) type).getComponentType()); JvmGenericArrayTypeReference reference = factory.createJvmGenericArrayTypeReference(); reference.setComponentType(componentType); return reference; } else { JvmParameterizedTypeReference reference = factory.createJvmParameterizedTypeReference(); reference.setType(type); return reference; } }
public boolean isVisible(final JvmMember jvmMember, JvmDeclaredType contextType) { if (jvmMember.getVisibility() == JvmVisibility.PUBLIC) return true; if (contextType == null) { return false; } else if (jvmMember.getVisibility() == JvmVisibility.DEFAULT) { if (jvmMember instanceof JvmDeclaredType) { return equal(((JvmDeclaredType) jvmMember).getPackageName(), contextType.getPackageName()); } else { JvmDeclaredType declaringType = jvmMember.getDeclaringType(); if (declaringType != null) return equal(declaringType.getPackageName(), contextType.getPackageName()); return true; } } else if (contextType.equals(jvmMember.getDeclaringType())) { return true; } else { JvmParameterizedTypeReference typeReference = typesFactory.createJvmParameterizedTypeReference(); typeReference.setType(contextType); Set<JvmType> rawTypes = superTypeCollector.collectSuperTypesAsRawTypes(typeReference); if (rawTypes.contains(jvmMember.getDeclaringType())) { return jvmMember.getVisibility() == JvmVisibility.PROTECTED; } return false; } } }
public Set<JvmType> collectSuperTypesAsRawTypes(JvmTypeReference type) { final Set<JvmType> result = Sets.newLinkedHashSet(); doCollectSupertypeData(type, new SuperTypeAcceptor() { public boolean accept(JvmTypeReference superType, int distance) { JvmType rawType = superType.getType(); if (rawType != null && !rawType.eIsProxy()) { boolean notYetSeen = result.add(superType.getType()); return notYetSeen; } return false; } }); return result; }
public Iterable<JvmFeature> getAllJvmFeatures(JvmDeclaredType type, ITypeArgumentContext ctx) { Multimap<Triple<EClass, String, Integer>, JvmFeature> featureIndex = LinkedHashMultimap.create(); indexFeatures(type, featureIndex); Set<JvmTypeReference> types = superTypeCollector.collectSuperTypes(type); for (JvmTypeReference jvmTypeReference : types) { JvmType jvmType = jvmTypeReference.getType(); if (jvmType instanceof JvmDeclaredType) { indexFeatures((JvmDeclaredType) jvmType, featureIndex); } } return removeOverridden(featureIndex, ctx); }
if (conformanceComputer.getSuperTypeCollector().isSuperType((JvmDeclaredType)rightType, (JvmDeclaredType)leftType)) { if (param.rawType) return TypeConformanceResult.SUBTYPE;
public Set<JvmTypeReference> collectSuperTypes(JvmTypeReference type) { final Set<JvmTypeReference> result = Sets.newLinkedHashSet(); final Set<JvmType> rawTypes = Sets.newHashSet(); doCollectSupertypeData(type, new SuperTypeAcceptor() { public boolean accept(JvmTypeReference superType, int distance) { JvmType rawType = superType.getType(); if (rawType != null && !rawType.eIsProxy() && rawTypes.add(superType.getType())) { result.add(superType); return true; } return false; } }); return result; }
protected void initializeDistance(final JvmTypeReference firstType, Multimap<JvmType, JvmTypeReference> all, Multiset<JvmType> cumulatedDistance) { ITypeArgumentContext firstContext = getTypeArgumentContextProvider().getTypeArgumentContext( new TypeArgumentContextProvider.ReceiverRequest(firstType)); MaxDistanceRawTypeAcceptor acceptor = new MaxDistanceRawTypeAcceptor( cumulatedDistance, all, new ArgumentResolver(firstContext)); acceptor.accept(firstType, 0); superTypeCollector.collectSuperTypes(firstType, acceptor); }
public Set<String> collectSuperTypeNames(JvmTypeReference type) { final Set<String> result = Sets.newLinkedHashSet(); doCollectSupertypeData(type, new SuperTypeAcceptor() { public boolean accept(JvmTypeReference superType, int distance) { String name = getSuperTypeName(superType); if (name != null) return result.add(name); return false; } public String getSuperTypeName(JvmTypeReference typeReference) { if (typeReference instanceof JvmParameterizedTypeReference) { JvmType rawType = typeReference.getType(); if (rawType != null && !rawType.eIsProxy()) { return rawType.getIdentifier(); } return null; } else { return typeReference.getIdentifier(); } } }); return result; }