Java Code Examples for org.eclipse.xtext.xbase.typesystem.references.ParameterizedTypeReference#isResolved()

The following examples show how to use org.eclipse.xtext.xbase.typesystem.references.ParameterizedTypeReference#isResolved() . 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: TypeParameterSubstitutor.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected LightweightTypeReference doVisitParameterizedTypeReference(ParameterizedTypeReference reference, Visiting visiting) {
	if (reference.isResolved() && reference.isOwnedBy(getOwner()))
		return reference;
	JvmType type = reference.getType();
	if (type instanceof JvmTypeParameter) {
		LightweightTypeReference boundTypeArgument = getBoundTypeArgument(reference, (JvmTypeParameter) type, visiting);
		if (boundTypeArgument != null)
			return boundTypeArgument;
	}
	return doVisitParameterizedTypeReference(reference, type, visiting);
}
 
Example 2
Source File: ExtensionScopeHelper.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected Boolean doVisitParameterizedTypeReference(ParameterizedTypeReference reference) {
	if (reference.isResolved()) {
		return true;
	}
	if (reference.getOwner().getDeclaredTypeParameters().contains(reference.getType())) {
		return true;
	}
	if (!visit(reference.getTypeArguments())) {
		return false;
	}
	return !(reference.getType() instanceof JvmTypeParameter);
}
 
Example 3
Source File: ExpectationTypeParameterHintCollector.java    From xtext-extras with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public void doVisitUnboundTypeReference(UnboundTypeReference reference,
		ParameterizedTypeReference declaration) {
	boolean constraintSeen = false;
	boolean constraintsMatch = true;
	boolean othersSeen = false;
	boolean declarationMatches = getExpectedVariance() != VarianceInfo.OUT;
	if (reference.getTypeParameter() != declaration.getType()) {
		List<LightweightBoundTypeArgument> hints = reference.getAllHints();
		for(int i = 0; i < hints.size(); i++) {
			LightweightBoundTypeArgument hint = hints.get(i);
			if (hint.getSource() == BoundTypeArgumentSource.CONSTRAINT) {
				constraintSeen = true;
				outerVisit(hint.getTypeReference(), declaration, hint.getSource(), hint.getDeclaredVariance(), hint.getActualVariance());
				if (constraintsMatch && !hint.getTypeReference().isAssignableFrom(declaration)) {
					constraintsMatch = false;
				}
			} else {
				othersSeen = true;
				// we don't break the list traversal here since we want to do the paired outerVisit for all constraints
				if (declarationMatches) {
					if (hint.getActualVariance() == VarianceInfo.OUT && hint.getDeclaredVariance() == VarianceInfo.OUT && 
							(hint.getSource() == BoundTypeArgumentSource.INFERRED || hint.getSource() == BoundTypeArgumentSource.INFERRED_EXPECTATION || hint.getSource() == BoundTypeArgumentSource.INFERRED_LATER)) {
						if (!declaration.isAssignableFrom(hint.getTypeReference())) {
							declarationMatches = false;
						}
					} else {
						declarationMatches = false;
					}
				}
			}
		}
	} else {
		if (getOwner().getDeclaredTypeParameters().contains(reference.getTypeParameter())) {
			reference.acceptHint(declaration, BoundTypeArgumentSource.RESOLVED, this, VarianceInfo.INVARIANT, VarianceInfo.INVARIANT);
			return;
		}
	}
	if (constraintSeen && constraintsMatch && !othersSeen) {
		reference.acceptHint(declaration, BoundTypeArgumentSource.RESOLVED, this, VarianceInfo.INVARIANT, VarianceInfo.INVARIANT);
	} else if (!constraintSeen && !reference.internalIsResolved() && declaration.isResolved() && !getOwner().isResolved(reference.getHandle()) && reference.canResolveTo(declaration)) {
		reference.acceptHint(declaration, BoundTypeArgumentSource.RESOLVED, this, VarianceInfo.INVARIANT, VarianceInfo.INVARIANT);
	} else if (othersSeen && declarationMatches) {
		reference.acceptHint(declaration, BoundTypeArgumentSource.INFERRED, this, VarianceInfo.INVARIANT, VarianceInfo.INVARIANT);
	} else {
		reference.tryResolve();
		if (reference.internalIsResolved()) {
			outerVisit(reference, declaration);
		} else {
			addHint(reference, declaration);
		}
	}
}