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


Java JvmGenericType类代码示例

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


JvmGenericType类属于org.eclipse.xtext.common.types包,在下文中一共展示了JvmGenericType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testMethods_publicStrictFpMethod_01

import org.eclipse.xtext.common.types.JvmGenericType; //导入依赖的package包/类
@Test
public void testMethods_publicStrictFpMethod_01() {
	String typeName = Methods.class.getName();
	JvmGenericType type = (JvmGenericType) getTypeProvider().findTypeByName(typeName);
	JvmOperation method = getMethodFromType(type, Methods.class, "publicStrictFpMethod()");
	assertSame(type, method.getDeclaringType());
	assertFalse(method.isAbstract());
	assertFalse(method.isFinal());
	assertFalse(method.isStatic());
	assertFalse(method.isSynchronized());
	assertTrue(method.isStrictFloatingPoint());
	assertFalse(method.isNative());
	assertEquals(JvmVisibility.PUBLIC, method.getVisibility());
	JvmType methodType = method.getReturnType().getType();
	assertEquals("void", methodType.getIdentifier());
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:17,代码来源:AbstractTypeProviderTest.java

示例2: testFindTypeByName_javaLangNumber_01

import org.eclipse.xtext.common.types.JvmGenericType; //导入依赖的package包/类
@Test
public void testFindTypeByName_javaLangNumber_01() {
	String typeName = Number.class.getName();
	JvmGenericType type = (JvmGenericType) getTypeProvider().findTypeByName(typeName);
	assertFalse("toplevel type is not static", type.isStatic());
	assertEquals(type.getSuperTypes().toString(), 2, type.getSuperTypes().size());
	JvmType objectType = type.getSuperTypes().get(0).getType();
	assertFalse("isProxy: " + objectType, objectType.eIsProxy());
	assertEquals(Object.class.getName(), objectType.getIdentifier());
	JvmType serializableType = type.getSuperTypes().get(1).getType();
	assertFalse("isProxy: " + serializableType, serializableType.eIsProxy());
	assertEquals(Serializable.class.getName(), serializableType.getIdentifier());
	diagnose(type);
	Resource resource = type.eResource();
	getAndResolveAllFragments(resource);
	recomputeAndCheckIdentifiers(resource);
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:18,代码来源:AbstractTypeProviderTest.java

示例3: testInterfaceCreation

import org.eclipse.xtext.common.types.JvmGenericType; //导入依赖的package包/类
@Test
public void testInterfaceCreation() {
  try {
    final XExpression e = this.expression("\'foo\'");
    final Procedure1<JvmGenericType> _function = (JvmGenericType it) -> {
      EList<JvmTypeReference> _superTypes = it.getSuperTypes();
      JvmTypeReference _typeRef = this._jvmTypeReferenceBuilder.typeRef(Iterable.class);
      this._jvmTypesBuilder.<JvmTypeReference>operator_add(_superTypes, _typeRef);
    };
    final JvmGenericType anno = this._jvmTypesBuilder.toInterface(e, "foo.bar.MyAnnotation", _function);
    Assert.assertTrue(anno.isInterface());
    Assert.assertEquals("foo.bar", anno.getPackageName());
    Assert.assertEquals("MyAnnotation", anno.getSimpleName());
    Assert.assertEquals(1, anno.getSuperTypes().size());
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:19,代码来源:JvmTypesBuilderTest.java

示例4: testFindTypeByName_javaUtilList_07

import org.eclipse.xtext.common.types.JvmGenericType; //导入依赖的package包/类
@Test
public void testFindTypeByName_javaUtilList_07() {
	String typeName = List.class.getName();
	JvmGenericType type = (JvmGenericType) getTypeProvider().findTypeByName(typeName);
	assertEquals(1, type.getSuperTypes().size());
	JvmParameterizedTypeReference superType = (JvmParameterizedTypeReference) type.getSuperTypes().get(0);
	assertFalse(superType.getType().eIsProxy());
	assertEquals("java.util.Collection<E>", superType.getIdentifier());
	assertEquals(1, type.getTypeParameters().size());
	JvmType rawType = superType.getType();
	assertFalse(rawType.eIsProxy());
	assertEquals(1, superType.getArguments().size());
	JvmTypeReference superTypeParameter = superType.getArguments().get(0);
	JvmType parameterType = superTypeParameter.getType();
	assertFalse(parameterType.eIsProxy());
	assertSame(parameterType, type.getTypeParameters().get(0));
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:18,代码来源:AbstractTypeProviderTest.java

示例5: getClosureBodyTypeComputationState

import org.eclipse.xtext.common.types.JvmGenericType; //导入依赖的package包/类
protected ITypeComputationState getClosureBodyTypeComputationState(ITypeAssigner typeAssigner) {
	ITypeComputationState result = assignParameters(typeAssigner);
	LightweightTypeReference expectedType = getExpectation().getExpectedType();
	if (expectedType == null) {
		throw new IllegalStateException();
	}
	JvmType knownType = expectedType.getType();
	if (knownType != null && knownType instanceof JvmGenericType) {
		result.assignType(IFeatureNames.SELF, knownType, expectedType);
	}
	List<JvmTypeReference> exceptions = operation.getExceptions();
	if (exceptions.isEmpty()) {
		result.withinScope(getClosure());
		return result;
	}
	List<LightweightTypeReference> expectedExceptions = Lists.newArrayListWithCapacity(exceptions.size());
	for (JvmTypeReference exception : exceptions) {
		expectedExceptions.add(typeAssigner.toLightweightTypeReference(exception));
	}
	result.withinScope(getClosure());
	return result.withExpectedExceptions(expectedExceptions);
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:23,代码来源:ClosureWithExpectationHelper.java

示例6: testFindTypeByName_AbstractMultimap_02

import org.eclipse.xtext.common.types.JvmGenericType; //导入依赖的package包/类
@Test
@Override
public void testFindTypeByName_AbstractMultimap_02() {
  String typeName = "com.google.common.collect.AbstractMultimap";
  JvmType _findTypeByName = this.getTypeProvider().findTypeByName(typeName);
  JvmGenericType type = ((JvmGenericType) _findTypeByName);
  JvmFeature _onlyElement = Iterables.<JvmFeature>getOnlyElement(type.findAllFeaturesByName("containsValue"));
  JvmOperation containsValue = ((JvmOperation) _onlyElement);
  Assert.assertNotNull(containsValue);
  JvmFormalParameter firstParam = containsValue.getParameters().get(0);
  Assert.assertEquals(1, firstParam.getAnnotations().size());
  JvmAnnotationReference annotationReference = firstParam.getAnnotations().get(0);
  JvmAnnotationType annotationType = annotationReference.getAnnotation();
  Assert.assertTrue(annotationType.eIsProxy());
  Assert.assertEquals("java:/Objects/javax.annotation.Nullable", EcoreUtil.getURI(annotationType).trimFragment().toString());
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:17,代码来源:ReusedTypeProviderTest.java

示例7: getAllLocalElements

import org.eclipse.xtext.common.types.JvmGenericType; //导入依赖的package包/类
@Override
protected List<IEObjectDescription> getAllLocalElements() {
	List<IEObjectDescription> result = super.getAllLocalElements();
	if (getSession().isInstanceContext() && !isExplicitStaticFeatureCall()) {
		ITypeReferenceOwner owner = getReceiverType().getOwner();
		QualifiedThisOrSuperDescription thisDescription = new QualifiedThisOrSuperDescription(THIS,
				owner.newParameterizedTypeReference(getTypeLiteral()), getBucket().getId(), true, getReceiver());
		addToList(thisDescription, result);
		JvmType receiverRawType = getTypeLiteral();
		if (receiverRawType instanceof JvmDeclaredType) {
			JvmType referencedType = receiverRawType;
			// If the receiver type is an interface, 'super' always refers to that interface
			if (!(receiverRawType instanceof JvmGenericType && ((JvmGenericType) receiverRawType).isInterface())) {
				JvmTypeReference superType = ((JvmDeclaredType) receiverRawType).getExtendedClass();
				if (superType != null) {
					referencedType = superType.getType();
				}
			}
			QualifiedThisOrSuperDescription superDescription = new QualifiedThisOrSuperDescription(SUPER,
					owner.newParameterizedTypeReference(referencedType), getBucket().getId(), true, getReceiver());
			addToList(superDescription, result);
		}
	}
	return result;
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:26,代码来源:StaticFeatureOnTypeLiteralScope.java

示例8: testImplements

import org.eclipse.xtext.common.types.JvmGenericType; //导入依赖的package包/类
@Test
public void testImplements() {
  try {
    final XExpression expression = this.expression("null", false);
    final Procedure1<JvmGenericType> _function = (JvmGenericType it) -> {
      it.setAbstract(true);
      EList<JvmTypeReference> _superTypes = it.getSuperTypes();
      JvmTypeReference _typeRef = this.typeRef(expression, Iterable.class, String.class);
      this.builder.<JvmTypeReference>operator_add(_superTypes, _typeRef);
    };
    final JvmGenericType clazz = this.builder.toClass(expression, "my.test.Foo", _function);
    final Class<?> compiled = this.compile(expression.eResource(), clazz);
    Assert.assertTrue(Iterable.class.isAssignableFrom(compiled));
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:18,代码来源:JvmModelGeneratorTest.java

示例9: testLinkToParameter

import org.eclipse.xtext.common.types.JvmGenericType; //导入依赖的package包/类
@Test
public void testLinkToParameter() {
  try {
    final XExpression expr = this.expression("x", false);
    final Resource resource = expr.eResource();
    resource.eSetDeliver(false);
    EList<EObject> _contents = resource.getContents();
    final Procedure1<JvmGenericType> _function = (JvmGenericType it) -> {
      EList<JvmMember> _members = it.getMembers();
      final Procedure1<JvmOperation> _function_1 = (JvmOperation it_1) -> {
        EList<JvmFormalParameter> _parameters = it_1.getParameters();
        JvmFormalParameter _parameter = this._jvmTypesBuilder.toParameter(expr, "x", this.stringType(expr));
        this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters, _parameter);
        this._jvmTypesBuilder.setBody(it_1, expr);
      };
      JvmOperation _method = this._jvmTypesBuilder.toMethod(expr, "doStuff", this.stringType(expr), _function_1);
      this._jvmTypesBuilder.<JvmOperation>operator_add(_members, _method);
    };
    JvmGenericType _class = this._jvmTypesBuilder.toClass(expr, "Foo", _function);
    this._jvmTypesBuilder.<JvmGenericType>operator_add(_contents, _class);
    this._validationTestHelper.assertNoErrors(expr);
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:26,代码来源:JvmModelBasedLinkingTest.java

示例10: getJavaLangObjectTypeRef

import org.eclipse.xtext.common.types.JvmGenericType; //导入依赖的package包/类
protected JvmTypeReference getJavaLangObjectTypeRef(JvmType rawType, TypesFactory typesFactory) {
	ResourceSet rs = EcoreUtil2.getResourceSet(rawType);
	JvmParameterizedTypeReference refToObject = typesFactory.createJvmParameterizedTypeReference();
	if (rs != null) {
		EObject javaLangObject = rs.getEObject(javaLangObjectURI, true);
		if (javaLangObject instanceof JvmType) {
			JvmType objectDeclaration = (JvmType) javaLangObject;
			refToObject.setType(objectDeclaration);
			return refToObject;
		}
	}
	JvmGenericType proxy = typesFactory.createJvmGenericType();
	((InternalEObject)proxy).eSetProxyURI(javaLangObjectURI);
	refToObject.setType(proxy);
	return refToObject;
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:17,代码来源:XFunctionTypeRefImplCustom.java

示例11: generateModifier

import org.eclipse.xtext.common.types.JvmGenericType; //导入依赖的package包/类
public ITreeAppendable generateModifier(final JvmMember it, final ITreeAppendable appendable, final GeneratorConfig config) {
  if (it instanceof JvmConstructor) {
    return _generateModifier((JvmConstructor)it, appendable, config);
  } else if (it instanceof JvmOperation) {
    return _generateModifier((JvmOperation)it, appendable, config);
  } else if (it instanceof JvmField) {
    return _generateModifier((JvmField)it, appendable, config);
  } else if (it instanceof JvmGenericType) {
    return _generateModifier((JvmGenericType)it, appendable, config);
  } else if (it instanceof JvmDeclaredType) {
    return _generateModifier((JvmDeclaredType)it, appendable, config);
  } else {
    throw new IllegalArgumentException("Unhandled parameter types: " +
      Arrays.<Object>asList(it, appendable, config).toString());
  }
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:17,代码来源:JvmModelGenerator.java

示例12: testBug377925No_Nullpointer

import org.eclipse.xtext.common.types.JvmGenericType; //导入依赖的package包/类
@Test
public void testBug377925No_Nullpointer() {
  try {
    final XExpression expression = this.expression("[Object o| null]");
    final Procedure1<JvmGenericType> _function = (JvmGenericType it) -> {
      EList<JvmMember> _members = it.getMembers();
      final Procedure1<JvmOperation> _function_1 = (JvmOperation it_1) -> {
        this.builder.setBody(it_1, expression);
      };
      JvmOperation _method = this.builder.toMethod(expression, "doStuff", this.references.getTypeForName("java.lang.Object", expression), _function_1);
      this.builder.<JvmOperation>operator_add(_members, _method);
    };
    final JvmGenericType clazz = this.builder.toClass(expression, "my.test.Foo", _function);
    this.compile(expression.eResource(), clazz);
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:19,代码来源:JvmModelGeneratorTest.java

示例13: getRootExpression

import org.eclipse.xtext.common.types.JvmGenericType; //导入依赖的package包/类
@Override
protected XExpression getRootExpression() {
	XExpression result = ((LogicalContainerAwareReentrantTypeResolver) getResolver()).getLogicalContainerProvider().getAssociatedExpression(getMember());
	if (result == null && member instanceof JvmFeature) {
		// make sure we process dangling local classes if the expression has been removed by an
		// active annotation
		// 
		// To some extend this is a workaround for a bug with #setBody which should
		// take care of local classes, too
		List<JvmGenericType> localClasses = ((JvmFeature) member).getLocalClasses();
		for(JvmGenericType localClass: localClasses) {
			LocalVariableCapturer.captureLocalVariables(localClass, this);
		}
	}
	return result;
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:17,代码来源:AbstractLogicalContainerAwareRootComputationState.java

示例14: testStubGeneration_02

import org.eclipse.xtext.common.types.JvmGenericType; //导入依赖的package包/类
@Test
public void testStubGeneration_02() {
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("public interface MyTest {");
  _builder.newLine();
  _builder.append("\t");
  _builder.append("public String helloWorld();");
  _builder.newLine();
  _builder.append("}");
  _builder.newLine();
  final Procedure1<IResourceDescription> _function = (IResourceDescription it) -> {
    Assert.assertEquals("MyTest", IterableExtensions.<IEObjectDescription>head(it.getExportedObjects()).getQualifiedName().toString());
    EObject _eObjectOrProxy = IterableExtensions.<IEObjectDescription>head(it.getExportedObjects()).getEObjectOrProxy();
    Assert.assertTrue(((JvmGenericType) _eObjectOrProxy).isInterface());
    Assert.assertEquals(1, IterableExtensions.size(it.getExportedObjects()));
  };
  this.resultsIn(_builder, _function);
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:19,代码来源:ResourceDescriptionProviderTest.java

示例15: test_ParameterizedTypes_Inner_08

import org.eclipse.xtext.common.types.JvmGenericType; //导入依赖的package包/类
@Test
public void test_ParameterizedTypes_Inner_08() {
	String typeName = ParameterizedTypes.Inner.class.getName();
	JvmGenericType type = (JvmGenericType) getTypeProvider().findTypeByName(typeName);
	JvmOperation methodV = getMethodFromType(type, ParameterizedTypes.Inner.class, "methodZArray_02()");
	JvmTypeReference listZ = methodV.getReturnType();
	assertEquals("java.util.List<Z[]>[]", listZ.getIdentifier());
	JvmParameterizedTypeReference listType = (JvmParameterizedTypeReference) ((JvmGenericArrayTypeReference) listZ)
			.getComponentType();
	assertEquals(1, listType.getArguments().size());
	JvmTypeReference typeArgument = listType.getArguments().get(0);
	JvmType argumentType = typeArgument.getType();
	assertTrue(argumentType instanceof JvmArrayType);
	JvmComponentType componentType = ((JvmArrayType) argumentType).getComponentType();
	JvmTypeParameter z = type.getTypeParameters().get(2);
	assertSame(z, componentType);
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:18,代码来源:AbstractTypeProviderTest.java


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