private void readAnnotations(DataInput input, AnnotationContainer annotations) throws IOException { int annotCount = input.readShort(); for (int i = 0; i < annotCount; ++i) { AnnotationHolder annot = readAnnotation(input); annotations.add(annot); } }
private void rename(AnnotationContainer source, AnnotationContainer target) { for (AnnotationHolder annot : source.all()) { if (!annot.getType().equals(Rename.class.getName()) && !annot.getType().equals(Superclass.class.getName())) { target.add(rename(annot)); } } }
public static void copyAnnotations(AnnotationContainerReader src, AnnotationContainer dst) { for (AnnotationReader annot : src.all()) { dst.add(copyAnnotation(annot)); } }
static void makeSync(MethodHolder method) { if (method.getAnnotations().get(Sync.class.getName()) == null) { AnnotationHolder annot = new AnnotationHolder(Sync.class.getName()); method.getAnnotations().add(annot); } }
private void parseAnnotations(AnnotationContainer annotations, List<AnnotationNode> visibleAnnotations, List<AnnotationNode> invisibleAnnotations) { List<Object> annotNodes = new ArrayList<>(); if (visibleAnnotations != null) { annotNodes.addAll(visibleAnnotations); } if (invisibleAnnotations != null) { annotNodes.addAll(invisibleAnnotations); } for (Object obj : annotNodes) { AnnotationNode annotNode = (AnnotationNode) obj; String desc = annotNode.desc; if (desc.startsWith("L") && desc.endsWith(";")) { desc = desc.substring(1, desc.length() - 1); } desc = desc.replace('/', '.'); if (annotations.get(desc) != null) { continue; } AnnotationHolder annot = new AnnotationHolder(referenceCache.getCached(desc)); parseAnnotationValues(annot, annotNode.values); annotations.add(annot); } }
@Override public void transformClass(ClassHolder cls, ClassHolderTransformerContext context) { for (MethodHolder method : cls.getMethods()) { if (method.getAnnotations().get(JavaScriptBody.class.getName()) != null) { AnnotationHolder genAnnot = new AnnotationHolder(GeneratedBy.class.getName()); genAnnot.getValues().put("value", new AnnotationValue(ValueType.object( JavaScriptBodyGenerator.class.getName()))); method.getAnnotations().add(genAnnot); method.setProgram(null); method.getModifiers().add(ElementModifier.NATIVE); } } } }
void createJSMethods(ClassHolder cls) { for (MethodHolder method : cls.getMethods().toArray(new MethodHolder[0])) { MethodReference methodRef = method.getReference(); if (method.getAnnotations().get(JSBody.class.getName()) == null) { continue; } requireJSBody(diagnostics, method); if (!repository.methodMap.containsKey(method.getReference())) { continue; } MethodReference proxyRef = repository.methodMap.get(methodRef); MethodHolder proxyMethod = new MethodHolder(proxyRef.getDescriptor()); proxyMethod.getModifiers().add(ElementModifier.NATIVE); proxyMethod.getModifiers().add(ElementModifier.STATIC); boolean inline = repository.inlineMethods.contains(methodRef); AnnotationHolder generatorAnnot = new AnnotationHolder(inline ? DynamicInjector.class.getName() : DynamicGenerator.class.getName()); proxyMethod.getAnnotations().add(generatorAnnot); cls.addMethod(proxyMethod); Set<MethodReference> callbacks = repository.callbackMethods.get(proxyRef); if (callbacks != null) { for (MethodReference callback : callbacks) { generateCallbackCaller(cls, callback); } } } }
private void addFunctorField(ClassHolder cls, MethodReference method) { if (cls.getAnnotations().get(FunctorImpl.class.getName()) != null) { return; } FieldHolder field = new FieldHolder("$$jso_functor$$"); field.setLevel(AccessLevel.PUBLIC); field.setType(ValueType.parse(JSObject.class)); cls.addField(field); AnnotationHolder annot = new AnnotationHolder(FunctorImpl.class.getName()); annot.getValues().put("value", new AnnotationValue(method.getDescriptor().toString())); cls.getAnnotations().add(annot); }
@Override public void transformClass(ClassHolder cls, ClassHolderTransformerContext context) { int index = 0; for (MethodHolder method : cls.getMethods().toArray(new MethodHolder[0])) { AnnotationReader providerAnnot = method.getAnnotations().get(MetadataProvider.class.getName()); if (providerAnnot != null) { transformMetadataMethod(cls, method, context.getDiagnostics(), context.getHierarchy(), index++); } providerAnnot = method.getAnnotations().get(ClassScopedMetadataProvider.class.getName()); if (providerAnnot != null) { ValueType[] params = method.getParameterTypes(); if (params.length != 1 && params[0].isObject(PlatformClass.class.getName())) { context.getDiagnostics().error(new CallLocation(method.getReference()), "Method {{m0}} marked with {{c1}} must take exactly one parameter of type {{c2}}", method.getReference(), ClassScopedMetadataProvider.class.getName(), PlatformClass.class.getName()); } AnnotationHolder genAnnot = new AnnotationHolder(GeneratedBy.class.getName()); genAnnot.getValues().put("value", new AnnotationValue(ValueType.object( ClassScopedMetadataProviderNativeGenerator.class.getName()))); method.getAnnotations().add(genAnnot); } } }
AnnotationHolder annot = new AnnotationHolder(JSMethodToExpose.class.getName()); annot.getValues().put("name", new AnnotationValue(publicAlias)); exportedMethod.getAnnotations().add(annot);
private void readAnnotations(DataInput input, AnnotationContainer annotations) throws IOException { int annotCount = input.readShort(); for (int i = 0; i < annotCount; ++i) { AnnotationHolder annot = readAnnotation(input); annotations.add(annot); } }
private void rename(AnnotationContainer source, AnnotationContainer target) { for (AnnotationHolder annot : source.all()) { if (!annot.getType().equals(Rename.class.getName()) && !annot.getType().equals(Superclass.class.getName())) { target.add(rename(annot)); } } }
public static void copyAnnotations(AnnotationContainerReader src, AnnotationContainer dst) { for (AnnotationReader annot : src.all()) { dst.add(copyAnnotation(annot)); } }
private void parseAnnotations(AnnotationContainer annotations, List<AnnotationNode> visibleAnnotations, List<AnnotationNode> invisibleAnnotations) { List<Object> annotNodes = new ArrayList<>(); if (visibleAnnotations != null) { annotNodes.addAll(visibleAnnotations); } if (invisibleAnnotations != null) { annotNodes.addAll(invisibleAnnotations); } for (Object obj : annotNodes) { AnnotationNode annotNode = (AnnotationNode) obj; String desc = annotNode.desc; if (desc.startsWith("L") && desc.endsWith(";")) { desc = desc.substring(1, desc.length() - 1); } desc = desc.replace('/', '.'); if (annotations.get(desc) != null) { continue; } AnnotationHolder annot = new AnnotationHolder(desc); parseAnnotationValues(annot, annotNode.values); annotations.add(annot); } }
void makeSync(ClassHolder cls) { Set<MethodDescriptor> methods = new HashSet<>(); findInheritedMethods(cls, methods, new HashSet<>()); for (MethodHolder method : cls.getMethods()) { if (methods.contains(method.getDescriptor()) && method.getAnnotations().get(Sync.class.getName()) == null) { AnnotationHolder annot = new AnnotationHolder(Sync.class.getName()); method.getAnnotations().add(annot); } } }
@Override public void transformClass(ClassHolder cls, ClassReaderSource innerSource, Diagnostics diagnostics) { for (MethodHolder method : cls.getMethods().toArray(new MethodHolder[0])) { AnnotationReader providerAnnot = method.getAnnotations().get(MetadataProvider.class.getName()); if (providerAnnot != null) { transformMetadataMethod(cls, method, diagnostics, innerSource); } providerAnnot = method.getAnnotations().get(ClassScopedMetadataProvider.class.getName()); if (providerAnnot != null) { ValueType[] params = method.getParameterTypes(); if (params.length != 1 && params[0].isObject(PlatformClass.class.getName())) { diagnostics.error(new CallLocation(method.getReference()), "Method {{m0}} marked with {{c1}} " + "must take exactly one parameter of type {{c2}}", method.getReference(), ClassScopedMetadataProvider.class.getName(), PlatformClass.class.getName()); } AnnotationHolder genAnnot = new AnnotationHolder(GeneratedBy.class.getName()); genAnnot.getValues().put("value", new AnnotationValue(ValueType.object( ClassScopedMetadataProviderNativeGenerator.class.getName()))); method.getAnnotations().add(genAnnot); AnnotationHolder noCacheAnnot = new AnnotationHolder(NoCache.class.getName()); method.getAnnotations().add(noCacheAnnot); } } }
void createJSMethods(ClassHolder cls) { for (MethodHolder method : cls.getMethods().toArray(new MethodHolder[0])) { MethodReference methodRef = method.getReference(); if (method.getAnnotations().get(JSBody.class.getName()) == null) { continue; } requireJSBody(diagnostics, method); if (!repository.methodMap.containsKey(method.getReference())) { continue; } MethodReference proxyRef = repository.methodMap.get(methodRef); MethodHolder proxyMethod = new MethodHolder(proxyRef.getDescriptor()); proxyMethod.getModifiers().add(ElementModifier.NATIVE); proxyMethod.getModifiers().add(ElementModifier.STATIC); boolean inline = repository.inlineMethods.contains(methodRef); AnnotationHolder generatorAnnot = new AnnotationHolder(inline ? InjectedBy.class.getName() : GeneratedBy.class.getName()); generatorAnnot.getValues().put("value", new AnnotationValue(ValueType.parse(JSBodyGenerator.class))); proxyMethod.getAnnotations().add(generatorAnnot); cls.addMethod(proxyMethod); Set<MethodReference> callbacks = repository.callbackMethods.get(proxyRef); if (callbacks != null) { for (MethodReference callback : callbacks) { generateCallbackCaller(cls, callback); } } } }
private void addFunctorField(ClassHolder cls, MethodReference method) { if (cls.getAnnotations().get(FunctorImpl.class.getName()) != null) { return; } FieldHolder field = new FieldHolder("$$jso_functor$$"); field.setLevel(AccessLevel.PUBLIC); field.setType(ValueType.parse(JSObject.class)); cls.addField(field); AnnotationHolder annot = new AnnotationHolder(FunctorImpl.class.getName()); annot.getValues().put("value", new AnnotationValue(method.getDescriptor().toString())); cls.getAnnotations().add(annot); }
genAnnot.getValues().put("value", new AnnotationValue(ValueType.object( MetadataProviderNativeGenerator.class.getName()))); createMethod.getAnnotations().add(genAnnot); ModelUtils.copyAnnotations(method.getAnnotations(), createMethod.getAnnotations()); createMethod.getAnnotations().add(refAnnot); method.getAnnotations().add(noCacheAnnot);