protected LightweightTypeReference createRawTypeReference(JvmType rawType) { return getOwner().toPlainTypeReference(rawType); }
/** * Determines if this type reference denotes the same type or a subtype of * the given {@code type}. */ public boolean isSubtypeOf(JvmType type) { if (type == null) { throw new IllegalArgumentException("type may not be null"); } // TODO interfaces don't inherit from non-interfaces, primitives, arrays, object // A final type does not have any subtypes // check for type == this.type LightweightTypeReference other = owner.toPlainTypeReference(type); boolean result = other.isAssignableFrom(this); return result; }
protected LightweightTypeReference getParameterType(JvmFormalParameter p) { JvmTypeReference parameterType = p.getParameterType(); JvmType type = parameterType.getType(); if (type == null) return null; return owner.toPlainTypeReference(type).getRawTypeReference(); }
/** * @since 2.14 */ protected LightweightTypeReference getRawTypeForName(String clazzName, ITypeComputationState state) { JvmType rawType = findDeclaredType(clazzName, state); if (rawType == null) { return state.getReferenceOwner().newUnknownTypeReference(clazzName); } return state.getReferenceOwner().toPlainTypeReference(rawType); }
private boolean isArrayTypeMismatch(LightweightTypeReference rawReceiverType, JvmType rawParameterType) { if (rawReceiverType.isArray()) { LightweightTypeReference parameterTypeReference = rawReceiverType.getOwner().toPlainTypeReference(rawParameterType); if (parameterTypeReference.getSuperType(Iterable.class) == null && isArrayTypeMismatch(rawReceiverType, parameterTypeReference)) { return true; } } return false; }
@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); }
protected AbstractNestedFeatureScopeSession tryCreateNestedSessionWithVisibilityContext(Map<QualifiedName, JvmIdentifiableElement> elements, ITypeReferenceOwner owner, QualifiedName thisName) { if (elements.containsKey(thisName)) { JvmIdentifiableElement associatedWithThis = elements.get(thisName); if (associatedWithThis instanceof JvmType) { if (IFeatureNames.SELF.equals(thisName)) { IEObjectDescription thisDescription = getLocalElement(IFeatureNames.THIS); if (thisDescription != null && thisDescription.getEObjectOrProxy() instanceof JvmDeclaredType) { JvmDeclaredType thisType = (JvmDeclaredType) thisDescription.getEObjectOrProxy(); LightweightTypeReference context = owner.toPlainTypeReference((JvmType) associatedWithThis); FeatureScopeSessionWithContext contextSession = new FeatureScopeSessionWithContext(this, context, thisType.getPackageName()); AbstractNestedFeatureScopeSession result = new FeatureScopeSessionWithLocalElements(contextSession, elements); return result; } } LightweightTypeReference context = owner.toPlainTypeReference((JvmType) associatedWithThis); FeatureScopeSessionWithContext contextSession = new FeatureScopeSessionWithContext(this, context); AbstractNestedFeatureScopeSession result = new FeatureScopeSessionWithLocalElements(contextSession, elements); return result; } } return null; }
ParameterizedTypeReference result = owner.newParameterizedTypeReference(((JvmOperation) feature).getReturnType().getType()); WildcardTypeReference wildcard = owner.newWildcardTypeReference(); wildcard.addUpperBound(owner.toPlainTypeReference(rawTypes.get(0))); result.addTypeArgument(wildcard); return result;
ParameterizedTypeReference result = owner.newParameterizedTypeReference(((JvmOperation) feature).getReturnType().getType()); WildcardTypeReference wildcard = owner.newWildcardTypeReference(); wildcard.addUpperBound(owner.toPlainTypeReference(rawTypes.get(0))); result.addTypeArgument(wildcard); return result;
protected boolean isMatchingFirstParameter(JvmOperation feature) { List<JvmFormalParameter> parameters = feature.getParameters(); JvmFormalParameter firstParameter = parameters.get(0); JvmTypeReference type = firstParameter.getParameterType(); if (type == null) return false; JvmType rawParameterType = type.getType(); if (rawParameterType == null || rawParameterType.eIsProxy()) return false; if (!(rawParameterType instanceof JvmTypeParameter)) { if (rawArgumentType.isResolved()) { // short circuit - limit extension scope entries to real candidates LightweightTypeReference parameterTypeReference = rawArgumentType.getOwner().toPlainTypeReference(rawParameterType); if (parameterTypeReference.isResolved() && !parameterTypeReference.isAssignableFrom(rawArgumentType)) { if (parameterTypeReference.isArray() && !rawArgumentType.isArray() && rawArgumentType.isSubtypeOf(Iterable.class)) { return true; } return false; } if (parameterTypeReference.isArray() && !rawArgumentType.isArray() && !rawArgumentType.isSubtypeOf(Iterable.class)) { return false; } } else if (isArrayTypeMismatch(rawArgumentType, rawParameterType)) { return false; } } return true; }