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

The following examples show how to use org.eclipse.xtext.common.types.JvmComponentType. 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_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 #2
Source File: JvmArrayTypeImpl.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 setComponentType(JvmComponentType newComponentType)
{
	if (newComponentType != eInternalContainer() || (eContainerFeatureID() != TypesPackage.JVM_ARRAY_TYPE__COMPONENT_TYPE && newComponentType != null))
	{
		if (EcoreUtil.isAncestor(this, newComponentType))
			throw new IllegalArgumentException("Recursive containment not allowed for " + toString());
		NotificationChain msgs = null;
		if (eInternalContainer() != null)
			msgs = eBasicRemoveFromContainer(msgs);
		if (newComponentType != null)
			msgs = ((InternalEObject)newComponentType).eInverseAdd(this, TypesPackage.JVM_COMPONENT_TYPE__ARRAY_TYPE, JvmComponentType.class, msgs);
		msgs = basicSetComponentType(newComponentType, msgs);
		if (msgs != null) msgs.dispatch();
	}
	else if (eNotificationRequired())
		eNotify(new ENotificationImpl(this, Notification.SET, TypesPackage.JVM_ARRAY_TYPE__COMPONENT_TYPE, newComponentType, newComponentType));
}
 
Example #3
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 #4
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 int eBaseStructuralFeatureID(int derivedFeatureID, Class<?> baseClass)
{
	if (baseClass == JvmType.class)
	{
		switch (derivedFeatureID)
		{
			default: return -1;
		}
	}
	if (baseClass == JvmComponentType.class)
	{
		switch (derivedFeatureID)
		{
			case TypesPackage.JVM_DECLARED_TYPE__ARRAY_TYPE: return TypesPackage.JVM_COMPONENT_TYPE__ARRAY_TYPE;
			default: return -1;
		}
	}
	return super.eBaseStructuralFeatureID(derivedFeatureID, baseClass);
}
 
Example #5
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 int eDerivedStructuralFeatureID(int baseFeatureID, Class<?> baseClass)
{
	if (baseClass == JvmType.class)
	{
		switch (baseFeatureID)
		{
			default: return -1;
		}
	}
	if (baseClass == JvmComponentType.class)
	{
		switch (baseFeatureID)
		{
			case TypesPackage.JVM_COMPONENT_TYPE__ARRAY_TYPE: return TypesPackage.JVM_DECLARED_TYPE__ARRAY_TYPE;
			default: return -1;
		}
	}
	return super.eDerivedStructuralFeatureID(baseFeatureID, baseClass);
}
 
Example #6
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 #7
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 #8
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 #9
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 #10
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 #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: 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 #13
Source File: JvmArrayTypeImplCustom.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public String getSimpleName() {
	JvmComponentType componentType = getComponentType();
	if (componentType != null)
		return componentType.getSimpleName() + "[]";
	return null;
}
 
Example #14
Source File: JvmComponentTypeItemProvider.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * This handles model notifications by calling {@link #updateChildren} to update any cached
 * children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged}.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public void notifyChanged(Notification notification)
{
	updateChildren(notification);

	switch (notification.getFeatureID(JvmComponentType.class))
	{
		case TypesPackage.JVM_COMPONENT_TYPE__ARRAY_TYPE:
			fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), true, false));
			return;
	}
	super.notifyChanged(notification);
}
 
Example #15
Source File: JvmArrayTypeImpl.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_ARRAY_TYPE__COMPONENT_TYPE:
			setComponentType((JvmComponentType)null);
			return;
	}
	super.eUnset(featureID);
}
 
Example #16
Source File: JvmArrayTypeImpl.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_ARRAY_TYPE__COMPONENT_TYPE:
			setComponentType((JvmComponentType)newValue);
			return;
	}
	super.eSet(featureID, newValue);
}
 
Example #17
Source File: JvmArrayTypeImpl.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 eBasicRemoveFromContainerFeature(NotificationChain msgs)
{
	switch (eContainerFeatureID())
	{
		case TypesPackage.JVM_ARRAY_TYPE__COMPONENT_TYPE:
			return eInternalContainer().eInverseRemove(this, TypesPackage.JVM_COMPONENT_TYPE__ARRAY_TYPE, JvmComponentType.class, msgs);
	}
	return super.eBasicRemoveFromContainerFeature(msgs);
}
 
Example #18
Source File: JvmArrayTypeImpl.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_ARRAY_TYPE__COMPONENT_TYPE:
			if (eInternalContainer() != null)
				msgs = eBasicRemoveFromContainer(msgs);
			return basicSetComponentType((JvmComponentType)otherEnd, msgs);
	}
	return super.eInverseAdd(otherEnd, featureID, msgs);
}
 
Example #19
Source File: JvmArrayTypeImpl.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 JvmComponentType getComponentType()
{
	if (eContainerFeatureID() != TypesPackage.JVM_ARRAY_TYPE__COMPONENT_TYPE) return null;
	return (JvmComponentType)eInternalContainer();
}
 
Example #20
Source File: JvmGenericArrayTypeReferenceImplCustom.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public JvmArrayType getType() {
	JvmTypeReference componentTypeReference = getComponentType();
	if (componentTypeReference != null) {
		JvmType componentType = componentTypeReference.getType();
		if (componentType instanceof JvmComponentType) {
			JvmArrayType result = ((JvmComponentType) componentType).getArrayType();
			return result;
		}
	}
	return null;
}
 
Example #21
Source File: JvmArrayTypeImplCustom.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public String getQualifiedName(char innerClassDelimiter) {
	JvmComponentType componentType = getComponentType();
	if (componentType != null)
		return componentType.getQualifiedName(innerClassDelimiter) + "[]";
	return null;
}
 
Example #22
Source File: JvmArrayTypeImplCustom.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public String getIdentifier() {
	JvmComponentType componentType = getComponentType();
	if (componentType != null)
		return componentType.getIdentifier() + "[]";
	return null;
}
 
Example #23
Source File: JvmArrayTypeImplCustom.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public int getDimensions() {
	int result = 1;
	JvmComponentType componentType = getComponentType();
	if (componentType == null)
		throw new NullPointerException("component type may not be null");
	while (componentType instanceof JvmArrayType) {
		result++;
		componentType = ((JvmArrayType) componentType).getComponentType();
		if (componentType == null)
			return result;
	}
	return result;
}
 
Example #24
Source File: RawTypeHelper.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public List<JvmType> doVisitGenericArrayTypeReference(JvmGenericArrayTypeReference reference, Resource resource) {
	JvmTypeReference componentType = reference.getComponentType();
	List<JvmType> rawComponentTypes = visit(componentType, resource);
	List<JvmType> result = Lists.newArrayListWithCapacity(rawComponentTypes.size());
	for (JvmType rawComponentType : rawComponentTypes) {
		if (!rawComponentType.eIsProxy() && rawComponentType instanceof JvmComponentType) {
			JvmArrayType arrayType = ((JvmComponentType) rawComponentType).getArrayType();
			result.add(arrayType);
		}
	}
	return result;
}
 
Example #25
Source File: ArrayTypeReference.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public JvmArrayType getType() {
	JvmType componentType = component.toJavaType().getType();
	if (componentType instanceof JvmComponentType) {
		return Preconditions.checkNotNull(((JvmComponentType) componentType).getArrayType());
	}
	if (component.isUnknown() || componentType.eIsProxy()) {
		return null;
	}
	throw new IllegalStateException("component type seems to be invalid: " + componentType + " / " + component);
}
 
Example #26
Source File: LightweightTypeReferenceFactory.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
public LightweightTypeReference toPlainTypeReference(JvmType type) {
	if (type.eClass() == TypesPackage.Literals.JVM_ARRAY_TYPE) {
		JvmComponentType componentType = ((JvmArrayType) type).getComponentType();
		LightweightTypeReference componentTypeReference = toPlainTypeReference(componentType);
		return owner.newArrayTypeReference(componentTypeReference);
	}
	return owner.newParameterizedTypeReference(type);
}
 
Example #27
Source File: IndexingLightweightTypeReferenceFactory.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
protected JvmType _getType(JvmGenericArrayTypeReferenceImplCustom it) {
	JvmTypeReference componentTypeReference = it.getComponentType();
	if (componentTypeReference == null) {
		return null;
	}
	JvmType componentType = getType(componentTypeReference);
	if (componentType instanceof JvmComponentType) {
		return ((JvmComponentType) componentType).getArrayType();
	}
	return null;
}
 
Example #28
Source File: JvmArrayTypeImpl.java    From xtext-extras with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public NotificationChain basicSetComponentType(JvmComponentType newComponentType, NotificationChain msgs)
{
	msgs = eBasicSetContainer((InternalEObject)newComponentType, TypesPackage.JVM_ARRAY_TYPE__COMPONENT_TYPE, msgs);
	return msgs;
}
 
Example #29
Source File: AbstractClassMirror.java    From xtext-extras with Eclipse Public License 2.0 4 votes vote down vote up
protected EObject getArrayEObject(Resource resource, String fragment, IFragmentProvider.Fallback fallback) {
	JvmComponentType component = (JvmComponentType) getEObject(resource, fragment.substring(0, fragment.length() - 2), fallback);
	if (component == null)
		return null;
	return component.getArrayType();
}
 
Example #30
Source File: IndexedJvmTypeAccess.java    From xtext-extras with Eclipse Public License 2.0 4 votes vote down vote up
public EObject resolveJavaArrayObject(JvmType rootType, String fragment) throws UnknownNestedTypeException {
	JvmComponentType component = (JvmComponentType) resolveJavaObject(rootType, fragment.substring(0, fragment.length() - 2));
	if (component == null)
		return null;
	return component.getArrayType();
}