protected void doTestEnum_05(String paramName) throws Exception { String typeName = TestEnum.class.getName(); JvmEnumerationType type = (JvmEnumerationType) getTypeProvider().findTypeByName(typeName); boolean constructorSeen = false; for (JvmMember member : type.getMembers()) { if (member instanceof JvmConstructor) { constructorSeen = true; List<JvmFormalParameter> parameters = ((JvmConstructor) member).getParameters(); assertEquals(1, parameters.size()); JvmFormalParameter singleParam = parameters.get(0); assertEquals(paramName, singleParam.getName()); } } assertTrue("constructorSeen", constructorSeen); }
private IScope getEnumerationLiteralsScopeForShape(JvmGenericType type, String className) { JvmEnumerationType enumType = null; for (JvmMember member : type.getMembers()) { if (member.getSimpleName().equals(className)) { enumType = (JvmEnumerationType) member; } } List<IEObjectDescription> descrList = new ArrayList<IEObjectDescription>(); if (enumType != null) { for (JvmEnumerationLiteral literal : enumType.getLiterals()) { IEObjectDescription description = EObjectDescription.create(literal.getSimpleName(), literal, null); descrList.add(description); } } return MapBasedScope.createScope(IScope.NULLSCOPE, descrList); }
@Test public void testEnumArtificialMethods() { try { StringConcatenation _builder = new StringConcatenation(); _builder.append("package bar"); _builder.newLine(); _builder.newLine(); _builder.append("enum Foo {"); _builder.newLine(); _builder.append("}"); _builder.newLine(); String _string = _builder.toString(); XtendEnum _enumeration = this.enumeration(_string); JvmEnumerationType _inferredEnumerationType = this._iXtendJvmAssociations.getInferredEnumerationType(_enumeration); final EList<JvmMember> inferred = _inferredEnumerationType.getMembers(); int _size = inferred.size(); Assert.assertEquals(2, _size); JvmMember _get = inferred.get(0); final JvmOperation values = ((JvmOperation) _get); String _identifier = values.getIdentifier(); Assert.assertEquals("bar.Foo.values()", _identifier); boolean _isStatic = values.isStatic(); Assert.assertTrue(_isStatic); JvmVisibility _visibility = values.getVisibility(); Assert.assertEquals(JvmVisibility.PUBLIC, _visibility); JvmMember _get_1 = inferred.get(1); final JvmOperation valueOf = ((JvmOperation) _get_1); String _identifier_1 = valueOf.getIdentifier(); Assert.assertEquals("bar.Foo.valueOf(java.lang.String)", _identifier_1); boolean _isStatic_1 = valueOf.isStatic(); Assert.assertTrue(_isStatic_1); JvmVisibility _visibility_1 = valueOf.getVisibility(); Assert.assertEquals(JvmVisibility.PUBLIC, _visibility_1); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
@Test public void testEnumImplicitSuperType() { try { StringConcatenation _builder = new StringConcatenation(); _builder.append("enum Foo {"); _builder.newLine(); _builder.append("}"); _builder.newLine(); String _string = _builder.toString(); XtendEnum _enumeration = this.enumeration(_string); final JvmEnumerationType inferred = this._iXtendJvmAssociations.getInferredEnumerationType(_enumeration); EList<JvmTypeReference> _superTypes = inferred.getSuperTypes(); int _size = _superTypes.size(); Assert.assertEquals(1, _size); EList<JvmTypeReference> _superTypes_1 = inferred.getSuperTypes(); JvmTypeReference _head = IterableExtensions.<JvmTypeReference>head(_superTypes_1); String _identifier = _head.getIdentifier(); Assert.assertEquals("java.lang.Enum<Foo>", _identifier); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
@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(); String _string = _builder.toString(); XtendEnum _enumeration = this.enumeration(_string); JvmEnumerationType _inferredEnumerationType = this._iXtendJvmAssociations.getInferredEnumerationType(_enumeration); EList<JvmMember> _members = _inferredEnumerationType.getMembers(); JvmMember _head = IterableExtensions.<JvmMember>head(_members); final JvmEnumerationLiteral inferred = ((JvmEnumerationLiteral) _head); boolean _isStatic = inferred.isStatic(); Assert.assertTrue(_isStatic); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }