use of org.eclipse.xtext.xbase.typesystem.references.LightweightTypeReference in project xtext-xtend by eclipse.
the class DeferredTypeParameterHintCollectorTest method hasHintsFor.
public List<LightweightBoundTypeArgument> hasHintsFor(final Map<JvmTypeParameter, LightweightMergedBoundTypeArgument> mapping, final String typeParamName) {
final Set<JvmTypeParameter> allKeys = mapping.keySet();
for (final JvmTypeParameter key : allKeys) {
String _simpleName = key.getSimpleName();
boolean _equals = Objects.equal(_simpleName, typeParamName);
if (_equals) {
LightweightTypeReference _typeReference = mapping.get(key).getTypeReference();
final UnboundTypeReference unbound = ((UnboundTypeReference) _typeReference);
final Consumer<LightweightBoundTypeArgument> _function = (LightweightBoundTypeArgument it) -> {
Assert.assertEquals(BoundTypeArgumentSource.INFERRED_LATER, it.getSource());
};
unbound.getAllHints().forEach(_function);
return unbound.getAllHints();
}
}
StringConcatenation _builder = new StringConcatenation();
_builder.append("No mapping for ");
_builder.append(typeParamName);
_builder.append(" in ");
final Function1<JvmTypeParameter, String> _function_1 = (JvmTypeParameter it) -> {
return it.getSimpleName();
};
Iterable<String> _map = IterableExtensions.<JvmTypeParameter, String>map(mapping.keySet(), _function_1);
_builder.append(_map);
Assert.fail(_builder.toString());
return null;
}
use of org.eclipse.xtext.xbase.typesystem.references.LightweightTypeReference in project xtext-xtend by eclipse.
the class MockTypeParameterSubstitutor method doVisitParameterizedTypeReference.
@Override
public LightweightTypeReference doVisitParameterizedTypeReference(final ParameterizedTypeReference reference, final Set<JvmTypeParameter> visiting) {
final JvmType type = reference.getType();
if ((type instanceof JvmTypeParameter)) {
boolean _add = visiting.add(((JvmTypeParameter) type));
boolean _not = (!_add);
if (_not) {
return null;
}
try {
final LightweightMergedBoundTypeArgument mappedReference = this.getTypeParameterMapping().get(type);
if ((mappedReference != null)) {
return mappedReference.getTypeReference().<Set<JvmTypeParameter>, LightweightTypeReference>accept(this, visiting);
} else {
ITypeReferenceOwner _owner = this.getOwner();
Object _object = new Object();
final SimpleUnboundTypeReference result = new SimpleUnboundTypeReference(_owner, ((JvmTypeParameter) type), _object);
Map<JvmTypeParameter, LightweightMergedBoundTypeArgument> _typeParameterMapping = this.getTypeParameterMapping();
LightweightMergedBoundTypeArgument _lightweightMergedBoundTypeArgument = new LightweightMergedBoundTypeArgument(result, VarianceInfo.INVARIANT);
_typeParameterMapping.put(((JvmTypeParameter) type), _lightweightMergedBoundTypeArgument);
return result;
}
} finally {
visiting.remove(type);
}
}
return super.doVisitParameterizedTypeReference(reference, visiting);
}
use of org.eclipse.xtext.xbase.typesystem.references.LightweightTypeReference in project xtext-xtend by eclipse.
the class Oven method assertIdentifiableTypeIsResolved.
public void assertIdentifiableTypeIsResolved(final JvmIdentifiableElement identifiable, final IResolvedTypes types) {
String _simpleName = identifiable.getSimpleName();
boolean _tripleEquals = (_simpleName == null);
if (_tripleEquals) {
return;
}
final LightweightTypeReference type = types.getActualType(identifiable);
Assert.assertNotNull(identifiable.toString(), type);
String _string = identifiable.toString();
String _plus = (_string + " / ");
String _plus_1 = (_plus + type);
Assert.assertNotNull(_plus_1, type.getIdentifier());
}
use of org.eclipse.xtext.xbase.typesystem.references.LightweightTypeReference in project xtext-xtend by eclipse.
the class LinkingTest method testTypeParameterReference_11.
@Test
public void testTypeParameterReference_11() throws Exception {
XtendFunction func = (XtendFunction) ((XtendClass) file("class X<Z> implements Iterable<Z> { def Iterable<Z> foo() { val result = new X result }}").getXtendTypes().get(0)).getMembers().get(0);
JvmOperation operation = associator.getDirectlyInferredOperation(func);
JvmTypeReference returnType = operation.getReturnType();
assertEquals("java.lang.Iterable<Z>", returnType.getIdentifier());
LightweightTypeReference bodyType = getType(func.getExpression());
assertEquals("X<Z>", bodyType.getIdentifier());
LightweightTypeReference bodyReturnType = getReturnType(func.getExpression());
assertEquals("X<Z>", bodyReturnType.getIdentifier());
}
use of org.eclipse.xtext.xbase.typesystem.references.LightweightTypeReference in project xtext-xtend by eclipse.
the class Bug409780Test method testConstraintsInfluenceFeatureScope_02.
@Test
public void testConstraintsInfluenceFeatureScope_02() throws Exception {
XtendFile file = file("class C {\n" + " def private a(Iterable<CharSequence> it) {\n" + " map[ b.append('') ]\n" + " }\n" + " def private <T extends Appendable> T b(CharSequence c) {}\n" + "}");
XtendClass c = (XtendClass) file.getXtendTypes().get(0);
XtendFunction m = (XtendFunction) c.getMembers().get(0);
XBlockExpression body = (XBlockExpression) m.getExpression();
XFeatureCall featureCall = (XFeatureCall) body.getExpressions().get(0);
JvmIdentifiableElement method = featureCall.getFeature();
assertEquals("org.eclipse.xtext.xbase.lib.IterableExtensions.map(java.lang.Iterable,org.eclipse.xtext.xbase.lib.Functions$Function1)", method.getIdentifier());
assertTrue(featureCall.isStatic());
assertTrue(featureCall.isExtension());
assertFalse(featureCall.isTypeLiteral());
LightweightTypeReference type = getType(featureCall);
assertEquals("java.lang.Iterable<java.lang.Appendable>", type.getIdentifier());
}
Aggregations