Java源码示例:org.eclipse.xtext.common.types.JvmParameterizedTypeReference
示例1
/** Generate the implemented types for the given SARL statement.
*
* @param context the context of the generation.
* @param owner the JVM element to change.
* @param defaultJvmType the default JVM type.
* @param defaultSarlType the default SARL type.
* @param implementedtypes the implemented types.
*/
protected void appendConstrainedImplements(
GenerationContext context,
JvmGenericType owner, Class<?> defaultJvmType,
Class<? extends XtendTypeDeclaration> defaultSarlType,
List<? extends JvmParameterizedTypeReference> implementedtypes) {
boolean explicitType = false;
for (final JvmParameterizedTypeReference superType : implementedtypes) {
if (!Objects.equal(owner.getIdentifier(), superType.getIdentifier())
&& superType.getType() instanceof JvmGenericType
/*&& this.inheritanceHelper.isProxyOrSubTypeOf(superType, defaultJvmType, defaultSarlType, true)*/) {
owner.getSuperTypes().add(this.typeBuilder.cloneWithProxies(superType));
context.incrementSerial(superType.getIdentifier().hashCode());
explicitType = true;
}
}
if (!explicitType) {
final JvmTypeReference type = this._typeReferenceBuilder.typeRef(defaultJvmType);
owner.getSuperTypes().add(type);
context.incrementSerial(type.getIdentifier().hashCode());
}
}
示例2
/**
* @throws Exception
*/
@Test
public void getTextJvmParametizedTypeReference_1() throws Exception {
SarlEvent event = helper().sarlTypeDeclaration(
SarlEvent.class,
PACKAGE_STATEMENT
+ "event E1 {\n" //$NON-NLS-1$
+ "var attr : org.eclipse.xtext.xbase.lib.Pair<java.lang.Integer,java.lang.Double>\n" //$NON-NLS-1$
+ "}"); //$NON-NLS-1$
validate(event.eResource()).assertNoErrors();
EList<XtendMember> features = event.getMembers();
assertNotNull(features);
assertEquals(1, features.size());
EObject eObject = features.get(0);
assertTrue(eObject instanceof SarlField);
SarlField attr = (SarlField)eObject;
JvmTypeReference typeReference = attr.getType();
assertTrue(typeReference instanceof JvmParameterizedTypeReference);
JvmParameterizedTypeReference parametizedTypeReference = (JvmParameterizedTypeReference)typeReference;
Object text = this.provider.getText(parametizedTypeReference);
assertNotNull(text);
assertEquals("Pair<Integer, Double>", text); //$NON-NLS-1$
}
示例3
@Test
public void test_ParameterizedTypes_05() {
String typeName = ParameterizedTypes.class.getName();
JvmGenericType type = (JvmGenericType) getTypeProvider().findTypeByName(typeName);
JvmOperation methodZ = getMethodFromType(type, ParameterizedTypes.class, "methodZ(java.util.List)");
assertEquals(1, methodZ.getParameters().size());
assertEquals(1, methodZ.getTypeParameters().size());
assertEquals("Z", methodZ.getTypeParameters().get(0).getIdentifier());
JvmTypeReference listZ = methodZ.getReturnType();
assertFalse(listZ.toString(), listZ.getType().eIsProxy());
assertEquals("java.util.List<? extends java.lang.Object & super Z>", listZ.getIdentifier());
JvmParameterizedTypeReference listType = (JvmParameterizedTypeReference) listZ;
assertEquals(1, listType.getArguments().size());
JvmTypeReference typeArgument = listType.getArguments().get(0);
assertTrue(typeArgument instanceof JvmWildcardTypeReference);
JvmWildcardTypeReference wildcardTypeArgument = (JvmWildcardTypeReference) typeArgument;
assertEquals("? extends java.lang.Object & super Z", wildcardTypeArgument.getIdentifier());
assertEquals(2, wildcardTypeArgument.getConstraints().size());
JvmUpperBound upperBound = (JvmUpperBound) wildcardTypeArgument.getConstraints().get(0);
assertEquals("java.lang.Object", upperBound.getTypeReference().getIdentifier());
JvmLowerBound lowerBound = (JvmLowerBound) wildcardTypeArgument.getConstraints().get(1);
assertEquals("Z", lowerBound.getTypeReference().getIdentifier());
JvmTypeParameter z = methodZ.getTypeParameters().get(0);
assertSame(z, lowerBound.getTypeReference().getType());
}
示例4
@Test
public void test_ParameterizedTypes_06() {
String typeName = ParameterizedTypes.class.getName();
JvmGenericType type = (JvmGenericType) getTypeProvider().findTypeByName(typeName);
JvmOperation methodMap = getMethodFromType(type, ParameterizedTypes.class, "methodMap(java.util.Map)");
assertEquals(1, methodMap.getParameters().size());
assertEquals(1, methodMap.getTypeParameters().size());
assertEquals("Z", methodMap.getTypeParameters().get(0).getIdentifier());
JvmType z = methodMap.getReturnType().getType();
assertSame(methodMap.getTypeParameters().get(0), z);
JvmTypeReference mapType = methodMap.getParameters().get(0).getParameterType();
assertEquals("java.util.Map<? extends java.lang.Object & super Z, ? extends S>", mapType.getIdentifier());
JvmParameterizedTypeReference parameterizedMapType = (JvmParameterizedTypeReference) mapType;
assertEquals(2, parameterizedMapType.getArguments().size());
JvmWildcardTypeReference extendsS = (JvmWildcardTypeReference) parameterizedMapType.getArguments().get(1);
assertEquals(1, extendsS.getConstraints().size());
JvmType s = type.getTypeParameters().get(0);
assertSame(s, extendsS.getConstraints().get(0).getTypeReference().getType());
}
示例5
@Test
public void test_ParameterizedTypes_W_01() {
String typeName = ParameterizedTypes.class.getName();
JvmGenericType type = (JvmGenericType) getTypeProvider().findTypeByName(typeName);
JvmTypeParameter typeParameterW = type.getTypeParameters().get(4);
assertEquals("W", typeParameterW.getIdentifier());
assertSame(type, typeParameterW.getDeclarator());
assertEquals(2, typeParameterW.getConstraints().size());
JvmTypeConstraint firstTypeConstraint = typeParameterW.getConstraints().get(0);
assertTrue(firstTypeConstraint instanceof JvmUpperBound);
JvmUpperBound firstUpperBound = (JvmUpperBound) firstTypeConstraint;
assertNotNull(firstUpperBound.getTypeReference());
assertFalse(firstUpperBound.getTypeReference().toString(), firstUpperBound.getTypeReference().eIsProxy());
assertEquals("java.lang.Comparable<S>", firstUpperBound.getTypeReference().getIdentifier());
JvmParameterizedTypeReference comparableType = (JvmParameterizedTypeReference) firstUpperBound
.getTypeReference();
assertEquals(1, comparableType.getArguments().size());
JvmTypeReference typeArgument = comparableType.getArguments().get(0);
assertEquals("S", typeArgument.getIdentifier());
JvmTypeParameter s = type.getTypeParameters().get(0);
assertSame(s, typeArgument.getType());
}
示例6
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@SuppressWarnings("unchecked")
@Override
public void eSet(int featureID, Object newValue)
{
switch (featureID)
{
case DomainmodelPackage.ENTITY__SUPER_TYPE:
setSuperType((JvmParameterizedTypeReference)newValue);
return;
case DomainmodelPackage.ENTITY__FEATURES:
getFeatures().clear();
getFeatures().addAll((Collection<? extends Feature>)newValue);
return;
}
super.eSet(featureID, newValue);
}
示例7
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@SuppressWarnings("unchecked")
@Override
public void eSet(int featureID, Object newValue)
{
switch (featureID)
{
case SarlPackage.SARL_SKILL__EXTENDS:
setExtends((JvmParameterizedTypeReference)newValue);
return;
case SarlPackage.SARL_SKILL__IMPLEMENTS:
getImplements().clear();
getImplements().addAll((Collection<? extends JvmParameterizedTypeReference>)newValue);
return;
}
super.eSet(featureID, newValue);
}
示例8
@Test
public void test_ParameterizedTypes_03() {
String typeName = ParameterizedTypes.class.getName();
JvmGenericType type = (JvmGenericType) getTypeProvider().findTypeByName(typeName);
JvmOperation methodT = getMethodFromType(type, ParameterizedTypes.class, "methodT(T)");
JvmTypeReference listS = methodT.getReturnType();
assertFalse(listS.toString(), listS.eIsProxy());
assertEquals("java.util.List<? extends java.lang.Object & super T>", listS.getIdentifier());
JvmParameterizedTypeReference listType = (JvmParameterizedTypeReference) listS;
assertEquals(1, listType.getArguments().size());
JvmTypeReference typeArgument = listType.getArguments().get(0);
assertTrue(typeArgument instanceof JvmWildcardTypeReference);
JvmWildcardTypeReference wildcardTypeArgument = (JvmWildcardTypeReference) typeArgument;
assertEquals("? extends java.lang.Object & super T", wildcardTypeArgument.getIdentifier());
assertEquals(2, wildcardTypeArgument.getConstraints().size());
JvmUpperBound uperBound = (JvmUpperBound) wildcardTypeArgument.getConstraints().get(0);
assertEquals("java.lang.Object", uperBound.getTypeReference().getIdentifier());
JvmLowerBound lowerBound = (JvmLowerBound) wildcardTypeArgument.getConstraints().get(1);
JvmTypeParameter t = type.getTypeParameters().get(1);
assertSame(t, lowerBound.getTypeReference().getType());
}
示例9
@Test
public void test_ParameterizedTypes_06() {
String typeName = ParameterizedTypes.class.getName();
JvmGenericType type = (JvmGenericType) getTypeProvider().findTypeByName(typeName);
JvmOperation methodMap = getMethodFromType(type, ParameterizedTypes.class, "methodMap(java.util.Map)");
assertEquals(1, methodMap.getParameters().size());
assertEquals(1, methodMap.getTypeParameters().size());
assertEquals("Z", methodMap.getTypeParameters().get(0).getIdentifier());
JvmType z = methodMap.getReturnType().getType();
assertSame(methodMap.getTypeParameters().get(0), z);
JvmTypeReference mapType = methodMap.getParameters().get(0).getParameterType();
assertEquals("java.util.Map<? extends java.lang.Object & super Z, ? extends S>", mapType.getIdentifier());
JvmParameterizedTypeReference parameterizedMapType = (JvmParameterizedTypeReference) mapType;
assertEquals(2, parameterizedMapType.getArguments().size());
JvmWildcardTypeReference extendsS = (JvmWildcardTypeReference) parameterizedMapType.getArguments().get(1);
assertEquals(1, extendsS.getConstraints().size());
JvmType s = type.getTypeParameters().get(0);
assertSame(s, extendsS.getConstraints().get(0).getTypeReference().getType());
}
示例10
/**
* Returns the type arguments including the surrounding angular brackets.
* If the typeRef is invalid in the sense that it contains unresolved proxies,
* null is returned.
*/
/* @Nullable */
public StringBuilder appendTypeArguments(JvmParameterizedTypeReference typeRef, StringBuilder result) {
List<JvmTypeReference> typeArguments = typeRef.getArguments();
if (typeArguments.isEmpty()) {
throw new IllegalArgumentException("typeRef is not parameterized");
}
result.append("<");
for(int i = 0, size = typeArguments.size(); i < size; i++) {
if (i != 0) {
result.append(", ");
}
result = visit(typeArguments.get(i), result);
if (result == null)
return null;
}
result.append(">");
return result;
}
示例11
@Test
public void test_ParameterizedTypes_U_01() {
String typeName = ParameterizedTypes.class.getName();
JvmGenericType type = (JvmGenericType) getTypeProvider().findTypeByName(typeName);
JvmTypeParameter typeVariable = type.getTypeParameters().get(2);
assertEquals("U", typeVariable.getIdentifier());
assertSame(type, typeVariable.getDeclarator());
assertEquals(1, typeVariable.getConstraints().size());
JvmTypeConstraint typeConstraint = typeVariable.getConstraints().get(0);
assertTrue(typeConstraint instanceof JvmUpperBound);
JvmUpperBound upperBound = (JvmUpperBound) typeConstraint;
assertNotNull(upperBound.getTypeReference());
assertFalse(upperBound.getTypeReference().toString(), upperBound.getTypeReference().eIsProxy());
assertEquals("java.util.List<S>", upperBound.getTypeReference().getIdentifier());
JvmParameterizedTypeReference listType = (JvmParameterizedTypeReference) upperBound.getTypeReference();
assertEquals(1, listType.getArguments().size());
JvmTypeReference typeArgument = listType.getArguments().get(0);
JvmTypeParameter s = type.getTypeParameters().get(0);
assertSame(s, typeArgument.getType());
}
示例12
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void setExtends(JvmParameterizedTypeReference newExtends)
{
if (newExtends != extends_)
{
NotificationChain msgs = null;
if (extends_ != null)
msgs = ((InternalEObject)extends_).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - SarlPackage.SARL_AGENT__EXTENDS, null, msgs);
if (newExtends != null)
msgs = ((InternalEObject)newExtends).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - SarlPackage.SARL_AGENT__EXTENDS, null, msgs);
msgs = basicSetExtends(newExtends, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, SarlPackage.SARL_AGENT__EXTENDS, newExtends, newExtends));
}
示例13
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void setExtends(JvmParameterizedTypeReference newExtends)
{
if (newExtends != extends_)
{
NotificationChain msgs = null;
if (extends_ != null)
msgs = ((InternalEObject)extends_).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - SarlPackage.SARL_ARTIFACT__EXTENDS, null, msgs);
if (newExtends != null)
msgs = ((InternalEObject)newExtends).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - SarlPackage.SARL_ARTIFACT__EXTENDS, null, msgs);
msgs = basicSetExtends(newExtends, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, SarlPackage.SARL_ARTIFACT__EXTENDS, newExtends, newExtends));
}
示例14
private LightweightTypeReference getSuperTypeByName(String typeName, boolean interfaceType) {
JvmTypeReference superType = getSuperTypeByName(typeName, interfaceType, type, new RecursionGuard<JvmType>());
if (superType != null) {
JvmType rawType = superType.getType();
if (isRawType()) {
return createRawTypeReference(rawType);
}
if (superType.eClass() == TypesPackage.Literals.JVM_PARAMETERIZED_TYPE_REFERENCE) {
if (((JvmParameterizedTypeReference) superType).getArguments().isEmpty()) {
return getOwner().newParameterizedTypeReference(rawType);
}
}
LightweightTypeReference unresolved = getOwner().toLightweightTypeReference(rawType);
TypeParameterSubstitutor<?> substitutor = createSubstitutor();
LightweightTypeReference result = substitutor.substitute(unresolved);
return result;
}
return null;
}
示例15
@Test
public void test_ParameterizedTypes_02() {
String typeName = ParameterizedTypes.class.getName();
JvmGenericType type = (JvmGenericType) getTypeProvider().findTypeByName(typeName);
JvmOperation methodS = getMethodFromType(type, ParameterizedTypes.class, "methodS(S)");
JvmTypeReference listS = methodS.getReturnType();
assertFalse(listS.toString(), listS.eIsProxy());
assertEquals("java.util.List<? extends S>", listS.getIdentifier());
JvmParameterizedTypeReference listType = (JvmParameterizedTypeReference) listS;
assertEquals(1, listType.getArguments().size());
JvmTypeReference typeArgument = listType.getArguments().get(0);
assertTrue(typeArgument instanceof JvmWildcardTypeReference);
JvmWildcardTypeReference wildcardTypeArgument = (JvmWildcardTypeReference) typeArgument;
assertEquals("? extends S", wildcardTypeArgument.getIdentifier());
assertEquals(1, wildcardTypeArgument.getConstraints().size());
JvmUpperBound upperBound = (JvmUpperBound) wildcardTypeArgument.getConstraints().get(0);
JvmTypeParameter s = type.getTypeParameters().get(0);
assertSame(s, upperBound.getTypeReference().getType());
}
示例16
@Test
public void test_ParameterizedTypes_W_01() {
String typeName = ParameterizedTypes.class.getName();
JvmGenericType type = (JvmGenericType) getTypeProvider().findTypeByName(typeName);
JvmTypeParameter typeParameterW = type.getTypeParameters().get(4);
assertEquals("W", typeParameterW.getIdentifier());
assertSame(type, typeParameterW.getDeclarator());
assertEquals(2, typeParameterW.getConstraints().size());
JvmTypeConstraint firstTypeConstraint = typeParameterW.getConstraints().get(0);
assertTrue(firstTypeConstraint instanceof JvmUpperBound);
JvmUpperBound firstUpperBound = (JvmUpperBound) firstTypeConstraint;
assertNotNull(firstUpperBound.getTypeReference());
assertFalse(firstUpperBound.getTypeReference().toString(), firstUpperBound.getTypeReference().eIsProxy());
assertEquals("java.lang.Comparable<S>", firstUpperBound.getTypeReference().getIdentifier());
JvmParameterizedTypeReference comparableType = (JvmParameterizedTypeReference) firstUpperBound
.getTypeReference();
assertEquals(1, comparableType.getArguments().size());
JvmTypeReference typeArgument = comparableType.getArguments().get(0);
assertEquals("S", typeArgument.getIdentifier());
JvmTypeParameter s = type.getTypeParameters().get(0);
assertSame(s, typeArgument.getType());
}
示例17
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID)
{
switch (featureID)
{
case SarlPackage.SARL_BEHAVIOR_UNIT__NAME:
setName((JvmParameterizedTypeReference)null);
return;
case SarlPackage.SARL_BEHAVIOR_UNIT__GUARD:
setGuard((XExpression)null);
return;
case SarlPackage.SARL_BEHAVIOR_UNIT__EXPRESSION:
setExpression((XExpression)null);
return;
}
super.eUnset(featureID);
}
示例18
protected JvmTypeReference toTypeReference(final JvmType type, final int arrayDimensions) {
if ((type == null)) {
return null;
}
JvmParameterizedTypeReference _createJvmParameterizedTypeReference = TypesFactory.eINSTANCE.createJvmParameterizedTypeReference();
final Procedure1<JvmParameterizedTypeReference> _function = (JvmParameterizedTypeReference it) -> {
it.setType(type);
};
JvmTypeReference resultTypeRef = ObjectExtensions.<JvmParameterizedTypeReference>operator_doubleArrow(_createJvmParameterizedTypeReference, _function);
ExclusiveRange _doubleDotLessThan = new ExclusiveRange(0, arrayDimensions, true);
for (final Integer i : _doubleDotLessThan) {
{
final JvmGenericArrayTypeReference arrayRef = TypesFactory.eINSTANCE.createJvmGenericArrayTypeReference();
arrayRef.setComponentType(resultTypeRef);
resultTypeRef = arrayRef;
}
}
return resultTypeRef;
}
示例19
@Test
public void test_twoListParamsNoResult_02() {
JvmOperation twoListParamsNoResult = getMethodFromParameterizedMethods(
"twoListParamsNoResult(java.util.List,java.util.List)");
JvmFormalParameter firstParam = twoListParamsNoResult.getParameters().get(0);
JvmTypeReference paramType = firstParam.getParameterType();
assertNotNull(paramType);
assertFalse(paramType.getType().eIsProxy());
assertEquals("java.util.List<T>", paramType.getIdentifier());
assertTrue(paramType instanceof JvmParameterizedTypeReference);
JvmParameterizedTypeReference parameterized = (JvmParameterizedTypeReference) paramType;
JvmType rawType = parameterized.getType();
assertFalse(rawType.eIsProxy());
assertEquals("java.util.List", rawType.getIdentifier());
}
示例20
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID)
{
switch (featureID)
{
case SarlPackage.SARL_ARTIFACT__EXTENDS:
setExtends((JvmParameterizedTypeReference)null);
return;
}
super.eUnset(featureID);
}
示例21
@Test
public void test_twoListWildcardsNoResult_02() {
JvmOperation twoListWildcardsNoResult = getMethodFromParameterizedMethods(
"twoListWildcardsNoResult(java.util.List,java.util.List)");
JvmFormalParameter firstParam = twoListWildcardsNoResult.getParameters().get(0);
JvmTypeReference paramType = firstParam.getParameterType();
assertNotNull(paramType);
assertEquals("java.util.List<? extends java.lang.Object>", paramType.getIdentifier());
assertTrue(paramType instanceof JvmParameterizedTypeReference);
JvmParameterizedTypeReference parameterized = (JvmParameterizedTypeReference) paramType;
JvmType rawType = parameterized.getType();
assertFalse(rawType.eIsProxy());
assertEquals("java.util.List", rawType.getIdentifier());
}
示例22
/** Replies the type reference for the given name in the given context.
*/
public JvmParameterizedTypeReference newTypeRef(Notifier context, String typeName) {
JvmTypeReference typeReference;
try {
typeReference = findType(context, typeName);
getImportManager().addImportFor(typeReference.getType());
return (JvmParameterizedTypeReference) typeReference;
} catch (TypeNotPresentException exception) {
}
final JvmParameterizedTypeReference pref = ExpressionBuilderImpl.parseType(context, typeName, this);
final JvmTypeReference baseType = findType(context, pref.getType().getIdentifier());
final int len = pref.getArguments().size();
final JvmTypeReference[] args = new JvmTypeReference[len];
for (int i = 0; i < len; ++i) {
final JvmTypeReference original = pref.getArguments().get(i);
if (original instanceof JvmAnyTypeReference) {
args[i] = EcoreUtil.copy(original);
} else if (original instanceof JvmWildcardTypeReference) {
final JvmWildcardTypeReference wc = EcoreUtil.copy((JvmWildcardTypeReference) original);
for (final JvmTypeConstraint c : wc.getConstraints()) {
c.setTypeReference(newTypeRef(context, c.getTypeReference().getIdentifier()));
}
args[i] = wc;
} else {
args[i] = newTypeRef(context, original.getIdentifier());
}
}
final TypeReferences typeRefs = getTypeReferences();
return typeRefs.createTypeRef(baseType.getType(), args);
}
示例23
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eSet(int featureID, Object newValue)
{
switch (featureID)
{
case SarlPackage.SARL_BEHAVIOR__EXTENDS:
setExtends((JvmParameterizedTypeReference)newValue);
return;
}
super.eSet(featureID, newValue);
}
示例24
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetExtends(JvmParameterizedTypeReference newExtends, NotificationChain msgs)
{
JvmParameterizedTypeReference oldExtends = extends_;
extends_ = newExtends;
if (eNotificationRequired())
{
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, SarlPackage.SARL_ARTIFACT__EXTENDS, oldExtends, newExtends);
if (msgs == null) msgs = notification; else msgs.add(notification);
}
return msgs;
}
示例25
/** Change the super type.
* @param superType the qualified name of the super type,
* or {@code null} if the default type.
*/
public void setExtends(String superType) {
if (!Strings.isEmpty(superType)
&& !Event.class.getName().equals(superType)) {
JvmParameterizedTypeReference superTypeRef = newTypeRef(this.sarlEvent, superType);
JvmTypeReference baseTypeRef = findType(this.sarlEvent, Event.class.getCanonicalName());
if (isSubTypeOf(this.sarlEvent, superTypeRef, baseTypeRef)) {
this.sarlEvent.setExtends(superTypeRef);
return;
}
}
this.sarlEvent.setExtends(null);
}
示例26
protected JvmParameterizedTypeReference createSuperTypeReference(JvmType superType, XConstructorCall constructorCall) {
JvmParameterizedTypeReference result = TypesFactory.eINSTANCE.createJvmParameterizedTypeReference();
result.setType(superType);
for(JvmTypeReference typeReference: constructorCall.getTypeArguments()) {
result.getArguments().add(typesBuilder.cloneWithProxies(typeReference));
}
return result;
}
示例27
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public EList<JvmParameterizedTypeReference> getImplements()
{
if (implements_ == null)
{
implements_ = new EObjectContainmentEList<JvmParameterizedTypeReference>(JvmParameterizedTypeReference.class, this, SarlPackage.SARL_SKILL__IMPLEMENTS);
}
return implements_;
}
示例28
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID)
{
switch (featureID)
{
case DomainmodelPackage.ENTITY__SUPER_TYPE:
setSuperType((JvmParameterizedTypeReference)null);
return;
case DomainmodelPackage.ENTITY__FEATURES:
getFeatures().clear();
return;
}
super.eUnset(featureID);
}
示例29
@Test
public void testRawIterable_01() {
String typeName = RawIterable.class.getName();
JvmGenericType type = (JvmGenericType) getTypeProvider().findTypeByName(typeName);
List<JvmTypeReference> superTypes = type.getSuperTypes();
JvmParameterizedTypeReference iterableSuperType = (JvmParameterizedTypeReference) superTypes.get(1);
assertEquals("java.lang.Iterable", iterableSuperType.getIdentifier());
assertTrue(iterableSuperType.getArguments().isEmpty());
}
示例30
@Test
public void testOverridenInterfaceMethod() {
StringConcatenation _builder = new StringConcatenation();
_builder.append("public interface MySuperClass {");
_builder.newLine();
_builder.append(" ");
_builder.append("public java.util.Collection<? extends CharSequence> getThem();");
_builder.newLine();
_builder.append("}");
_builder.newLine();
Pair<String, String> _mappedTo = Pair.<String, String>of("MySuperClass.java", _builder.toString());
StringConcatenation _builder_1 = new StringConcatenation();
_builder_1.append("public interface MySubClass extends MySuperClass {");
_builder_1.newLine();
_builder_1.append(" ");
_builder_1.append("@Override");
_builder_1.newLine();
_builder_1.append(" ");
_builder_1.append("public java.util.List<? extends String> getThem();");
_builder_1.newLine();
_builder_1.append("}");
_builder_1.newLine();
Pair<String, String> _mappedTo_1 = Pair.<String, String>of("MySubClass.java", _builder_1.toString());
final XtextResourceSet rs = this.resourceSet(_mappedTo, _mappedTo_1);
final Function1<Resource, Boolean> _function = (Resource it) -> {
return Boolean.valueOf(it.getURI().toString().endsWith("MySubClass.java"));
};
final Resource resource = IterableExtensions.<Resource>findFirst(rs.getResources(), _function);
EObject _head = IterableExtensions.<EObject>head(resource.getContents());
final JvmGenericType clazz = ((JvmGenericType) _head);
final JvmTypeReference referenced = IterableExtensions.<JvmOperation>head(clazz.getDeclaredOperations()).getReturnType();
Assert.assertNotNull(IterableExtensions.<JvmTypeReference>head(((JvmParameterizedTypeReference) referenced).getArguments()));
}