protected void requestCapturedLocalVariables(JvmTypeReference toBeWrapped, JvmDeclaredType type, ResolvedTypes resolvedTypes, Map<JvmIdentifiableElement, ResolvedTypes> resolvedTypesByContext, IAcceptor<JvmTypeReference> result) { LocalVariableCapturerImpl capturer = new LocalVariableCapturerImpl(toBeWrapped, type, this, resolvedTypes, resolvedTypesByContext); XComputedTypeReference ref = getServices().getXtypeFactory().createXComputedTypeReference(); ref.setTypeProvider(capturer); result.accept(ref); capturer.awaitCapturing(); } }
@Override public JvmTypeReference toTypeReference() { if (internalGetResolvedTo() != null) { return resolvedTo.toTypeReference(); } XComputedTypeReference result = getServices().getXtypeFactory().createXComputedTypeReference(); result.setTypeProvider(new UnboundTypeReferenceResolver(this)); return result; }
@Override public JvmTypeReference toTypeReference() { XFunctionTypeRef result = getOwner().getServices().getXtypeFactory().createXFunctionTypeRef(); result.setType(getType()); result.setEquivalent(getEquivalentTypeReference()); if (parameterTypes != null) { for(LightweightTypeReference parameterType: parameterTypes) { result.getParamTypes().add(parameterType.toTypeReference()); } } if (returnType != null) { result.setReturnType(returnType.toTypeReference()); } return result; }
if (InferredTypeIndicator.isInferred(parameterType)) { XComputedTypeReference casted = (XComputedTypeReference) parameterType; XComputedTypeReference computedParameterType = getServices().getXtypeFactory().createXComputedTypeReference(); computedParameterType.setTypeProvider(new DispatchParameterTypeReferenceProvider(operation, i, resolvedTypes, featureScopeSession, this)); casted.setEquivalent(computedParameterType); } else if (parameterType == null) { XComputedTypeReference computedParameterType = getServices().getXtypeFactory().createXComputedTypeReference(); computedParameterType.setTypeProvider(new DispatchParameterTypeReferenceProvider(operation, i, resolvedTypes, featureScopeSession, this)); parameter.setParameterType(computedParameterType); if (InferredTypeIndicator.isInferred(parameterType)) { XComputedTypeReference casted = (XComputedTypeReference) parameterType; XComputedTypeReference computedParameterType = getServices().getXtypeFactory().createXComputedTypeReference(); computedParameterType.setTypeProvider(new InitializerParameterTypeReferenceProvider( firstParameter,
protected JvmTypeReference createComputedTypeReference( Map<JvmIdentifiableElement, ResolvedTypes> resolvedTypesByContext, ResolvedTypes resolvedTypes, IFeatureScopeSession featureScopeSession, JvmMember member, /* @Nullable */ InferredTypeIndicator indicator, boolean returnType) { XComputedTypeReference result = getServices().getXtypeFactory().createXComputedTypeReference(); if (indicator == null || indicator.getExpression() == null) result.setTypeProvider(createTypeProvider(resolvedTypesByContext, resolvedTypes, featureScopeSession, member, returnType)); else result.setTypeProvider(createTypeProvider(resolvedTypesByContext, resolvedTypes, featureScopeSession, member, indicator.getExpression(), returnType)); // TODO do we need a lightweight computed type reference? // resolvedTypes.setType(member, result); return result; }
/** * Initializes the type inference strategy for the cache field for create extensions. */ @Override protected void _doPrepare(ResolvedTypes resolvedTypes, IFeatureScopeSession featureScopeSession, JvmField field, Map<JvmIdentifiableElement, ResolvedTypes> resolvedTypesByContext) { JvmTypeReference knownType = field.getType(); if (InferredTypeIndicator.isInferred(knownType)) { XComputedTypeReference castedKnownType = (XComputedTypeReference) knownType; EObject sourceElement = associations.getPrimarySourceElement(field); if (sourceElement instanceof XtendFunction) { XtendFunction function = (XtendFunction) sourceElement; if (function.getCreateExtensionInfo() != null) { JvmOperation operation = associations.getDirectlyInferredOperation(function); if (operation != null) { declareTypeParameters(resolvedTypes, field, resolvedTypesByContext); XComputedTypeReference fieldType = getServices().getXtypeFactory().createXComputedTypeReference(); fieldType.setTypeProvider(new CreateCacheFieldTypeReferenceProvider(operation, resolvedTypes, featureScopeSession)); castedKnownType.setEquivalent(fieldType); return; } } } } super._doPrepare(resolvedTypes, featureScopeSession, field, resolvedTypesByContext); doPrepareLocalTypes(resolvedTypesByContext.get(field), featureScopeSession, field, resolvedTypesByContext); }