use of org.eclipse.xtext.common.types.JvmTypeParameter 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.common.types.JvmTypeParameter in project xtext-xtend by eclipse.
the class ActualTypeArgumentMergeTest method mappedBy.
public Map<JvmTypeParameter, List<LightweightBoundTypeArgument>> mappedBy(final String typeParameters, final String... alternatingTypeReferences) {
try {
StringConcatenation _builder = new StringConcatenation();
_builder.append("def ");
{
boolean _isNullOrEmpty = StringExtensions.isNullOrEmpty(typeParameters);
boolean _not = (!_isNullOrEmpty);
if (_not) {
_builder.append("<");
_builder.append(typeParameters);
_builder.append(">");
}
}
_builder.append(" void method(");
final Function1<String, CharSequence> _function = (String it) -> {
return it;
};
String _join = IterableExtensions.<String>join(((Iterable<String>) Conversions.doWrapArray(alternatingTypeReferences)), null, " p, ", " p", _function);
_builder.append(_join);
_builder.append(") {}");
final String signature = _builder.toString();
final XtendFunction function = this.function(signature.toString());
final JvmOperation operation = this._iXtendJvmAssociations.getDirectlyInferredOperation(function);
EList<JvmTypeParameter> _typeParameters = operation.getTypeParameters();
ITypeReferenceOwner _owner = this.getOwner();
final ActualTypeArgumentCollector collector = new ActualTypeArgumentCollector(_typeParameters, BoundTypeArgumentSource.INFERRED, _owner);
int _size = ((List<String>) Conversions.doWrapArray(alternatingTypeReferences)).size();
int _minus = (_size - 1);
IntegerRange _withStep = new IntegerRange(0, _minus).withStep(2);
for (final Integer i : _withStep) {
collector.populateTypeParameterMapping(this.toLightweightTypeReference(operation.getParameters().get((i).intValue()).getParameterType()), this.toLightweightTypeReference(operation.getParameters().get(((i).intValue() + 1)).getParameterType()));
}
return collector.getTypeParameterMapping();
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
use of org.eclipse.xtext.common.types.JvmTypeParameter in project xtext-xtend by eclipse.
the class XtendJvmModelInferrer method copyTypeParameters.
protected void copyTypeParameters(List<JvmTypeParameter> typeParameters, JvmTypeParameterDeclarator target) {
for (JvmTypeParameter typeParameter : typeParameters) {
if (!Strings.isEmpty(typeParameter.getName())) {
final JvmTypeParameter clonedTypeParameter = jvmTypesBuilder.cloneWithProxies(typeParameter);
if (clonedTypeParameter != null) {
target.getTypeParameters().add(clonedTypeParameter);
associator.associate(typeParameter, clonedTypeParameter);
}
}
}
}
use of org.eclipse.xtext.common.types.JvmTypeParameter in project xtext-xtend by eclipse.
the class SimpleUnboundTypeReference method createCopy.
@Override
protected UnboundTypeReference createCopy(final ITypeReferenceOwner owner) {
JvmTypeParameter _typeParameter = this.getTypeParameter();
Object _handle = this.getHandle();
return new SimpleUnboundTypeReference(owner, _typeParameter, _handle);
}
use of org.eclipse.xtext.common.types.JvmTypeParameter 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;
}
Aggregations