当前位置: 首页>>代码示例>>Java>>正文


Java JvmEnumerationType.getMembers方法代码示例

本文整理汇总了Java中org.eclipse.xtext.common.types.JvmEnumerationType.getMembers方法的典型用法代码示例。如果您正苦于以下问题:Java JvmEnumerationType.getMembers方法的具体用法?Java JvmEnumerationType.getMembers怎么用?Java JvmEnumerationType.getMembers使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.xtext.common.types.JvmEnumerationType的用法示例。


在下文中一共展示了JvmEnumerationType.getMembers方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testEnum_04

import org.eclipse.xtext.common.types.JvmEnumerationType; //导入方法依赖的package包/类
@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);
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:17,代码来源:AbstractTypeProviderTest.java

示例2: testNestedEnum_04

import org.eclipse.xtext.common.types.JvmEnumerationType; //导入方法依赖的package包/类
@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);
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:17,代码来源:AbstractTypeProviderTest.java

示例3: testEnumerationWithCompleter

import org.eclipse.xtext.common.types.JvmEnumerationType; //导入方法依赖的package包/类
@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);
  }
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:26,代码来源:JvmModelGeneratorTest.java


注:本文中的org.eclipse.xtext.common.types.JvmEnumerationType.getMembers方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。