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

The following examples show how to use org.eclipse.xtext.common.types.TypesFactory. 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: JvmTypeDeclarationImpl.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
public MutableConstructorDeclaration addConstructor(final Procedure1<MutableConstructorDeclaration> initializer) {
  this.checkMutable();
  Preconditions.checkArgument((initializer != null), "initializer cannot be null");
  final Function1<JvmConstructor, Boolean> _function = (JvmConstructor it) -> {
    return Boolean.valueOf(this.getCompilationUnit().getTypeExtensions().isSingleSyntheticDefaultConstructor(it));
  };
  final JvmConstructor constructor = IterableExtensions.<JvmConstructor>findFirst(Iterables.<JvmConstructor>filter(this.getDelegate().getMembers(), JvmConstructor.class), _function);
  if ((constructor != null)) {
    EcoreUtil.remove(constructor);
  }
  final JvmConstructor newConstructor = TypesFactory.eINSTANCE.createJvmConstructor();
  newConstructor.setVisibility(JvmVisibility.PUBLIC);
  newConstructor.setSimpleName(this.getSimpleName());
  this.getDelegate().getMembers().add(newConstructor);
  MemberDeclaration _memberDeclaration = this.getCompilationUnit().toMemberDeclaration(newConstructor);
  final MutableConstructorDeclaration mutableConstructorDeclaration = ((MutableConstructorDeclaration) _memberDeclaration);
  initializer.apply(mutableConstructorDeclaration);
  return mutableConstructorDeclaration;
}
 
Example #2
Source File: JvmCompoundTypeReferenceImplCustom.java    From xtext-extras with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 * 
 * Returns the value of the 'Type' reference. If there is no type set, 
 * a reference to <code>java.lang.Object</code> is assumed as soon as there is more 
 * than one contained reference.
 * If there is only one contained reference, its type is returned.
 */
@Override
public JvmType getType() {
	if (references != null && !references.isEmpty()) {
		if (references.size() == 1) {
			return references.get(0).getType();
		}
		if (type == null) {
			JvmGenericType objectType = TypesFactory.eINSTANCE.createJvmGenericType();
			String objectClassName = Object.class.getName();
			((InternalEObject) objectType).eSetProxyURI(URIHelperConstants.OBJECTS_URI.appendSegment(objectClassName).appendFragment(objectClassName));
			type = objectType;
		}
	}
	return super.getType();
}
 
Example #3
Source File: JvmTypeParameterItemProvider.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * This adds {@link org.eclipse.emf.edit.command.CommandParameter}s describing the children
 * that can be created under this object.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
protected void collectNewChildDescriptors(Collection<Object> newChildDescriptors, Object object)
{
	super.collectNewChildDescriptors(newChildDescriptors, object);

	newChildDescriptors.add
		(createChildParameter
			(TypesPackage.Literals.JVM_CONSTRAINT_OWNER__CONSTRAINTS,
			 TypesFactory.eINSTANCE.createJvmUpperBound()));

	newChildDescriptors.add
		(createChildParameter
			(TypesPackage.Literals.JVM_CONSTRAINT_OWNER__CONSTRAINTS,
			 TypesFactory.eINSTANCE.createJvmLowerBound()));
}
 
Example #4
Source File: MutableJvmInterfaceDeclarationImpl.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public MutableTypeParameterDeclaration addTypeParameter(final String name, final TypeReference... upperBounds) {
  this.checkMutable();
  ConditionUtils.checkJavaIdentifier(name, "name");
  ConditionUtils.checkIterable(((Iterable<?>)Conversions.doWrapArray(upperBounds)), "upperBounds");
  ConditionUtils.checkInferredTypeReferences("parameter type", upperBounds);
  final JvmTypeParameter param = TypesFactory.eINSTANCE.createJvmTypeParameter();
  param.setName(name);
  this.getDelegate().getTypeParameters().add(param);
  for (final TypeReference upper : upperBounds) {
    {
      final JvmTypeReference typeRef = this.getCompilationUnit().toJvmTypeReference(upper);
      final JvmUpperBound jvmUpperBound = TypesFactory.eINSTANCE.createJvmUpperBound();
      jvmUpperBound.setTypeReference(typeRef);
      param.getConstraints().add(jvmUpperBound);
    }
  }
  TypeParameterDeclaration _typeParameterDeclaration = this.getCompilationUnit().toTypeParameterDeclaration(param);
  return ((MutableTypeParameterDeclaration) _typeParameterDeclaration);
}
 
Example #5
Source File: JdtBasedTypeFactory.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
private JvmAnnotationValue createBooleanAnnotationValue(Object value) {
	JvmBooleanAnnotationValue annotationValue = TypesFactory.eINSTANCE.createJvmBooleanAnnotationValue();
	if (value != null) {
		@SuppressWarnings("unchecked")
		InternalEList<Object> values = (InternalEList<Object>)(InternalEList<?>)annotationValue.getValues();
		if (value instanceof Object[]) {
			for (Object element : (Object[])value) {
				if (element instanceof Boolean) {
					values.addUnique(element);
				}
			}
		} else {
			values.addUnique(value);
		}
	}
	return annotationValue;
}
 
Example #6
Source File: JdtBasedTypeFactory.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
private JvmAnnotationValue createShortAnnotationValue(Object value) {
	JvmShortAnnotationValue annotationValue = TypesFactory.eINSTANCE.createJvmShortAnnotationValue();
	if (value != null) {
		@SuppressWarnings("unchecked")
		InternalEList<Object> values = (InternalEList<Object>)(InternalEList<?>)annotationValue.getValues();
		if (value instanceof Object[]) {
			for (Object element : (Object[])value) {
				if (element instanceof Short) {
					values.addUnique(element);
				} else if (element != null) {
					values.addUnique(((Number)element).shortValue());
				}
			}
		} else if (value instanceof Short) {
			values.addUnique(value);
		} else if (value instanceof Number) {
			values.addUnique(((Number)value).shortValue());
		}
	}
	return annotationValue;
}
 
Example #7
Source File: JvmModelCompleter.java    From xtext-extras with Eclipse Public License 2.0 6 votes vote down vote up
protected void completeJvmGenericType(JvmGenericType element) {
	// if no super type add Object
	ensureSuperTypeObject(element);
	addAnnotations(element);
	if (!element.isInterface()) {
		// if no constructors have been added, add a default constructor
		if (isEmpty(element.getDeclaredConstructors())) {
			JvmConstructor constructor = TypesFactory.eINSTANCE.createJvmConstructor();
			constructor.setSimpleName(element.getSimpleName());
			constructor.setVisibility(JvmVisibility.PUBLIC);
			typeExtensions.setSynthetic(constructor, true);
			EObject primarySourceElement = associations.getPrimarySourceElement(element);
			if (primarySourceElement != null) {
				associator.associate(primarySourceElement, constructor);
			}
			element.getMembers().add(constructor);
		}
	}
}
 
Example #8
Source File: JdtBasedTypeFactory.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * @since 2.4
 */
protected JvmOperation createOperation(StringBuilder qualifiedName, String handleIdentifier, String[] path, IMethodBinding method) {
	JvmOperation result = TypesFactory.eINSTANCE.createJvmOperation();
	enhanceGenericDeclaration(result, method.getTypeParameters());
	enhanceExecutable(qualifiedName, handleIdentifier, path, result, method);
	int modifiers = method.getModifiers();
	result.setAbstract(Modifier.isAbstract(modifiers));
	result.setFinal(Modifier.isFinal(modifiers));
	result.setStatic(Modifier.isStatic(modifiers));
	result.setStrictFloatingPoint(Modifier.isStrictfp(modifiers));
	result.setSynchronized(Modifier.isSynchronized(modifiers));
	result.setNative(Modifier.isNative(modifiers));
	result.setReturnType(createTypeReference(method.getReturnType()));
	createAnnotationValues(method, result);
	return result;
}
 
Example #9
Source File: XFunctionTypeRefImplCustom.java    From xtext-extras with Eclipse Public License 2.0 6 votes vote down vote up
protected JvmTypeReference getJavaLangObjectTypeRef(JvmType rawType, TypesFactory typesFactory) {
	ResourceSet rs = EcoreUtil2.getResourceSet(rawType);
	JvmParameterizedTypeReference refToObject = typesFactory.createJvmParameterizedTypeReference();
	if (rs != null) {
		EObject javaLangObject = rs.getEObject(javaLangObjectURI, true);
		if (javaLangObject instanceof JvmType) {
			JvmType objectDeclaration = (JvmType) javaLangObject;
			refToObject.setType(objectDeclaration);
			return refToObject;
		}
	}
	JvmGenericType proxy = typesFactory.createJvmGenericType();
	((InternalEObject)proxy).eSetProxyURI(javaLangObjectURI);
	refToObject.setType(proxy);
	return refToObject;
}
 
Example #10
Source File: ReflectionTypeFactory.java    From xtext-extras with Eclipse Public License 2.0 6 votes vote down vote up
protected JvmEnumerationType createEnumerationType(Class<?> clazz) {
	JvmEnumerationType result = TypesFactory.eINSTANCE.createJvmEnumerationType();
	result.internalSetIdentifier(clazz.getName());
	result.setSimpleName(clazz.getSimpleName());
	if (clazz.getDeclaringClass() == null && clazz.getPackage() != null)
		result.setPackageName(clazz.getPackage().getName());
	setVisibility(clazz, result);
	setTypeModifiers(clazz, result);
	createNestedTypes(clazz, result);
	createMethods(clazz, result);
	createFields(clazz, result);
	createConstructors(clazz, result);
	setSuperTypes(clazz, result);
	createAnnotationValues(clazz, result);
	return result;
}
 
Example #11
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 #12
Source File: JdtBasedTypeFactory.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
private JvmAnnotationValue createIntAnnotationValue(Object value) {
	JvmIntAnnotationValue annotationValue = TypesFactory.eINSTANCE.createJvmIntAnnotationValue();
	if (value != null) {
		@SuppressWarnings("unchecked")
		InternalEList<Object> values = (InternalEList<Object>)(InternalEList<?>)annotationValue.getValues();
		if (value instanceof Object[]) {
			for (Object element : (Object[])value) {
				if (element instanceof Integer) {
					values.addUnique(element);
				} else if (element != null) {
					values.addUnique(((Number)element).intValue());
				}
			}
		} else if (value instanceof Integer) {
			values.addUnique(value);
		} else if (value instanceof Number) {
			values.addUnique(((Number)value).intValue());
		}
	}
	return annotationValue;
}
 
Example #13
Source File: JdtBasedTypeFactory.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
private JvmAnnotationValue createStringAnnotationValue(Object value) {
	JvmStringAnnotationValue annotationValue = TypesFactory.eINSTANCE.createJvmStringAnnotationValue();
	if (value != null) {
		@SuppressWarnings("unchecked")
		InternalEList<Object> values = (InternalEList<Object>)(InternalEList<?>)annotationValue.getValues();
		if (value instanceof Object[]) {
			for (Object element : (Object[])value) {
				if (element instanceof String) {
					values.addUnique(element);
				}
			}
		} else {
			values.addUnique(value);
		}
	}
	return annotationValue;
}
 
Example #14
Source File: JdtBasedTypeFactory.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
protected JvmType createProxy(ITypeBinding typeBinding) {
	JvmType proxy = typeProxies.get(typeBinding);
	if (proxy == null) {
		if (typeBinding.isPrimitive()) {
			proxy = PRIMITIVE_PROXIES[typeBinding.getKey().charAt(0) - 'B'];
		} else {
			URI uri = uriHelper.getFullURI(typeBinding);
			proxy = COMMON_PROXIES.get(uri.fragment());
			if (proxy == null) {
				proxy = TypesFactory.eINSTANCE.createJvmVoid();
				((InternalEObject)proxy).eSetProxyURI(uri);
			}
		}
		typeProxies.put(typeBinding, proxy);
	}
	return proxy;
}
 
Example #15
Source File: Proxies.java    From xtext-extras with Eclipse Public License 2.0 6 votes vote down vote up
public JvmType createProxy(BinaryTypeSignature type, Map<String, JvmTypeParameter> typeParameters) {
	String variableName = type.getTypeVariableName();
	if (variableName != null) {
		if (typeParameters == null) {
			throw new IllegalStateException(type.toString());
		}
		JvmType result = typeParameters.get(variableName);
		if (result == null) {
			throw new IllegalStateException(type.toString());
		}
		return result;
	}
	JvmType proxy = typeProxies.get(type);
	if (proxy == null) {
		proxy = TypesFactory.eINSTANCE.createJvmVoid();
		URI uri = type.getURI();
		((InternalEObject) proxy).eSetProxyURI(uri);
		typeProxies.put(type, proxy);
	}
	return proxy;
}
 
Example #16
Source File: JvmExecutableDeclarationImpl.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
public MutableTypeParameterDeclaration addTypeParameter(final String name, final TypeReference... upperBounds) {
  this.checkMutable();
  ConditionUtils.checkJavaIdentifier(name, "name");
  ConditionUtils.checkIterable(((Iterable<?>)Conversions.doWrapArray(upperBounds)), "upperBounds");
  ConditionUtils.checkInferredTypeReferences("parameter type", upperBounds);
  final JvmTypeParameter param = TypesFactory.eINSTANCE.createJvmTypeParameter();
  param.setName(name);
  this.getDelegate().getTypeParameters().add(param);
  for (final TypeReference upper : upperBounds) {
    {
      final JvmTypeReference typeRef = this.getCompilationUnit().toJvmTypeReference(upper);
      final JvmUpperBound jvmUpperBound = TypesFactory.eINSTANCE.createJvmUpperBound();
      jvmUpperBound.setTypeReference(typeRef);
      param.getConstraints().add(jvmUpperBound);
    }
  }
  TypeParameterDeclaration _typeParameterDeclaration = this.getCompilationUnit().toTypeParameterDeclaration(param);
  return ((MutableTypeParameterDeclaration) _typeParameterDeclaration);
}
 
Example #17
Source File: MissedMethodAddModification.java    From sarl with Apache License 2.0 6 votes vote down vote up
private List<JvmTypeParameter> cloneTypeParameters(JvmOperation fromOperation, JvmDeclaredType declaringType) {
	final SARLQuickfixProvider tools = getTools();
	final JvmTypeReferenceBuilder builder1 = tools.getJvmTypeParameterBuilder();
	final JvmTypesBuilder builder2 = tools.getJvmTypeBuilder();
	final TypeReferences builder3 = tools.getTypeServices().getTypeReferences();
	final TypesFactory builder4 = tools.getTypeServices().getTypesFactory();
	final List<JvmTypeParameter> outParameters = new ArrayList<>();
	// Get the type parameter mapping that is a consequence of the super type extension within the container.
	final Map<String, JvmTypeReference> superTypeParameterMapping = new HashMap<>();
	Utils.getSuperTypeParameterMap(declaringType, superTypeParameterMapping);
	Utils.copyTypeParametersFromJvmOperation(
			fromOperation.getTypeParameters(),
			outParameters,
			superTypeParameterMapping,
			builder1, builder2, builder3, builder4);
	return outParameters;
}
 
Example #18
Source File: JdtBasedTypeFactory.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
private JvmAnnotationValue createAnnotationAnnotationValue(Object value) {
	JvmAnnotationAnnotationValue annotationValue = TypesFactory.eINSTANCE.createJvmAnnotationAnnotationValue();
	if (value != null) {
		InternalEList<JvmAnnotationReference> values = (InternalEList<JvmAnnotationReference>)annotationValue.getValues();
		if (value instanceof Object[]) {
			for (Object element : (Object[])value) {
				if (element instanceof IAnnotationBinding) {
					values.addUnique(createAnnotationReference((IAnnotationBinding)element));
				}
			}
		} else if (value instanceof IAnnotationBinding) {
			values.addUnique(createAnnotationReference((IAnnotationBinding)value));
		}
	}
	return annotationValue;
}
 
Example #19
Source File: JvmConstraintOwnerItemProvider.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * This adds {@link org.eclipse.emf.edit.command.CommandParameter}s describing the children
 * that can be created under this object.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
protected void collectNewChildDescriptors(Collection<Object> newChildDescriptors, Object object)
{
	super.collectNewChildDescriptors(newChildDescriptors, object);

	newChildDescriptors.add
		(createChildParameter
			(TypesPackage.Literals.JVM_CONSTRAINT_OWNER__CONSTRAINTS,
			 TypesFactory.eINSTANCE.createJvmUpperBound()));

	newChildDescriptors.add
		(createChildParameter
			(TypesPackage.Literals.JVM_CONSTRAINT_OWNER__CONSTRAINTS,
			 TypesFactory.eINSTANCE.createJvmLowerBound()));
}
 
Example #20
Source File: JvmComponentTypeImplCustom.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public JvmArrayType getArrayType() {
	JvmArrayType result = super.getArrayType();
	if (result == null) {
		result = TypesFactory.eINSTANCE.createJvmArrayType();
		boolean wasDeliver = eDeliver();
		eSetDeliver(false);
		try {
			setArrayType(result);
		} finally {
			eSetDeliver(wasDeliver);
		}
	}
	return result;
}
 
Example #21
Source File: ReflectionTypeFactory.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
protected JvmType createProxy(Type type) {
	JvmType proxy = typeProxies.get(type);
	if (proxy == null) {
		proxy = TypesFactory.eINSTANCE.createJvmVoid();
		URI uri = uriHelper.getFullURI(type);
		((InternalEObject)proxy).eSetProxyURI(uri);
		typeProxies.put(type, proxy);
	}
	return proxy;
}
 
Example #22
Source File: XbaseResourceDescriptionStrategyTest.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testInterfaceDescription_01() {
	JvmGenericType interfaceType = TypesFactory.eINSTANCE.createJvmGenericType();
	interfaceType.setInterface(true);
	interfaceType.setPackageName("foo");
	interfaceType.setSimpleName("MyType");
	List<IEObjectDescription> list = new ArrayList<>();
	descriptionStrategy.createEObjectDescriptions(interfaceType, it -> list.add(it));
	Assert.assertTrue(
			list.stream().anyMatch(it -> "true".equals(it.getUserData(JvmTypesResourceDescriptionStrategy.IS_INTERFACE))));
}
 
Example #23
Source File: ReflectionTypeFactory.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
protected JvmTypeParameter createTypeParameter(TypeVariable<?> variable, JvmMember container) {
	JvmTypeParameter result = TypesFactory.eINSTANCE.createJvmTypeParameter();
	result.setName(variable.getName());
	Type[] bounds = variable.getBounds();
	if (bounds.length != 0) {
		InternalEList<JvmTypeConstraint> constraints = (InternalEList<JvmTypeConstraint>)result.getConstraints();
		for (Type bound : variable.getBounds()) {
			JvmUpperBound upperBound = TypesFactory.eINSTANCE.createJvmUpperBound();
			((JvmTypeConstraintImplCustom) upperBound).internalSetTypeReference(createTypeReference(bound));
			constraints.addUnique(upperBound);
		}
	}
	return result;
}
 
Example #24
Source File: JvmAnnotationReferenceBuilder.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void visitEnum(final String name, final String desc, final String value) {
	JvmEnumAnnotationValue result = TypesFactory.eINSTANCE.createJvmEnumAnnotationValue();
	JvmEnumerationLiteral enumLiteralProxy = proxies.createEnumLiteral(value, desc);
	((InternalEList<JvmEnumerationLiteral>) result.getValues()).addUnique(enumLiteralProxy);
	result.setOperation(proxies.createMethodProxy(annotationType, name));
	values.addUnique(result);
}
 
Example #25
Source File: JvmAnnotationReferenceBuilder.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
public JvmAnnotationReferenceBuilder(InternalEList<JvmAnnotationReference> target, String desc, Proxies proxies) {
	super(Opcodes.ASM8);
	this.proxies = proxies;
	this.target = target;
	this.annotationType = BinarySignatures.createTypeSignature(desc);
	result = TypesFactory.eINSTANCE.createJvmAnnotationReference();
	result.setAnnotation(proxies.createAnnotationProxy(annotationType));
	values = (InternalEList<JvmAnnotationValue>) result.getExplicitValues();
}
 
Example #26
Source File: JvmAnnotationValueBuilder.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void visitEnum(String name, String desc, String value) {
	if (name != null) {
		throw new IllegalStateException();
	}
	if (result == null) {
		result = TypesFactory.eINSTANCE.createJvmEnumAnnotationValue();
	}
	JvmEnumerationLiteral enumLiteralProxy = proxies.createEnumLiteral(value, desc);
	((InternalEList<JvmEnumerationLiteral>) ((JvmEnumAnnotationValue) result).getValues()).addUnique(enumLiteralProxy);
}
 
Example #27
Source File: PyGenerator.java    From sarl with Apache License 2.0 5 votes vote down vote up
/** Create a JvmType for a Python type.
 *
 * @param pythonName the python type name.
 * @return the type.
 */
@SuppressWarnings("static-method")
protected JvmType newType(String pythonName) {
	final JvmGenericType type = TypesFactory.eINSTANCE.createJvmGenericType();
	final int index = pythonName.indexOf("."); //$NON-NLS-1$
	if (index <= 0) {
		type.setSimpleName(pythonName);
	} else {
		type.setPackageName(pythonName.substring(0, index - 1));
		type.setSimpleName(pythonName.substring(index + 1));
	}
	return type;
}
 
Example #28
Source File: XbaseResourceDescriptionStrategyTest.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testInterfaceDescription_02() {
	JvmGenericType interfaceType = TypesFactory.eINSTANCE.createJvmGenericType();
	interfaceType.setInterface(false);
	interfaceType.setPackageName("foo");
	interfaceType.setSimpleName("MyType");
	List<IEObjectDescription> list = new ArrayList<>();
	descriptionStrategy.createEObjectDescriptions(interfaceType, it -> list.add(it));
	Assert.assertFalse(list.stream().anyMatch(
			it -> "true".equals(it.getUserData(JvmTypesResourceDescriptionStrategy.IS_INTERFACE))));
}
 
Example #29
Source File: JvmAnyTypeReferenceImplCustom.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 * 
 * Returns the value of the 'Type' reference. If there is no type set, 
 * a reference to <code>java.lang.Object</code> is assumed.
 */
@Override
public JvmType getType() {
	if (type == null) {
		JvmGenericType objectType = TypesFactory.eINSTANCE.createJvmGenericType();
		String objectClassName = Object.class.getName();
		((InternalEObject) objectType).eSetProxyURI(URIHelperConstants.OBJECTS_URI.appendSegment(objectClassName).appendFragment(objectClassName));
		setType(objectType);
	}
	return super.getType();
}
 
Example #30
Source File: JdtBasedTypeFactory.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * @since 2.4
 */
protected JvmConstructor createConstructor(StringBuilder qualifiedName, String handleIdentifier, String[] path, IMethodBinding method) {
	JvmConstructor result = TypesFactory.eINSTANCE.createJvmConstructor();
	enhanceGenericDeclaration(result, method.getTypeParameters());
	enhanceExecutable(qualifiedName, handleIdentifier, path, result, method);
	createAnnotationValues(method, result);
	return result;
}