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

The following examples show how to use org.eclipse.xtext.common.types.JvmEnumerationLiteral. 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: JvmModelGeneratorTest.java    From xtext-extras with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void testEnumerationWithCompleter() {
  try {
    final XExpression expression = this.expression("null", false);
    final Procedure1<JvmEnumerationType> _function = (JvmEnumerationType it) -> {
      EList<JvmMember> _members = it.getMembers();
      JvmEnumerationLiteral _enumerationLiteral = this.builder.toEnumerationLiteral(expression, "BAR");
      this.builder.<JvmEnumerationLiteral>operator_add(_members, _enumerationLiteral);
      EList<JvmMember> _members_1 = it.getMembers();
      JvmEnumerationLiteral _enumerationLiteral_1 = this.builder.toEnumerationLiteral(expression, "BAZ");
      this.builder.<JvmEnumerationLiteral>operator_add(_members_1, _enumerationLiteral_1);
    };
    final JvmEnumerationType enumeration = this.builder.toEnumerationType(expression, "my.test.Foo", _function);
    expression.eResource().getContents().add(enumeration);
    this.completer.complete(enumeration);
    final Class<?> compiled = this.compile(expression.eResource(), enumeration);
    final Method valuesMethod = compiled.getMethod("values");
    Object _invoke = valuesMethod.invoke(null);
    final Object[] values = ((Object[]) _invoke);
    Assert.assertEquals("BAR", (values[0]).toString());
    Assert.assertEquals("BAZ", (values[1]).toString());
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example #2
Source File: ConstantConditionsInterpreter.java    From xtext-extras with Eclipse Public License 2.0 6 votes vote down vote up
public EvaluationResult evaluateAssociatedExpression(final XExpression it, final EvaluationContext context) {
  EvaluationResult _switchResult = null;
  boolean _matched = false;
  if (it instanceof XAbstractFeatureCall) {
    JvmIdentifiableElement _feature = ((XAbstractFeatureCall)it).getFeature();
    if ((_feature instanceof JvmEnumerationLiteral)) {
      _matched=true;
      final EvaluationResult arg = this.doEvaluate(it, context);
      Object _rawValue = arg.getRawValue();
      return new EvaluationResult(_rawValue, false);
    }
  }
  if (!_matched) {
    _switchResult = this.doEvaluate(it, context);
  }
  return _switchResult;
}
 
Example #3
Source File: JvmEnumerationTypeImplCustom.java    From xtext-extras with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public EList<JvmEnumerationLiteral> getLiterals() {
	checkPendingInitialization();
	if (literals == null) {
		@SuppressWarnings("serial")
		EObjectResolvingEList<JvmEnumerationLiteral> list = new EObjectResolvingEList<JvmEnumerationLiteral>(
				JvmEnumerationLiteral.class, this, TypesPackage.JVM_ENUMERATION_TYPE__LITERALS) {
			@Override
			protected boolean isNotificationRequired() {
				return false;
			}
		};
		for (JvmMember member : getMembers()) {
			if (member instanceof JvmEnumerationLiteral)
				list.add((JvmEnumerationLiteral) member);
		}
		literals = new DelegatingEcoreEList.UnmodifiableEList<JvmEnumerationLiteral>(this, TypesPackage.Literals.JVM_ENUMERATION_TYPE__LITERALS, list);
	}
	return literals;
}
 
Example #4
Source File: ReflectionTypeFactory.java    From xtext-extras with Eclipse Public License 2.0 6 votes vote down vote up
protected JvmAnnotationValue createAnnotationValue(Object value, Class<?> type) {
	EStructuralFeature.Setting result = createAnnotationValue(type);
	@SuppressWarnings("unchecked")
	InternalEList<Object> values = (InternalEList<Object>)result;
	if (type.isPrimitive() || String.class == type) {
		values.addUnique(value);
	} else if (type == Class.class) {
		Class<?> referencedClass = (Class<?>) value;
		JvmTypeReference reference = createTypeReference(referencedClass);
		values.addUnique(reference);
	} else if (type.isAnnotation()) {
		Annotation nestedAnnotation = (Annotation) value;
		values.addUnique(createAnnotationReference(nestedAnnotation));
	} else if (type.isEnum()) {
		Enum<?> e = (Enum<?>) value;
		JvmEnumerationLiteral proxy = createEnumLiteralProxy(e);
		values.addUnique(proxy);
	}
	return (JvmAnnotationValue)result.getEObject();
}
 
Example #5
Source File: TypeUsageCollector.java    From xtext-extras with Eclipse Public License 2.0 6 votes vote down vote up
protected void collectStaticImportsFrom(XExpression expression, JvmIdentifiableElement feature) {
	if (expression instanceof XAbstractFeatureCall) {
		if (feature instanceof JvmEnumerationLiteral && expression instanceof XFeatureCall) {
			if (isEnumLiteralImplicitelyImported(expression, (JvmEnumerationLiteral) feature)) {
				return;
			}
		}
		XAbstractFeatureCall featureCall = (XAbstractFeatureCall) expression;
		if ((feature instanceof JvmOperation || feature instanceof JvmField) && featureCall.isStatic()) {
			if (featureCall.isExtension()) {
				acceptStaticExtensionImport((JvmMember) feature);
			} else {
				acceptStaticImport((JvmMember) feature);
			}
		}
	}
}
 
Example #6
Source File: XAnnotationUtil.java    From xtext-extras with Eclipse Public License 2.0 6 votes vote down vote up
public Set<ElementType> getAnnotationTargets(JvmAnnotationType annotation) {
	EList<JvmAnnotationReference> annotations = annotation.getAnnotations();
	for (JvmAnnotationReference annoRef : annotations) {
		if (Target.class.getName().equals(annoRef.getAnnotation().getIdentifier())) {
			EList<JvmAnnotationValue> values = annoRef.getValues();
			JvmAnnotationValue value = values.isEmpty() ? null : values.get(0);
			if (value instanceof JvmEnumAnnotationValue) {
				Set<ElementType> result = newHashSet();
				for (JvmEnumerationLiteral elementType : ((JvmEnumAnnotationValue) value).getValues()) {
					final String simpleName = elementType.getSimpleName();
					result.add(ElementType.valueOf(simpleName));
				}
				return result;
			}
		}
	}
	return emptySet();
}
 
Example #7
Source File: JvmModelCompleter.java    From xtext-extras with Eclipse Public License 2.0 6 votes vote down vote up
public void complete(JvmIdentifiableElement element) {
	if (element instanceof JvmGenericType) {
		completeJvmGenericType((JvmGenericType)element);
	}
	if (element instanceof JvmDeclaredType) {
		JvmDeclaredType declaredType = (JvmDeclaredType) element;
		complete(declaredType.getMembers());
	}
	if(element instanceof JvmConstructor) {
		completeJvmConstructor((JvmConstructor) element);
	}
	if (element instanceof JvmEnumerationType) {
		completeJvmEnumerationType((JvmEnumerationType)element);
	}
	if (element instanceof JvmEnumerationLiteral) {
		completeJvmEnumerationLiteral((JvmEnumerationLiteral)element);
	}
	if (element instanceof JvmAnnotationType) {
		completeJvmAnnotationType((JvmAnnotationType)element);
	}
}
 
Example #8
Source File: JdtBasedTypeFactory.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
private JvmAnnotationValue createEnumAnnotationValue(Object value) {
	JvmEnumAnnotationValue annotationValue = TypesFactory.eINSTANCE.createJvmEnumAnnotationValue();
	if (value != null) {
		InternalEList<JvmEnumerationLiteral> values = (InternalEList<JvmEnumerationLiteral>)annotationValue.getValues();
		if (value instanceof Object[]) {
			for (Object element : (Object[])value) {
				if (element instanceof IVariableBinding) {
					values.addUnique(createEnumLiteralProxy((IVariableBinding)element));
				}
			}
		} else if (value instanceof IVariableBinding) {
			values.addUnique(createEnumLiteralProxy((IVariableBinding)value));
		}
	}
	return annotationValue;
}
 
Example #9
Source File: FeatureKinds.java    From xtext-extras with Eclipse Public License 2.0 6 votes vote down vote up
public static String getTypeName(JvmIdentifiableElement feature) {
	if (feature instanceof JvmFormalParameter) {
		return "parameter";
	}
	if (feature instanceof XVariableDeclaration) {
		return "local variable";
	}
	if (feature instanceof JvmEnumerationLiteral) {
		return "enum literal";
	}
	if (feature instanceof JvmField) {
		return "field";
	}
	if (feature instanceof JvmOperation) {
		return "method";
	}
	if (feature instanceof JvmConstructor) {
		return "constructor";
	}
	if (feature instanceof JvmType) {
		return "type";
	}
	throw new IllegalStateException();
}
 
Example #10
Source File: ConstantExpressionsInterpreterTest.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void testEnumLiteral_WithStaticImport() {
  try {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("import static test.Enum1.* ");
    _builder.newLine();
    _builder.append("class C { ");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("Enum1 testFoo = RED");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    final XtendFile file = this.file(_builder.toString());
    final XtendField field = IterableExtensions.<XtendField>head(Iterables.<XtendField>filter(IterableExtensions.<XtendTypeDeclaration>head(file.getXtendTypes()).getMembers(), XtendField.class));
    Object _evaluate = this.interpreter.evaluate(field.getInitialValue(), field.getType());
    final JvmEnumerationLiteral blue = ((JvmEnumerationLiteral) _evaluate);
    Assert.assertEquals("RED", blue.getSimpleName());
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example #11
Source File: JvmModelTests.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void testEnumLiteralIsStatic() {
  try {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("enum Foo {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("BAR");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    JvmMember _head = IterableExtensions.<JvmMember>head(this._iXtendJvmAssociations.getInferredEnumerationType(this.enumeration(_builder.toString())).getMembers());
    final JvmEnumerationLiteral inferred = ((JvmEnumerationLiteral) _head);
    Assert.assertTrue(inferred.isStatic());
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example #12
Source File: XtendJvmModelInferrer.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
protected void transform(XtendEnumLiteral literal, JvmEnumerationType container) {
	if (literal.getName() == null)
		return;
	JvmEnumerationLiteral jvmLiteral = typesFactory.createJvmEnumerationLiteral();
	associator.associatePrimary(literal, jvmLiteral);
	jvmLiteral.setSimpleName(literal.getName());
	jvmLiteral.setVisibility(JvmVisibility.PUBLIC);
	jvmLiteral.setStatic(true);
	jvmLiteral.setFinal(true);
	jvmTypesBuilder.copyDocumentationTo(literal, jvmLiteral);
	for (XAnnotation anno : literal.getAnnotations()) {
		if (!annotationTranslationFilter.apply(anno))
			continue;
		JvmAnnotationReference annotationReference = jvmTypesBuilder.getJvmAnnotationReference(anno);
		if(annotationReference != null)
			jvmLiteral.getAnnotations().add(annotationReference);
	}
	container.getMembers().add(jvmLiteral);
}
 
Example #13
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 #14
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 #15
Source File: ReflectionTypeFactory.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
protected JvmEnumerationLiteral createEnumLiteralProxy(Enum<?> e) {
	JvmEnumerationLiteral enumLiteralProxy = TypesFactory.eINSTANCE.createJvmEnumerationLiteral();
	InternalEObject internalEObject = (InternalEObject) enumLiteralProxy;
	Class<?> type = e.getDeclaringClass();
	try {
		Field field = type.getDeclaredField(e.name());
		internalEObject.eSetProxyURI(uriHelper.getFullURI(field));
	} catch (Exception exception) {
		log.error(exception.getMessage(), exception);
		return null;
	}
	return enumLiteralProxy;
}
 
Example #16
Source File: Proxies.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
protected JvmEnumerationLiteral createEnumLiteral(String literalName, BinaryTypeSignature typeName) {
	JvmEnumerationLiteral enumLiteralProxy = TypesFactory.eINSTANCE.createJvmEnumerationLiteral();
	InternalEObject internalEObject = (InternalEObject) enumLiteralProxy;
	BinarySimpleMemberSignature fieldSignature = typeName.appendField(literalName);
	URI uri = fieldSignature.getURI();
	internalEObject.eSetProxyURI(uri);
	return enumLiteralProxy;
}
 
Example #17
Source File: JvmEnumerationTypeImpl.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 EList<JvmEnumerationLiteral> getLiterals()
{
	if (literals == null)
	{
		literals = new EObjectResolvingEList<JvmEnumerationLiteral>(JvmEnumerationLiteral.class, this, TypesPackage.JVM_ENUMERATION_TYPE__LITERALS);
	}
	return literals;
}
 
Example #18
Source File: JvmEnumAnnotationValueImpl.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 EList<JvmEnumerationLiteral> getValues()
{
	if (values == null)
	{
		values = new EObjectResolvingEList<JvmEnumerationLiteral>(JvmEnumerationLiteral.class, this, TypesPackage.JVM_ENUM_ANNOTATION_VALUE__VALUES);
	}
	return values;
}
 
Example #19
Source File: AbstractTypeProviderTest.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testEnumAnnotationValue_02() throws Exception {
	JvmEnumAnnotationValue value = (JvmEnumAnnotationValue) getConstructorParameterAnnotationValue("enumValue");
	assertEquals(1, value.getValues().size());
	JvmEnumerationLiteral enumLiteral = value.getValues().get(0);
	assertFalse(enumLiteral.eIsProxy());
	assertEquals(TestEnum.FirstValue.name(), enumLiteral.getSimpleName());
}
 
Example #20
Source File: JvmEnumAnnotationValueImpl.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_ENUM_ANNOTATION_VALUE__VALUES:
			getValues().clear();
			getValues().addAll((Collection<? extends JvmEnumerationLiteral>)newValue);
			return;
	}
	super.eSet(featureID, newValue);
}
 
Example #21
Source File: AbstractTypeProviderTest.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testEnum_03() throws Exception {
	String typeName = TestEnum.class.getName();
	JvmEnumerationType type = (JvmEnumerationType) getTypeProvider().findTypeByName(typeName);
	assertEquals(2, type.getLiterals().size());
	Set<String> expectedLiterals = Sets.newHashSet(TestEnum.FirstValue.name(), TestEnum.SecondValue.name());
	for (JvmEnumerationLiteral literal : type.getLiterals()) {
		assertTrue(expectedLiterals.remove(literal.getSimpleName()));
		assertSame(type, literal.getEnumType());
		assertEquals(JvmVisibility.PUBLIC, literal.getVisibility());
	}
	assertTrue(expectedLiterals.toString(), expectedLiterals.isEmpty());
}
 
Example #22
Source File: AbstractTypeProviderTest.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testNestedEnum_03() throws Exception {
	String typeName = TestEnum.Nested.class.getName();
	JvmEnumerationType type = (JvmEnumerationType) getTypeProvider().findTypeByName(typeName);
	assertEquals(1, type.getLiterals().size());
	Set<String> expectedLiterals = Sets.newHashSet(TestEnum.Nested.SINGLETON.name());
	for (JvmEnumerationLiteral literal : type.getLiterals()) {
		assertTrue(expectedLiterals.remove(literal.getSimpleName()));
		assertSame(type, literal.getEnumType());
		assertEquals(JvmVisibility.PUBLIC, literal.getVisibility());
	}
	assertTrue(expectedLiterals.toString(), expectedLiterals.isEmpty());
}
 
Example #23
Source File: AbstractTypeProviderTest.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testEnumAnnotationValue_01() throws Exception {
	JvmEnumAnnotationValue value = (JvmEnumAnnotationValue) getAnnotationValue("enumValue");
	assertEquals(1, value.getValues().size());
	JvmEnumerationLiteral enumLiteral = value.getValues().get(0);
	assertFalse(enumLiteral.eIsProxy());
	assertEquals(TestEnum.FirstValue.name(), enumLiteral.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 testNestedEnum_03() throws Exception {
	String typeName = TestEnum.Nested.class.getName();
	JvmEnumerationType type = (JvmEnumerationType) getTypeProvider().findTypeByName(typeName);
	assertEquals(1, type.getLiterals().size());
	Set<String> expectedLiterals = Sets.newHashSet(TestEnum.Nested.SINGLETON.name());
	for (JvmEnumerationLiteral literal : type.getLiterals()) {
		assertTrue(expectedLiterals.remove(literal.getSimpleName()));
		assertSame(type, literal.getEnumType());
		assertEquals(JvmVisibility.PUBLIC, literal.getVisibility());
	}
	assertTrue(expectedLiterals.toString(), expectedLiterals.isEmpty());
}
 
Example #25
Source File: AbstractTypeProviderTest.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testEnumAnnotationValue_03() throws Exception {
	JvmEnumAnnotationValue value = (JvmEnumAnnotationValue) getMethodParameterAnnotationValue("enumValue");
	assertEquals(1, value.getValues().size());
	JvmEnumerationLiteral enumLiteral = value.getValues().get(0);
	assertFalse(enumLiteral.eIsProxy());
	assertEquals(TestEnum.FirstValue.name(), enumLiteral.getSimpleName());
}
 
Example #26
Source File: AbstractTypeProviderTest.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testDefaultEnumAnnotationValue_01() throws Exception {
	JvmEnumAnnotationValue value = (JvmEnumAnnotationValue) getDefaultAnnotationValue("enumValue");
	assertEquals(1, value.getValues().size());
	JvmEnumerationLiteral literal = value.getValues().get(0);
	assertEquals("org.eclipse.xtext.common.types.testSetups.TestEnum.FirstValue", literal.getIdentifier());
}
 
Example #27
Source File: JvmEnumerationLiteralItemProvider.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * This returns the label text for the adapted class.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public String getText(Object object)
{
	String label = ((JvmEnumerationLiteral)object).getSimpleName();
	return label == null || label.length() == 0 ?
		getString("_UI_JvmEnumerationLiteral_type") :
		getString("_UI_JvmEnumerationLiteral_type") + " " + label;
}
 
Example #28
Source File: JdtBasedTypeFactory.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
protected JvmEnumerationLiteral createEnumLiteralProxy(/* @NonNull */ IVariableBinding binding) {
	JvmEnumerationLiteral proxy = enumerationLiteralProxies.get(binding);
	if (proxy == null) {
		proxy = TypesFactory.eINSTANCE.createJvmEnumerationLiteral();
		URI uri = uriHelper.getFullURI(binding);
		((InternalEObject)proxy).eSetProxyURI(uri);
		enumerationLiteralProxies.put(binding, proxy);
	}
	return proxy;
}
 
Example #29
Source File: ConstantExpressionsInterpreter.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
protected Class<?> getJavaType(final JvmType type, final ClassFinder classFinder) throws ClassNotFoundException {
  if ((type instanceof JvmArrayType)) {
    JvmType t = type;
    String dimensions = "";
    while ((t instanceof JvmArrayType)) {
      {
        dimensions = (dimensions + "[]");
        t = ((JvmArrayType)t).getComponentType();
      }
    }
    final Class<?> componentClass = this.getJavaType(t, classFinder);
    String _name = componentClass.getName();
    String _plus = (_name + dimensions);
    return classFinder.forName(_plus);
  }
  String _identifier = type.getIdentifier();
  boolean _equals = Objects.equal(_identifier, "java.lang.Class");
  if (_equals) {
    return JvmTypeReference.class;
  }
  if ((type instanceof JvmEnumerationType)) {
    return JvmEnumerationLiteral.class;
  }
  if ((type instanceof JvmAnnotationType)) {
    return XAnnotation.class;
  }
  return classFinder.forName(type.getIdentifier());
}
 
Example #30
Source File: MutableJvmEnumerationTypeDeclarationImpl.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public MutableEnumerationValueDeclaration addValue(final String name, final Procedure1<MutableEnumerationValueDeclaration> initializer) {
  this.checkMutable();
  ConditionUtils.checkJavaIdentifier(name, "name");
  Preconditions.checkArgument((initializer != null), "initializer cannot be null");
  final JvmEnumerationLiteral jvmLiteral = TypesFactory.eINSTANCE.createJvmEnumerationLiteral();
  jvmLiteral.setSimpleName(name);
  jvmLiteral.setVisibility(JvmVisibility.PUBLIC);
  this.getDelegate().getMembers().add(jvmLiteral);
  MemberDeclaration _memberDeclaration = this.getCompilationUnit().toMemberDeclaration(jvmLiteral);
  final MutableEnumerationValueDeclaration mutableEnumerationValueDeclaration = ((MutableEnumerationValueDeclaration) _memberDeclaration);
  initializer.apply(mutableEnumerationValueDeclaration);
  return mutableEnumerationValueDeclaration;
}