private JvmTypeReference ensureValidType(Resource targetResource, JvmTypeReference returnType) { // No return type could be inferred => assume "void" if (returnType == null) { return this._typeReferenceBuilder.typeRef(Void.TYPE); } // The given type is not associated to the target resource => force relocation. final Resource returnTypeResource = returnType.eResource(); if (returnTypeResource != null && !Objects.equal(returnType.eResource(), targetResource)) { return this.typeBuilder.cloneWithProxies(returnType); } // A return type was inferred => use it as-is because it is not yet resolved to the concrete type. if (InferredTypeIndicator.isInferred(returnType)) { return returnType; } // A return was inferred and resolved => use it. return this.typeBuilder.cloneWithProxies(returnType); }
final boolean canAssociate = languageInfo.isLanguage(original.eResource()); EcoreUtil.Copier copier = new EcoreUtil.Copier(false) { private static final long serialVersionUID = 1L;
/** * Returns the resolved features targeting a specific Java version in order to support new language features. */ public ResolvedFeatures getResolvedFeatures(JvmTypeReference contextType, JavaVersion targetVersion) { ITypeReferenceOwner owner = new StandardTypeReferenceOwner(services, contextType.eResource().getResourceSet()); return getResolvedFeatures(owner.toLightweightTypeReference(contextType), targetVersion); }
/** * Returns the resolved features that are defined in the given <code>context type</code> and its supertypes. * Considers private methods of super types, too. * @param contextType the context type. Has to be contained in a resource. * @return the resolved features. */ public ResolvedFeatures getResolvedFeatures(JvmTypeReference contextType) { ITypeReferenceOwner owner = new StandardTypeReferenceOwner(services, contextType.eResource().getResourceSet()); return getResolvedFeatures(owner.toLightweightTypeReference(contextType)); }
/** * @since 2.4 */ public String referenceToString(JvmTypeReference typeRef, String defaultLabel) { if (typeRef == null) return defaultLabel; if (typeRef.eResource() == null) { if (typeRef instanceof JvmAnyTypeReference) { return "Object"; } return typeRef.getSimpleName(); } StandardTypeReferenceOwner owner = new StandardTypeReferenceOwner(services, typeRef); LightweightTypeReference reference = owner.toLightweightTypeReference(typeRef); return referenceToString(reference); }
@Override public JvmTypeReference getEquivalent() { if (equivalent == null) { IJvmTypeReferenceProvider provider = getTypeProvider(); if (provider != null) { JvmTypeReference result = provider.getTypeReference(this); if (equivalent == null || equivalent != result) { if (result != null && (result.eResource() != null || result.eContainer() != null)) { JvmDelegateTypeReference delegate = TypesFactory.eINSTANCE.createJvmDelegateTypeReference(); delegate.setDelegate(result); result = delegate; } if (result != null) { boolean wasDeliver = eDeliver(); try { eSetDeliver(false); setEquivalent(result); } finally { eSetDeliver(wasDeliver); } } } } else { equivalent = null; } } return equivalent; }
public void serialize(final JvmTypeReference type, EObject context, IAppendable appendable, boolean withoutConstraints, boolean paramsToWildcard, boolean paramsToObject, boolean allowPrimitives) { IAppendable tracedAppendable = appendable; boolean tracing = false; if (appendable instanceof ITreeAppendable && type.eResource() == context.eResource()) { tracedAppendable = ((ITreeAppendable) appendable).trace(type); tracing = true;