Refine search
private String createTypeGenerator (JType t) { sb.setLength(0); int id = nextTypeId++; typeNames2typeIds.put(t.getErasedType().getQualifiedSourceName(), id); JClassType c = t.isClass(); String name = t.getErasedType().getQualifiedSourceName(); pb(varName + ".componentType = " + getType(c.isArray().getComponentType()) + ";");
private String getBinaryOrPrimitiveName(JType type) { JArrayType asArray = type.isArray(); JClassType asClass = type.isClassOrInterface(); JPrimitiveType asPrimitive = type.isPrimitive(); if (asClass != null) { return getBinaryName(asClass); } else if (asPrimitive != null) { return asPrimitive.getQualifiedSourceName(); } else if (asArray != null) { JType componentType = asArray.getComponentType(); return getBinaryOrPrimitiveName(componentType) + "[]"; } else { throw new InternalCompilerException("Cannot create binary name for " + type.getQualifiedSourceName()); } }
if (stringValue != null) { constantsCount++; if (!returnType.getQualifiedSourceName().equals("java.lang.String")) { throw new AnnotationsError( "@DefaultStringValue can only be used with a method returning String"); JArrayType arrayType = returnType.isArray(); if (arrayType == null || !arrayType.getComponentType().getQualifiedSourceName().equals( "java.lang.String")) { throw new AnnotationsError(
String ifaceName = method.getEnclosingType().getQualifiedSourceName(); String retType = method.getReturnType().getParameterizedQualifiedSourceName(); sw.print("public final " + retType + " " + method.getName()); JParameter[] params = method.getParameters(); if (params.length == 0) { JArrayType arr = method.getReturnType().isArray(); JParameterizedType list = method.getReturnType().isParameterized(); sw.println("return p.getFunction(\"" + name + "\");"); } else if (arr != null || list != null) { JType type = arr != null ? arr.getComponentType() : list.getTypeArgs()[0]; boolean buildType = isTypeAssignableTo(type, jsonBuilderType);
public static MetaType fromType(final TypeOracle oracle, final JType t) { if (t.isTypeParameter() != null) { return new GWTTypeVariable(oracle, t.isTypeParameter()); } else if (t.isArray() != null && (t.isArray().getComponentType().isTypeParameter() != null || t.isArray().getComponentType().isWildcard() != null)) { return new GWTGenericArrayType(oracle, t.isArray()); } else if (t.isParameterized() != null) { return new GWTParameterizedType(oracle, t.isParameterized()); } else if (t.isWildcard() != null) { return new GWTWildcardType(oracle, t.isWildcard()); } else if (t.isClassOrInterface() != null || t.isEnum() != null || t.isPrimitive() != null || t.isRawType() != null || t.isArray() != null) { return GWTClass.newInstance(oracle, t); } else { throw new RuntimeException("Don't know how to make a MetaType from given JType " + t + " (which is a " + (t.getClass()) + ")"); } }
UnsupportedTypeException { JDeserializerType.Builder builder = new JDeserializerType.Builder().type( type ); if ( null != type.isWildcard() ) { type = type.isWildcard().getBaseType(); if ( null != type.isRawType() ) { type = type.isRawType().getBaseType(); TypeSpec arrayCreator; Class arrayDeserializer; JType leafType = arrayType.getLeafType(); if ( arrayType.getRank() == 1 ) { arrayDeserializer = ArrayJsonDeserializer.class; } else if ( arrayType.getRank() == 2 ) {
throws UnableToCompleteException { JType returnType = method.getReturnType(); JPrimitiveType primitive = returnType.isPrimitive(); if (primitive != null && (primitive == JPrimitiveType.BOOLEAN return; JArrayType arrayType = returnType.isArray(); if (arrayType != null) { String arrayComponent = arrayType.getComponentType().getQualifiedSourceName(); if (!arrayComponent.equals("java.lang.String")) { throw error(logger,
@SuppressWarnings("unchecked") public static <T extends JType> T ensureBaseType(T maybeParameterized) { if (maybeParameterized.isArray() != null) { JArrayType array = maybeParameterized.isArray(); return (T) array.getOracle().getArrayType( ensureBaseType(array.getComponentType())); } if (maybeParameterized.isTypeParameter() != null) { return (T) maybeParameterized.isTypeParameter().getBaseType(); } if (maybeParameterized.isParameterized() != null) { return (T) maybeParameterized.isParameterized().getBaseType(); } if (maybeParameterized.isRawType() != null) { return (T) maybeParameterized.isRawType().getBaseType(); } if (maybeParameterized.isWildcard() != null) { return (T) maybeParameterized.isWildcard().getBaseType(); } return maybeParameterized; }
logger = logger.branch(TreeLogger.DEBUG, "Adding array types for " + array); JType leafType = array.getLeafType(); JTypeParameter isLeafTypeParameter = leafType.isTypeParameter(); if (isLeafTypeParameter != null) { if (typeParametersInRootTypes.contains(isLeafTypeParameter)) { if (leafTic == null) { problems.add(array, "internal error: leaf type not computed: " + leafType.getQualifiedSourceName(), Priority.FATAL); return; if (leafType.isClassOrInterface() == null) { assert leafType.isPrimitive() != null; markArrayTypesInstantiable(leafType, array.getRank(), path); return; covariantArrayLogger.branch(TreeLogger.DEBUG, getArrayType(typeOracle, array.getRank(), instantiableType).getParameterizedQualifiedSourceName()); markArrayTypesInstantiable(instantiableType, array.getRank(), path);
String retType = method.getReturnType().getParameterizedQualifiedSourceName(); JArrayType arr = method.getReturnType().isArray(); sw.println("() {"); sw.indent(); if (retType.matches("(java.lang.Boolean|boolean)")) { sw.println("return getBooleanBase(\"" + name + "\");"); } else if (method.getReturnType().isPrimitive() != null) { sw.println("return (" + retType + ")getFloatBase(\"" + name + "\");"); } else if (isTypeAssignableTo(method.getReturnType(), stringType)) { sw.println("return getPropertiesBase(\"" + name + "\");"); } else if (arr != null) { String q = arr.getComponentType().getQualifiedSourceName(); sw.println("ArrayList<" + q + "> l = new ArrayList<" + q + ">();"); sw.println("for (Element e: getElementsBase(\"" + name + "\")) {");
JPrimitiveType primitiveType = type.isPrimitive(); if (primitiveType != null) { return primitiveType.getJNISignature(); JArrayType arrayType = type.isArray(); if (arrayType != null) { JType component = arrayType.getComponentType(); if (component.isClassOrInterface() != null) { return "[L" + getRpcTypeName(arrayType.getComponentType()) + ";"; } else { return "[" + getRpcTypeName(arrayType.getComponentType());
boolean isSafeHtml = m.getReturnType().getQualifiedSourceName().equals( SAFE_HTML_FQCN); if (param.getType().getQualifiedSourceName().equals(SAFE_HTML_FQCN)) { throw error(logger, "Message methods with SafeHtml arguments can only have SafeHtml return type"); int listArgNum = argChunk.getArgumentNumber(); JType listType = params[listArgNum].getType(); JClassType classType = listType.isInterface(); JType elemType = null; if (classType != null) { JArrayType arrayType = listType.isArray(); if (arrayType != null) { elemType = arrayType.getComponentType(); listAccessor = new ListAccessorArray(listArgNum);
public JClassType getAssociationType(PropertyDescriptor p, boolean useField) { JType type = this.getElementType(p, useField); JArrayType jArray = type.isArray(); if (jArray != null) { return jArray.getComponentType().isClassOrInterface(); } JParameterizedType pType = type.isParameterized(); JClassType[] typeArgs; if (pType == null) { JRawType rType = type.isRawType(); typeArgs = rType.getGenericType().getTypeParameters(); } else { typeArgs = pType.getTypeArgs(); } // it is either a Iterable or a Map use the last type arg. return typeArgs[typeArgs.length - 1].isClassOrInterface(); }
protected void createInvokerMethod(final ClassBuffer cb, final JClassType type, final JType returnType, final String methodName, final JParameter[] params, final boolean isStatic, final boolean isNotPrivate) { boolean hasLong = returnType.getJNISignature().equals("J"); final boolean isArray = param.isArray() != null; while (param.isArray() != null) { jsniSig.append("["); param = param.isArray().getComponentType(); jsniSig.append(param.getJNISignature());
private boolean isValideType(JType type){ if(type == null) return false; if(type.isInterface() != null) return false; if(type.isPrimitive() != null) return true; JClassType aClass = type.isClass(); if(aClass != null && (aClass.isAssignableTo(serializableIntf) || aClass.isAssignableTo(isSerializableIntf))){ return true; } JArrayType array = type.isArray(); if(array == null) return false; return isValideType(array.getComponentType()); } }
private static void generateSerializationSignature(GeneratorContext context, JType type, CRC32 crc) throws UnsupportedEncodingException { JParameterizedType parameterizedType = type.isParameterized(); if (parameterizedType != null) { generateSerializationSignature(context, parameterizedType.getRawType(), crc); if (customSerializer != null) { generateSerializationSignature(context, customSerializer, crc); } else if (type.isArray() != null) { JArrayType isArray = type.isArray(); generateSerializationSignature(context, isArray.getComponentType(), crc); } else if (type.isEnum() != null) { List<JEnumConstant> constants = Arrays.asList(type.isEnum().getEnumConstants());
if (leafType.isPrimitive() != null) { className = leafType.getSimpleSourceName(); packageName = "com.google.gwt.user.client.rpc.core"; } else { JClassType classOrInterface = leafType.isClassOrInterface(); assert (classOrInterface != null); className = classOrInterface.getName(); className += "_Array_Rank_" + isArray.getRank();
private static JType getRootComponentType(JArrayType type) { JType root = null; while (type.getComponentType() != null) { if (type.getComponentType().isArray() != null) { type = type.getComponentType().isArray(); } else { root = type.getComponentType(); break; } } return root; }
JArrayType arrayType = param.getType().isArray(); assert (arrayType != null); sb.append(arrayType.getComponentType().getParameterizedQualifiedSourceName()); sb.append("..."); } else { sb.append(param.getType().getParameterizedQualifiedSourceName());
if (t instanceof JPrimitiveType) varName = "p"; int id = nextId(); typeNames2typeIds.put(t.getErasedType().getQualifiedSourceName(), id); pb("Type " + varName + " = new Type();"); pb(varName + ".name = \"" + t.getErasedType().getQualifiedSourceName() + "\";"); pb(varName + ".id = " + id + ";"); pb(varName + ".clazz = " + t.getErasedType().getQualifiedSourceName() + ".class;"); pb(varName + ".componentType = " + getType(c.isArray().getComponentType()) + ";");