org.eclipse.xtext.common.types.JvmArrayType Java Examples

The following examples show how to use org.eclipse.xtext.common.types.JvmArrayType. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AbstractTypeProviderTest.java    From xtext-extras with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void test_ParameterizedTypes_Inner_06() {
	String typeName = ParameterizedTypes.class.getName();
	JvmGenericType type = (JvmGenericType) getTypeProvider().findTypeByName(typeName);
	JvmOperation methodV = getMethodFromType(type, ParameterizedTypes.Inner.class, "methodVArray_02()");
	JvmTypeReference listV = methodV.getReturnType();
	assertEquals("java.util.List<? extends V[]>", listV.getIdentifier());
	JvmParameterizedTypeReference listType = (JvmParameterizedTypeReference) listV;
	assertEquals(1, listType.getArguments().size());
	JvmTypeReference typeArgument = listType.getArguments().get(0);
	assertTrue(typeArgument instanceof JvmWildcardTypeReference);
	JvmWildcardTypeReference wildcardTypeArgument = (JvmWildcardTypeReference) typeArgument;
	assertEquals("? extends V[]", wildcardTypeArgument.getIdentifier());
	assertEquals(1, wildcardTypeArgument.getConstraints().size());
	JvmUpperBound upperBound = (JvmUpperBound) wildcardTypeArgument.getConstraints().get(0);
	JvmType upperBoundType = upperBound.getTypeReference().getType();
	assertTrue(upperBoundType instanceof JvmArrayType);
	assertTrue(((JvmArrayType) upperBoundType).getComponentType() instanceof JvmTypeParameter);
	JvmTypeParameter v = type.getTypeParameters().get(3);
	assertSame(v, ((JvmArrayType) upperBoundType).getComponentType());
}
 
Example #2
Source File: AbstractTypeProviderTest.java    From xtext-extras with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void test_ParameterizedTypes_Inner_08() {
	String typeName = ParameterizedTypes.Inner.class.getName();
	JvmGenericType type = (JvmGenericType) getTypeProvider().findTypeByName(typeName);
	JvmOperation methodV = getMethodFromType(type, ParameterizedTypes.Inner.class, "methodZArray_02()");
	JvmTypeReference listZ = methodV.getReturnType();
	assertEquals("java.util.List<Z[]>[]", listZ.getIdentifier());
	JvmParameterizedTypeReference listType = (JvmParameterizedTypeReference) ((JvmGenericArrayTypeReference) listZ)
			.getComponentType();
	assertEquals(1, listType.getArguments().size());
	JvmTypeReference typeArgument = listType.getArguments().get(0);
	JvmType argumentType = typeArgument.getType();
	assertTrue(argumentType instanceof JvmArrayType);
	JvmComponentType componentType = ((JvmArrayType) argumentType).getComponentType();
	JvmTypeParameter z = type.getTypeParameters().get(2);
	assertSame(z, componentType);
}
 
Example #3
Source File: AbstractTypeProviderTest.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void test_ParameterizedTypes_Inner_08() {
	String typeName = ParameterizedTypes.Inner.class.getName();
	JvmGenericType type = (JvmGenericType) getTypeProvider().findTypeByName(typeName);
	JvmOperation methodV = getMethodFromType(type, ParameterizedTypes.Inner.class, "methodZArray_02()");
	JvmTypeReference listZ = methodV.getReturnType();
	assertEquals("java.util.List<Z[]>[]", listZ.getIdentifier());
	JvmParameterizedTypeReference listType = (JvmParameterizedTypeReference) ((JvmGenericArrayTypeReference) listZ)
			.getComponentType();
	assertEquals(1, listType.getArguments().size());
	JvmTypeReference typeArgument = listType.getArguments().get(0);
	JvmType argumentType = typeArgument.getType();
	assertTrue(argumentType instanceof JvmArrayType);
	JvmComponentType componentType = ((JvmArrayType) argumentType).getComponentType();
	JvmTypeParameter z = type.getTypeParameters().get(2);
	assertSame(z, componentType);
}
 
Example #4
Source File: AbstractTypeProviderTest.java    From xtext-extras with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void test_ParameterizedTypes_Inner_07() {
	String typeName = ParameterizedTypes.Inner.class.getName();
	JvmGenericType type = (JvmGenericType) getTypeProvider().findTypeByName(typeName);
	JvmOperation methodV = getMethodFromType(type, ParameterizedTypes.Inner.class, "methodZArray_01()");
	JvmTypeReference listZ = methodV.getReturnType();
	assertEquals("java.util.List<Z[][]>", listZ.getIdentifier());
	JvmParameterizedTypeReference listType = (JvmParameterizedTypeReference) listZ;
	assertEquals(1, listType.getArguments().size());
	JvmTypeReference typeArgument = listType.getArguments().get(0);
	JvmType argumentType = typeArgument.getType();
	assertTrue(argumentType instanceof JvmArrayType);
	assertTrue(((JvmArrayType) argumentType).getComponentType() instanceof JvmArrayType);
	JvmComponentType componentType = ((JvmArrayType) ((JvmArrayType) argumentType).getComponentType())
			.getComponentType();
	JvmTypeParameter z = type.getTypeParameters().get(2);
	assertSame(z, componentType);
}
 
Example #5
Source File: AbstractTypeProviderTest.java    From xtext-extras with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void test_ParameterizedTypes_Inner_06() {
	String typeName = ParameterizedTypes.class.getName();
	JvmGenericType type = (JvmGenericType) getTypeProvider().findTypeByName(typeName);
	JvmOperation methodV = getMethodFromType(type, ParameterizedTypes.Inner.class, "methodVArray_02()");
	JvmTypeReference listV = methodV.getReturnType();
	assertEquals("java.util.List<? extends V[]>", listV.getIdentifier());
	JvmParameterizedTypeReference listType = (JvmParameterizedTypeReference) listV;
	assertEquals(1, listType.getArguments().size());
	JvmTypeReference typeArgument = listType.getArguments().get(0);
	assertTrue(typeArgument instanceof JvmWildcardTypeReference);
	JvmWildcardTypeReference wildcardTypeArgument = (JvmWildcardTypeReference) typeArgument;
	assertEquals("? extends V[]", wildcardTypeArgument.getIdentifier());
	assertEquals(1, wildcardTypeArgument.getConstraints().size());
	JvmUpperBound upperBound = (JvmUpperBound) wildcardTypeArgument.getConstraints().get(0);
	JvmType upperBoundType = upperBound.getTypeReference().getType();
	assertTrue(upperBoundType instanceof JvmArrayType);
	assertTrue(((JvmArrayType) upperBoundType).getComponentType() instanceof JvmTypeParameter);
	JvmTypeParameter v = type.getTypeParameters().get(3);
	assertSame(v, ((JvmArrayType) upperBoundType).getComponentType());
}
 
Example #6
Source File: DocumentSourceAppender.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
public void appendType(final /* @NonNull */ JvmType type, /* @NonNull */ StringBuilder builder) {
	if (type instanceof JvmPrimitiveType || type instanceof JvmVoid || type instanceof JvmTypeParameter) {
		builder.append(type.getQualifiedName(getInnerTypeSeparator()));
	} else if (type instanceof JvmArrayType) {
		appendType(((JvmArrayType) type).getComponentType(), builder);
		builder.append("[]");
	} else {
		final String qualifiedName = type.getQualifiedName(getInnerTypeSeparator());
		final String simpleName = type.getSimpleName();
		JvmDeclaredType importedType = getImportedType(type);
		if (importedType == type) {
			builder.append(simpleName);
		} else if (importedType == null) {
			importSection.addImport((JvmDeclaredType) type);
			builder.append(simpleName);
		} else {
			builder.append(qualifiedName);
		}
	}
}
 
Example #7
Source File: JvmComponentTypeImpl.java    From xtext-extras with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public void setArrayType(JvmArrayType newArrayType)
{
	if (newArrayType != arrayType)
	{
		NotificationChain msgs = null;
		if (arrayType != null)
			msgs = ((InternalEObject)arrayType).eInverseRemove(this, TypesPackage.JVM_ARRAY_TYPE__COMPONENT_TYPE, JvmArrayType.class, msgs);
		if (newArrayType != null)
			msgs = ((InternalEObject)newArrayType).eInverseAdd(this, TypesPackage.JVM_ARRAY_TYPE__COMPONENT_TYPE, JvmArrayType.class, msgs);
		msgs = basicSetArrayType(newArrayType, msgs);
		if (msgs != null) msgs.dispatch();
	}
	else if (eNotificationRequired())
		eNotify(new ENotificationImpl(this, Notification.SET, TypesPackage.JVM_COMPONENT_TYPE__ARRAY_TYPE, newArrayType, newArrayType));
}
 
Example #8
Source File: AbstractTypeProviderTest.java    From xtext-extras with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void testFindTypeByName_javaLangNumber_02() {
	String typeName = Number[][].class.getName();
	JvmArrayType type = (JvmArrayType) getTypeProvider().findTypeByName(typeName);
	JvmOperation longValue = (JvmOperation) type.eResource().getEObject("java.lang.Number.longValue()");
	assertNotNull(longValue);
	JvmDeclaredType number = longValue.getDeclaringType();
	assertNotNull(number.getArrayType());
	assertSame(type, number.getArrayType().getArrayType());
	assertNull(type.eGet(TypesPackage.Literals.JVM_COMPONENT_TYPE__ARRAY_TYPE));
	// array will created on the fly
	assertNotNull(type.getArrayType());
	diagnose(type);
	Resource resource = type.eResource();
	getAndResolveAllFragments(resource);
	recomputeAndCheckIdentifiers(resource);
}
 
Example #9
Source File: JavaLinkingTest.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
@Test public void testGetXtendClassAsArray() throws Exception {
	IFile xtendFile = testHelper.createFile(
			"test/XtendClass", 
			"package test\nclass XtendClass {}");
	waitForBuild();

	assertNumberOfMarkers(xtendFile, 0);
	
	ResourceSet resourceSet = resourceSetProvider.get(testHelper.getProject());
	IJvmTypeProvider jvmTypeProvider = typeProviderFactory.findOrCreateTypeProvider(resourceSet);
	JvmType xtendArrayType = jvmTypeProvider.findTypeByName("test.XtendClass[][]");
	assertNotNull(xtendArrayType);
	assertTrue(xtendArrayType instanceof JvmArrayType);
	assertEquals("test.XtendClass[][]", xtendArrayType.getQualifiedName());
	Resource xtendResource = xtendArrayType.eResource();
	assertEquals("platform:/resource" + xtendFile.getFullPath(), xtendResource.getURI().toString());
}
 
Example #10
Source File: ConstantExpressionsInterpreter.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
private boolean isEnumExpectationInAnnotationValue(final XFeatureCall it, final JvmType expectedRawType) {
  if (((expectedRawType instanceof JvmEnumerationType) || ((expectedRawType instanceof JvmArrayType) && (((JvmArrayType) expectedRawType).getComponentType() instanceof JvmEnumerationType)))) {
    EObject container = it.eContainer();
    if ((container instanceof XAnnotationElementValuePair)) {
      return true;
    }
    if ((container instanceof XAnnotation)) {
      return true;
    }
    if ((container instanceof XListLiteral)) {
      container = ((XListLiteral)container).eContainer();
      if ((container instanceof XAnnotationElementValuePair)) {
        return true;
      }
      if ((container instanceof XAnnotation)) {
        return true;
      }
    }
  }
  return false;
}
 
Example #11
Source File: TypeConformanceComputer.java    From xtext-extras with Eclipse Public License 2.0 6 votes vote down vote up
protected LightweightTypeReference doGetTypeParametersForSuperType(
		final Multimap<JvmType, LightweightTypeReference> all, JvmArrayType rawType, ITypeReferenceOwner owner,
		List<LightweightTypeReference> types) {
	JvmComponentType componentType = rawType.getComponentType();
	Multimap<JvmType, LightweightTypeReference> copiedMultimap = LinkedHashMultimap.create(all);
	Collection<LightweightTypeReference> originalReferences = all.get(rawType);
	List<LightweightTypeReference> componentReferences = Lists.newArrayListWithCapacity(originalReferences.size());
	for(LightweightTypeReference originalReference: originalReferences) {
		addComponentType(originalReference, componentReferences);
	}
	copiedMultimap.replaceValues(componentType, componentReferences);
	List<LightweightTypeReference> componentRequests = Lists.newArrayListWithCapacity(types.size());
	for(LightweightTypeReference type: types) {
		addComponentType(type, componentRequests);
	}
	LightweightTypeReference componentTypeReference = getTypeParametersForSuperType(
			copiedMultimap, 
			componentType,
			owner,
			componentRequests);
	if (componentTypeReference != null) {
		return owner.newArrayTypeReference(componentTypeReference);
	}
	return null;
}
 
Example #12
Source File: ParameterizedTypeReference.java    From xtext-extras with Eclipse Public License 2.0 6 votes vote down vote up
public ParameterizedTypeReference(ITypeReferenceOwner owner, JvmType type) {
	super(owner);
	if (type == null) {
		throw new NullPointerException("type may not be null");
	}
	if (type instanceof JvmArrayType) {
		throw new IllegalArgumentException("type may not be an array type");
	}
	if (type.eClass() == TypesPackage.Literals.JVM_GENERIC_TYPE) {
		EObject container = type.eContainer();
		if (container instanceof JvmDeclaredType) {
			checkStaticFlag((JvmDeclaredType)type);
		}
	}
	this.type = type;
	this.resolved = !(type instanceof JvmTypeParameter);
}
 
Example #13
Source File: AbstractTypeProviderTest.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void test_ParameterizedTypes_Inner_06() {
	String typeName = ParameterizedTypes.class.getName();
	JvmGenericType type = (JvmGenericType) getTypeProvider().findTypeByName(typeName);
	JvmOperation methodV = getMethodFromType(type, ParameterizedTypes.Inner.class, "methodVArray_02()");
	JvmTypeReference listV = methodV.getReturnType();
	assertEquals("java.util.List<? extends V[]>", listV.getIdentifier());
	JvmParameterizedTypeReference listType = (JvmParameterizedTypeReference) listV;
	assertEquals(1, listType.getArguments().size());
	JvmTypeReference typeArgument = listType.getArguments().get(0);
	assertTrue(typeArgument instanceof JvmWildcardTypeReference);
	JvmWildcardTypeReference wildcardTypeArgument = (JvmWildcardTypeReference) typeArgument;
	assertEquals("? extends V[]", wildcardTypeArgument.getIdentifier());
	assertEquals(1, wildcardTypeArgument.getConstraints().size());
	JvmUpperBound upperBound = (JvmUpperBound) wildcardTypeArgument.getConstraints().get(0);
	JvmType upperBoundType = upperBound.getTypeReference().getType();
	assertTrue(upperBoundType instanceof JvmArrayType);
	assertTrue(((JvmArrayType) upperBoundType).getComponentType() instanceof JvmTypeParameter);
	JvmTypeParameter v = type.getTypeParameters().get(3);
	assertSame(v, ((JvmArrayType) upperBoundType).getComponentType());
}
 
Example #14
Source File: ArrayTypeReference.java    From xtext-extras with Eclipse Public License 2.0 6 votes vote down vote up
@Override
/* @Nullable */
public LightweightTypeReference getSuperType(JvmType rawType) {
	if (rawType.eClass() == TypesPackage.Literals.JVM_ARRAY_TYPE) {
		JvmComponentType rawComponentType = ((JvmArrayType) rawType).getComponentType();
		LightweightTypeReference result = component.getSuperType(rawComponentType);
		if (result == null) {
			return null;
		}
		if (result == component)
			return this;
		return getOwner().newArrayTypeReference(result);
	} else if (rawType.eClass() == TypesPackage.Literals.JVM_GENERIC_TYPE) {
		String identifier = rawType.getIdentifier();
		if (Object.class.getName().equals(identifier)
				|| Cloneable.class.getName().equals(identifier)
				|| Serializable.class.getName().equals(identifier)) {
			return getOwner().newParameterizedTypeReference(rawType);
		}
	}
	return null;
}
 
Example #15
Source File: JvmDeclaredTypeImpl.java    From xtext-extras with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public void setArrayType(JvmArrayType newArrayType)
{
	if (newArrayType != arrayType)
	{
		NotificationChain msgs = null;
		if (arrayType != null)
			msgs = ((InternalEObject)arrayType).eInverseRemove(this, TypesPackage.JVM_ARRAY_TYPE__COMPONENT_TYPE, JvmArrayType.class, msgs);
		if (newArrayType != null)
			msgs = ((InternalEObject)newArrayType).eInverseAdd(this, TypesPackage.JVM_ARRAY_TYPE__COMPONENT_TYPE, JvmArrayType.class, msgs);
		msgs = basicSetArrayType(newArrayType, msgs);
		if (msgs != null) msgs.dispatch();
	}
	else if (eNotificationRequired())
		eNotify(new ENotificationImpl(this, Notification.SET, TypesPackage.JVM_DECLARED_TYPE__ARRAY_TYPE, newArrayType, newArrayType));
}
 
Example #16
Source File: AbstractTypeProviderTest.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void testFindTypeByName_javaLangNumber_02() {
	String typeName = Number[][].class.getName();
	JvmArrayType type = (JvmArrayType) getTypeProvider().findTypeByName(typeName);
	JvmOperation longValue = (JvmOperation) type.eResource().getEObject("java.lang.Number.longValue()");
	assertNotNull(longValue);
	JvmDeclaredType number = longValue.getDeclaringType();
	assertNotNull(number.getArrayType());
	assertSame(type, number.getArrayType().getArrayType());
	assertNull(type.eGet(TypesPackage.Literals.JVM_COMPONENT_TYPE__ARRAY_TYPE));
	// array will created on the fly
	assertNotNull(type.getArrayType());
	diagnose(type);
	Resource resource = type.eResource();
	getAndResolveAllFragments(resource);
	recomputeAndCheckIdentifiers(resource);
}
 
Example #17
Source File: AbstractClassMirror.java    From xtext-extras with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public String getFragment(EObject obj, IFragmentProvider.Fallback fallback) {
	if (obj instanceof JvmTypeParameter)
		return getFragment(obj.eContainer(), fallback) + "/" + ((JvmTypeParameter) obj).getName();
	if (obj instanceof JvmTypeReference || obj instanceof JvmFormalParameter)
		return fallback.getFragment(obj);
	if (obj instanceof JvmIdentifiableElement) {
		if (obj instanceof JvmArrayType) {
			if (obj.eContainer() instanceof JvmGenericArrayTypeReference)
				return fallback.getFragment(obj);
			if (obj.eContainer() instanceof JvmIdentifiableElement) {
				return getFragment(obj.eContainer(), fallback) + "[]";
			}
		}
		return ((JvmIdentifiableElement) obj).getIdentifier();
	}
	return fallback.getFragment(obj);
}
 
Example #18
Source File: JvmDeclaredTypeImpl.java    From xtext-extras with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@SuppressWarnings("unchecked")
@Override
public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs)
{
	switch (featureID)
	{
		case TypesPackage.JVM_DECLARED_TYPE__ARRAY_TYPE:
			if (arrayType != null)
				msgs = ((InternalEObject)arrayType).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - TypesPackage.JVM_DECLARED_TYPE__ARRAY_TYPE, null, msgs);
			return basicSetArrayType((JvmArrayType)otherEnd, msgs);
		case TypesPackage.JVM_DECLARED_TYPE__MEMBERS:
			return ((InternalEList<InternalEObject>)(InternalEList<?>)getMembers()).basicAdd(otherEnd, msgs);
	}
	return super.eInverseAdd(otherEnd, featureID, msgs);
}
 
Example #19
Source File: AbstractTypeProviderTest.java    From xtext-extras with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void testFindTypeByName_javaLangNumber_02() {
	String typeName = Number[][].class.getName();
	JvmArrayType type = (JvmArrayType) getTypeProvider().findTypeByName(typeName);
	JvmOperation longValue = (JvmOperation) type.eResource().getEObject("java.lang.Number.longValue()");
	assertNotNull(longValue);
	JvmDeclaredType number = longValue.getDeclaringType();
	assertNotNull(number.getArrayType());
	assertSame(type, number.getArrayType().getArrayType());
	assertNull(type.eGet(TypesPackage.Literals.JVM_COMPONENT_TYPE__ARRAY_TYPE));
	// array will created on the fly
	assertNotNull(type.getArrayType());
	diagnose(type);
	Resource resource = type.eResource();
	getAndResolveAllFragments(resource);
	recomputeAndCheckIdentifiers(resource);
}
 
Example #20
Source File: RawTypeHelper.java    From xtext-extras with Eclipse Public License 2.0 6 votes vote down vote up
@Override
protected List<JvmType> doVisitArrayTypeReference(ArrayTypeReference reference, ResourceSet resourceSet) {
	LightweightTypeReference componentType = reference.getComponentType();
	List<JvmType> result;
	if (!componentType.isResolved()) {
		result = createObjectReference(resourceSet);
	} else {
		List<JvmType> rawComponentTypes = componentType.accept(this, resourceSet);
		result = Lists.newArrayListWithCapacity(rawComponentTypes.size());
		for(JvmType rawComponentType: rawComponentTypes) {
			if (!rawComponentType.eIsProxy() && rawComponentType instanceof JvmComponentType) {
				JvmArrayType arrayType = ((JvmComponentType) rawComponentType).getArrayType();
				if (arrayType == null) {
					arrayType = factory.createJvmArrayType();
					arrayType.setComponentType((JvmComponentType) rawComponentType);
				}
				result.add(arrayType);
			}
		}
	}
	return result;
}
 
Example #21
Source File: AbstractTypeProviderTest.java    From xtext-extras with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void test_ParameterizedTypes_Inner_08() {
	String typeName = ParameterizedTypes.Inner.class.getName();
	JvmGenericType type = (JvmGenericType) getTypeProvider().findTypeByName(typeName);
	JvmOperation methodV = getMethodFromType(type, ParameterizedTypes.Inner.class, "methodZArray_02()");
	JvmTypeReference listZ = methodV.getReturnType();
	assertEquals("java.util.List<Z[]>[]", listZ.getIdentifier());
	JvmParameterizedTypeReference listType = (JvmParameterizedTypeReference) ((JvmGenericArrayTypeReference) listZ)
			.getComponentType();
	assertEquals(1, listType.getArguments().size());
	JvmTypeReference typeArgument = listType.getArguments().get(0);
	JvmType argumentType = typeArgument.getType();
	assertTrue(argumentType instanceof JvmArrayType);
	JvmComponentType componentType = ((JvmArrayType) argumentType).getComponentType();
	JvmTypeParameter z = type.getTypeParameters().get(2);
	assertSame(z, componentType);
}
 
Example #22
Source File: AbstractTypeProviderTest.java    From xtext-extras with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void test_ParameterizedTypes_Inner_07() {
	String typeName = ParameterizedTypes.Inner.class.getName();
	JvmGenericType type = (JvmGenericType) getTypeProvider().findTypeByName(typeName);
	JvmOperation methodV = getMethodFromType(type, ParameterizedTypes.Inner.class, "methodZArray_01()");
	JvmTypeReference listZ = methodV.getReturnType();
	assertEquals("java.util.List<Z[][]>", listZ.getIdentifier());
	JvmParameterizedTypeReference listType = (JvmParameterizedTypeReference) listZ;
	assertEquals(1, listType.getArguments().size());
	JvmTypeReference typeArgument = listType.getArguments().get(0);
	JvmType argumentType = typeArgument.getType();
	assertTrue(argumentType instanceof JvmArrayType);
	assertTrue(((JvmArrayType) argumentType).getComponentType() instanceof JvmArrayType);
	JvmComponentType componentType = ((JvmArrayType) ((JvmArrayType) argumentType).getComponentType())
			.getComponentType();
	JvmTypeParameter z = type.getTypeParameters().get(2);
	assertSame(z, componentType);
}
 
Example #23
Source File: AbstractTypeProviderTest.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void test_ParameterizedTypes_Inner_07() {
	String typeName = ParameterizedTypes.Inner.class.getName();
	JvmGenericType type = (JvmGenericType) getTypeProvider().findTypeByName(typeName);
	JvmOperation methodV = getMethodFromType(type, ParameterizedTypes.Inner.class, "methodZArray_01()");
	JvmTypeReference listZ = methodV.getReturnType();
	assertEquals("java.util.List<Z[][]>", listZ.getIdentifier());
	JvmParameterizedTypeReference listType = (JvmParameterizedTypeReference) listZ;
	assertEquals(1, listType.getArguments().size());
	JvmTypeReference typeArgument = listType.getArguments().get(0);
	JvmType argumentType = typeArgument.getType();
	assertTrue(argumentType instanceof JvmArrayType);
	assertTrue(((JvmArrayType) argumentType).getComponentType() instanceof JvmArrayType);
	JvmComponentType componentType = ((JvmArrayType) ((JvmArrayType) argumentType).getComponentType())
			.getComponentType();
	JvmTypeParameter z = type.getTypeParameters().get(2);
	assertSame(z, componentType);
}
 
Example #24
Source File: JvmDeclaredTypeImpl.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public NotificationChain basicSetArrayType(JvmArrayType newArrayType, NotificationChain msgs)
{
	JvmArrayType oldArrayType = arrayType;
	arrayType = newArrayType;
	if (eNotificationRequired())
	{
		ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, TypesPackage.JVM_DECLARED_TYPE__ARRAY_TYPE, oldArrayType, newArrayType);
		if (msgs == null) msgs = notification; else msgs.add(notification);
	}
	return msgs;
}
 
Example #25
Source File: JvmDeclaredTypeImpl.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@SuppressWarnings("unchecked")
@Override
public void eSet(int featureID, Object newValue)
{
	switch (featureID)
	{
		case TypesPackage.JVM_DECLARED_TYPE__ARRAY_TYPE:
			setArrayType((JvmArrayType)newValue);
			return;
		case TypesPackage.JVM_DECLARED_TYPE__SUPER_TYPES:
			getSuperTypes().clear();
			getSuperTypes().addAll((Collection<? extends JvmTypeReference>)newValue);
			return;
		case TypesPackage.JVM_DECLARED_TYPE__MEMBERS:
			getMembers().clear();
			getMembers().addAll((Collection<? extends JvmMember>)newValue);
			return;
		case TypesPackage.JVM_DECLARED_TYPE__ABSTRACT:
			setAbstract((Boolean)newValue);
			return;
		case TypesPackage.JVM_DECLARED_TYPE__STATIC:
			setStatic((Boolean)newValue);
			return;
		case TypesPackage.JVM_DECLARED_TYPE__FINAL:
			setFinal((Boolean)newValue);
			return;
		case TypesPackage.JVM_DECLARED_TYPE__PACKAGE_NAME:
			setPackageName((String)newValue);
			return;
	}
	super.eSet(featureID, newValue);
}
 
Example #26
Source File: JvmComponentTypeImpl.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public void eUnset(int featureID)
{
	switch (featureID)
	{
		case TypesPackage.JVM_COMPONENT_TYPE__ARRAY_TYPE:
			setArrayType((JvmArrayType)null);
			return;
	}
	super.eUnset(featureID);
}
 
Example #27
Source File: JvmComponentTypeImpl.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs)
{
	switch (featureID)
	{
		case TypesPackage.JVM_COMPONENT_TYPE__ARRAY_TYPE:
			if (arrayType != null)
				msgs = ((InternalEObject)arrayType).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - TypesPackage.JVM_COMPONENT_TYPE__ARRAY_TYPE, null, msgs);
			return basicSetArrayType((JvmArrayType)otherEnd, msgs);
	}
	return super.eInverseAdd(otherEnd, featureID, msgs);
}
 
Example #28
Source File: AbstractTypeProviderTest.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void test_arrayWildcard_02() {
	JvmOperation arrayWildcard = getMethodFromParameterizedMethods("arrayWildcard(java.util.List[])");
	JvmTypeReference paramType = arrayWildcard.getParameters().get(0).getParameterType();
	assertEquals("java.util.List<? extends java.lang.Object>[]", paramType.getIdentifier());
	assertTrue(paramType.getType() instanceof JvmArrayType);
	JvmArrayType arrayType = (JvmArrayType) paramType.getType();
	assertTrue(arrayType.getComponentType() instanceof JvmDeclaredType);
	assertTrue(paramType instanceof JvmGenericArrayTypeReference);
	assertTrue(
			((JvmGenericArrayTypeReference) paramType).getComponentType() instanceof JvmParameterizedTypeReference);
}
 
Example #29
Source File: JvmComponentTypeImpl.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public NotificationChain basicSetArrayType(JvmArrayType newArrayType, NotificationChain msgs)
{
	JvmArrayType oldArrayType = arrayType;
	arrayType = newArrayType;
	if (eNotificationRequired())
	{
		ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, TypesPackage.JVM_COMPONENT_TYPE__ARRAY_TYPE, oldArrayType, newArrayType);
		if (msgs == null) msgs = notification; else msgs.add(notification);
	}
	return msgs;
}
 
Example #30
Source File: JvmComponentTypeImpl.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public void eSet(int featureID, Object newValue)
{
	switch (featureID)
	{
		case TypesPackage.JVM_COMPONENT_TYPE__ARRAY_TYPE:
			setArrayType((JvmArrayType)newValue);
			return;
	}
	super.eSet(featureID, newValue);
}