private void addImplicitEnumParamTypes( IType owningType, List<IRType> paramTypes ) { // Enums have name and ordinal arguments implicitly added to their constructors if (owningType.isEnum()) { paramTypes.add(IRTypeConstants.STRING()); paramTypes.add(IRTypeConstants.pINT()); } }
private void addImplicitEnumParamTypes( IType owningType, List<IRType> paramTypes ) { // Enums have name and ordinal arguments implicitly added to their constructors if (owningType.isEnum()) { paramTypes.add(IRTypeConstants.STRING()); paramTypes.add(IRTypeConstants.pINT()); } }
@Override public boolean canResolve( ParseException pe ) { if( !super.canResolve( pe ) ) { return false; } IType typeExpected = getExpectedType( pe ); return typeExpected != null && typeExpected.isEnum(); }
@Override protected boolean isDefaultEnumFeature() { if( getOwnersType().isEnum() ) { String name = getName(); return isStatic() && (name.equals( "values()" ) || name.equals( "valueOf( java.lang.String )" )); } else { return false; } }
@Override protected boolean isDefaultEnumFeature() { if( getOwnersType().isEnum() ) { String name = getName(); return isStatic() && (name.equals( "values()" ) || name.equals( "valueOf( java.lang.String )" )); } else { return false; } }
private IType addValuesForType( List<ISymbol> listSymbols ) { IType expectedType = getGosuEditor().findExpectedTypeErrorAtCaret(); if( expectedType != null && expectedType.isEnum() ) { int[] i = {0}; ((IEnumType)expectedType).getEnumConstants().forEach( e -> listSymbols.add( i[0]++, GosuShop.createSymbol( e, expectedType, null ) ) ); } return expectedType; }
public void pushEnumNameAndOrdinal( IType type, List<IRExpression> args ) { if( type.isEnum() ) { args.add( pushConstant( _enumCounter.getNextEnumName() ) ); args.add( pushConstant( _enumCounter.getNextEnumOrdinal() ) ); } }
public void pushEnumNameAndOrdinal( IType type, List<IRExpression> args ) { if( type.isEnum() ) { args.add( pushConstant( _enumCounter.getNextEnumName() ) ); args.add( pushConstant( _enumCounter.getNextEnumOrdinal() ) ); } }
private boolean isBuiltinStaticEnumMethod( DynamicFunctionSymbol method ) { return method.isStatic() && method.getDeclaringTypeInfo().getOwnersType().isEnum() && (method.getDisplayName().equals( "values" ) || method.getDisplayName().equals( "valueOf")); }
public static Pair<QName, XmlSimpleValueFactory> gosuToSchemaIfValid( IType gosuType ) { if (gosuType == null) { return null; } maybeInit(); if ( gosuType.isPrimitive() ) { gosuType = TypeSystem.getBoxType( gosuType ); } else if ( gosuType.isEnum() ) { return new Pair<QName, XmlSimpleValueFactory>( new QName( XMLConstants.W3C_XML_SCHEMA_NS_URI, "string" ), new GosuEnumSimpleValueFactory( (IEnumType) gosuType ) ); } return _gosuToSchema.get( gosuType ); }
if( !switchType.isEnum() )
@Override public boolean isGeneratedEnumMethod() { return getOwningIType().isEnum() && isStatic() && (hasSignature( "getAllValues" ) || hasSignature( "values" ) || hasSignature( "valueOf", JavaTypes.STRING() )); }
@Override public boolean isGeneratedEnumMethod() { return getOwningIType().isEnum() && isStatic() && (hasSignature( "getAllValues" ) || hasSignature( "values" ) || hasSignature( "valueOf", JavaTypes.STRING() )); }
public static Class<?> getArrayClass( IType type ) { if( JavaTypes.COLLECTION().isAssignableFrom( type ) ) { return Array.newInstance(getArrayClass(type.getTypeParameters()[0]), 0).getClass(); } if( StandardCoercionManager.isBoxed(type) ) { type = TypeSystem.getPrimitiveType( type ); } else if( type.isEnum() ) { // An enum evaluates as the name of the enum constant field (for compile-time constant evaluation) type = JavaTypes.STRING(); } if( !type.isPrimitive() && type != JavaTypes.STRING() ) { throw new IllegalStateException( "A compile-time constant expression must be either primitive, String, or Enum" ); } return ((IJavaType)type).getBackingClass(); }
private static void maybePushEnumTypes(ISymbolTable symbolTable, IType returnType) { if( !returnType.isEnum() ) { return; } for(IPropertyInfo pi : returnType.getTypeInfo().getProperties() ) { if( pi.isStatic() && pi.isPublic() ) { symbolTable.putSymbol( new Symbol(pi.getName(), pi.getFeatureType(), null) ); } } }
private static void maybePushEnumTypes(ISymbolTable symbolTable, IType returnType) { if( !returnType.isEnum() ) { return; } for(IPropertyInfo pi : returnType.getTypeInfo().getProperties() ) { if( pi.isStatic() && pi.isPublic() ) { symbolTable.putSymbol( new Symbol(pi.getName(), pi.getFeatureType(), null) ); } } }
public static Class<?> getArrayClass( IType type ) { if( JavaTypes.COLLECTION().isAssignableFrom( type ) ) { return Array.newInstance(getArrayClass(type.getTypeParameters()[0]), 0).getClass(); } if( StandardCoercionManager.isBoxed( type ) ) { type = TypeSystem.getPrimitiveType( type ); } else if( type == JavaTypes.BIG_DECIMAL() || type == JavaTypes.BIG_INTEGER()) { type = JavaTypes.STRING(); } else if( type.isEnum() ) { // An enum evaluates as the name of the enum constant field (for compile-time constant evaluation) type = JavaTypes.STRING(); } if( !type.isPrimitive() && type != JavaTypes.STRING() ) { throw new IllegalStateException( "A compile-time constant expression must be either primitive, String, or Enum" ); } return ((IJavaType)type).getBackingClass(); }
private boolean isValidAnnotationMethodReturnType( IType returnType ) { return (returnType.isPrimitive() && returnType != JavaTypes.pVOID()) || returnType == JavaTypes.STRING() || returnType.getGenericType() == JavaTypes.CLASS() || JavaTypes.ANNOTATION().isAssignableFrom( returnType ) || returnType.isEnum() || (returnType.isArray() && isValidAnnotationMethodReturnType( returnType.getComponentType())); }
private Class<?> getComponentClass(IType type) { if( StandardCoercionManager.isBoxed(type) ) { type = TypeSystem.getPrimitiveType(type); } else if( type.isEnum() ) { // An enum evaluates as the name of the enum constant field (for compile-time constant evaluation) type = JavaTypes.STRING(); } else if( JavaTypes.ANNOTATION().isAssignableFrom( type ) ) { type = TypeSystem.get( IAnnotationInfo.class ); } else if( JavaTypes.CLASS().isAssignableFrom( type ) ) { type = JavaTypes.ITYPE(); } else if( !type.isPrimitive() && type != JavaTypes.STRING() && !TypeSystem.get( IAnnotationInfo.class ).isAssignableFrom( type ) && !JavaTypes.CLASS().isAssignableFrom( type ) ) { throw new IllegalStateException( " Illegal type: " + type.getName() + " A compile-time constant expression must be either primitive, String, Class, or Enum." ); } Class<?> cls = ((IJavaType)type).getBackingClass(); cls = cls != null ? cls : getClassForRareCaseWhenRunningIJEditorProjectWhereGosuCoreJavaTypesAreSourceBased( type ); return cls; }
private MemberAccess parseUnqualifiedEnumConstant( String strConstValue ) { IType contextType = getContextType().getType(); if( contextType != null ) { if( contextType.isEnum() || TypeSystem.get( IEnumValue.class ).isAssignableFrom( contextType ) ) { try { IPropertyInfo property = contextType.getTypeInfo().getProperty( strConstValue ); if( property != null && property.isStatic() ) { MemberAccess ma = new UnqualifiedEnumMemberAccess(); TypeLiteral e = new TypeLiteral( MetaType.getLiteral( property.getOwnersType() ) ); ma.setRootExpression( e ); ma.setMemberName( property.getName() ); ma.setType( property.getFeatureType() ); ma.setMemberAccessKind( MemberAccessKind.NORMAL ); return ma; } } catch( IllegalArgumentException iae ) { // skip } } } return null; }