Java Code Examples for org.eclipse.xtext.common.types.JvmGenericArrayTypeReference#setComponentType()

The following examples show how to use org.eclipse.xtext.common.types.JvmGenericArrayTypeReference#setComponentType() . 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: AbstractConstantExpressionsInterpreter.java    From xtext-extras with Eclipse Public License 2.0 6 votes vote down vote up
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;
}
 
Example 2
Source File: RawTypeHelper.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public JvmTypeReference doVisitGenericArrayTypeReference(JvmGenericArrayTypeReference reference,
		Resource resource) {
	JvmTypeReference componentType = reference.getComponentType();
	JvmTypeReference rawComponentType = visit(componentType, resource);
	if (componentType != rawComponentType) {
		JvmGenericArrayTypeReference result = factory.createJvmGenericArrayTypeReference();
		result.setComponentType(rawComponentType);
		return result;
	}
	return reference;
}
 
Example 3
Source File: ReflectionTypeFactory.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
protected JvmTypeReference createLocalArrayTypeReference(Type componentType, JvmTypeParameterDeclarator container,
		GenericDeclaration member) {
	JvmTypeReference componentTypeReference = createLocalTypeReference(componentType, container, member);
	JvmGenericArrayTypeReference result = TypesFactory.eINSTANCE.createJvmGenericArrayTypeReference();
	result.setComponentType(componentTypeReference);
	return result;
}
 
Example 4
Source File: RawTypeReferenceComputer.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public JvmTypeReference doVisitGenericArrayTypeReference(JvmGenericArrayTypeReference reference, Pair<Resource, Set<JvmType>> context) {
	JvmTypeReference componentType = reference.getComponentType();
	JvmTypeReference rawComponentType = visit(componentType, context);
	if (componentType != rawComponentType) {
		JvmGenericArrayTypeReference result = factory.createJvmGenericArrayTypeReference();
		result.setComponentType(rawComponentType);
		return result;
	}
	return reference;
}
 
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: ArrayTypeReference.java    From xtext-extras with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public JvmTypeReference toTypeReference() {
	JvmGenericArrayTypeReference result = getTypesFactory().createJvmGenericArrayTypeReference();
	result.setComponentType(component.toTypeReference());
	return result;
}
 
Example 7
Source File: ArrayTypeReference.java    From xtext-extras with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public JvmTypeReference toJavaCompliantTypeReference(IVisibilityHelper visibilityHelper) {
	JvmGenericArrayTypeReference result = getTypesFactory().createJvmGenericArrayTypeReference();
	result.setComponentType(component.toJavaCompliantTypeReference(visibilityHelper));
	return result;
}
 
Example 8
Source File: ReflectionTypeFactory.java    From xtext-extras with Eclipse Public License 2.0 4 votes vote down vote up
protected JvmTypeReference createArrayTypeReference(Type componentType) {
	JvmTypeReference componentTypeReference = createTypeReference(componentType);
	JvmGenericArrayTypeReference result = TypesFactory.eINSTANCE.createJvmGenericArrayTypeReference();
	result.setComponentType(componentTypeReference);
	return result;
}
 
Example 9
Source File: TypeReferences.java    From xtext-extras with Eclipse Public License 2.0 4 votes vote down vote up
public JvmGenericArrayTypeReference createArrayType(JvmTypeReference componentType) {
	JvmGenericArrayTypeReference result = factory.createJvmGenericArrayTypeReference();
	result.setComponentType(EcoreUtil2.cloneIfContained(componentType));
	return result;
}