protected LightweightTypeReference getRawTypeFromConstraints(ITypeReferenceOwner owner, JvmTypeParameter typeParameter, ResourceSet resourceSet) { if (visited.add(typeParameter)) { List<JvmTypeConstraint> constraints = typeParameter.getConstraints(); if (!constraints.isEmpty()) { if (constraints.size() > 1) { CompoundTypeReference result = owner.newCompoundTypeReference(false); for(JvmTypeConstraint constraint: constraints) { if (constraint instanceof JvmUpperBound) { JvmTypeReference typeReference = constraint.getTypeReference(); if (typeReference != null) result.addComponent(owner.toLightweightTypeReference(typeReference).accept(this, resourceSet)); } } return result; } else { JvmTypeReference typeReference = constraints.get(0).getTypeReference(); if (typeReference != null) { LightweightTypeReference result = owner.toLightweightTypeReference(typeReference).accept(this, resourceSet); return result; } } } } return createObjectReference(owner, resourceSet); }
@Override protected LightweightTypeReference doVisitWildcardTypeReference(WildcardTypeReference reference, ResourceSet resourceSet) { if (reference.isUnbounded()) { return reference.getUpperBoundSubstitute(); } if (reference.getUpperBounds().size() == 1) { return reference.getUpperBoundSubstitute().accept(this, resourceSet); } CompoundTypeReference result = reference.getOwner().newCompoundTypeReference(false); enhanceCompoundReference(reference.getUpperBounds(), result, resourceSet); return result; }
@Override public LightweightTypeReference getRawTypeReference(LightweightTypeReference reference, ResourceSet resourceSet) { LightweightTypeReference result = new RawTypeReferenceImplementation(factory).getRawTypeReference(reference, resourceSet); return result; } }
@Override protected LightweightTypeReference doVisitCompoundTypeReference(CompoundTypeReference reference, ResourceSet resourceSet) { if (reference.isRawType()) return reference; CompoundTypeReference result = reference.getOwner().newCompoundTypeReference(reference.isSynonym()); enhanceCompoundReference(reference.getMultiTypeComponents(), result, resourceSet); return result; }
@Override protected LightweightTypeReference doVisitParameterizedTypeReference(ParameterizedTypeReference reference, ResourceSet resourceSet) { JvmType type = reference.getType(); if (reference.isRawType() && !(type instanceof JvmTypeParameter)) { return reference; } if (type instanceof JvmTypeParameter) { return getRawTypeFromConstraints(reference.getOwner(), (JvmTypeParameter) type, resourceSet); } return reference.getOwner().toPlainTypeReference(type); }