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

The following examples show how to use org.eclipse.xtext.xtype.XComputedTypeReference#getEquivalent() . 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 5 votes vote down vote up
protected AbstractDemandTypeReferenceProvider getComputedTypeReference(JvmTypeReference knownType) {
	if (InferredTypeIndicator.isInferred(knownType)) {
		XComputedTypeReference casted = (XComputedTypeReference) knownType;
		JvmTypeReference equivalent = casted.getEquivalent();
		if (equivalent instanceof XComputedTypeReference) {
			IJvmTypeReferenceProvider typeProvider = ((XComputedTypeReference) equivalent).getTypeProvider();
			if (typeProvider instanceof AbstractDemandTypeReferenceProvider) {
				return (AbstractDemandTypeReferenceProvider) typeProvider;
			}
		}
	}
	return null;
}
 
Example 2
Source File: LogicalContainerAwareReentrantTypeResolver.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Returns the expression that will be used to infer the given type from. If the type is 
 * already resolved, the result will be null. If no expression can be determined, null is
 * also returned.
 */
protected XExpression getInferredFrom(JvmTypeReference typeReference) {
	if (InferredTypeIndicator.isInferred(typeReference)) {
		XComputedTypeReference computed = (XComputedTypeReference) typeReference;
		if (computed.getEquivalent() instanceof XComputedTypeReference) {
			XComputedTypeReference inferred = (XComputedTypeReference) computed.getEquivalent();
			IJvmTypeReferenceProvider typeProvider = inferred.getTypeProvider();
			if (typeProvider instanceof DemandTypeReferenceProvider) {
				return ((DemandTypeReferenceProvider) typeProvider).expression;
			}
		}
	}
	return null;
}
 
Example 3
Source File: LightweightTypeReferenceFactory.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public LightweightTypeReference doVisitComputedTypeReference(XComputedTypeReference reference) {
	IJvmTypeReferenceProvider typeProvider = reference.getTypeProvider();
	if (typeProvider instanceof UnboundTypeReferenceResolver) {
		UnboundTypeReference typeReference = ((UnboundTypeReferenceResolver) typeProvider).getUnboundTypeReference();
		return typeReference.copyInto(owner);
	}
	JvmTypeReference equivalent = reference.getEquivalent();
	if (equivalent == null)
		return owner.newUnknownTypeReference();
	return super.doVisitComputedTypeReference(reference);
}