private static String createUniqueParamNameFromType( IType paramType, HashSet<String> generatedNames ) { String initialName = paramType.getRelativeName(); if( !GosuStringUtil.isAlphanumeric( initialName.substring( 0, 1 ) ) ) { initialName = paramType.getDisplayName(); } initialName = initialName.substring( 0, 1 ); initialName = initialName.toLowerCase(); String name = initialName; int j = 2; while( generatedNames.contains( name ) ) { name = initialName + j; j++; } generatedNames.add( name ); return name; }
@Override public IAnnotationInfo getAnnotation( IType type ) { return ANNOTATION_HELPER.getAnnotation(type, getAnnotations(), type.getDisplayName()); }
protected IType resolveTypeForArithmeticExpression( ParsedElement parsedElement, IType lhsType, String op, IType rhsType ) { IType type = resolveType( parsedElement, lhsType, op.charAt(0), rhsType ); if( parsedElement.hasParseException( Res.MSG_TYPE_MISMATCH ) ) { parsedElement.removeParseException( Res.MSG_TYPE_MISMATCH ); parsedElement.addParseException( new ParseException( makeLightweightParserState(), Res.MSG_ARITHMETIC_OPERATOR_CANNOT_BE_APPLIED_TO_TYPES, op, rhsType.getDisplayName(), lhsType.getDisplayName() ) ); } return type; }
@Override public void checkType(Marshaller marshaller, IParsedElement parsedElement, String label, IType type, Map<String, Object> seenNamespaces) { if (!_gwRemotableEnumType.get().isAssignableFrom(getType())) { super.checkType(marshaller, parsedElement, label, type, seenNamespaces); return; } if (!(type instanceof IJavaType)) { // java enums parsedElement.addParseException(Res.WS_ERR_Can_Not_Marshal, type.getDisplayName(), label); } else if (getFields((IJavaType) type).size() == 0) { parsedElement.addParseException(Res.WS_ERR_Can_Not_Marshal, type.getDisplayName(), label); } }
public MarshalInfo checkType(IParsedElement parsedElement, String label, IType type, Map<String, Object> seenNamespaces) { final MarshalInfo marshalInfo = XmlMarshaller.getMarshalInfo( type, null ); if (marshalInfo == null) { parsedElement.addParseException(ERR_CAN_NOT_MARSHAL_TYPE, type.getDisplayName(), label ); XmlSchemaAccessImpl xmlSchemaAccessImpl = (XmlSchemaAccessImpl) xmlSchemaAccess; if (xmlSchemaAccessImpl.getSchemaIndex().getPackageName().startsWith("wsi.local.")) { parsedElement.addParseException(ERR_CAN_NOT_MARSHAL_TYPE, label, type.getDisplayName()); if (found != null) { if (!found.equals(xmlSchemaAccessImpl)) { parsedElement.addParseException(ERR_DUPLICATE_NAMESPACE, label, uri, found, type.getDisplayName());
@Override public void checkType(Marshaller marshaller, IParsedElement parsedElement, String label, IType type, Map<String, Object> seenNamespaces) { if (!type.isValid() && !type.equals(_type)) { parsedElement.addParseException(Res.WS_ERR_Can_Not_Marshal, type.getDisplayName(), label ); } else { for (Map.Entry<String,IPropertyInfo> prop : getProperties(type).entrySet()) { String newLabel = label + (label.equals("") ? "" : ".") + prop.getKey(); IType partType = prop.getValue().getFeatureType(); if (!_type.equals(partType) && isExportable(partType)) { // do not recurse } else if (_type.equals(getComponentType(partType))) { // test this before recursing into checkType parsedElement.addParseWarning(Res.WS_ERR_Export_Recursive, newLabel ); } else { MarshalInfo marshalInfo = marshaller.checkType(parsedElement, newLabel, prop.getValue().getFeatureType(), seenNamespaces); checkMarshalInfoType(parsedElement, prop, newLabel, marshalInfo); } } } }
@Override public void checkType(Marshaller marshaller, IParsedElement parsedElement, String label, IType type, Map<String, Object> seenNamespaces) { if (!type.isValid() && !type.equals(_type)) { parsedElement.addParseException(Res.WS_ERR_Can_Not_Marshal, type.getDisplayName(), label ); } else { for (Map.Entry<String,IPropertyInfo> prop : getProperties(type).entrySet()) { String newLabel = label + (label.equals("") ? "" : ".") + prop.getKey(); IType partType = prop.getValue().getFeatureType(); if (!_type.equals(partType) && isExportable(partType)) { // do not recurse } else if (_type.equals(getComponentType(partType))) { // test this before recursing into checkType parsedElement.addParseWarning(Res.WS_ERR_Export_Recursive, newLabel ); } else { MarshalInfo marshalInfo = marshaller.checkType(parsedElement, newLabel, prop.getValue().getFeatureType(), seenNamespaces); checkMarshalInfoType(parsedElement, prop, newLabel, marshalInfo); } } } }
public Collection<TestMetadata> createMethodMetadata( String method ) { if (getType() instanceof IJavaType) { // For Java types, we have to do things based on Method instead of MethodInfo, since Java TypeInfo isn't currently // reloadable, but the DCEVM means that Java classes themselves are try { Method testMethod = ((IJavaType) getType()).getBackingClass().getMethod(method); return createMetadata(testMethod.getAnnotations()); } catch (NoSuchMethodException e) { throw new IllegalStateException( "Method not found: " + getType().getDisplayName() + "." + method); } } else { IMethodInfo testMethod = getType().getTypeInfo().getMethod(method); if(testMethod == null) { throw new IllegalStateException( "Method not found: " + getType().getDisplayName() + "." + method); } return createMetadata(testMethod.getAnnotations()); } }
@Override public void validate( IParsedElement rootParsedElement, String scriptSrc ) { IType actualType = getType( scriptSrc ); if( actualType == null ) { rootParsedElement.addParseException( new ParseException( GosuShop.createStandardParserState( rootParsedElement, scriptSrc, true ), Res.MSG_INVALID_TYPE, scriptSrc ) ); } else if( !_expectedType.isAssignableFrom( actualType ) ) { rootParsedElement.addParseException( new ParseException( GosuShop.createStandardParserState( rootParsedElement, scriptSrc, true ), Res.MSG_TYPE_MISMATCH, _expectedType.getDisplayName(), actualType.getDisplayName() ) ); } }
@Override public void validate( IParsedElement rootParsedElement, String scriptSrc ) { IType actualType = getType( scriptSrc ); if( actualType == null ) { rootParsedElement.addParseException( new ParseException( GosuShop.createStandardParserState( rootParsedElement, scriptSrc, true ), Res.MSG_INVALID_TYPE, scriptSrc ) ); } else if( !_expectedType.isAssignableFrom( actualType ) ) { rootParsedElement.addParseException( new ParseException( GosuShop.createStandardParserState( rootParsedElement, scriptSrc, true ), Res.MSG_TYPE_MISMATCH, _expectedType.getDisplayName(), actualType.getDisplayName() ) ); } }
Res.MSG_IMPLICIT_COERCION_ERROR, lhsType, rhsType.getDisplayName(), lhsType.getDisplayName() ) );
Res.MSG_IMPLICIT_COERCION_WARNING, lhsType, rhsType.getDisplayName(), lhsType.getDisplayName() ) ); Res.MSG_IMPLICIT_COERCION_ERROR, lhsType, rhsType.getDisplayName(), lhsType.getDisplayName() ) );
e.getType().getDisplayName(), argTypes[i].getDisplayName() ) );
addParseWarning( new ParseWarningForDeprecatedMember(null, thisType.getDisplayName(), thisType.getDisplayName() ) );
addParseWarning( new ParseWarningForDeprecatedMember(null, thisType.getDisplayName(), thisType.getDisplayName() ) );
IType type = resolveTypeForArithmeticExpression( e, lhs.getType(), value, rhs.getType() ); e.setType( type ); verify( e, TypeSystem.isNumericType( type ) || value.charAt(0) != '!', Res.MSG_ARITHMETIC_OPERATOR_CANNOT_BE_APPLIED_TO_TYPES, "!*", lhs.getType().getDisplayName(), rhs.getType().getDisplayName() ); verify( e, !(e.isNullSafe() && e.getType().isPrimitive()), Res.MSG_EXPECTING_REFERENCE_TYPE ); pushExpression( e );
public static Object coerceValue( Object value, IType type, ICoercer coercer ) { Object retValue = value; if( type == GosuParserTypes.NUMBER_TYPE() ) { retValue = CommonServices.getCoercionManager().makeDoubleFrom( value ); } else if( type == GosuParserTypes.STRING_TYPE() ) { retValue = CommonServices.getCoercionManager().makeStringFrom( value ); } else if( type == GosuParserTypes.DATETIME_TYPE() ) { retValue = CommonServices.getCoercionManager().makeDateFrom( value ); } else if( coercer != null && (value != null || coercer.handlesNull()) ) { retValue = coercer.coerceValue( type, value ); } if( retValue == StandardCoercionManager.NO_DICE ) { throw new ClassCastException( value + " cannot be cast to " + type.getDisplayName() ); } return retValue; }
(!isFinalDimension( this, lhsType, parsedElement ) || BeanAccess.isNumericType( retType )), Res.MSG_TYPE_MISMATCH, rhsType.getDisplayName(), lhsType.getDisplayName(), rhsType.getTypeLoader().getModule().getName(), lhsType.getTypeLoader().getModule().getName()); type != ErrorType.getInstance() && (!isFinalDimension( this, lhsType, parsedElement ) || BeanAccess.isNumericType( type )), Res.MSG_TYPE_MISMATCH, rhsType.getDisplayName(), lhsType.getDisplayName() ); return type;
(!isFinalDimension( this, lhsType, parsedElement ) || BeanAccess.isNumericType( retType )), Res.MSG_TYPE_MISMATCH, rhsType.getDisplayName(), lhsType.getDisplayName(), rhsType.getTypeLoader() == null ? null : rhsType.getTypeLoader().getModule().getName(), lhsType.getTypeLoader() == null ? null : lhsType.getTypeLoader().getModule().getName()); type != ErrorType.getInstance() && (!isFinalDimension( this, lhsType, parsedElement ) || BeanAccess.isNumericType( type )), Res.MSG_TYPE_MISMATCH, rhsType.getDisplayName(), lhsType.getDisplayName() ); return type;
IType type = resolveTypeForArithmeticExpression( e, lhs.getType(), bPlus ? "+" : "-", rhs.getType() ); e.setType( type ); verify( e, TypeSystem.isNumericType( type ) || value.charAt(0) != '!', Res.MSG_ARITHMETIC_OPERATOR_CANNOT_BE_APPLIED_TO_TYPES, value, lhs.getType().getDisplayName(), rhs.getType().getDisplayName() ); verify( e, !(e.isNullSafe() && e.getType().isPrimitive()), Res.MSG_EXPECTING_REFERENCE_TYPE ); pushExpression( e );