use of org.eclipse.xtext.xbase.typesystem.references.LightweightBoundTypeArgument in project xtext-xtend by eclipse.
the class ActualTypeArgumentCollectorTest method assertMapping.
public Map<JvmTypeParameter, List<LightweightBoundTypeArgument>> assertMapping(final Map<JvmTypeParameter, List<LightweightBoundTypeArgument>> mapping, final String typeParamName, final Triple<String, VarianceInfo, VarianceInfo>... mappedTypes) {
final Set<JvmTypeParameter> allKeys = mapping.keySet();
for (final JvmTypeParameter key : allKeys) {
String _simpleName = key.getSimpleName();
boolean _equals = Objects.equal(_simpleName, typeParamName);
if (_equals) {
Assert.assertNotNull(mappedTypes);
final List<LightweightBoundTypeArgument> mappingData = mapping.get(key);
final Function1<LightweightBoundTypeArgument, String> _function = (LightweightBoundTypeArgument it) -> {
StringConcatenation _builder = new StringConcatenation();
LightweightTypeReference _typeReference = it.getTypeReference();
_builder.append(_typeReference);
_builder.append("(");
VarianceInfo _declaredVariance = it.getDeclaredVariance();
_builder.append(_declaredVariance);
_builder.append("/");
VarianceInfo _actualVariance = it.getActualVariance();
_builder.append(_actualVariance);
_builder.append(")");
return _builder.toString();
};
Assert.assertEquals(ListExtensions.<LightweightBoundTypeArgument, String>map(mappingData, _function).toString(), ((List<Triple<String, VarianceInfo, VarianceInfo>>) Conversions.doWrapArray(mappedTypes)).size(), mappingData.size());
final Function1<LightweightBoundTypeArgument, Triple<String, VarianceInfo, VarianceInfo>> _function_1 = (LightweightBoundTypeArgument it) -> {
return Tuples.<String, VarianceInfo, VarianceInfo>create(it.getTypeReference().toString(), it.getDeclaredVariance(), it.getActualVariance());
};
Assert.assertEquals(IterableExtensions.<Triple<String, VarianceInfo, VarianceInfo>>toList(((Iterable<Triple<String, VarianceInfo, VarianceInfo>>) Conversions.doWrapArray(mappedTypes))), IterableExtensions.<Triple<String, VarianceInfo, VarianceInfo>>toList(ListExtensions.<LightweightBoundTypeArgument, Triple<String, VarianceInfo, VarianceInfo>>map(mappingData, _function_1)));
return mapping;
}
}
if ((mappedTypes != null)) {
StringConcatenation _builder = new StringConcatenation();
_builder.append("No mapping for ");
_builder.append(typeParamName);
_builder.append(" in ");
final Function1<JvmTypeParameter, String> _function_2 = (JvmTypeParameter it) -> {
return it.getSimpleName();
};
Iterable<String> _map = IterableExtensions.<JvmTypeParameter, String>map(mapping.keySet(), _function_2);
_builder.append(_map);
Assert.fail(_builder.toString());
}
return mapping;
}
use of org.eclipse.xtext.xbase.typesystem.references.LightweightBoundTypeArgument in project xtext-xtend by eclipse.
the class ActualTypeArgumentMergeTest method merge.
public Pair<Map<JvmTypeParameter, List<LightweightBoundTypeArgument>>, LightweightMergedBoundTypeArgument> merge(final Map<JvmTypeParameter, List<LightweightBoundTypeArgument>> 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) {
final List<LightweightBoundTypeArgument> mappingData = mapping.get(key);
LightweightMergedBoundTypeArgument _merge = this.merger.merge(mappingData, this.getOwner());
return Pair.<Map<JvmTypeParameter, List<LightweightBoundTypeArgument>>, LightweightMergedBoundTypeArgument>of(mapping, _merge);
}
}
StringConcatenation _builder = new StringConcatenation();
_builder.append("No mapping for ");
_builder.append(typeParamName);
_builder.append(" in ");
final Function1<JvmTypeParameter, String> _function = (JvmTypeParameter it) -> {
return it.getSimpleName();
};
Iterable<String> _map = IterableExtensions.<JvmTypeParameter, String>map(mapping.keySet(), _function);
_builder.append(_map);
Assert.fail(_builder.toString());
return null;
}
use of org.eclipse.xtext.xbase.typesystem.references.LightweightBoundTypeArgument 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.LightweightBoundTypeArgument in project xtext-xtend by eclipse.
the class DeferredTypeParameterHintCollectorTest method like.
public List<LightweightBoundTypeArgument> like(final List<LightweightBoundTypeArgument> mappingData, final Triple<String, VarianceInfo, VarianceInfo>... mappedTypes) {
final Function1<LightweightBoundTypeArgument, String> _function = (LightweightBoundTypeArgument it) -> {
StringConcatenation _builder = new StringConcatenation();
String _string = it.getTypeReference().toString();
_builder.append(_string);
_builder.append("(");
VarianceInfo _declaredVariance = it.getDeclaredVariance();
_builder.append(_declaredVariance);
_builder.append("/");
VarianceInfo _actualVariance = it.getActualVariance();
_builder.append(_actualVariance);
_builder.append(")");
return _builder.toString();
};
Assert.assertEquals(ListExtensions.<LightweightBoundTypeArgument, String>map(mappingData, _function).toString(), ((List<Triple<String, VarianceInfo, VarianceInfo>>) Conversions.doWrapArray(mappedTypes)).size(), mappingData.size());
List<Triple<String, VarianceInfo, VarianceInfo>> _list = IterableExtensions.<Triple<String, VarianceInfo, VarianceInfo>>toList(((Iterable<Triple<String, VarianceInfo, VarianceInfo>>) Conversions.doWrapArray(mappedTypes)));
final Function1<LightweightBoundTypeArgument, Triple<String, VarianceInfo, VarianceInfo>> _function_1 = (LightweightBoundTypeArgument it) -> {
return Tuples.<String, VarianceInfo, VarianceInfo>create(it.getTypeReference().toString(), it.getDeclaredVariance(), it.getActualVariance());
};
Assert.assertEquals(((Object) _list), IterableExtensions.<Triple<String, VarianceInfo, VarianceInfo>>toList(ListExtensions.<LightweightBoundTypeArgument, Triple<String, VarianceInfo, VarianceInfo>>map(mappingData, _function_1)));
return mappingData;
}
use of org.eclipse.xtext.xbase.typesystem.references.LightweightBoundTypeArgument in project xtext-xtend by eclipse.
the class DeferredTypeParameterHintCollectorTest method createOwner.
@Override
protected StandardTypeReferenceOwner createOwner() {
CommonTypeComputationServices _services = this.getServices();
ResourceSet _contextResourceSet = this.getContextResourceSet();
return new StandardTypeReferenceOwner(_services, _contextResourceSet) {
@Override
public void acceptHint(final Object handle, final LightweightBoundTypeArgument boundTypeArgument) {
DeferredTypeParameterHintCollectorTest.this.hints.put(handle, boundTypeArgument);
}
@Override
public List<LightweightBoundTypeArgument> getAllHints(final Object handle) {
return DeferredTypeParameterHintCollectorTest.this.hints.get(handle);
}
@Override
public boolean isResolved(final Object handle) {
return false;
}
};
}
Aggregations