Java Code Examples for org.eclipse.xtext.xbase.typesystem.references.LightweightTypeReference#getSuperType()

The following examples show how to use org.eclipse.xtext.xbase.typesystem.references.LightweightTypeReference#getSuperType() . 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: CollectionLiteralsTypeComputer.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * If the expected type is a subtype of {@link Map}, the resolved super type is returned.
 * This allows to query for the type arguments that are available on the expectation.
 */
protected LightweightTypeReference getMapExpectation(LightweightTypeReference expectation) {
	if (expectation != null && expectation.isResolved()) {
		LightweightTypeReference result = expectation.getSuperType(Map.class);
		if (result != null && result.getTypeArguments().size() == 2) {
			return result;
		}
	}
	return null;
}
 
Example 2
Source File: TypeConformanceComputer.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
protected int doIsConformantOuterType(LightweightTypeReference left, LightweightTypeReference right, int flags) {
	LightweightTypeReference leftOuter = left.getOuter();
	LightweightTypeReference rightOuter = right.getOuter();
	if (leftOuter != null) {
		JvmType rawLeftOuter = (JvmType) left.getType().eContainer();
		if (rightOuter != null) {
			JvmType rawRightOuter = (JvmType) right.getType().eContainer();
			if (rawLeftOuter != rawRightOuter) {
				throw new IllegalStateException("References must point to same raw types: " + left + " / " + right);
			}
			if (leftOuter.getType() != rawLeftOuter) {
				leftOuter = leftOuter.getSuperType(rawLeftOuter);
				if (leftOuter == null) {
					return flags;
				}
			}
			if (rightOuter.getType() != rawRightOuter) {
				rightOuter = rightOuter.getSuperType(rawRightOuter);
				if (rightOuter == null) {
					return flags;
				}
			}
			return doIsConformantTypeArguments(leftOuter, rightOuter, flags);
		} else {
			throw new IllegalStateException("References must point to same raw types: " + left + " / " + right);
		}
	} else if (rightOuter != null) {
		throw new IllegalStateException("References must point to same raw types: " + left + " / " + right);
	}
	return flags | SUCCESS;
}
 
Example 3
Source File: ExtensionScopeHelper.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
private boolean isArrayTypeMismatch(LightweightTypeReference rawReceiverType, JvmType rawParameterType) {
	if (rawReceiverType.isArray()) {
		LightweightTypeReference parameterTypeReference = rawReceiverType.getOwner().toPlainTypeReference(rawParameterType);
		if (parameterTypeReference.getSuperType(Iterable.class) == null && isArrayTypeMismatch(rawReceiverType, parameterTypeReference)) {
			return true;
		}
	}
	return false;
}