static JSTypeExpression getTypeFromProperty ( MemberDefinition property , AbstractCompiler compiler ) { if ( property . info != null && property . info . hasType ( ) ) { return property . info . getType ( ) ; } String typeString ; if ( property . value . isObjectLit ( ) ) { Node typeValue = NodeUtil . getFirstPropMatchingKey ( property . value , "type" ) ; if ( typeValue == null || ! typeValue . isName ( ) ) { compiler . report ( JSError . make ( property . name , PolymerPassErrors . POLYMER_INVALID_PROPERTY ) ) ; return null ; } typeString = typeValue . getString ( ) ; } else if ( property . value . isName ( ) ) { typeString = property . value . getString ( ) ; } else { typeString = "" ; } Node typeNode ; switch ( typeString ) { case "Boolean" : case "String" : case "Number" : typeNode = IR . string ( typeString . toLowerCase ( ) ) ; break ; case "Array" : case "Function" : case "Object" : case "Date" : typeNode = new Node ( Token . BANG , IR . string ( typeString ) ) ; break ; default : compiler . report ( JSError . make ( property . name , PolymerPassErrors . POLYMER_INVALID_PROPERTY ) ) ; return null ; } return new JSTypeExpression ( typeNode , VIRTUAL_FILE ) ; }
Gets the JSTypeExpression for a given property using its type key .