use of org.eclipse.xtext.common.types.JvmTypeParameter in project xtext-xtend by eclipse.
the class MutableJvmTypeParameterDeclarationImpl method setSimpleName.
@Override
public void setSimpleName(final String name) {
this.checkMutable();
ConditionUtils.checkJavaIdentifier(name, "name");
JvmTypeParameter _delegate = this.getDelegate();
_delegate.setName(name);
}
use of org.eclipse.xtext.common.types.JvmTypeParameter in project xtext-xtend by eclipse.
the class MutableJvmTypeParameterDeclarationImpl method remove.
@Override
public void remove() {
this.checkMutable();
Resource _eResource = this.getDelegate().eResource();
boolean _tripleNotEquals = (_eResource != null);
StringConcatenation _builder = new StringConcatenation();
_builder.append("This element has already been removed: ");
JvmTypeParameter _delegate = this.getDelegate();
_builder.append(_delegate);
Preconditions.checkState(_tripleNotEquals, _builder);
this.getCompilationUnit().getJvmModelAssociator().removeAllAssociation(this.getDelegate());
EcoreUtil.remove(this.getDelegate());
Resource _eResource_1 = this.getDelegate().eResource();
boolean _tripleEquals = (_eResource_1 == null);
StringConcatenation _builder_1 = new StringConcatenation();
_builder_1.append("Couldn\'t remove: ");
JvmTypeParameter _delegate_1 = this.getDelegate();
_builder_1.append(_delegate_1);
Preconditions.checkState(_tripleEquals, _builder_1);
}
use of org.eclipse.xtext.common.types.JvmTypeParameter in project xtext-xtend by eclipse.
the class TypeReferenceProviderImpl method createTypeRef.
public JvmParameterizedTypeReference createTypeRef(final JvmType type, final JvmTypeReference... typeArgs) {
if ((type == null)) {
throw new NullPointerException("type");
}
final JvmParameterizedTypeReference reference = TypesFactory.eINSTANCE.createJvmParameterizedTypeReference();
reference.setType(type);
for (final JvmTypeReference typeArg : typeArgs) {
reference.getArguments().add(EcoreUtil2.<JvmTypeReference>cloneIfContained(typeArg));
}
if ((type instanceof JvmGenericType)) {
final EList<JvmTypeParameter> list = ((JvmGenericType) type).getTypeParameters();
if (((!reference.getArguments().isEmpty()) && (list.size() != reference.getArguments().size()))) {
String _identifier = ((JvmGenericType) type).getIdentifier();
String _plus = ("The type " + _identifier);
String _plus_1 = (_plus + " expects ");
int _size = list.size();
String _plus_2 = (_plus_1 + Integer.valueOf(_size));
String _plus_3 = (_plus_2 + " type arguments, but was ");
int _size_1 = reference.getArguments().size();
String _plus_4 = (_plus_3 + Integer.valueOf(_size_1));
String _plus_5 = (_plus_4 + ". Either pass zero arguments (raw type) or the correct number.");
throw new IllegalArgumentException(_plus_5);
}
}
return reference;
}
use of org.eclipse.xtext.common.types.JvmTypeParameter in project xtext-xtend by eclipse.
the class ActualTypeArgumentCollectorTest method mappedBy.
public Map<JvmTypeParameter, List<LightweightBoundTypeArgument>> mappedBy(final String typeParameters, final String... alternatingTypeReferences) {
final JvmOperation operation = this.operation(typeParameters, alternatingTypeReferences);
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();
}
use of org.eclipse.xtext.common.types.JvmTypeParameter 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;
}
Aggregations