本文整理汇总了Java中org.eclipse.xtext.common.types.JvmTypeReference.getType方法的典型用法代码示例。如果您正苦于以下问题:Java JvmTypeReference.getType方法的具体用法?Java JvmTypeReference.getType怎么用?Java JvmTypeReference.getType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.xtext.common.types.JvmTypeReference
的用法示例。
在下文中一共展示了JvmTypeReference.getType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testFindTypeByName_javaUtilList_07
import org.eclipse.xtext.common.types.JvmTypeReference; //导入方法依赖的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));
}
示例2: test_ParameterizedTypes_Inner_07
import org.eclipse.xtext.common.types.JvmTypeReference; //导入方法依赖的package包/类
@Test
public void test_ParameterizedTypes_Inner_07() {
String typeName = ParameterizedTypes.Inner.class.getName();
JvmGenericType type = (JvmGenericType) getTypeProvider().findTypeByName(typeName);
JvmOperation methodV = getMethodFromType(type, ParameterizedTypes.Inner.class, "methodZArray_01()");
JvmTypeReference listZ = methodV.getReturnType();
assertEquals("java.util.List<Z[][]>", listZ.getIdentifier());
JvmParameterizedTypeReference listType = (JvmParameterizedTypeReference) listZ;
assertEquals(1, listType.getArguments().size());
JvmTypeReference typeArgument = listType.getArguments().get(0);
JvmType argumentType = typeArgument.getType();
assertTrue(argumentType instanceof JvmArrayType);
assertTrue(((JvmArrayType) argumentType).getComponentType() instanceof JvmArrayType);
JvmComponentType componentType = ((JvmArrayType) ((JvmArrayType) argumentType).getComponentType())
.getComponentType();
JvmTypeParameter z = type.getTypeParameters().get(2);
assertSame(z, componentType);
}
示例3: getSuperTypeByName
import org.eclipse.xtext.common.types.JvmTypeReference; //导入方法依赖的package包/类
private LightweightTypeReference getSuperTypeByName(String typeName, boolean interfaceType) {
JvmTypeReference superType = getSuperTypeByName(typeName, interfaceType, type, new RecursionGuard<JvmType>());
if (superType != null) {
JvmType rawType = superType.getType();
if (isRawType()) {
return createRawTypeReference(rawType);
}
if (superType.eClass() == TypesPackage.Literals.JVM_PARAMETERIZED_TYPE_REFERENCE) {
if (((JvmParameterizedTypeReference) superType).getArguments().isEmpty()) {
return getOwner().newParameterizedTypeReference(rawType);
}
}
LightweightTypeReference unresolved = getOwner().toLightweightTypeReference(rawType);
TypeParameterSubstitutor<?> substitutor = createSubstitutor();
LightweightTypeReference result = substitutor.substitute(unresolved);
return result;
}
return null;
}
示例4: checkContextTypeIsEClass
import org.eclipse.xtext.common.types.JvmTypeReference; //导入方法依赖的package包/类
/**
* Checks that a context's context type is an EClass.
*
* @param context
* the context
*/
@Check
public void checkContextTypeIsEClass(final ContextVariable context) {
final JvmTypeReference contextType = context.getType();
if (contextType == null) {
// Check only applicable if context type has been defined
return;
}
JvmType type = contextType.getType();
try {
if (type != null && !EObject.class.isAssignableFrom(Class.forName(type.getIdentifier()))) {
error(Messages.CheckJavaValidator_CONTEXT_TYPE_IS_ECLASS, context, CheckPackage.Literals.CONTEXT_VARIABLE__TYPE, IssueCodes.CONTEXT_TYPE_IS_ECLASS);
}
// CHECKSTYLE:OFF
} catch (ClassNotFoundException e) {
// CHECKSTYLE:ON
}
}
示例5: getType
import org.eclipse.xtext.common.types.JvmTypeReference; //导入方法依赖的package包/类
@Override
public JvmType getType() {
JvmTypeReference resolvedEquivalent = getEquivalent();
if (resolvedEquivalent != null)
return resolvedEquivalent.getType();
return null;
}
示例6: test_arrayParameterized_02
import org.eclipse.xtext.common.types.JvmTypeReference; //导入方法依赖的package包/类
@Test
public void test_arrayParameterized_02() {
JvmOperation arrayParameterized = getMethodFromParameterizedMethods("arrayParameterized(java.util.List[])");
JvmTypeReference paramType = arrayParameterized.getParameters().get(0).getParameterType();
assertEquals("java.util.List<T>[]", paramType.getIdentifier());
assertTrue(paramType.getType() instanceof JvmArrayType);
JvmArrayType arrayType = (JvmArrayType) paramType.getType();
assertTrue(arrayType.getComponentType() instanceof JvmDeclaredType);
assertTrue(paramType instanceof JvmGenericArrayTypeReference);
assertTrue(
((JvmGenericArrayTypeReference) paramType).getComponentType() instanceof JvmParameterizedTypeReference);
}
示例7: getType
import org.eclipse.xtext.common.types.JvmTypeReference; //导入方法依赖的package包/类
@Override
public JvmType getType() {
JvmTypeReference resolvedDelegate = getDelegate();
if (resolvedDelegate == null || resolvedDelegate.eIsProxy())
return null;
return resolvedDelegate.getType();
}
示例8: isLikelyAValidConstraintBound
import org.eclipse.xtext.common.types.JvmTypeReference; //导入方法依赖的package包/类
/**
* Constraint bounds are definitely invalid if they are <code>not null</code> and point to a primitive type.
* {@link JvmSpecializedTypeReference} will not be resolved by this check thus they may lead to finally
* invalid constraint bounds.
*
* @param constraintBound the reference that shall be come the new constraint.
* @return <code>false</code> if the given constraint is definitely invalid.
*/
protected boolean isLikelyAValidConstraintBound(JvmTypeReference constraintBound) {
if (constraintBound == null)
return true;
if (constraintBound instanceof JvmSpecializedTypeReference) {
JvmTypeReference equivalent = (JvmTypeReference) constraintBound.eGet(TypesPackage.Literals.JVM_SPECIALIZED_TYPE_REFERENCE__EQUIVALENT, false);
if (equivalent != null) {
return isLikelyAValidConstraintBound(equivalent);
}
return true;
}
boolean invalid = (constraintBound.getType() instanceof JvmPrimitiveType
|| (constraintBound.getType() instanceof JvmVoid && !constraintBound.getType().eIsProxy()));
return !invalid;
}
示例9: getType
import org.eclipse.xtext.common.types.JvmTypeReference; //导入方法依赖的package包/类
@Override
public JvmArrayType getType() {
JvmTypeReference componentTypeReference = getComponentType();
if (componentTypeReference != null) {
JvmType componentType = componentTypeReference.getType();
if (componentType instanceof JvmComponentType) {
JvmArrayType result = ((JvmComponentType) componentType).getArrayType();
return result;
}
}
return null;
}
示例10: isMatchesSignature
import org.eclipse.xtext.common.types.JvmTypeReference; //导入方法依赖的package包/类
protected boolean isMatchesSignature(JvmFormalParameter parameter, JvmFormalParameter candidateParameter, TypeParameterSubstitutor<?> substitutor, ITypeReferenceOwner owner) {
JvmTypeReference parameterType = parameter.getParameterType();
if (parameterType == null || parameterType.getType() == null) {
return false;
}
String identifier = parameterType.getIdentifier();
LightweightTypeReference candidateParameterType = substitutor.substitute(owner.toLightweightTypeReference(candidateParameter.getParameterType()));
return identifier.equals(candidateParameterType.getJavaIdentifier());
}
示例11: getParameterType
import org.eclipse.xtext.common.types.JvmTypeReference; //导入方法依赖的package包/类
protected LightweightTypeReference getParameterType(JvmFormalParameter p) {
JvmTypeReference parameterType = p.getParameterType();
JvmType type = parameterType.getType();
if (type == null)
return null;
return owner.toPlainTypeReference(type).getRawTypeReference();
}
示例12: getDeclaredTypeParameters
import org.eclipse.xtext.common.types.JvmTypeReference; //导入方法依赖的package包/类
@Override
protected List<JvmTypeParameter> getDeclaredTypeParameters() {
if (isAnonymousClassConstructorCall()) {
JvmDeclaredType anonymousType = getConstructor().getDeclaringType();
JvmTypeReference superType = Iterables.getLast(anonymousType.getSuperTypes());
JvmType rawSuperType = superType.getType();
if (rawSuperType instanceof JvmTypeParameterDeclarator) {
return ((JvmTypeParameterDeclarator) rawSuperType).getTypeParameters();
}
return Collections.emptyList();
}
return new FeatureLinkHelper().getDeclaredTypeParameters(getConstructor());
}
示例13: addThisAndSuper
import org.eclipse.xtext.common.types.JvmTypeReference; //导入方法依赖的package包/类
protected IFeatureScopeSession addThisAndSuper(
IFeatureScopeSession session,
ITypeReferenceOwner owner,
JvmDeclaredType thisType,
/* @Nullable */ JvmTypeReference superType,
boolean addNestedTypes) {
IFeatureScopeSession childSession = session;
if (thisType.eContainer() != null) {
if (thisType.isStatic()) {
childSession = childSession.dropLocalElements();
} else {
childSession = childSession.captureLocalElements();
}
}
if (superType != null && superType.getType() != null) {
ImmutableMap.Builder<QualifiedName, JvmIdentifiableElement> builder = ImmutableMap.builder();
builder.put(IFeatureNames.THIS, thisType);
builder.put(IFeatureNames.SUPER, superType.getType());
childSession = childSession.addLocalElements(builder.build(), owner);
} else {
childSession = childSession.addLocalElement(IFeatureNames.THIS, thisType, owner);
}
childSession = addThisTypeToStaticScope(childSession, thisType);
if (addNestedTypes)
childSession = childSession.addNestedTypesToScope(thisType);
return childSession;
}
示例14: isRawType
import org.eclipse.xtext.common.types.JvmTypeReference; //导入方法依赖的package包/类
private boolean isRawType(JvmTypeParameter current, RecursionGuard<JvmTypeParameter> guard) {
if (guard.tryNext(current)) {
List<JvmTypeConstraint> constraints = current.getConstraints();
for(int i = 0, size = constraints.size(); i < size; i++) {
JvmTypeConstraint constraint = constraints.get(i);
if (constraint.eClass() == TypesPackage.Literals.JVM_UPPER_BOUND && constraint.getTypeReference() != null) {
JvmTypeReference superType = constraint.getTypeReference();
JvmType rawSuperType = superType.getType();
if (rawSuperType != null) {
if (rawSuperType.eClass() == TypesPackage.Literals.JVM_TYPE_PARAMETER) {
if (isRawType((JvmTypeParameter) rawSuperType, guard)) {
return true;
}
}
if (rawSuperType.eClass() == TypesPackage.Literals.JVM_GENERIC_TYPE) {
if (!((JvmGenericType) rawSuperType).getTypeParameters().isEmpty()) {
if (superType.eClass() == TypesPackage.Literals.JVM_PARAMETERIZED_TYPE_REFERENCE) {
JvmParameterizedTypeReference casted = (JvmParameterizedTypeReference) superType;
if (casted.getArguments().isEmpty()) {
return true;
}
}
}
}
}
}
}
}
return false;
}
示例15: isWrapper
import org.eclipse.xtext.common.types.JvmTypeReference; //导入方法依赖的package包/类
private boolean isWrapper(JvmTypeParameter typeParameter, /* @Nullable */ RecursionGuard<JvmTypeParameter> stack) {
for(JvmTypeConstraint constraint: typeParameter.getConstraints()) {
if (constraint.eClass() == TypesPackage.Literals.JVM_UPPER_BOUND) {
JvmTypeReference upperBound = constraint.getTypeReference();
if (upperBound != null) {
JvmType upperBoundType = upperBound.getType();
if (upperBoundType == null) {
return false;
}
if (upperBoundType.eClass() == TypesPackage.Literals.JVM_GENERIC_TYPE) {
return isWrapper((JvmGenericType)upperBoundType);
}
// guard against recursive deps
if (upperBoundType.eClass() == TypesPackage.Literals.JVM_TYPE_PARAMETER) {
if (typeParameter == upperBoundType || stack != null && !stack.tryNext((JvmTypeParameter) upperBoundType)) {
return false;
}
if (stack == null) {
stack = new RecursionGuard<JvmTypeParameter>();
stack.tryNext(typeParameter);
stack.tryNext((JvmTypeParameter) upperBoundType);
}
return isWrapper((JvmTypeParameter) upperBoundType, stack);
}
}
}
}
return false;
}