private Iterable<JvmEnumerationLiteral> getEnumLiterals(final Iterable<XImportDeclaration> imports) { final Function1<XImportDeclaration, JvmEnumerationType> _function = (XImportDeclaration it) -> { JvmDeclaredType _importedType = it.getImportedType(); return ((JvmEnumerationType) _importedType); }; final Function1<JvmEnumerationType, EList<JvmEnumerationLiteral>> _function_1 = (JvmEnumerationType it) -> { return it.getLiterals(); }; return Iterables.<JvmEnumerationLiteral>concat(IterableExtensions.<JvmEnumerationType, EList<JvmEnumerationLiteral>>map(IterableExtensions.<XImportDeclaration, JvmEnumerationType>map(imports, _function), _function_1)); } }
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; }
protected Iterable<JvmMember> _getMembersToBeCompiled(final JvmEnumerationType type) { Iterable<JvmMember> _xblockexpression = null; { String _identifier = type.getIdentifier(); String _plus = (_identifier + "."); String _plus_1 = (_plus + "valueOf(java.lang.String)"); String _identifier_1 = type.getIdentifier(); String _plus_2 = (_identifier_1 + "."); String _plus_3 = (_plus_2 + "values()"); final Set<String> syntheticEnumMethods = Collections.<String>unmodifiableSet(CollectionLiterals.<String>newHashSet(_plus_1, _plus_3)); final Function1<JvmMember, Boolean> _function = (JvmMember it) -> { return Boolean.valueOf((!((it instanceof JvmOperation) && syntheticEnumMethods.contains(it.getIdentifier())))); }; _xblockexpression = IterableExtensions.<JvmMember>filter(type.getMembers(), _function); } return _xblockexpression; }
/** * Creates a public enum declaration, associated to the given sourceElement. It sets the given name, which might be * fully qualified using the standard Java notation. * * @param sourceElement * the sourceElement the resulting element is associated with. * @param name * the qualified name of the resulting enum type. * @param initializer * the initializer to apply on the created enumeration type. If <code>null</code>, the enum won't be initialized. * * @return a result representing a Java enum type with the given name, <code>null</code> * if sourceElement or name are <code>null</code>. */ /* @Nullable */ public JvmEnumerationType toEnumerationType(/* @Nullable */ EObject sourceElement, /* @Nullable */ String name, /* @Nullable */ Procedure1<? super JvmEnumerationType> initializer) { if (sourceElement == null || name == null) return null; Pair<String, String> fullName = splitQualifiedName(name); JvmEnumerationType result = typesFactory.createJvmEnumerationType(); result.setSimpleName(fullName.getSecond()); result.setVisibility(JvmVisibility.PUBLIC); if (fullName.getFirst() != null) result.setPackageName(fullName.getFirst()); associate(sourceElement, result); return initializeSafely(result, initializer); }
this.generateAnnotations(it.getAnnotations(), childAppendable, true, config); this.generateModifier(it, childAppendable, config); childAppendable.append("enum "); this._treeAppendableUtil.traceSignificant(childAppendable, it).append(this.makeJavaIdentifier(it.getSimpleName())); childAppendable.append(" "); this.generateExtendsClause(it, childAppendable, config); this.generateEnumLiteral(it_1, childAppendable.trace(it_1), config); }; this._loopExtensions.<JvmEnumerationLiteral>forEach(childAppendable, it.getLiterals(), _function, _function_1); final Function1<JvmMember, Boolean> _function_2 = (JvmMember it_1) -> { return Boolean.valueOf((!(it_1 instanceof JvmEnumerationLiteral))); childAppendable.decreaseIndentation().newLine().append("}"); ITreeAppendable _xifexpression = null; EObject _eContainer = it.eContainer(); boolean _not = (!(_eContainer instanceof JvmType)); if (_not) {
List<String> expectedEnumerationLiterals = toList(map(enumerationType.getLiterals(), new Functions.Function1<JvmEnumerationLiteral, String>() { else builder.append(" need corresponding case labels in this enum switch on "); builder.append(enumerationType.getQualifiedName()); String message = builder.toString(); addIssue(message, switchExpression.getSwitch(), null, IssueCodes.INCOMPLETE_CASES_ON_ENUM, expectedEnumerationLiterals.toArray(new String[0]));
protected void initialize(XtendEnum source, JvmEnumerationType inferredJvmType) { inferredJvmType.setVisibility(source.getVisibility()); inferredJvmType.setStatic(source.isStatic() && !isTopLevel(source)); translateAnnotationsTo(source.getAnnotations(), inferredJvmType); for (XtendMember member : source.getMembers()) { if (member instanceof XtendEnumLiteral) transform((XtendEnumLiteral) member, inferredJvmType); } jvmTypesBuilder.copyDocumentationTo(source, inferredJvmType); }
protected void completeJvmEnumerationType(JvmEnumerationType element) { if (element.getSuperTypes().isEmpty()) { JvmTypeReference objectType = references.getTypeForName(Enum.class, element, references.createTypeRef(element)); if (objectType != null) element.getSuperTypes().add(objectType); associator.associate(primarySourceElement, values); element.getMembers().add(values); associator.associate(primarySourceElement, valueOf); element.getMembers().add(valueOf);
@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; } }
@Override public void registerEnumerationType(final String qualifiedName) throws IllegalArgumentException { final JvmEnumerationType newType = TypesFactory.eINSTANCE.createJvmEnumerationType(); newType.setVisibility(JvmVisibility.PUBLIC); this.setNameAndAccept(newType, qualifiedName); }
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); }
public Iterable<String> getEnumValues(final JvmTypeReference reference) { JvmType _type = reference.getType(); final JvmEnumerationType enumType = ((JvmEnumerationType) _type); final Function1<JvmEnumerationLiteral, String> _function = (JvmEnumerationLiteral it) -> { return it.getSimpleName(); }; return ListExtensions.<JvmEnumerationLiteral, String>map(enumType.getLiterals(), _function); }
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; }
return Boolean.valueOf(Objects.equal(_simpleName, sourceValue)); }; return IterableExtensions.<JvmEnumerationLiteral>exists(enumType.getLiterals(), _function);
return Boolean.valueOf(Objects.equal(_simpleName, featureName)); }; final JvmEnumerationLiteral enumValue = IterableExtensions.<JvmEnumerationLiteral>findFirst(((JvmEnumerationType)type).getLiterals(), _function); if ((enumValue == null)) { String _simpleName = ((JvmTypeReference)receiver).getSimpleName();
copy.put(it_2.getSimpleName(), it_2); }; enumType.getLiterals().forEach(_function); _xblockexpression = copy;
Set<JvmEnumerationLiteral> uncheckedEnumLiterals = null; if (isEnum) { uncheckedEnumLiterals = new HashSet<JvmEnumerationLiteral>(((JvmEnumerationType) potentialEnumType).getLiterals());
if (type instanceof JvmEnumerationType) { _matched_2=true; EList<JvmEnumerationLiteral> _literals = ((JvmEnumerationType)type).getLiterals(); for (final JvmEnumerationLiteral feature : _literals) { result.put(feature.getSimpleName(), feature);