Java Code Examples for org.eclipse.xtext.common.types.JvmEnumerationType#getMembers()
The following examples show how to use
org.eclipse.xtext.common.types.JvmEnumerationType#getMembers() .
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: AbstractTypeProviderTest.java From xtext-extras with Eclipse Public License 2.0 | 6 votes |
@Test public void testEnum_04() throws Exception { String typeName = TestEnum.class.getName(); JvmEnumerationType type = (JvmEnumerationType) getTypeProvider().findTypeByName(typeName); List<JvmMember> members = type.getMembers(); boolean constructorFound = false; for (JvmMember member : members) { if (member instanceof JvmConstructor) { assertFalse(constructorFound); constructorFound = true; List<JvmFormalParameter> parameters = ((JvmConstructor) member).getParameters(); assertEquals(1, parameters.size()); // synthetic parameters are not returned } } assertTrue(constructorFound); }
Example 2
Source File: AbstractTypeProviderTest.java From xtext-extras with Eclipse Public License 2.0 | 6 votes |
@Test public void testNestedEnum_04() throws Exception { String typeName = TestEnum.Nested.class.getName(); JvmEnumerationType type = (JvmEnumerationType) getTypeProvider().findTypeByName(typeName); List<JvmMember> members = type.getMembers(); boolean constructorFound = false; for (JvmMember member : members) { if (member instanceof JvmConstructor) { assertFalse(constructorFound); constructorFound = true; List<JvmFormalParameter> parameters = ((JvmConstructor) member).getParameters(); assertEquals(0, parameters.size()); // synthetic parameters are not returned } } assertTrue(constructorFound); }
Example 3
Source File: AbstractTypeProviderTest.java From xtext-extras with Eclipse Public License 2.0 | 6 votes |
@Test public void testEnum_04() throws Exception { String typeName = TestEnum.class.getName(); JvmEnumerationType type = (JvmEnumerationType) getTypeProvider().findTypeByName(typeName); List<JvmMember> members = type.getMembers(); boolean constructorFound = false; for (JvmMember member : members) { if (member instanceof JvmConstructor) { assertFalse(constructorFound); constructorFound = true; List<JvmFormalParameter> parameters = ((JvmConstructor) member).getParameters(); assertEquals(1, parameters.size()); // synthetic parameters are not returned } } assertTrue(constructorFound); }
Example 4
Source File: AbstractTypeProviderTest.java From xtext-extras with Eclipse Public License 2.0 | 6 votes |
@Test public void testNestedEnum_04() throws Exception { String typeName = TestEnum.Nested.class.getName(); JvmEnumerationType type = (JvmEnumerationType) getTypeProvider().findTypeByName(typeName); List<JvmMember> members = type.getMembers(); boolean constructorFound = false; for (JvmMember member : members) { if (member instanceof JvmConstructor) { assertFalse(constructorFound); constructorFound = true; List<JvmFormalParameter> parameters = ((JvmConstructor) member).getParameters(); assertEquals(0, parameters.size()); // synthetic parameters are not returned } } assertTrue(constructorFound); }
Example 5
Source File: JvmModelGeneratorTest.java From xtext-extras with Eclipse Public License 2.0 | 6 votes |
@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 6
Source File: AbstractTypeProviderTest.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
@Test public void testEnum_04() throws Exception { String typeName = TestEnum.class.getName(); JvmEnumerationType type = (JvmEnumerationType) getTypeProvider().findTypeByName(typeName); List<JvmMember> members = type.getMembers(); boolean constructorFound = false; for (JvmMember member : members) { if (member instanceof JvmConstructor) { assertFalse(constructorFound); constructorFound = true; List<JvmFormalParameter> parameters = ((JvmConstructor) member).getParameters(); assertEquals(1, parameters.size()); // synthetic parameters are not returned } } assertTrue(constructorFound); }
Example 7
Source File: AbstractTypeProviderTest.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
@Test public void testNestedEnum_04() throws Exception { String typeName = TestEnum.Nested.class.getName(); JvmEnumerationType type = (JvmEnumerationType) getTypeProvider().findTypeByName(typeName); List<JvmMember> members = type.getMembers(); boolean constructorFound = false; for (JvmMember member : members) { if (member instanceof JvmConstructor) { assertFalse(constructorFound); constructorFound = true; List<JvmFormalParameter> parameters = ((JvmConstructor) member).getParameters(); assertEquals(0, parameters.size()); // synthetic parameters are not returned } } assertTrue(constructorFound); }
Example 8
Source File: AbstractJdtTypeProviderTest.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
protected void doTestEnum_07(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); }