private boolean isStrictResource(JMethod method) { NotStrict notStrict = method.getAnnotation(NotStrict.class); return notStrict == null; }
/** * Check for the presence of the NotStrict annotation on the method. This will * also perform some limited sanity-checking for the now-deprecated Strict * annotation. */ @SuppressWarnings("deprecation") // keep references to deprecated Strict annotation local private boolean isStrict(TreeLogger logger, JMethod method) { com.google.gwt.resources.client.CssResource.Strict strictAnnotation = method.getAnnotation(com.google.gwt.resources.client.CssResource.Strict.class); NotStrict nonStrictAnnotation = method.getAnnotation(NotStrict.class); boolean strict = true; if (strictAnnotation != null && nonStrictAnnotation != null) { // Both annotations logger.log(TreeLogger.WARN, "Contradictory annotations " + com.google.gwt.resources.client.CssResource.Strict.class.getName() + " and " + NotStrict.class.getName() + " applied to the CssResource accessor method; assuming strict"); } else if (nonStrictAnnotation != null) { // Only the non-strict annotation strict = false; } return strict; }
public ImageResourceDeclaration(JMethod method) { super(key(method)); this.name = method.getName(); this.method = method; this.options = method.getAnnotation(ImageOptions.class); }
private String getClassName(JMethod method) { String name = method.getName(); ClassName classNameOverride = method.getAnnotation(ClassName.class); if (classNameOverride != null) { name = classNameOverride.value(); } return name; }
ClassName className = method.getAnnotation(ClassName.class); if (className != null) { sourceClassName = className.value();
Import imp = method.getAnnotation(Import.class); if (imp != null) { boolean fail = false;
for (JMethod m : missingClasses) { String name = m.getName(); ClassName className = m.getAnnotation(ClassName.class); if (className != null) { name = className.value();
private Map<String, Map<String, String>> computeReplacements(JMethod method, TreeLogger logger, ResourceContext context) throws UnableToCompleteException { Map<String, Map<String, String>> replacementsWithPrefix = new HashMap<String, Map<String, String>>(); replacementsWithPrefix .put("", computeReplacementsForType(method.getReturnType().isInterface())); // Process the Import annotation if any Import imp = method.getAnnotation(Import.class); if (imp != null) { boolean fail = false; TypeOracle typeOracle = context.getGeneratorContext().getTypeOracle(); for (Class<? extends CssResource> clazz : imp.value()) { JClassType importType = typeOracle.findType(clazz.getName().replace('$', '.')); assert importType != null : "TypeOracle does not have type " + clazz.getName(); // add this import type as a requirement for this generator context.getRequirements().addTypeHierarchy(importType); String prefix = getImportPrefix(importType); if (replacementsWithPrefix.put(prefix, computeReplacementsForType(importType)) != null) { logger.log(TreeLogger.ERROR, "Multiple imports that would use the prefix " + prefix); fail = true; } } if (fail) { throw new UnableToCompleteException(); } } return replacementsWithPrefix; }
boolean gssEnabled) throws UnableToCompleteException { boolean isSourceAnnotationUsed = method.getAnnotation(Source.class) != null; String[] sourceFiles = method.getAnnotation(Source.class).value(); for (int i = 0; i < sourceFiles.length; i++) { String original = sourceFiles[i];
MimeType mimeTypeAnnotation = method.getAnnotation(MimeType.class); String mimeType = mimeTypeAnnotation != null ? mimeTypeAnnotation.value() : null; DoNotEmbed doNotEmbed = method.getAnnotation(DoNotEmbed.class); boolean forceExternal = (doNotEmbed != null);
ClassName classNameOverride = method.getAnnotation(ClassName.class); if (classNameOverride != null) { name = classNameOverride.value();
@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() + "\";}}"; } }
private boolean isCache(JMethod method) { boolean cache = false; Cache cacheAnn = method.getAnnotation(Cache.class); cache = (cacheAnn != null); return cache; }
@Override @SuppressWarnings("deprecation") public Resource getAnnotation(Class<Resource> clazz) { return delegate.getAnnotation(clazz); }
ImageOptions options = imageMethod.getAnnotation(ImageOptions.class); RepeatStyle repeatStyle; if (options != null) {
Source resourceAnnotation = method.getAnnotation(Source.class); URL[] toReturn;
ImageOptions options = imageMethod.getAnnotation(ImageOptions.class); RepeatStyle repeatStyle = options != null ? options.repeatStyle() : RepeatStyle.None;
public <A extends Annotation> A getAnnotation(Class<A> annotClass) { A annot = method.getAnnotation(annotClass); if (annot != null) { return annot; } return method.getEnclosingType().findAnnotationInTypeHierarchy(annotClass); }
public static EditorAccess via(JMethod method) { String path = method.getName(); Path pathAnnotation = method.getAnnotation(Editor.Path.class); if (pathAnnotation != null) { path = pathAnnotation.value(); } else if (path.endsWith(EDITOR_SUFFIX)) { path = path.substring(0, path.length() - EDITOR_SUFFIX.length()); } return new EditorAccess(path, method.getReturnType().isClassOrInterface(), method.getName() + "()"); }
protected void generateMethodBody(SourceWriter sw, JMethod method, TreeLogger treeLogger, boolean hasContext) throws UnableToCompleteException { String selector = method.getAnnotation(Selector.class).value(); sw.println("return " + wrap(method, "impl.select(\"" + selector + "\", root)") + ";"); } }