Java Code Examples for org.eclipse.xtext.xtype.XComputedTypeReference#setTypeProvider()

The following examples show how to use org.eclipse.xtext.xtype.XComputedTypeReference#setTypeProvider() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LogicalContainerAwareReentrantTypeResolver.java    From xtext-extras with Eclipse Public License 2.0 6 votes vote down vote up
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;
	}
 
Example 2
Source File: XtendReentrantTypeResolver.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * 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);
}
 
Example 3
Source File: LogicalContainerAwareReentrantTypeResolver.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
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();
}
 
Example 4
Source File: UnboundTypeReference.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public JvmTypeReference toTypeReference() {
	if (internalGetResolvedTo() != null) {
		return resolvedTo.toTypeReference();
	}
	XComputedTypeReference result = getServices().getXtypeFactory().createXComputedTypeReference();
	result.setTypeProvider(new UnboundTypeReferenceResolver(this));
	return result;
}
 
Example 5
Source File: JvmTypesBuilder.java    From xtext-extras with Eclipse Public License 2.0 3 votes vote down vote up
/**
 * Produces an inferred type which will be resolved on demand. It should not be attempted to resolve
 * this type during the model inference.
 * 
 * @param expression the expression that will be used resolve the type. May not be <code>null</code>.
 * @return an inferred type.
 */
public JvmTypeReference inferredType(XExpression expression) {
	Preconditions.checkNotNull(expression);
	XComputedTypeReference result = xtypesFactory.createXComputedTypeReference();
	result.setTypeProvider(new InferredTypeIndicator(expression));
	return result;
}
 
Example 6
Source File: JvmTypesBuilder.java    From xtext-extras with Eclipse Public License 2.0 2 votes vote down vote up
/**
 * Produces an inferred type which will be resolved on demand. It should not be attempted to resolve
 * this type during the model inference.
 * 
 * @return an inferred type.
 */
public JvmTypeReference inferredType() {
	XComputedTypeReference result = xtypesFactory.createXComputedTypeReference();
	result.setTypeProvider(new InferredTypeIndicator(null));
	return result;
}