protected String getRawTypeIdentifier(JvmTypeReference reference) { if (reference instanceof JvmParameterizedTypeReference) { JvmType typeOrProxy = (JvmType) reference.eGet(TypesPackage.Literals.JVM_PARAMETERIZED_TYPE_REFERENCE__TYPE, false); if (typeOrProxy.eIsProxy()) { URI uri = ((InternalEObject)typeOrProxy).eProxyURI(); if (URIHelperConstants.PROTOCOL.equals(uri.scheme())) { if (URIHelperConstants.PRIMITIVES.regionMatches(1, uri.segment(0), 0, URIHelperConstants.PRIMITIVES.length() - 1)) { String fragment = uri.fragment(); return fragment; } else if (URIHelperConstants.OBJECTS.regionMatches(1, uri.segment(0), 0, URIHelperConstants.OBJECTS.length() - 2)) { String fragment = uri.fragment(); if (fragment.lastIndexOf('/') == -1) return fragment; } } } } RawTypeReferenceComputer strategy = new RawTypeReferenceComputer(TypesFactory.eINSTANCE); JvmTypeReference result = strategy.getRawTypeReference(reference, eResource()); if (result == null) return null; JvmType rawResult = result.getType(); return rawResult == null ? null : rawResult.getIdentifier(); }
protected String getRawTypeIdentifier(JvmTypeReference reference) { if (reference instanceof JvmParameterizedTypeReference) { JvmType typeOrProxy = (JvmType) reference.eGet(TypesPackage.Literals.JVM_PARAMETERIZED_TYPE_REFERENCE__TYPE, false); if (typeOrProxy.eIsProxy()) { URI uri = ((InternalEObject)typeOrProxy).eProxyURI(); if (URIHelperConstants.PROTOCOL.equals(uri.scheme())) { if (URIHelperConstants.PRIMITIVES.regionMatches(1, uri.segment(0), 0, URIHelperConstants.PRIMITIVES.length() - 1)) { String fragment = uri.fragment(); return fragment; } else if (URIHelperConstants.OBJECTS.regionMatches(1, uri.segment(0), 0, URIHelperConstants.OBJECTS.length() - 2)) { String fragment = uri.fragment(); if (fragment.lastIndexOf('/') == -1) return fragment; } } } } RawTypeReferenceImplementation strategy = new RawTypeReferenceImplementation(TypesFactory.eINSTANCE); JvmTypeReference result = strategy.getRawTypeReference(reference, eResource()); if (result == null) return null; JvmType rawResult = result.getType(); return rawResult == null ? null : rawResult.getIdentifier(); }
/** * Constraint bounds are definitely invalid if they are <code>not null</code> and point to a primitive type. * {@link JvmSpecializedTypeReference} will not be resolved by this check thus they may lead to finally * invalid constraint bounds. * * @param constraintBound the reference that shall be come the new constraint. * @return <code>false</code> if the given constraint is definitely invalid. */ protected boolean isLikelyAValidConstraintBound(JvmTypeReference constraintBound) { if (constraintBound == null) return true; if (constraintBound instanceof JvmSpecializedTypeReference) { JvmTypeReference equivalent = (JvmTypeReference) constraintBound.eGet(TypesPackage.Literals.JVM_SPECIALIZED_TYPE_REFERENCE__EQUIVALENT, false); if (equivalent != null) { return isLikelyAValidConstraintBound(equivalent); } return true; } boolean invalid = (constraintBound.getType() instanceof JvmPrimitiveType || (constraintBound.getType() instanceof JvmVoid && !constraintBound.getType().eIsProxy())); return !invalid; }
/** * Constraint bounds are definitely invalid if they are <code>not null</code> and point to a primitive type. * {@link JvmSpecializedTypeReference} will not be resolved by this check thus they may lead to finally * invalid constraint bounds. * * @param constraintBound the reference that shall be come the new constraint. * @return <code>false</code> if the given constraint is definitely invalid. */ protected boolean isLikelyAValidConstraintBound(JvmTypeReference constraintBound) { if (constraintBound == null) return true; if (constraintBound instanceof JvmSpecializedTypeReference) { JvmTypeReference equivalent = (JvmTypeReference) constraintBound.eGet(TypesPackage.Literals.JVM_SPECIALIZED_TYPE_REFERENCE__EQUIVALENT, false); if (equivalent != null) { return isLikelyAValidConstraintBound(equivalent); } return true; } boolean invalid = (constraintBound.getType() instanceof JvmPrimitiveType || (constraintBound.getType() instanceof JvmVoid && !constraintBound.getType().eIsProxy())); return !invalid; }