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

The following examples show how to use org.eclipse.xtext.common.types.JvmInnerTypeReference. 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: NameConcatHelper.java    From xtext-extras with Eclipse Public License 2.0 6 votes vote down vote up
private static void computeFor(JvmParameterizedTypeReference typeReference, char innerClassDelimiter,
		NameType nameType, StringBuilder result) {
	if (typeReference.eClass() == TypesPackage.Literals.JVM_INNER_TYPE_REFERENCE) {
		JvmParameterizedTypeReference outer = ((JvmInnerTypeReference) typeReference).getOuter();
		if (outer != null) {
			computeFor(outer, innerClassDelimiter, nameType, result);
			if (result.length() != 0) {
				JvmType type = typeReference.getType();
				result.append(innerClassDelimiter);
				result.append(type.getSimpleName());
			} else {
				appendType(typeReference, innerClassDelimiter, nameType, result);	
			}
		} else {
			appendType(typeReference, innerClassDelimiter, nameType, result);
		}
	} else {
		appendType(typeReference, innerClassDelimiter, nameType, result);
	}
	if (typeReference.eIsSet(TypesPackage.Literals.JVM_PARAMETERIZED_TYPE_REFERENCE__ARGUMENTS)) {
		result.append("<");
		appendArguments(result, typeReference.getArguments(), innerClassDelimiter, nameType);
		result.append(">");
	}
}
 
Example #2
Source File: LightweightTypeReferenceFactory.java    From xtext-extras with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public LightweightTypeReference doVisitInnerTypeReference(JvmInnerTypeReference reference) {
	JvmType type = getType(reference);
	if (type == null || type.eIsProxy()) {
		return createUnknownTypeReference(reference);
	}
	if (!isInner(type)) {
		return doVisitParameterizedTypeReference(reference);
	}
	JvmParameterizedTypeReference outer = reference.getOuter();
	if (outer == null)
		return doVisitParameterizedTypeReference(reference);
	ParameterizedTypeReference lightweightOuter = (ParameterizedTypeReference) outer.accept(this);
	// constructor call instead of owner.newParameterized to avoid second check for isInner(..)
	InnerTypeReference result = new InnerTypeReference(owner, lightweightOuter, type);
	for(JvmTypeReference argument: reference.getArguments()) {
		result.addTypeArgument(visit(argument).getWrapperTypeIfPrimitive());
	}
	return result;
}
 
Example #3
Source File: TypeScopes.java    From xtext-extras with Eclipse Public License 2.0 6 votes vote down vote up
public IScope createTypeScope(EObject context, EReference reference) {
	if (context.eClass() == TypesPackage.Literals.JVM_INNER_TYPE_REFERENCE) {
		JvmInnerTypeReference casted = (JvmInnerTypeReference) context;
		JvmParameterizedTypeReference outerType = casted.getOuter();
		JvmType outerRawType = outerType.getType();
		if (outerRawType instanceof JvmDeclaredType) {
			Iterable<JvmDeclaredType> nestedTypes = ((JvmDeclaredType) outerRawType).getAllNestedTypes();
			List<IEObjectDescription> descriptions = Lists.newArrayList();
			for(JvmDeclaredType nestedType: nestedTypes) {
				descriptions.add(EObjectDescription.create(nestedType.getSimpleName(), nestedType));
			}
			return new SimpleScope(descriptions);
		}
		return IScope.NULLSCOPE;
	} else {
		final IScope delegateScope = getDelegate().getScope(context, reference);
		return delegateScope;
	}
}
 
Example #4
Source File: AbstractTypeProviderTest.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void test_ParameterizedTypes_inner_param_01() {
	String typeName = ParameterizedTypes.class.getName();
	JvmGenericType type = (JvmGenericType) getTypeProvider().findTypeByName(typeName);
	JvmOperation operation = getMethodFromType(type, ParameterizedTypes.class,
			"plainInner(org.eclipse.xtext.common.types.testSetups.ParameterizedTypes$Inner)");
	JvmTypeReference parameterType = operation.getParameters().get(0).getParameterType();
	assertTrue(parameterType.getIdentifier(), parameterType instanceof JvmInnerTypeReference);
	assertEquals("ParameterizedTypes<S, T, U, V, W>$Inner<W, List<W>, List<W>>", parameterType.getSimpleName());
}
 
Example #5
Source File: JdtBasedTypeFactory.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Returns a type reference for the given type binding. If the binding is null, an {@link JvmUnknownTypeReference unknown}
 * type reference is returned.
 */
// @NonNull 
protected JvmTypeReference createTypeReference(/* @Nullable */ ITypeBinding typeBinding) {
	if (typeBinding == null) {
		return TypesFactory.eINSTANCE.createJvmUnknownTypeReference();
	}
	if (typeBinding.isArray()) {
		ITypeBinding componentType = typeBinding.getComponentType();
		JvmTypeReference componentTypeReference = createTypeReference(componentType);
		JvmGenericArrayTypeReference typeReference = TypesFactory.eINSTANCE.createJvmGenericArrayTypeReference();
		typeReference.setComponentType(componentTypeReference);
		return typeReference;
	}
	ITypeBinding outer = null;
	if (typeBinding.isMember() && !Modifier.isStatic(typeBinding.getModifiers())) {
		outer = typeBinding.getDeclaringClass();
	}
	JvmParameterizedTypeReference result;
	if (outer != null) {
		JvmParameterizedTypeReference outerReference = (JvmParameterizedTypeReference) createTypeReference(outer);
		result = TypesFactory.eINSTANCE.createJvmInnerTypeReference();
		((JvmInnerTypeReference) result).setOuter(outerReference);
	} else {
		result = TypesFactory.eINSTANCE.createJvmParameterizedTypeReference();
	}
	ITypeBinding[] typeArguments = typeBinding.getTypeArguments();
	if (typeArguments.length != 0) {
		ITypeBinding erasure = typeBinding.getErasure();
		result.setType(createProxy(erasure));
		InternalEList<JvmTypeReference> arguments = (InternalEList<JvmTypeReference>)result.getArguments();
		for (int i = 0; i < typeArguments.length; i++) {
			JvmTypeReference argument = createTypeArgument(typeArguments[i]);
			arguments.addUnique(argument);
		}
	} else {
		result.setType(createProxy(typeBinding));
	}
	return result;
}
 
Example #6
Source File: JvmInnerTypeReferenceItemProvider.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(JvmInnerTypeReference.class))
	{
		case TypesPackage.JVM_INNER_TYPE_REFERENCE__OUTER:
			fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), true, false));
			return;
	}
	super.notifyChanged(notification);
}
 
Example #7
Source File: AbstractTypeProviderTest.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void test_ParameterizedTypes2_inner_return_02() {
	String typeName = ParameterizedTypes2.class.getName();
	JvmGenericType type = (JvmGenericType) getTypeProvider().findTypeByName(typeName);
	JvmOperation operation = getMethodFromType(type, ParameterizedTypes2.class, "concreteInner()");
	JvmTypeReference returnType = operation.getReturnType();
	assertTrue(returnType.getIdentifier(), returnType instanceof JvmInnerTypeReference);
	assertEquals("ParameterizedTypes2<Number>$Inner<String>", returnType.getSimpleName());
}
 
Example #8
Source File: AbstractTypeProviderTest.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void test_ParameterizedTypes2_inner_return_01() {
	String typeName = ParameterizedTypes2.class.getName();
	JvmGenericType type = (JvmGenericType) getTypeProvider().findTypeByName(typeName);
	JvmOperation operation = getMethodFromType(type, ParameterizedTypes2.class, "plainInner()");
	JvmTypeReference returnType = operation.getReturnType();
	assertTrue(returnType.getIdentifier(), returnType instanceof JvmInnerTypeReference);
	assertEquals("ParameterizedTypes2<P>$Inner<String>", returnType.getSimpleName());
}
 
Example #9
Source File: AbstractTypeProviderTest.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void test_ParameterizedTypes_inner_return_02() {
	String typeName = ParameterizedTypes.class.getName();
	JvmGenericType type = (JvmGenericType) getTypeProvider().findTypeByName(typeName);
	JvmOperation operation = getMethodFromType(type, ParameterizedTypes.class, "concreteInner()");
	JvmTypeReference returnType = operation.getReturnType();
	assertTrue(returnType.getIdentifier(), returnType instanceof JvmInnerTypeReference);
	assertEquals(
			"ParameterizedTypes<String, String, List<String>, V, String>$Inner<String, List<String>, List<String>>",
			returnType.getSimpleName());
}
 
Example #10
Source File: AbstractTypeProviderTest.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void test_ParameterizedTypes_inner_return_01() {
	String typeName = ParameterizedTypes.class.getName();
	JvmGenericType type = (JvmGenericType) getTypeProvider().findTypeByName(typeName);
	JvmOperation operation = getMethodFromType(type, ParameterizedTypes.class,
			"plainInner(org.eclipse.xtext.common.types.testSetups.ParameterizedTypes$Inner)");
	JvmTypeReference returnType = operation.getReturnType();
	assertTrue(returnType.getIdentifier(), returnType instanceof JvmInnerTypeReference);
	assertEquals("ParameterizedTypes<S, T, U, V, W>$Inner<W, List<W>, List<W>>", returnType.getSimpleName());
}
 
Example #11
Source File: AbstractTypeProviderTest.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void test_ParameterizedTypes_inner_param_01() {
	String typeName = ParameterizedTypes.class.getName();
	JvmGenericType type = (JvmGenericType) getTypeProvider().findTypeByName(typeName);
	JvmOperation operation = getMethodFromType(type, ParameterizedTypes.class,
			"plainInner(org.eclipse.xtext.common.types.testSetups.ParameterizedTypes$Inner)");
	JvmTypeReference parameterType = operation.getParameters().get(0).getParameterType();
	assertTrue(parameterType.getIdentifier(), parameterType instanceof JvmInnerTypeReference);
	assertEquals("ParameterizedTypes<S, T, U, V, W>$Inner<W, List<W>, List<W>>", parameterType.getSimpleName());
}
 
Example #12
Source File: AbstractTypeProviderTest.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void test_ParameterizedTypes2_inner_return_02() {
	String typeName = ParameterizedTypes2.class.getName();
	JvmGenericType type = (JvmGenericType) getTypeProvider().findTypeByName(typeName);
	JvmOperation operation = getMethodFromType(type, ParameterizedTypes2.class, "concreteInner()");
	JvmTypeReference returnType = operation.getReturnType();
	assertTrue(returnType.getIdentifier(), returnType instanceof JvmInnerTypeReference);
	assertEquals("ParameterizedTypes2<Number>$Inner<String>", returnType.getSimpleName());
}
 
Example #13
Source File: AbstractTypeProviderTest.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void test_ParameterizedTypes2_inner_return_01() {
	String typeName = ParameterizedTypes2.class.getName();
	JvmGenericType type = (JvmGenericType) getTypeProvider().findTypeByName(typeName);
	JvmOperation operation = getMethodFromType(type, ParameterizedTypes2.class, "plainInner()");
	JvmTypeReference returnType = operation.getReturnType();
	assertTrue(returnType.getIdentifier(), returnType instanceof JvmInnerTypeReference);
	assertEquals("ParameterizedTypes2<P>$Inner<String>", returnType.getSimpleName());
}
 
Example #14
Source File: AbstractTypeProviderTest.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void test_ParameterizedTypes_inner_return_02() {
	String typeName = ParameterizedTypes.class.getName();
	JvmGenericType type = (JvmGenericType) getTypeProvider().findTypeByName(typeName);
	JvmOperation operation = getMethodFromType(type, ParameterizedTypes.class, "concreteInner()");
	JvmTypeReference returnType = operation.getReturnType();
	assertTrue(returnType.getIdentifier(), returnType instanceof JvmInnerTypeReference);
	assertEquals(
			"ParameterizedTypes<String, String, List<String>, V, String>$Inner<String, List<String>, List<String>>",
			returnType.getSimpleName());
}
 
Example #15
Source File: AbstractTypeProviderTest.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void test_ParameterizedTypes_inner_return_01() {
	String typeName = ParameterizedTypes.class.getName();
	JvmGenericType type = (JvmGenericType) getTypeProvider().findTypeByName(typeName);
	JvmOperation operation = getMethodFromType(type, ParameterizedTypes.class,
			"plainInner(org.eclipse.xtext.common.types.testSetups.ParameterizedTypes$Inner)");
	JvmTypeReference returnType = operation.getReturnType();
	assertTrue(returnType.getIdentifier(), returnType instanceof JvmInnerTypeReference);
	assertEquals("ParameterizedTypes<S, T, U, V, W>$Inner<W, List<W>, List<W>>", returnType.getSimpleName());
}
 
Example #16
Source File: AbstractTypeProviderTest.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void test_ParameterizedTypes_inner_param_01() {
	String typeName = ParameterizedTypes.class.getName();
	JvmGenericType type = (JvmGenericType) getTypeProvider().findTypeByName(typeName);
	JvmOperation operation = getMethodFromType(type, ParameterizedTypes.class,
			"plainInner(org.eclipse.xtext.common.types.testSetups.ParameterizedTypes$Inner)");
	JvmTypeReference parameterType = operation.getParameters().get(0).getParameterType();
	assertTrue(parameterType.getIdentifier(), parameterType instanceof JvmInnerTypeReference);
	assertEquals("ParameterizedTypes<S, T, U, V, W>$Inner<W, List<W>, List<W>>", parameterType.getSimpleName());
}
 
Example #17
Source File: InnerTypeReference.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public JvmTypeReference toTypeReference() {
	JvmInnerTypeReference result = getTypesFactory().createJvmInnerTypeReference();
	result.setType(getType());
	result.setOuter((JvmParameterizedTypeReference) outer.toTypeReference());
	for(LightweightTypeReference typeArgument: getTypeArguments()) {
		result.getArguments().add(typeArgument.toTypeReference());
	}
	return result;
}
 
Example #18
Source File: LightweightTypeReferenceFactory.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public LightweightTypeReference doVisitFunctionTypeReference(XFunctionTypeRef reference) {
	JvmTypeReference equivalent = reference.getEquivalent();
	if (equivalent == null) {
		return super.doVisitFunctionTypeReference(reference);
	}
	FunctionTypeReference result;
	// constructors used below to avoid subsequent checks for isInner which was supposed to be done by 
	// the computation of the equivalent
	if (equivalent.eClass() == TypesPackage.Literals.JVM_INNER_TYPE_REFERENCE) {
		JvmParameterizedTypeReference outer = ((JvmInnerTypeReference) equivalent).getOuter();
		LightweightTypeReference outerEquivalent = outer.accept(this);
		result = new InnerFunctionTypeReference(owner, outerEquivalent, reference.getType());
	} else {
		result = new FunctionTypeReference(owner, reference.getType());
	}
	if (equivalent instanceof JvmParameterizedTypeReference) {
		for(JvmTypeReference argument: ((JvmParameterizedTypeReference)equivalent).getArguments()) {
			result.addTypeArgument(visit(argument));
		}
	}
	for(JvmTypeReference parameter: reference.getParamTypes()) {
		result.addParameterType(visit(parameter));
	}
	if (reference.getReturnType() != null) {
		result.setReturnType(visit(reference.getReturnType()));
	}
	return result;
}
 
Example #19
Source File: InnerFunctionTypeReference.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public JvmTypeReference toJavaCompliantTypeReference(IVisibilityHelper visibilityHelper) {
	if (isTypeVisible(visibilityHelper)) {
		JvmInnerTypeReference result = getTypesFactory().createJvmInnerTypeReference();
		result.setType(getType());
		result.setOuter((JvmParameterizedTypeReference) outer.toJavaCompliantTypeReference());
		for(LightweightTypeReference typeArgument: getTypeArguments()) {
			result.getArguments().add(typeArgument.toJavaCompliantTypeReference());
		}
		return result;
	} else {
		return toJavaCompliantTypeReference(getSuperTypes(), visibilityHelper);
	}
}
 
Example #20
Source File: InnerFunctionTypeReference.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public JvmTypeReference getEquivalentTypeReference() {
	JvmInnerTypeReference result = getTypesFactory().createJvmInnerTypeReference();
	result.setType(getType());
	result.setOuter((JvmParameterizedTypeReference) outer.toTypeReference());
	for(LightweightTypeReference typeArgument: getTypeArguments()) {
		result.getArguments().add(typeArgument.toTypeReference());
	}
	return result;
}
 
Example #21
Source File: ProxyAwareUIStrings.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public StringBuilder doVisitInnerTypeReference(JvmInnerTypeReference reference, StringBuilder param) {
	JvmType type = reference.getType();
	if (type == null || type.eIsProxy()) {
		return null;
	}
	param = reference.getOuter().accept(this, param);
	if (param == null)
		return null;
	param.append(".");
	return doVisitParameterizedTypeReference(reference, param);
}
 
Example #22
Source File: AbstractTypeProviderTest.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void test_ParameterizedTypes_inner_return_01() {
	String typeName = ParameterizedTypes.class.getName();
	JvmGenericType type = (JvmGenericType) getTypeProvider().findTypeByName(typeName);
	JvmOperation operation = getMethodFromType(type, ParameterizedTypes.class,
			"plainInner(org.eclipse.xtext.common.types.testSetups.ParameterizedTypes$Inner)");
	JvmTypeReference returnType = operation.getReturnType();
	assertTrue(returnType.getIdentifier(), returnType instanceof JvmInnerTypeReference);
	assertEquals("ParameterizedTypes<S, T, U, V, W>$Inner<W, List<W>, List<W>>", returnType.getSimpleName());
}
 
Example #23
Source File: AbstractTypeProviderTest.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void test_ParameterizedTypes_inner_return_02() {
	String typeName = ParameterizedTypes.class.getName();
	JvmGenericType type = (JvmGenericType) getTypeProvider().findTypeByName(typeName);
	JvmOperation operation = getMethodFromType(type, ParameterizedTypes.class, "concreteInner()");
	JvmTypeReference returnType = operation.getReturnType();
	assertTrue(returnType.getIdentifier(), returnType instanceof JvmInnerTypeReference);
	assertEquals(
			"ParameterizedTypes<String, String, List<String>, V, String>$Inner<String, List<String>, List<String>>",
			returnType.getSimpleName());
}
 
Example #24
Source File: AbstractTypeProviderTest.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void test_ParameterizedTypes2_inner_return_01() {
	String typeName = ParameterizedTypes2.class.getName();
	JvmGenericType type = (JvmGenericType) getTypeProvider().findTypeByName(typeName);
	JvmOperation operation = getMethodFromType(type, ParameterizedTypes2.class, "plainInner()");
	JvmTypeReference returnType = operation.getReturnType();
	assertTrue(returnType.getIdentifier(), returnType instanceof JvmInnerTypeReference);
	assertEquals("ParameterizedTypes2<P>$Inner<String>", returnType.getSimpleName());
}
 
Example #25
Source File: AbstractTypeProviderTest.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void test_ParameterizedTypes2_inner_return_02() {
	String typeName = ParameterizedTypes2.class.getName();
	JvmGenericType type = (JvmGenericType) getTypeProvider().findTypeByName(typeName);
	JvmOperation operation = getMethodFromType(type, ParameterizedTypes2.class, "concreteInner()");
	JvmTypeReference returnType = operation.getReturnType();
	assertTrue(returnType.getIdentifier(), returnType instanceof JvmInnerTypeReference);
	assertEquals("ParameterizedTypes2<Number>$Inner<String>", returnType.getSimpleName());
}
 
Example #26
Source File: InnerTypeReference.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public JvmTypeReference toJavaCompliantTypeReference(IVisibilityHelper visibilityHelper) {
	if (isTypeVisible(visibilityHelper)) {
		JvmInnerTypeReference result = getTypesFactory().createJvmInnerTypeReference();
		result.setType(getType());
		result.setOuter((JvmParameterizedTypeReference) outer.toJavaCompliantTypeReference());
		for(LightweightTypeReference typeArgument: getTypeArguments()) {
			result.getArguments().add(typeArgument.toJavaCompliantTypeReference());
		}
		return result;
	} else {
		return toJavaCompliantTypeReference(getSuperTypes(), visibilityHelper);
	}
}
 
Example #27
Source File: AbstractXtypeSemanticSequencer.java    From xtext-extras with Eclipse Public License 2.0 4 votes vote down vote up
@Deprecated
protected void sequence_JvmParameterizedTypeReference(EObject context, JvmInnerTypeReference semanticObject) {
	sequence_JvmParameterizedTypeReference(createContext(context, semanticObject), semanticObject);
}
 
Example #28
Source File: AbstractXtypeSemanticSequencer.java    From xtext-extras with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public void sequence(ISerializationContext context, EObject semanticObject) {
	EPackage epackage = semanticObject.eClass().getEPackage();
	ParserRule rule = context.getParserRule();
	Action action = context.getAssignedAction();
	Set<Parameter> parameters = context.getEnabledBooleanParameters();
	if (epackage == TypesPackage.eINSTANCE)
		switch (semanticObject.eClass().getClassifierID()) {
		case TypesPackage.JVM_GENERIC_ARRAY_TYPE_REFERENCE:
			sequence_JvmTypeReference(context, (JvmGenericArrayTypeReference) semanticObject); 
			return; 
		case TypesPackage.JVM_INNER_TYPE_REFERENCE:
			sequence_JvmParameterizedTypeReference(context, (JvmInnerTypeReference) semanticObject); 
			return; 
		case TypesPackage.JVM_LOWER_BOUND:
			if (rule == grammarAccess.getJvmLowerBoundAndedRule()) {
				sequence_JvmLowerBoundAnded(context, (JvmLowerBound) semanticObject); 
				return; 
			}
			else if (rule == grammarAccess.getJvmLowerBoundRule()) {
				sequence_JvmLowerBound(context, (JvmLowerBound) semanticObject); 
				return; 
			}
			else break;
		case TypesPackage.JVM_PARAMETERIZED_TYPE_REFERENCE:
			if (action == grammarAccess.getJvmParameterizedTypeReferenceAccess().getJvmInnerTypeReferenceOuterAction_1_4_0_0_0()) {
				sequence_JvmParameterizedTypeReference_JvmInnerTypeReference_1_4_0_0_0(context, (JvmParameterizedTypeReference) semanticObject); 
				return; 
			}
			else if (rule == grammarAccess.getJvmTypeReferenceRule()
					|| action == grammarAccess.getJvmTypeReferenceAccess().getJvmGenericArrayTypeReferenceComponentTypeAction_0_1_0_0()
					|| rule == grammarAccess.getJvmParameterizedTypeReferenceRule()
					|| rule == grammarAccess.getJvmArgumentTypeReferenceRule()) {
				sequence_JvmParameterizedTypeReference(context, (JvmParameterizedTypeReference) semanticObject); 
				return; 
			}
			else break;
		case TypesPackage.JVM_TYPE_PARAMETER:
			sequence_JvmTypeParameter(context, (JvmTypeParameter) semanticObject); 
			return; 
		case TypesPackage.JVM_UPPER_BOUND:
			if (rule == grammarAccess.getJvmUpperBoundAndedRule()) {
				sequence_JvmUpperBoundAnded(context, (JvmUpperBound) semanticObject); 
				return; 
			}
			else if (rule == grammarAccess.getJvmUpperBoundRule()) {
				sequence_JvmUpperBound(context, (JvmUpperBound) semanticObject); 
				return; 
			}
			else break;
		case TypesPackage.JVM_WILDCARD_TYPE_REFERENCE:
			sequence_JvmWildcardTypeReference(context, (JvmWildcardTypeReference) semanticObject); 
			return; 
		}
	else if (epackage == XtypePackage.eINSTANCE)
		switch (semanticObject.eClass().getClassifierID()) {
		case XtypePackage.XFUNCTION_TYPE_REF:
			sequence_XFunctionTypeRef(context, (XFunctionTypeRef) semanticObject); 
			return; 
		case XtypePackage.XIMPORT_DECLARATION:
			sequence_XImportDeclaration(context, (XImportDeclaration) semanticObject); 
			return; 
		case XtypePackage.XIMPORT_SECTION:
			sequence_XImportSection(context, (XImportSection) semanticObject); 
			return; 
		}
	if (errorAcceptor != null)
		errorAcceptor.accept(diagnosticProvider.createInvalidContextOrTypeDiagnostic(semanticObject, context));
}
 
Example #29
Source File: AbstractTypeReferenceVisitorWithParameter.java    From xtext-extras with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public Result doVisitInnerTypeReference(JvmInnerTypeReference reference, Parameter param) {
	return doVisitParameterizedTypeReference(reference, param);
}
 
Example #30
Source File: TypeReferences.java    From xtext-extras with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * @return a fresh {@link JvmParameterizedTypeReference} for the given {@link JvmType} parameterized with the given
 *         typeArgs. This method does not check whether the given type can handle the given type arguments.
 */
public JvmParameterizedTypeReference createTypeRef(JvmType type, JvmTypeReference... typeArgs) {
	if (type == null)
		throw new NullPointerException("type");
	List<JvmTypeReference> typeReferences = Collections.emptyList();
	if (typeArgs != null && typeArgs.length > 0) {
		typeReferences = Lists.newArrayListWithCapacity(typeArgs.length);
		for (int i = 0; i < typeArgs.length; i++) {
			JvmTypeReference jvmTypeReference = typeArgs[i];
			typeReferences.add(EcoreUtil2.cloneIfContained(jvmTypeReference));
		}
	}
	JvmParameterizedTypeReference reference;
	if (type instanceof JvmGenericType) {
		JvmGenericType casted = (JvmGenericType) type;
		List<JvmTypeParameter> list = casted.getTypeParameters();
		if (!typeReferences.isEmpty() && list.size() != typeReferences.size()) {
			throw new IllegalArgumentException("The type " + type.getIdentifier() + " expects " + list.size()
					+ " type arguments, but was " + typeReferences.size()
					+ ". Either pass zero arguments (raw type) or the correct number.");
		}
		// Raw type -> create type references to type param
		if (typeReferences.isEmpty() && !list.isEmpty()) {
			typeReferences = Lists.newArrayListWithCapacity(list.size());
			for (JvmTypeParameter typeParameter : list) {
				typeReferences.add(createTypeRef(typeParameter));
			}
		}
		if (!casted.isStatic() && casted.eContainer() instanceof JvmType) {
			JvmParameterizedTypeReference outer = createTypeRef((JvmType)casted.eContainer());
			reference = factory.createJvmInnerTypeReference();
			((JvmInnerTypeReference) reference).setOuter(outer);
		} else {
			reference = factory.createJvmParameterizedTypeReference();	
		}
	} else {
		reference = factory.createJvmParameterizedTypeReference();
	}
	reference.setType(type);
	if (!typeReferences.isEmpty())
		reference.getArguments().addAll(typeReferences);
	return reference;
}