private String getElementTypes (JField f) { StringBuilder b = new StringBuilder(); JParameterizedType params = f.getType().isParameterized(); if (params != null) { JClassType[] typeArgs = params.getTypeArgs(); b.append("new Class[] {"); for (JClassType typeArg : typeArgs) { if (typeArg.isWildcard() != null) b.append("null"); else if (!isVisible(typeArg)) b.append("null"); else if (typeArg.isClassOrInterface() != null) b.append(typeArg.isClassOrInterface().getQualifiedSourceName()).append(".class"); else if (typeArg.isParameterized() != null) b.append(typeArg.isParameterized().getQualifiedBinaryName()).append(".class"); else b.append("null"); b.append(", "); } b.append("}"); return b.toString(); } return "null"; }
private String getElementTypes (JField f) { StringBuilder b = new StringBuilder(); JParameterizedType params = f.getType().isParameterized(); if (params != null) { JClassType[] typeArgs = params.getTypeArgs(); b.append("new Class[] {"); for (JClassType typeArg : typeArgs) { if (typeArg.isWildcard() != null) b.append("null"); else if (!isVisible(typeArg)) b.append("null"); else if (typeArg.isClassOrInterface() != null) b.append(typeArg.isClassOrInterface().getQualifiedSourceName()).append(".class"); else if (typeArg.isParameterized() != null) b.append(typeArg.isParameterized().getQualifiedBinaryName()).append(".class"); else b.append("null"); b.append(", "); } b.append("}"); return b.toString(); } return "null"; }
public ReflectionCacheSourceCreator (TreeLogger logger, GeneratorContext context, JClassType type) { this.logger = logger; this.context = context; this.type = type; this.packageName = type.getPackage().getName(); this.simpleName = type.getSimpleSourceName() + "Generated"; logger.log(Type.INFO, type.getQualifiedSourceName()); }
public ReflectionCacheSourceCreator (TreeLogger logger, GeneratorContext context, JClassType type) { this.logger = logger; this.context = context; this.type = type; this.packageName = type.getPackage().getName(); this.simpleName = type.getSimpleSourceName() + "Generated"; logger.log(Type.INFO, type.getQualifiedSourceName()); }
@Override public int compare(JClassType o1, JClassType o2) { return o1.getQualifiedSourceName().compareTo(o2.getQualifiedSourceName()); } }
protected boolean isReturnTypeString(JClassType classReturnType) { return (classReturnType != null && String.class.getName().equals(classReturnType.getQualifiedSourceName())); }
private String source(JMethod o) { return o.getEnclosingType().getQualifiedSourceName(); } });
String superClass = null; if (c != null && (isVisible(c.getSuperclass()))) superClass = c.getSuperclass().getErasedType().getQualifiedSourceName() + ".class"; String assignables = null; String interfaces = null; pb(varName + ".enumConstants = new Object[" + enumConstants.length + "];"); for (int i = 0; i < enumConstants.length; i++) { pb(varName + ".enumConstants[" + i + "] = " + c.getErasedType().getQualifiedSourceName() + "." + enumConstants[i].getName() + ";");
@Override public String parse(XMLElement source, String value) throws UnableToCompleteException { JEnumConstant c = values.get(value); if (c != null) { return String.format("%s.%s", c.getEnclosingType().getQualifiedSourceName(), value); } return super.parse(source, value); } }
String superClass = null; if (c != null && (isVisible(c.getSuperclass()))) superClass = c.getSuperclass().getErasedType().getQualifiedSourceName() + ".class"; String assignables = null; String interfaces = null; pb(varName + ".enumConstants = new Object[" + enumConstants.length + "];"); for (int i = 0; i < enumConstants.length; i++) { pb(varName + ".enumConstants[" + i + "] = " + c.getErasedType().getQualifiedSourceName() + "." + enumConstants[i].getName() + ";");
private static String key(JMethod method) { return method.getEnclosingType().getQualifiedSourceName() + "." + method.getName(); }
private String computeDefaultPrefix(ResourceContext context) { SortedSet<JClassType> gssResources = computeOperableTypes(context); Adler32 checksum = new Adler32(); for (JClassType type : gssResources) { checksum.update(Util.getBytes(type.getQualifiedSourceName())); } int seed = Math.abs((int) checksum.getValue()); return encode(seed) + "-"; }
@Override public String createAssignment(TreeLogger logger, ResourceContext context, JMethod method) throws UnableToCompleteException { JClassType gwtType = context.getGeneratorContext().getTypeOracle().findType( GWT.class.getName()); assert gwtType != null; return gwtType.getQualifiedSourceName() + ".create(" + method.getReturnType().getQualifiedSourceName() + ".class)"; } }
checksum.update(Util.getBytes(type.getQualifiedSourceName()));
/** * Creates a cache key to be used with {@link ResourceContext#putCachedData}. * The key is based on the ClientBundle type, support for data URLs, and the * current locale. */ private String createCacheKey(ResourceContext context) { StringBuilder sb = new StringBuilder(); sb.append(context.getClientBundleType().getQualifiedSourceName()); sb.append(":").append(context.supportsDataUrls()); try { String locale = context.getGeneratorContext().getPropertyOracle().getSelectionProperty( TreeLogger.NULL, "locale").getCurrentValue(); // add the locale selection property as a permuation axis for our requirements context.getRequirements().addPermutationAxis("locale"); sb.append(locale); } catch (BadPropertyValueException e) { // OK, locale isn't defined } return sb.toString(); }
@Override public void createFields(TreeLogger logger, ResourceContext context, ClientBundleFields fields) throws UnableToCompleteException { data.append(']'); StringBuffer wrappedData = new StringBuffer(); if (shouldUseJsonp(context, logger)) { wrappedData.append(JSONP_CALLBACK_PREFIX); wrappedData.append(getMd5HashOfData()); wrappedData.append(".onSuccess(\n"); wrappedData.append(data.toString()); wrappedData.append(")"); } else { wrappedData = data; } urlExpression = context.deploy( context.getClientBundleType().getQualifiedSourceName().replace('.', '_') + "_jsonbundle.txt", "text/plain", Util.getBytes(wrappedData.toString()), true); TypeOracle typeOracle = context.getGeneratorContext().getTypeOracle(); JClassType stringType = typeOracle.findType(String.class.getName()); assert stringType != null; externalTextUrlIdent = fields.define(stringType, "externalTextUrl", urlExpression, true, true); JClassType textResourceType = typeOracle.findType(TextResource.class.getName()); assert textResourceType != null; JType textResourceArrayType = typeOracle.getArrayType(textResourceType); externalTextCacheIdent = fields.define(textResourceArrayType, "externalTextCache", "new " + TextResource.class.getName() + "[" + currentIndex + "]", true, true); }
@Override public String createAssignment(TreeLogger logger, ResourceContext context, JMethod method) throws UnableToCompleteException { JParameterizedType returnType = method.getReturnType().isParameterized(); assert returnType != null; JClassType args[] = returnType.getTypeArgs(); assert args.length == 1; ClassType override = method.getAnnotation(ClassType.class); JClassType toCreate; if (override != null) { toCreate = context.getGeneratorContext().getTypeOracle().findType( override.value().getName().replace('$', '.')); assert toCreate != null; } else { toCreate = args[0]; } JClassType gwtType = context.getGeneratorContext().getTypeOracle().findType( GWT.class.getName()); assert gwtType != null; return "new " + returnType.getParameterizedQualifiedSourceName() + "() {\n public " + toCreate.getQualifiedSourceName() + " create() {\n return " + gwtType.getQualifiedSourceName() + ".create(" + toCreate.getQualifiedSourceName() + ".class);}\n" + "public String getName() { return \"" + method.getName() + "\";}}"; } }
public String getPrettyName(String method, JClassType type, String obfuscatedName) { if (!isPretty()) { return obfuscatedName; } String toReturn = method; /* * Note that by dropping the type, or using it's short name, you are * allowing name collisions in the css selector names. These options should * only be used if you are sure that your GWT application is ensuring that * there are no namespace collisions. */ if (showClassName) { if (showPackageName) { toReturn = getPrettyCssClass(type.getQualifiedSourceName(), toReturn); } else { toReturn = getPrettyCssClass(type.getName(), toReturn); } } /* * For stable styles the obfuscated class name is dropped from the pretty * output. This results in class names that are constant, no matter how * many other selectors are added. */ if (!isStable) { toReturn = obfuscatedName += "-" + toReturn; } return toReturn; }
public void parse(XMLElement elem, String fieldName, JClassType type, UiBinderWriter writer) throws UnableToCompleteException { HtmlInterpreter interpreter = new HtmlInterpreter(writer, fieldName, new HtmlMessageInterpreter(writer, fieldName)); interpreter.interpretElement(elem); writer.beginAttachedSection(fieldName); String html = elem.consumeOpeningTag() + elem.consumeInnerHtml(interpreter) + elem.getClosingTag(); writer.endAttachedSection(); writer.setFieldInitializer(fieldName, String.format( "(%1$s) UiBinderUtil.fromHtml(%2$s)", type.getQualifiedSourceName(), writer.declareTemplateCall(html, fieldName))); } }
public void parse(XMLElement elem, String fieldName, JClassType type, UiBinderWriter writer) throws UnableToCompleteException { if (MenuBar.class.getName().equals(type.getQualifiedSourceName())) { if (elem.hasAttribute("vertical")) { String vertical = elem.consumeBooleanAttribute("vertical");