private boolean isRecursiveTypeParsing( IType type ) { for( IType typeParam : type.getTypeParameters() ) { if( typeParam == GosuParser.PENDING_BOUNDING_TYPE ) { // type is errant because at least one of it's type variables recurse, // therefore we can't load the default parameterized type for it. return true; } } return false; }
private boolean isRecursivelyParameterized( IType type ) { for( IType typeParam : type.getTypeParameters() ) { if( typeParam == GosuParser.PENDING_BOUNDING_TYPE ) { // type is errant because at least one of it's type variables recurse, // therefore we can't load the default parameterized type for it. return true; } } return false; }
private static Object deepCopyJsonList(Stack<String> propertyPath, IType toType, JsonList from, IType fromType, IdentityHashMap<Object,Object> serializationMap) { IType toComponent = toType.getTypeParameters()[0]; IType fromComponent = fromType.getTypeParameters()[0]; JsonList copy = new JsonList(toType); serializationMap.put(from, copy); for (Object o : from) { copy.add(deepCopy(propertyPath, toComponent, o, fromComponent, serializationMap)); } return copy; }
public static IType getTypeForTypeVar( Object ref, IType iface, int iIndex ) { IType rtType = TypeSystem.getFromObject( ref ); IType rtIface = TypeSystem.findParameterizedType( rtType, iface ); return rtIface.getTypeParameters()[iIndex]; }
private static Object deepCopyJsonMap(Stack<String> propertyPath, IType toType, JsonMap from, IType fromType, IdentityHashMap<Object,Object> serializationMap) { IType toComponent = toType.getTypeParameters()[0]; IType fromComponent = fromType.getTypeParameters()[0]; JsonMap copy = new JsonMap(toType); serializationMap.put(from, copy); for (Object o : from.keySet()) { copy.put((String) o, deepCopy(propertyPath, toComponent, from.get(o), fromComponent, serializationMap)); } return copy; }
public static IType getKeyType( IType type ) { IType paramedType = TypeLord.findParameterizedTypeInHierarchy( type, JavaTypes.MAP() ); if( paramedType != null ) { IType[] parameters = paramedType.getTypeParameters(); return parameters[0]; } else { return GosuParserTypes.GENERIC_BEAN_TYPE(); } }
public static IType getKeyType( IType type ) { IType paramedType = TypeLord.findParameterizedTypeInHierarchy( type, JavaTypes.MAP() ); if( paramedType != null ) { IType[] parameters = paramedType.getTypeParameters(); return parameters[0]; } else { return GosuParserTypes.GENERIC_BEAN_TYPE(); } }
public IType resolveType( IType target, IType source ) { if( target.getGenericType() == JavaTypes.CLASS() ) { return JavaTypes.CLASS().getParameterizedType(source.getTypeParameters()[0]); } else { return source; } }
protected boolean isCoercingDimensionWithSameType( IType to, IType from ) { if( JavaTypes.IDIMENSION().isAssignableFrom( from ) ) { IType numberType = TypeSystem.findParameterizedType( from, JavaTypes.IDIMENSION() ).getTypeParameters()[1]; if( to == numberType ) { // must be better than Boxed coercion (which is 2 right now) return true; } } return false; } }
public static IType findDimensionType( IType type ) { if( !JavaTypes.IDIMENSION().isAssignableFrom( type ) ) { return null; } IType dimType = TypeLord.findParameterizedType( type, JavaTypes.IDIMENSION() ); return dimType.isGenericType() ? null : dimType.getTypeParameters()[1]; }
public static IType getTypeToAutoInsert( IExpression rootExpression ) { IType featureType = ((MemberAccess)rootExpression).getPropertyInfo().getFeatureType().getTypeParameters()[0]; if( (featureType.isAbstract() || featureType.isInterface()) ) { IType concreteType = GosuParser.findImpl( featureType ); if( concreteType != null ) { featureType = concreteType; } } return featureType; }
public static IType getTypeToAutoInsert( IExpression rootExpression ) { IType featureType = ((MemberAccess)rootExpression).getPropertyInfo().getFeatureType().getTypeParameters()[0]; if( (featureType.isAbstract() || featureType.isInterface()) ) { IType concreteType = GosuParser.findImpl( featureType ); if( concreteType != null ) { featureType = concreteType; } } return featureType; }
private void addImplicitEnhancementParams( IType owner, boolean bStatic, List<IRType> params ) { if ( owner instanceof IGosuEnhancement && !bStatic ) { params.add( IRTypeResolver.getDescriptor( ( (IGosuEnhancement) owner).getEnhancedType() ) ); if( owner.isParameterizedType() ) { addTypeVariableParameters( params, owner.getTypeParameters().length ); } else if( owner.isGenericType() ) { addTypeVariableParameters( params, owner.getGenericTypeVariables().length ); } } }
public IType resolveType( IType target, IType source ) { IType type = source.getTypeParameters()[0]; if( type instanceof IMetaType ) { type = ((IMetaType)type).getType(); } if( target.getGenericType() == JavaTypes.CLASS() ) { return JavaTypes.CLASS().getParameterizedType( type ); } else { return source; } }
private IType getComponentType(IType partType) { if ( partType.isArray()) { return getComponentType(partType.getComponentType()); } if ( JavaTypes.LIST().isAssignableFrom( partType )) { IType[] parameters = partType.getTypeParameters(); return parameters.length != 1 ? partType : getComponentType(parameters[0]); } return partType; }
private IType getComponentType(IType partType) { if ( partType.isArray()) { return getComponentType(partType.getComponentType()); } if ( JavaTypes.LIST().isAssignableFrom( partType )) { IType[] parameters = partType.getTypeParameters(); return parameters.length != 1 ? partType : getComponentType(parameters[0]); } return partType; }
private void setTypeInternal( IType type ) { IType paramedType = TypeLord.findParameterizedTypeInHierarchy(type, JavaTypes.MAP()); if( paramedType != null ) { IType[] parameters = paramedType.getTypeParameters(); _keyType = parameters[0]; setType( parameters[1] ); } else { _keyType = GosuParserTypes.GENERIC_BEAN_TYPE(); setType( GosuParserTypes.GENERIC_BEAN_TYPE() ); } }
private void setTypeInternal( IType type ) { IType paramedType = TypeLord.findParameterizedTypeInHierarchy(type, JavaTypes.MAP()); if( paramedType != null ) { IType[] parameters = paramedType.getTypeParameters(); _keyType = parameters[0]; setType( parameters[1] ); } else { _keyType = GosuParserTypes.GENERIC_BEAN_TYPE(); setType( GosuParserTypes.GENERIC_BEAN_TYPE() ); } }
private void verifySuperTypeVarVariance( ClassStatement classStatement, IType type ) { if( !type.isParameterizedType() || !getGosuClass().isGenericType() ) { return; } IGenericTypeVariable[] gtvs = type.getGenericType().getGenericTypeVariables(); IType[] typeParameters = type.getTypeParameters(); for( int i = 0; i < typeParameters.length; i++ ) { if( gtvs[i] != null && gtvs[i].getTypeVariableDefinition() != null ) { Variance variance = Variance.maybeInferVariance( type, gtvs[i] ); verifyTypeVarVariance( variance, classStatement, typeParameters[i] ); } } }
private boolean canCastMetaType( IType lhsType, IType rhsType ) { return (lhsType instanceof IMetaType && ((IMetaType) lhsType).getType() instanceof ITypeVariableType && canCast( ((ITypeVariableType) ((IMetaType) lhsType).getType()).getBoundingType(), rhsType )) || (rhsType instanceof IGosuClass && ((IGosuClass)rhsType).isStructure() && (lhsType instanceof IMetaType && StandardCoercionManager.isStructurallyAssignable( rhsType, ((IMetaType) lhsType).getType() ) || JavaTypes.CLASS().isAssignableFrom( lhsType ) && (!lhsType.isParameterizedType() || StandardCoercionManager.isStructurallyAssignable( rhsType, lhsType.getTypeParameters()[0] )))); }