Java Code Examples for org.eclipse.xtext.xbase.typesystem.references.LightweightBoundTypeArgument#getOrigin()

The following examples show how to use org.eclipse.xtext.xbase.typesystem.references.LightweightBoundTypeArgument#getOrigin() . 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: ActualTypeArgumentCollectorTest.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
public Map<JvmTypeParameter, List<LightweightBoundTypeArgument>> assertOrigins(final Map<JvmTypeParameter, List<LightweightBoundTypeArgument>> mapping, final String typeParamName, final int count) {
  final Set<JvmTypeParameter> allKeys = mapping.keySet();
  for (final JvmTypeParameter key : allKeys) {
    String _simpleName = key.getSimpleName();
    boolean _equals = Objects.equal(_simpleName, typeParamName);
    if (_equals) {
      final List<LightweightBoundTypeArgument> mappingData = mapping.get(key);
      final Function1<LightweightBoundTypeArgument, Object> _function = (LightweightBoundTypeArgument it) -> {
        return it.getOrigin();
      };
      Assert.assertEquals(count, IterableExtensions.<Object>toSet(ListExtensions.<LightweightBoundTypeArgument, Object>map(mappingData, _function)).size());
      return mapping;
    }
  }
  return mapping;
}
 
Example 2
Source File: ResolvedTypes.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
protected void addNonRecursiveHints(LightweightBoundTypeArgument original, List<LightweightBoundTypeArgument> hints, Set<Object> seenHandles,
		List<LightweightBoundTypeArgument> result) {
	for(LightweightBoundTypeArgument hint: hints) {
		LightweightTypeReference reference = hint.getTypeReference();
		if (reference instanceof UnboundTypeReference) {
			addNonRecursiveHints(original, (UnboundTypeReference)reference, seenHandles, result);
		} else {
			if (original.getDeclaredVariance() == VarianceInfo.IN && hint.getTypeReference() instanceof WildcardTypeReference) {
				LightweightTypeReference upperBound = hint.getTypeReference().getUpperBoundSubstitute();
				if (upperBound instanceof UnboundTypeReference) {
					addNonRecursiveHints(original, (UnboundTypeReference)upperBound, seenHandles, result);
				} else {
					LightweightBoundTypeArgument delegateHint = new LightweightBoundTypeArgument(
							upperBound, original.getSource(), hint.getOrigin(), hint.getDeclaredVariance(), original.getActualVariance());
					result.add(delegateHint);
				}
			} else {
				if (!result.isEmpty()) {
					if (original.getDeclaredVariance() == VarianceInfo.OUT && original.getActualVariance() == VarianceInfo.INVARIANT) {
						if (hint.getDeclaredVariance() == VarianceInfo.OUT && hint.getActualVariance() == VarianceInfo.INVARIANT) {
							continue;
						}
					}
					if (!result.contains(hint))
						result.add(hint);
				} else {
					result.add(hint);
				}
			}
		}
	}
}
 
Example 3
Source File: StackedResolvedTypes.java    From xtext-extras with Eclipse Public License 2.0 4 votes vote down vote up
protected void mergeTypeParametersIntoParent(ResolvedTypes parent) {
	for(UnboundTypeReference unbound: basicGetTypeParameters().values()) {
		LightweightTypeReference resolvedTo = unbound.getResolvedTo();
		if (resolvedTo == null) {
			List<JvmTypeParameter> typeParameters = basicGetDeclardTypeParameters();
			if (typeParameters != null && typeParameters.contains(unbound.getTypeParameter())) {
				unbound.tryResolve();
				if (!unbound.internalIsResolved()) {
					if (unbound.getExpression() instanceof XConstructorCall) {
						unbound.resolve(); // resolve against constraints 
					} else {
						unbound.acceptHint(unbound.getOwner().newParameterizedTypeReference(unbound.getTypeParameter()), 
								BoundTypeArgumentSource.RESOLVED, unbound, VarianceInfo.INVARIANT, VarianceInfo.INVARIANT);
					}
				}
			} else {
				LightweightTypeReference reference = unbound.copyInto(parent.getReferenceOwner());
				if (reference instanceof UnboundTypeReference) {
					parent.acceptUnboundTypeReference(unbound.getHandle(), (UnboundTypeReference) reference);
				}
			}
		}
	}
	Map<Object, List<LightweightBoundTypeArgument>> typeParameterHints = basicGetTypeParameterHints();
	for(Map.Entry<Object, List<LightweightBoundTypeArgument>> hint: typeParameterHints.entrySet()) {
		if (!parent.isResolved(hint.getKey())) {
			List<LightweightBoundTypeArgument> boundTypeArguments = hint.getValue();
			for(LightweightBoundTypeArgument boundTypeArgument: boundTypeArguments) {
				if (boundTypeArgument.getOrigin() instanceof VarianceInfo) {
					parent.acceptHint(hint.getKey(), boundTypeArgument);
				} else {
					LightweightBoundTypeArgument copy = new LightweightBoundTypeArgument(
							boundTypeArgument.getTypeReference().copyInto(parent.getReferenceOwner()), 
							boundTypeArgument.getSource(), boundTypeArgument.getOrigin(), 
							boundTypeArgument.getDeclaredVariance(), 
							boundTypeArgument.getActualVariance());
					parent.acceptHint(hint.getKey(), copy);
				}
			}
		}
	}
}
 
Example 4
Source File: ResolvedTypes.java    From xtext-extras with Eclipse Public License 2.0 4 votes vote down vote up
protected LightweightBoundTypeArgument copyBoundTypeArgument(LightweightTypeReference typeReference,
		LightweightBoundTypeArgument boundTypeArgument) {
	return new LightweightBoundTypeArgument(typeReference, boundTypeArgument.getSource(),
			boundTypeArgument.getOrigin(), boundTypeArgument.getDeclaredVariance(),
			boundTypeArgument.getActualVariance());
}