Java 类org.eclipse.xtext.common.types.JvmWildcardTypeReference 实例源码

项目:xtext-extras    文件:AbstractTypeProviderTest.java   
@Test
public void test_twoListWildcardsNoResult_03() {
    JvmOperation twoListWildcardsNoResult = getMethodFromParameterizedMethods(
            "twoListWildcardsNoResult(java.util.List,java.util.List)");
    JvmFormalParameter firstParam = twoListWildcardsNoResult.getParameters().get(0);
    JvmTypeReference paramType = firstParam.getParameterType();
    JvmParameterizedTypeReference parameterized = (JvmParameterizedTypeReference) paramType;
    assertEquals(1, parameterized.getArguments().size());
    JvmTypeReference typeParameter = parameterized.getArguments().get(0);
    assertTrue(typeParameter instanceof JvmWildcardTypeReference);
    JvmWildcardTypeReference wildcard = (JvmWildcardTypeReference) typeParameter;
    assertEquals(1, wildcard.getConstraints().size());
    assertTrue(wildcard.getConstraints().get(0) instanceof JvmUpperBound);
    JvmUpperBound upperBound = (JvmUpperBound) wildcard.getConstraints().get(0);
    assertNotNull(upperBound.getTypeReference());
    JvmType upperBoundType = upperBound.getTypeReference().getType();
    assertFalse(upperBoundType.eIsProxy());
    assertEquals("java.lang.Object", upperBoundType.getIdentifier());
}
项目:xtext-extras    文件:AbstractTypeProviderTest.java   
@Test
public void test_twoListWildcardsListResult_03() {
    JvmOperation twoListWildcardsListResult = getMethodFromParameterizedMethods(
            "twoListWildcardsListResult(java.util.List,java.util.List)");
    JvmTypeReference returnType = twoListWildcardsListResult.getReturnType();
    JvmParameterizedTypeReference parameterized = (JvmParameterizedTypeReference) returnType;
    assertEquals(1, parameterized.getArguments().size());
    JvmTypeReference typeParameter = parameterized.getArguments().get(0);
    assertTrue(typeParameter instanceof JvmWildcardTypeReference);
    JvmWildcardTypeReference wildcard = (JvmWildcardTypeReference) typeParameter;
    assertEquals(1, wildcard.getConstraints().size());
    assertTrue(wildcard.getConstraints().get(0) instanceof JvmUpperBound);
    JvmUpperBound upperBound = (JvmUpperBound) wildcard.getConstraints().get(0);
    assertNotNull(upperBound.getTypeReference());
    JvmType upperBoundType = upperBound.getTypeReference().getType();
    assertFalse(upperBoundType.eIsProxy());
    assertEquals("java.lang.Object", upperBoundType.getIdentifier());
}
项目:xtext-extras    文件:AbstractTypeProviderTest.java   
@Test
public void test_ParameterizedTypes_02() {
    String typeName = ParameterizedTypes.class.getName();
    JvmGenericType type = (JvmGenericType) getTypeProvider().findTypeByName(typeName);
    JvmOperation methodS = getMethodFromType(type, ParameterizedTypes.class, "methodS(S)");
    JvmTypeReference listS = methodS.getReturnType();
    assertFalse(listS.toString(), listS.eIsProxy());
    assertEquals("java.util.List<? extends S>", listS.getIdentifier());
    JvmParameterizedTypeReference listType = (JvmParameterizedTypeReference) listS;
    assertEquals(1, listType.getArguments().size());
    JvmTypeReference typeArgument = listType.getArguments().get(0);
    assertTrue(typeArgument instanceof JvmWildcardTypeReference);
    JvmWildcardTypeReference wildcardTypeArgument = (JvmWildcardTypeReference) typeArgument;
    assertEquals("? extends S", wildcardTypeArgument.getIdentifier());
    assertEquals(1, wildcardTypeArgument.getConstraints().size());
    JvmUpperBound upperBound = (JvmUpperBound) wildcardTypeArgument.getConstraints().get(0);
    JvmTypeParameter s = type.getTypeParameters().get(0);
    assertSame(s, upperBound.getTypeReference().getType());
}
项目:xtext-extras    文件:AbstractTypeProviderTest.java   
@Test
public void test_ParameterizedTypes_03() {
    String typeName = ParameterizedTypes.class.getName();
    JvmGenericType type = (JvmGenericType) getTypeProvider().findTypeByName(typeName);
    JvmOperation methodT = getMethodFromType(type, ParameterizedTypes.class, "methodT(T)");
    JvmTypeReference listS = methodT.getReturnType();
    assertFalse(listS.toString(), listS.eIsProxy());
    assertEquals("java.util.List<? extends java.lang.Object & super T>", listS.getIdentifier());
    JvmParameterizedTypeReference listType = (JvmParameterizedTypeReference) listS;
    assertEquals(1, listType.getArguments().size());
    JvmTypeReference typeArgument = listType.getArguments().get(0);
    assertTrue(typeArgument instanceof JvmWildcardTypeReference);
    JvmWildcardTypeReference wildcardTypeArgument = (JvmWildcardTypeReference) typeArgument;
    assertEquals("? extends java.lang.Object & super T", wildcardTypeArgument.getIdentifier());
    assertEquals(2, wildcardTypeArgument.getConstraints().size());
    JvmUpperBound uperBound = (JvmUpperBound) wildcardTypeArgument.getConstraints().get(0);
    assertEquals("java.lang.Object", uperBound.getTypeReference().getIdentifier());
    JvmLowerBound lowerBound = (JvmLowerBound) wildcardTypeArgument.getConstraints().get(1);
    JvmTypeParameter t = type.getTypeParameters().get(1);
    assertSame(t, lowerBound.getTypeReference().getType());
}
项目:xtext-extras    文件:AbstractTypeProviderTest.java   
@Test
public void test_ParameterizedTypes_05() {
    String typeName = ParameterizedTypes.class.getName();
    JvmGenericType type = (JvmGenericType) getTypeProvider().findTypeByName(typeName);
    JvmOperation methodZ = getMethodFromType(type, ParameterizedTypes.class, "methodZ(java.util.List)");
    assertEquals(1, methodZ.getParameters().size());
    assertEquals(1, methodZ.getTypeParameters().size());
    assertEquals("Z", methodZ.getTypeParameters().get(0).getIdentifier());
    JvmTypeReference listZ = methodZ.getReturnType();
    assertFalse(listZ.toString(), listZ.getType().eIsProxy());
    assertEquals("java.util.List<? extends java.lang.Object & super Z>", listZ.getIdentifier());
    JvmParameterizedTypeReference listType = (JvmParameterizedTypeReference) listZ;
    assertEquals(1, listType.getArguments().size());
    JvmTypeReference typeArgument = listType.getArguments().get(0);
    assertTrue(typeArgument instanceof JvmWildcardTypeReference);
    JvmWildcardTypeReference wildcardTypeArgument = (JvmWildcardTypeReference) typeArgument;
    assertEquals("? extends java.lang.Object & super Z", wildcardTypeArgument.getIdentifier());
    assertEquals(2, wildcardTypeArgument.getConstraints().size());
    JvmUpperBound upperBound = (JvmUpperBound) wildcardTypeArgument.getConstraints().get(0);
    assertEquals("java.lang.Object", upperBound.getTypeReference().getIdentifier());
    JvmLowerBound lowerBound = (JvmLowerBound) wildcardTypeArgument.getConstraints().get(1);
    assertEquals("Z", lowerBound.getTypeReference().getIdentifier());
    JvmTypeParameter z = methodZ.getTypeParameters().get(0);
    assertSame(z, lowerBound.getTypeReference().getType());
}
项目:xtext-extras    文件:AbstractTypeProviderTest.java   
@Test
public void test_ParameterizedTypes_06() {
    String typeName = ParameterizedTypes.class.getName();
    JvmGenericType type = (JvmGenericType) getTypeProvider().findTypeByName(typeName);
    JvmOperation methodMap = getMethodFromType(type, ParameterizedTypes.class, "methodMap(java.util.Map)");
    assertEquals(1, methodMap.getParameters().size());
    assertEquals(1, methodMap.getTypeParameters().size());
    assertEquals("Z", methodMap.getTypeParameters().get(0).getIdentifier());
    JvmType z = methodMap.getReturnType().getType();
    assertSame(methodMap.getTypeParameters().get(0), z);
    JvmTypeReference mapType = methodMap.getParameters().get(0).getParameterType();
    assertEquals("java.util.Map<? extends java.lang.Object & super Z, ? extends S>", mapType.getIdentifier());
    JvmParameterizedTypeReference parameterizedMapType = (JvmParameterizedTypeReference) mapType;
    assertEquals(2, parameterizedMapType.getArguments().size());
    JvmWildcardTypeReference extendsS = (JvmWildcardTypeReference) parameterizedMapType.getArguments().get(1);
    assertEquals(1, extendsS.getConstraints().size());
    JvmType s = type.getTypeParameters().get(0);
    assertSame(s, extendsS.getConstraints().get(0).getTypeReference().getType());
}
项目:xtext-extras    文件:AbstractTypeProviderTest.java   
@Test
public void test_ParameterizedTypes_Inner_05() {
    String typeName = ParameterizedTypes.class.getName();
    JvmGenericType type = (JvmGenericType) getTypeProvider().findTypeByName(typeName);
    JvmOperation methodV = getMethodFromType(type, ParameterizedTypes.Inner.class, "methodVArray_01()");
    JvmTypeReference listT = methodV.getReturnType();
    assertEquals("java.util.List<? extends V>[]", listT.getIdentifier());
    JvmParameterizedTypeReference listType = (JvmParameterizedTypeReference) ((JvmGenericArrayTypeReference) listT)
            .getComponentType();
    assertEquals(1, listType.getArguments().size());
    JvmTypeReference typeArgument = listType.getArguments().get(0);
    assertTrue(typeArgument instanceof JvmWildcardTypeReference);
    JvmWildcardTypeReference wildcardTypeArgument = (JvmWildcardTypeReference) typeArgument;
    assertEquals("? extends V", wildcardTypeArgument.getIdentifier());
    assertEquals(1, wildcardTypeArgument.getConstraints().size());
    JvmUpperBound upperBound = (JvmUpperBound) wildcardTypeArgument.getConstraints().get(0);
    JvmTypeParameter v = type.getTypeParameters().get(3);
    assertSame(v, upperBound.getTypeReference().getType());
}
项目:xtext-extras    文件:AbstractTypeProviderTest.java   
@Test
public void test_ParameterizedTypes_Inner_06() {
    String typeName = ParameterizedTypes.class.getName();
    JvmGenericType type = (JvmGenericType) getTypeProvider().findTypeByName(typeName);
    JvmOperation methodV = getMethodFromType(type, ParameterizedTypes.Inner.class, "methodVArray_02()");
    JvmTypeReference listV = methodV.getReturnType();
    assertEquals("java.util.List<? extends V[]>", listV.getIdentifier());
    JvmParameterizedTypeReference listType = (JvmParameterizedTypeReference) listV;
    assertEquals(1, listType.getArguments().size());
    JvmTypeReference typeArgument = listType.getArguments().get(0);
    assertTrue(typeArgument instanceof JvmWildcardTypeReference);
    JvmWildcardTypeReference wildcardTypeArgument = (JvmWildcardTypeReference) typeArgument;
    assertEquals("? extends V[]", wildcardTypeArgument.getIdentifier());
    assertEquals(1, wildcardTypeArgument.getConstraints().size());
    JvmUpperBound upperBound = (JvmUpperBound) wildcardTypeArgument.getConstraints().get(0);
    JvmType upperBoundType = upperBound.getTypeReference().getType();
    assertTrue(upperBoundType instanceof JvmArrayType);
    assertTrue(((JvmArrayType) upperBoundType).getComponentType() instanceof JvmTypeParameter);
    JvmTypeParameter v = type.getTypeParameters().get(3);
    assertSame(v, ((JvmArrayType) upperBoundType).getComponentType());
}
项目:xtext-extras    文件:JvmTypeReferencesValidator.java   
@Check
public void checkNotMultipleBounds(JvmWildcardTypeReference typeRef) {
    List<JvmTypeConstraint> constraints = typeRef.getConstraints();
    if (constraints.size() >= 2) {
        int upperBounds = 0;
        int lowerBounds = 0;
        for(int i = 0; i < constraints.size(); i++) {
            JvmTypeConstraint constraint = constraints.get(i);
            if (constraint.eClass() == TypesPackage.Literals.JVM_UPPER_BOUND) {
                upperBounds++;
                if (upperBounds > 1) {
                    error("Invalid type constraint. Cannot use multiple upper bounds in wildcards.", 
                            typeRef, TypesPackage.Literals.JVM_CONSTRAINT_OWNER__CONSTRAINTS, i, IssueCodes.INVALID_WILDCARD_CONSTRAINTS);
                    return;
                }
            } else {
                lowerBounds++;
                if (lowerBounds > 1) {
                    error("Invalid type constraint. Cannot use multiple lower bounds in wildcards.", 
                            typeRef, TypesPackage.Literals.JVM_CONSTRAINT_OWNER__CONSTRAINTS, i, IssueCodes.INVALID_WILDCARD_CONSTRAINTS);
                }
            }
        }
    }
}
项目:xtext-extras    文件:AbstractTypeProviderTest.java   
@Test
public void test_twoListWildcardsNoResult_03() {
    JvmOperation twoListWildcardsNoResult = getMethodFromParameterizedMethods(
            "twoListWildcardsNoResult(java.util.List,java.util.List)");
    JvmFormalParameter firstParam = twoListWildcardsNoResult.getParameters().get(0);
    JvmTypeReference paramType = firstParam.getParameterType();
    JvmParameterizedTypeReference parameterized = (JvmParameterizedTypeReference) paramType;
    assertEquals(1, parameterized.getArguments().size());
    JvmTypeReference typeParameter = parameterized.getArguments().get(0);
    assertTrue(typeParameter instanceof JvmWildcardTypeReference);
    JvmWildcardTypeReference wildcard = (JvmWildcardTypeReference) typeParameter;
    assertEquals(1, wildcard.getConstraints().size());
    assertTrue(wildcard.getConstraints().get(0) instanceof JvmUpperBound);
    JvmUpperBound upperBound = (JvmUpperBound) wildcard.getConstraints().get(0);
    assertNotNull(upperBound.getTypeReference());
    JvmType upperBoundType = upperBound.getTypeReference().getType();
    assertFalse(upperBoundType.eIsProxy());
    assertEquals("java.lang.Object", upperBoundType.getIdentifier());
}
项目:xtext-extras    文件:AbstractTypeProviderTest.java   
@Test
public void test_twoListWildcardsListResult_03() {
    JvmOperation twoListWildcardsListResult = getMethodFromParameterizedMethods(
            "twoListWildcardsListResult(java.util.List,java.util.List)");
    JvmTypeReference returnType = twoListWildcardsListResult.getReturnType();
    JvmParameterizedTypeReference parameterized = (JvmParameterizedTypeReference) returnType;
    assertEquals(1, parameterized.getArguments().size());
    JvmTypeReference typeParameter = parameterized.getArguments().get(0);
    assertTrue(typeParameter instanceof JvmWildcardTypeReference);
    JvmWildcardTypeReference wildcard = (JvmWildcardTypeReference) typeParameter;
    assertEquals(1, wildcard.getConstraints().size());
    assertTrue(wildcard.getConstraints().get(0) instanceof JvmUpperBound);
    JvmUpperBound upperBound = (JvmUpperBound) wildcard.getConstraints().get(0);
    assertNotNull(upperBound.getTypeReference());
    JvmType upperBoundType = upperBound.getTypeReference().getType();
    assertFalse(upperBoundType.eIsProxy());
    assertEquals("java.lang.Object", upperBoundType.getIdentifier());
}
项目:xtext-extras    文件:AbstractTypeProviderTest.java   
@Test
public void test_ParameterizedTypes_02() {
    String typeName = ParameterizedTypes.class.getName();
    JvmGenericType type = (JvmGenericType) getTypeProvider().findTypeByName(typeName);
    JvmOperation methodS = getMethodFromType(type, ParameterizedTypes.class, "methodS(S)");
    JvmTypeReference listS = methodS.getReturnType();
    assertFalse(listS.toString(), listS.eIsProxy());
    assertEquals("java.util.List<? extends S>", listS.getIdentifier());
    JvmParameterizedTypeReference listType = (JvmParameterizedTypeReference) listS;
    assertEquals(1, listType.getArguments().size());
    JvmTypeReference typeArgument = listType.getArguments().get(0);
    assertTrue(typeArgument instanceof JvmWildcardTypeReference);
    JvmWildcardTypeReference wildcardTypeArgument = (JvmWildcardTypeReference) typeArgument;
    assertEquals("? extends S", wildcardTypeArgument.getIdentifier());
    assertEquals(1, wildcardTypeArgument.getConstraints().size());
    JvmUpperBound upperBound = (JvmUpperBound) wildcardTypeArgument.getConstraints().get(0);
    JvmTypeParameter s = type.getTypeParameters().get(0);
    assertSame(s, upperBound.getTypeReference().getType());
}
项目:xtext-extras    文件:AbstractTypeProviderTest.java   
@Test
public void test_ParameterizedTypes_03() {
    String typeName = ParameterizedTypes.class.getName();
    JvmGenericType type = (JvmGenericType) getTypeProvider().findTypeByName(typeName);
    JvmOperation methodT = getMethodFromType(type, ParameterizedTypes.class, "methodT(T)");
    JvmTypeReference listS = methodT.getReturnType();
    assertFalse(listS.toString(), listS.eIsProxy());
    assertEquals("java.util.List<? extends java.lang.Object & super T>", listS.getIdentifier());
    JvmParameterizedTypeReference listType = (JvmParameterizedTypeReference) listS;
    assertEquals(1, listType.getArguments().size());
    JvmTypeReference typeArgument = listType.getArguments().get(0);
    assertTrue(typeArgument instanceof JvmWildcardTypeReference);
    JvmWildcardTypeReference wildcardTypeArgument = (JvmWildcardTypeReference) typeArgument;
    assertEquals("? extends java.lang.Object & super T", wildcardTypeArgument.getIdentifier());
    assertEquals(2, wildcardTypeArgument.getConstraints().size());
    JvmUpperBound uperBound = (JvmUpperBound) wildcardTypeArgument.getConstraints().get(0);
    assertEquals("java.lang.Object", uperBound.getTypeReference().getIdentifier());
    JvmLowerBound lowerBound = (JvmLowerBound) wildcardTypeArgument.getConstraints().get(1);
    JvmTypeParameter t = type.getTypeParameters().get(1);
    assertSame(t, lowerBound.getTypeReference().getType());
}
项目:xtext-extras    文件:AbstractTypeProviderTest.java   
@Test
public void test_ParameterizedTypes_05() {
    String typeName = ParameterizedTypes.class.getName();
    JvmGenericType type = (JvmGenericType) getTypeProvider().findTypeByName(typeName);
    JvmOperation methodZ = getMethodFromType(type, ParameterizedTypes.class, "methodZ(java.util.List)");
    assertEquals(1, methodZ.getParameters().size());
    assertEquals(1, methodZ.getTypeParameters().size());
    assertEquals("Z", methodZ.getTypeParameters().get(0).getIdentifier());
    JvmTypeReference listZ = methodZ.getReturnType();
    assertFalse(listZ.toString(), listZ.getType().eIsProxy());
    assertEquals("java.util.List<? extends java.lang.Object & super Z>", listZ.getIdentifier());
    JvmParameterizedTypeReference listType = (JvmParameterizedTypeReference) listZ;
    assertEquals(1, listType.getArguments().size());
    JvmTypeReference typeArgument = listType.getArguments().get(0);
    assertTrue(typeArgument instanceof JvmWildcardTypeReference);
    JvmWildcardTypeReference wildcardTypeArgument = (JvmWildcardTypeReference) typeArgument;
    assertEquals("? extends java.lang.Object & super Z", wildcardTypeArgument.getIdentifier());
    assertEquals(2, wildcardTypeArgument.getConstraints().size());
    JvmUpperBound upperBound = (JvmUpperBound) wildcardTypeArgument.getConstraints().get(0);
    assertEquals("java.lang.Object", upperBound.getTypeReference().getIdentifier());
    JvmLowerBound lowerBound = (JvmLowerBound) wildcardTypeArgument.getConstraints().get(1);
    assertEquals("Z", lowerBound.getTypeReference().getIdentifier());
    JvmTypeParameter z = methodZ.getTypeParameters().get(0);
    assertSame(z, lowerBound.getTypeReference().getType());
}
项目:xtext-extras    文件:AbstractTypeProviderTest.java   
@Test
public void test_ParameterizedTypes_06() {
    String typeName = ParameterizedTypes.class.getName();
    JvmGenericType type = (JvmGenericType) getTypeProvider().findTypeByName(typeName);
    JvmOperation methodMap = getMethodFromType(type, ParameterizedTypes.class, "methodMap(java.util.Map)");
    assertEquals(1, methodMap.getParameters().size());
    assertEquals(1, methodMap.getTypeParameters().size());
    assertEquals("Z", methodMap.getTypeParameters().get(0).getIdentifier());
    JvmType z = methodMap.getReturnType().getType();
    assertSame(methodMap.getTypeParameters().get(0), z);
    JvmTypeReference mapType = methodMap.getParameters().get(0).getParameterType();
    assertEquals("java.util.Map<? extends java.lang.Object & super Z, ? extends S>", mapType.getIdentifier());
    JvmParameterizedTypeReference parameterizedMapType = (JvmParameterizedTypeReference) mapType;
    assertEquals(2, parameterizedMapType.getArguments().size());
    JvmWildcardTypeReference extendsS = (JvmWildcardTypeReference) parameterizedMapType.getArguments().get(1);
    assertEquals(1, extendsS.getConstraints().size());
    JvmType s = type.getTypeParameters().get(0);
    assertSame(s, extendsS.getConstraints().get(0).getTypeReference().getType());
}
项目:xtext-extras    文件:AbstractTypeProviderTest.java   
@Test
public void test_ParameterizedTypes_Inner_05() {
    String typeName = ParameterizedTypes.class.getName();
    JvmGenericType type = (JvmGenericType) getTypeProvider().findTypeByName(typeName);
    JvmOperation methodV = getMethodFromType(type, ParameterizedTypes.Inner.class, "methodVArray_01()");
    JvmTypeReference listT = methodV.getReturnType();
    assertEquals("java.util.List<? extends V>[]", listT.getIdentifier());
    JvmParameterizedTypeReference listType = (JvmParameterizedTypeReference) ((JvmGenericArrayTypeReference) listT)
            .getComponentType();
    assertEquals(1, listType.getArguments().size());
    JvmTypeReference typeArgument = listType.getArguments().get(0);
    assertTrue(typeArgument instanceof JvmWildcardTypeReference);
    JvmWildcardTypeReference wildcardTypeArgument = (JvmWildcardTypeReference) typeArgument;
    assertEquals("? extends V", wildcardTypeArgument.getIdentifier());
    assertEquals(1, wildcardTypeArgument.getConstraints().size());
    JvmUpperBound upperBound = (JvmUpperBound) wildcardTypeArgument.getConstraints().get(0);
    JvmTypeParameter v = type.getTypeParameters().get(3);
    assertSame(v, upperBound.getTypeReference().getType());
}
项目:xtext-extras    文件:AbstractTypeProviderTest.java   
@Test
public void test_ParameterizedTypes_Inner_06() {
    String typeName = ParameterizedTypes.class.getName();
    JvmGenericType type = (JvmGenericType) getTypeProvider().findTypeByName(typeName);
    JvmOperation methodV = getMethodFromType(type, ParameterizedTypes.Inner.class, "methodVArray_02()");
    JvmTypeReference listV = methodV.getReturnType();
    assertEquals("java.util.List<? extends V[]>", listV.getIdentifier());
    JvmParameterizedTypeReference listType = (JvmParameterizedTypeReference) listV;
    assertEquals(1, listType.getArguments().size());
    JvmTypeReference typeArgument = listType.getArguments().get(0);
    assertTrue(typeArgument instanceof JvmWildcardTypeReference);
    JvmWildcardTypeReference wildcardTypeArgument = (JvmWildcardTypeReference) typeArgument;
    assertEquals("? extends V[]", wildcardTypeArgument.getIdentifier());
    assertEquals(1, wildcardTypeArgument.getConstraints().size());
    JvmUpperBound upperBound = (JvmUpperBound) wildcardTypeArgument.getConstraints().get(0);
    JvmType upperBoundType = upperBound.getTypeReference().getType();
    assertTrue(upperBoundType instanceof JvmArrayType);
    assertTrue(((JvmArrayType) upperBoundType).getComponentType() instanceof JvmTypeParameter);
    JvmTypeParameter v = type.getTypeParameters().get(3);
    assertSame(v, ((JvmArrayType) upperBoundType).getComponentType());
}
项目:xtext-extras    文件:NameConcatHelper.java   
static String computeFor(JvmWildcardTypeReference typeReference, char innerClassDelimiter, NameType nameType) {
    if (typeReference.eIsSet(TypesPackage.Literals.JVM_CONSTRAINT_OWNER__CONSTRAINTS)) {
        if (typeReference.getConstraints().size() == 1) {
            JvmTypeConstraint onlyConstraint = typeReference.getConstraints().get(0);
            if (nameType != NameType.ID && nameType != NameType.TO_STRING) {
                JvmTypeReference reference = onlyConstraint.getTypeReference();
                if (reference == null || (onlyConstraint instanceof JvmUpperBound && 
                        Object.class.getCanonicalName().equals(onlyConstraint.getTypeReference().getIdentifier()))) {
                    return "?";
                }
            } else if (nameType == NameType.ID && onlyConstraint.getTypeReference() == null) {
                return "?";
            }
        }
        StringBuilder mutableResult = new StringBuilder(64);
        mutableResult.append("? ");
        appendConstraintsName(mutableResult, typeReference.getConstraints(), innerClassDelimiter, nameType);
        return mutableResult.toString();
    }
    return "?";
}
项目:xtext-extras    文件:AbstractTypeProviderTest.java   
@Test
public void test_ParameterizedTypes_V_01() {
    String typeName = ParameterizedTypes.class.getName();
    JvmGenericType type = (JvmGenericType) getTypeProvider().findTypeByName(typeName);
    JvmTypeParameter typeParameterV = type.getTypeParameters().get(3);
    assertEquals("V", typeParameterV.getIdentifier());
    assertSame(type, typeParameterV.getDeclarator());
    assertEquals(1, typeParameterV.getConstraints().size());
    JvmTypeConstraint typeConstraint = typeParameterV.getConstraints().get(0);
    assertTrue(typeConstraint instanceof JvmUpperBound);
    JvmUpperBound upperBound = (JvmUpperBound) typeConstraint;
    assertNotNull(upperBound.getTypeReference());
    assertFalse(upperBound.getTypeReference().toString(), upperBound.getTypeReference().eIsProxy());
    assertEquals("java.util.List<java.util.List<? extends V>>", upperBound.getTypeReference().getIdentifier());
    JvmParameterizedTypeReference listType = (JvmParameterizedTypeReference) upperBound.getTypeReference();
    assertEquals(1, listType.getArguments().size());
    JvmTypeReference typeArgument = listType.getArguments().get(0);
    assertEquals("java.util.List<? extends V>", typeArgument.getIdentifier());
    JvmParameterizedTypeReference nestedListType = (JvmParameterizedTypeReference) typeArgument;
    assertEquals(1, nestedListType.getArguments().size());
    JvmTypeReference nestedArgument = nestedListType.getArguments().get(0);
    assertTrue(nestedArgument instanceof JvmWildcardTypeReference);
    assertEquals(1, ((JvmWildcardTypeReference) nestedArgument).getConstraints().size());
    JvmUpperBound nestedUpperBound = (JvmUpperBound) ((JvmWildcardTypeReference) nestedArgument).getConstraints()
            .get(0);
    assertSame(typeParameterV, nestedUpperBound.getTypeReference().getType());
}
项目:xtext-extras    文件:TypeUsageCollector.java   
protected void acceptType(JvmTypeReference ref) {
    if (ref instanceof XFunctionTypeRef 
     || ref instanceof JvmWildcardTypeReference
     || ref instanceof JvmGenericArrayTypeReference
     || (ref.eContainer() instanceof XFunctionTypeRef 
             && ref.eContainmentFeature() == JVM_SPECIALIZED_TYPE_REFERENCE__EQUIVALENT)
     || NodeModelUtils.findActualNodeFor(ref) == null) 
        return;
    else 
        acceptPreferredType(ref);
}
项目:xtext-extras    文件:XtypeFormatter.java   
protected void _format(final JvmWildcardTypeReference ref, @Extension final IFormattableDocument document) {
  boolean _isEmpty = ref.getConstraints().isEmpty();
  boolean _not = (!_isEmpty);
  if (_not) {
    final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.append(this.textRegionExtensions.regionFor(ref).keyword("?"), _function);
  }
  EList<JvmTypeConstraint> _constraints = ref.getConstraints();
  for (final JvmTypeConstraint c : _constraints) {
    document.<JvmTypeConstraint>format(c);
  }
}
项目:xtext-extras    文件:XtypeFormatter.java   
public void format(final Object ref, final IFormattableDocument document) {
  if (ref instanceof JvmTypeParameter) {
    _format((JvmTypeParameter)ref, document);
    return;
  } else if (ref instanceof XtextResource) {
    _format((XtextResource)ref, document);
    return;
  } else if (ref instanceof XFunctionTypeRef) {
    _format((XFunctionTypeRef)ref, document);
    return;
  } else if (ref instanceof JvmParameterizedTypeReference) {
    _format((JvmParameterizedTypeReference)ref, document);
    return;
  } else if (ref instanceof JvmWildcardTypeReference) {
    _format((JvmWildcardTypeReference)ref, document);
    return;
  } else if (ref instanceof XImportDeclaration) {
    _format((XImportDeclaration)ref, document);
    return;
  } else if (ref instanceof XImportSection) {
    _format((XImportSection)ref, document);
    return;
  } else if (ref instanceof EObject) {
    _format((EObject)ref, document);
    return;
  } else if (ref == null) {
    _format((Void)null, document);
    return;
  } else if (ref != null) {
    _format(ref, document);
    return;
  } else {
    throw new IllegalArgumentException("Unhandled parameter types: " +
      Arrays.<Object>asList(ref, document).toString());
  }
}
项目:xtext-extras    文件:BrokenTypeRefDetector.java   
@Override
public Boolean doVisitWildcardTypeReference(final JvmWildcardTypeReference it) {
  final Function1<JvmTypeConstraint, Boolean> _function = (JvmTypeConstraint it_1) -> {
    return this.visit(it_1.getTypeReference());
  };
  return Boolean.valueOf(IterableExtensions.<JvmTypeConstraint>exists(it.getConstraints(), _function));
}
项目:xtext-extras    文件:XbaseFormatter2.java   
protected void _format(final JvmWildcardTypeReference ref, final FormattableDocument document) {
  boolean _isEmpty = ref.getConstraints().isEmpty();
  boolean _not = (!_isEmpty);
  if (_not) {
    final Procedure1<FormattingDataInit> _function = (FormattingDataInit it) -> {
      it.oneSpace();
    };
    Function1<? super FormattableDocument, ? extends Iterable<FormattingData>> _append = this._formattingDataFactory.append(this._nodeModelAccess.nodeForKeyword(ref, "?"), _function);
    document.operator_add(_append);
  }
  EList<JvmTypeConstraint> _constraints = ref.getConstraints();
  for (final JvmTypeConstraint c : _constraints) {
    this.format(c, document);
  }
}
项目:xtext-extras    文件:AbstractTypeProviderTest.java   
@Test
public void test_ParameterizedTypes_V_01() {
    String typeName = ParameterizedTypes.class.getName();
    JvmGenericType type = (JvmGenericType) getTypeProvider().findTypeByName(typeName);
    JvmTypeParameter typeParameterV = type.getTypeParameters().get(3);
    assertEquals("V", typeParameterV.getIdentifier());
    assertSame(type, typeParameterV.getDeclarator());
    assertEquals(1, typeParameterV.getConstraints().size());
    JvmTypeConstraint typeConstraint = typeParameterV.getConstraints().get(0);
    assertTrue(typeConstraint instanceof JvmUpperBound);
    JvmUpperBound upperBound = (JvmUpperBound) typeConstraint;
    assertNotNull(upperBound.getTypeReference());
    assertFalse(upperBound.getTypeReference().toString(), upperBound.getTypeReference().eIsProxy());
    assertEquals("java.util.List<java.util.List<? extends V>>", upperBound.getTypeReference().getIdentifier());
    JvmParameterizedTypeReference listType = (JvmParameterizedTypeReference) upperBound.getTypeReference();
    assertEquals(1, listType.getArguments().size());
    JvmTypeReference typeArgument = listType.getArguments().get(0);
    assertEquals("java.util.List<? extends V>", typeArgument.getIdentifier());
    JvmParameterizedTypeReference nestedListType = (JvmParameterizedTypeReference) typeArgument;
    assertEquals(1, nestedListType.getArguments().size());
    JvmTypeReference nestedArgument = nestedListType.getArguments().get(0);
    assertTrue(nestedArgument instanceof JvmWildcardTypeReference);
    assertEquals(1, ((JvmWildcardTypeReference) nestedArgument).getConstraints().size());
    JvmUpperBound nestedUpperBound = (JvmUpperBound) ((JvmWildcardTypeReference) nestedArgument).getConstraints()
            .get(0);
    assertSame(typeParameterV, nestedUpperBound.getTypeReference().getType());
}
项目:xtext-extras    文件:JvmTypeReferences.java   
public JvmParameterizedTypeReferenceConstructor wildCardExtends(String qualifiedName) {
    JvmWildcardTypeReference argument = typesFactory.createJvmWildcardTypeReference();
    JvmUpperBound upperBound = typesFactory.createJvmUpperBound();
    argument.getConstraints().add(upperBound);
    JvmParameterizedTypeReferenceConstructor constructor = new JvmParameterizedTypeReferenceConstructor(qualifiedName, typesFactory, typesProvider, this);
    upperBound.setTypeReference(constructor.getReference());
    reference.getArguments().add(argument);
    return constructor;
}
项目:xtext-extras    文件:JvmTypeReferences.java   
public JvmParameterizedTypeReferenceConstructor wildCardSuper(String qualifiedName) {
    JvmWildcardTypeReference argument = typesFactory.createJvmWildcardTypeReference();
    JvmLowerBound upperBound = typesFactory.createJvmLowerBound();
    argument.getConstraints().add(upperBound);
    JvmParameterizedTypeReferenceConstructor constructor = new JvmParameterizedTypeReferenceConstructor(qualifiedName, typesFactory, typesProvider, this);
    upperBound.setTypeReference(constructor.getReference());
    reference.getArguments().add(argument);
    return constructor;
}
项目:xtext-extras    文件:JvmTypeReferenceBuilderTest.java   
@Test
public void testWildcard_02() {
  JvmTypeReference _wildcardExtends = this.typeReferenceBuilder.wildcardExtends(this.typeReferenceBuilder.typeRef(CharSequence.class));
  final EList<JvmTypeConstraint> constraints = ((JvmWildcardTypeReference) _wildcardExtends).getConstraints();
  Assert.assertEquals(1, constraints.size());
  Assert.assertEquals("java.lang.CharSequence", IterableExtensions.<JvmUpperBound>head(Iterables.<JvmUpperBound>filter(constraints, JvmUpperBound.class)).getTypeReference().getIdentifier());
}
项目:xtext-extras    文件:JvmTypeReferenceBuilderTest.java   
@Test
public void testWildcard_03() {
  JvmTypeReference _wildcardSuper = this.typeReferenceBuilder.wildcardSuper(this.typeReferenceBuilder.typeRef(CharSequence.class));
  final EList<JvmTypeConstraint> constraints = ((JvmWildcardTypeReference) _wildcardSuper).getConstraints();
  Assert.assertEquals(2, constraints.size());
  Assert.assertEquals("java.lang.CharSequence", IterableExtensions.<JvmLowerBound>head(Iterables.<JvmLowerBound>filter(constraints, JvmLowerBound.class)).getTypeReference().getIdentifier());
}
项目:xtext-extras    文件:TypeReferences.java   
public JvmWildcardTypeReference wildCardExtends(JvmTypeReference clone) {
    JvmWildcardTypeReference result = factory.createJvmWildcardTypeReference();
    JvmUpperBound upperBound = factory.createJvmUpperBound();
    upperBound.setTypeReference(clone);
    result.getConstraints().add(upperBound);
    return result;
}
项目:xtext-extras    文件:TypeReferences.java   
public JvmWildcardTypeReference wildCardSuper(JvmTypeReference clone) {
    JvmWildcardTypeReference result = factory.createJvmWildcardTypeReference();
    JvmLowerBound lowerBound = factory.createJvmLowerBound();
    lowerBound.setTypeReference(clone);
    JvmUpperBound upperBound = factory.createJvmUpperBound();
    upperBound.setTypeReference(getTypeForName(Object.class, clone.getType()));
    result.getConstraints().add(lowerBound);
    result.getConstraints().add(upperBound);
    return result;
}
项目:xtext-extras    文件:JvmTypeConstraintImplCustom.java   
@Override
public void setTypeReference(JvmTypeReference newTypeReference) {
    if (newTypeReference instanceof JvmWildcardTypeReference)
        throw new IllegalArgumentException("wildcard type references are not supported as constraint bounds");
    if (!isLikelyAValidConstraintBound(newTypeReference))
        throw new IllegalArgumentException("primitive type references are not supported as constraint bounds");
    super.setTypeReference(newTypeReference);
}
项目:xtext-extras    文件:AbstractXtypeSemanticSequencer.java   
@Override
public void sequence(ISerializationContext context, EObject semanticObject) {
    EPackage epackage = semanticObject.eClass().getEPackage();
    ParserRule rule = context.getParserRule();
    Action action = context.getAssignedAction();
    Set<Parameter> parameters = context.getEnabledBooleanParameters();
    if (epackage == TypesPackage.eINSTANCE)
        switch (semanticObject.eClass().getClassifierID()) {
        case TypesPackage.JVM_GENERIC_ARRAY_TYPE_REFERENCE:
            sequence_JvmTypeReference(context, (JvmGenericArrayTypeReference) semanticObject); 
            return; 
        case TypesPackage.JVM_INNER_TYPE_REFERENCE:
            sequence_JvmParameterizedTypeReference(context, (JvmInnerTypeReference) semanticObject); 
            return; 
        case TypesPackage.JVM_LOWER_BOUND:
            if (rule == grammarAccess.getJvmLowerBoundAndedRule()) {
                sequence_JvmLowerBoundAnded(context, (JvmLowerBound) semanticObject); 
                return; 
            }
            else if (rule == grammarAccess.getJvmLowerBoundRule()) {
                sequence_JvmLowerBound(context, (JvmLowerBound) semanticObject); 
                return; 
            }
            else break;
        case TypesPackage.JVM_PARAMETERIZED_TYPE_REFERENCE:
            if (action == grammarAccess.getJvmParameterizedTypeReferenceAccess().getJvmInnerTypeReferenceOuterAction_1_4_0_0_0()) {
                sequence_JvmParameterizedTypeReference_JvmInnerTypeReference_1_4_0_0_0(context, (JvmParameterizedTypeReference) semanticObject); 
                return; 
            }
            else if (rule == grammarAccess.getJvmTypeReferenceRule()
                    || action == grammarAccess.getJvmTypeReferenceAccess().getJvmGenericArrayTypeReferenceComponentTypeAction_0_1_0_0()
                    || rule == grammarAccess.getJvmParameterizedTypeReferenceRule()
                    || rule == grammarAccess.getJvmArgumentTypeReferenceRule()) {
                sequence_JvmParameterizedTypeReference(context, (JvmParameterizedTypeReference) semanticObject); 
                return; 
            }
            else break;
        case TypesPackage.JVM_TYPE_PARAMETER:
            sequence_JvmTypeParameter(context, (JvmTypeParameter) semanticObject); 
            return; 
        case TypesPackage.JVM_UPPER_BOUND:
            if (rule == grammarAccess.getJvmUpperBoundAndedRule()) {
                sequence_JvmUpperBoundAnded(context, (JvmUpperBound) semanticObject); 
                return; 
            }
            else if (rule == grammarAccess.getJvmUpperBoundRule()) {
                sequence_JvmUpperBound(context, (JvmUpperBound) semanticObject); 
                return; 
            }
            else break;
        case TypesPackage.JVM_WILDCARD_TYPE_REFERENCE:
            sequence_JvmWildcardTypeReference(context, (JvmWildcardTypeReference) semanticObject); 
            return; 
        }
    else if (epackage == XtypePackage.eINSTANCE)
        switch (semanticObject.eClass().getClassifierID()) {
        case XtypePackage.XFUNCTION_TYPE_REF:
            sequence_XFunctionTypeRef(context, (XFunctionTypeRef) semanticObject); 
            return; 
        case XtypePackage.XIMPORT_DECLARATION:
            sequence_XImportDeclaration(context, (XImportDeclaration) semanticObject); 
            return; 
        case XtypePackage.XIMPORT_SECTION:
            sequence_XImportSection(context, (XImportSection) semanticObject); 
            return; 
        }
    if (errorAcceptor != null)
        errorAcceptor.accept(diagnosticProvider.createInvalidContextOrTypeDiagnostic(semanticObject, context));
}
项目:xtext-extras    文件:AbstractXtypeSemanticSequencer.java   
@Deprecated
protected void sequence_JvmWildcardTypeReference(EObject context, JvmWildcardTypeReference semanticObject) {
    sequence_JvmWildcardTypeReference(createContext(context, semanticObject), semanticObject);
}
项目:xtext-extras    文件:JvmTypeReferenceBuilderTest.java   
@Test
public void testWildcard_01() {
  JvmTypeReference _wildcard = this.typeReferenceBuilder.wildcard();
  Assert.assertEquals("java.lang.Object", IterableExtensions.<JvmTypeConstraint>head(((JvmWildcardTypeReference) _wildcard).getConstraints()).getTypeReference().getIdentifier());
}
项目:xtext-extras    文件:RawTypeHelper.java   
@Override
public List<JvmType> doVisitWildcardTypeReference(JvmWildcardTypeReference reference, Resource resource) {
    return getRawTypesFromConstraints(reference.getConstraints(), resource);
}
项目:xtext-extras    文件:RawTypeHelper.java   
@Override
public JvmTypeReference doVisitWildcardTypeReference(JvmWildcardTypeReference reference, Resource resource) {
    return getRawTypeFromConstraints(reference.getConstraints(), resource);
}
项目:xtext-extras    文件:RawTypeReferenceComputer.java   
@Override
public JvmTypeReference doVisitWildcardTypeReference(JvmWildcardTypeReference reference, Pair<Resource, Set<JvmType>> context) {
    return getRawTypeFromConstraints(reference.getConstraints(), context);
}
项目:xtext-extras    文件:AbstractTypeReferenceVisitor.java   
@Override
public Result doVisitWildcardTypeReference(JvmWildcardTypeReference reference) {
    return doVisitTypeReference(reference);
}
项目:xtext-extras    文件:TypeReferences.java   
public JvmWildcardTypeReference wildCard() {
    JvmWildcardTypeReference result = factory.createJvmWildcardTypeReference();
    return result;
}