private String generateChecksum( JMethod[] methods ) { StringBuilder b = new StringBuilder(); for( int i = 0; i < methods.length; i++ ) b.append( methods[i].getJsniSignature() ); return String.valueOf( Math.abs( b.toString().hashCode() ) ); }
private String generateChecksum( JMethod[] methods ) { StringBuilder b = new StringBuilder(); for( int i = 0; i < methods.length; i++ ) b.append( methods[i].getJsniSignature() ); return String.valueOf( Math.abs( b.toString().hashCode() ) ); }
private static void extractMethods(TreeLogger logger, KeepMethod keepMethod, JClassType injectionType, ReflectionManifest manifest) { boolean keepMethods = keepMethod != null; boolean keepAnnos = manifest.anno != null; Set<String> seen = new HashSet<String>(); Set<? extends JClassType> allTypes = injectionType.getFlattenedSupertypeHierarchy(); for(JClassType nextClass : allTypes) { for (JMethod method : nextClass.getMethods()) { if (keepMethods || method.getAnnotation(KeepMethod.class) != null){ // do not include overridden methods if (seen.add(method.getJsniSignature())) { final Annotation[] annos; if (keepAnnos || method.getAnnotation(KeepAnnotation.class) != null) { annos = method.getAnnotations(); } else { // only keep annotations annotated with KeepAnnotation. final List<Annotation> keepers = new ArrayList<Annotation>(); for (Annotation anno : method.getAnnotations()) { if (anno.annotationType().getAnnotation(KeepAnnotation.class) != null) keepers.add(anno); } annos = keepers.toArray(new Annotation[keepers.size()]); } manifest.methods.put(method, annos); } } } nextClass = nextClass.getSuperclass(); } }
public static void generateFilter(GeneratorContext context, SourceWriter sw, Class<?> clazz, NgInject ngInject, String compInstance) { sw.println("module.filter('" + determineName(clazz.getSimpleName(),ngInject) + "', function() {"); sw.indent(); JClassType filterType = context.getTypeOracle().findType(clazz.getName()); JMethod filter = ClassHelper.methodByName(filterType,"filter"); sw.println("return %s.%s;", compInstance, filter.getJsniSignature()); sw.outdent(); sw.println("});"); }
if (retention == null) retention = strategy.methodRetention(); declaredMethods.put(method.getJsniSignature(), new ReflectionUnit<JMethod>(method, retention)); if (!uniqueNames.add(method.getName())) { overloadedMethods.add(method.getName());
sw.println("directive." + initMethod.getJsniSignature() + "()");
retention = strategy.methodRetention(); declaredMethods.put(method.getJsniSignature(), new ReflectionUnit<JMethod>(method, retention)); if (!uniqueNames.add(method.getName())) { overloadedMethods.add(method.getName());
if (!method.isPublic()) { logger.log(Type.TRACE, "Non-public method " +method.getJsniSignature() + " skipped because declared=false."); continue;
if (!method.isPublic()) { logger.log(Type.TRACE, "Non-public method " +method.getJsniSignature() + " skipped because declared=false."); continue;
JClassType implementingJso = findImplementingTypeForMethod(jso, method); assert implementingJso != null : "Jso should contain method: " + method.getJsniSignature(); add(implementingJso, method);
JClassType implementingJso = findImplementingTypeForMethod(jso, method); assert implementingJso != null : "Jso should contain method: " + method.getJsniSignature(); add(implementingJso, method);
private static void generateService(SourceWriter sw, final String instance, JClassType serviceType) { boolean first=true; sw.println("return $wnd.angular.extend(" + instance +",{"); sw.indent(); for(JMethod m : ClassHelper.publicMethods(serviceType)) { if(!first) sw.print(","); else first=false; String argString = ClassHelper.declareArgs(m); sw.println(m.getName() + " : $entry(function(" + argString + ") {"); sw.indent(); sw.print(ClassHelper.isVoidMethod(m) ? "" : "return "); sw.print(instance + "." + m.getJsniSignature()); sw.println("(" + argString + ");"); sw.outdent(); sw.println("})"); } sw.outdent(); sw.println("});"); //sw.println(" return " + instance + ";"); }
sw.indent(); sw.print(ClassHelper.isVoidMethod(action) ? "" : "return "); sw.print("self." + action.getJsniSignature()); sw.println("(" + argString + ");"); sw.outdent(); sw.indent(); sw.print(ClassHelper.isVoidMethod(action) ? "" : "return "); sw.print("self." + action.getJsniSignature()); sw.println("(" + argString + ");"); sw.outdent();
private void writeGetterWrapperMethod(SourceWriter sw, JMethod method) { writeUnsafeNativeLongIfNeeded(sw, method.getReturnType()); // private native fieldType _getter(Bean object) /*={ sw.print("private native "); sw.print(method.getReturnType().getQualifiedSourceName()); sw.print(" "); sw.print(toWrapperName(method)); sw.print("("); sw.print(beanType.getName()); sw.println(" object) /*-{"); sw.indent(); // return object.@com.examples.Bean::myMethod()(); sw.print("return object."); sw.print(method.getJsniSignature()); sw.println("();"); // }-*/; sw.outdent(); sw.println("}-*/;"); }
private void writeGetterWrapperMethod(SourceWriter sw, JMethod method) { writeUnsafeNativeLongIfNeeded(sw, method.getReturnType()); // private native fieldType _getter(Bean object) /*={ sw.print("private native "); sw.print(method.getReturnType().getQualifiedSourceName()); sw.print(" "); sw.print(toWrapperName(method)); sw.print("("); sw.print(beanType.getName()); sw.println(" object) /*-{"); sw.indent(); // return object.@com.examples.Bean::myMethod()(); sw.print("return object."); sw.print(method.getJsniSignature()); sw.println("();"); // }-*/; sw.outdent(); sw.println("}-*/;"); }
private void writeGetterWrapperMethod(final SourceWriter sw, final JMethod method) { writeUnsafeNativeLongIfNeeded(sw, method.getReturnType()); // private native fieldType _getter(Bean object) /*={ sw.print("private native "); sw.print(method.getReturnType().getQualifiedSourceName()); sw.print(" "); sw.print(this.toWrapperName(method)); sw.print("("); sw.print(beanType.getName()); sw.println(" object) /*-{"); sw.indent(); // return object.@com.examples.Bean::myMethod()(); sw.print("return object."); sw.print(method.getJsniSignature()); sw.println("();"); // }-*/; sw.outdent(); sw.println("}-*/;"); }
for (JMethod m : list) { sw.println("case '" + m.getName() + "': return this." + m.getJsniSignature() + "();");
for (JMethod m : list) { sw.println("case '" + m.getName() + "': return this." + m.getJsniSignature() + "();");
final boolean fluent = method.getReturnType() != JPrimitiveType.VOID; assert !fluent || isAssignableFrom(method.getReturnType(), method.getEnclosingType()) : "Cannot implement fluent method " + method.getJsniSignature(); out .println("return function(i) {")