private static void getAllMethods(
     ClassOrInterface c, TypeDeclaration t, List<MethodWithContainer> members) {
   for (Declaration d : t.getMembers()) {
     if (d instanceof Function) {
       Function m = (Function) d;
       boolean contains = false;
       for (MethodWithContainer member : members) {
         if (member.getMethod().getName().equals(m.getName())) {
           contains = true;
           break;
         }
       }
       if (!contains) {
         members.add(new MethodWithContainer(c, m));
       }
     }
   }
   Type et = t.getExtendedType();
   if (et != null) {
     getAllMethods(c, et.getDeclaration(), members);
   }
   for (Type st : t.getSatisfiedTypes()) {
     getAllMethods(c, st.getDeclaration(), members);
   }
 }
Пример #2
0
 /**
  * See #547 - a generic actual method that has different names in its type parameters as the one
  * it's refining, can receive the type arguments of the parent instead.
  */
 static void addParentMethodTypeParameters(final Function m, final GenerateJsVisitor gen) {
   List<TypeParameter> tps = m.getTypeParameters();
   if (m.isActual() && tps != null && !tps.isEmpty()) {
     // This gives us the root declaration
     Function sm = (Function) m.getRefinedDeclaration();
     for (int i = 0; i < tps.size(); i++) {
       boolean end = false;
       end |= copyMissingTypeParameters(m, sm, i, true, gen);
       // We still need to find intermediate declarations
       if (m.isClassOrInterfaceMember()) {
         final Set<Declaration> decs = new HashSet<Declaration>();
         decs.add(sm);
         decs.add(m);
         // This gives us the containing type
         TypeDeclaration cont = ModelUtil.getContainingClassOrInterface(m);
         for (TypeDeclaration sup : cont.getSupertypeDeclarations()) {
           Declaration d = sup.getDirectMember(m.getName(), null, false);
           if (d instanceof Function && !decs.contains(d)) {
             decs.add(d);
             end |= copyMissingTypeParameters(m, (Function) d, i, false, gen);
           }
         }
         for (Type sup : cont.getSatisfiedTypes()) {
           Declaration d = sup.getDeclaration().getDirectMember(m.getName(), null, false);
           if (d instanceof Function && !decs.contains(d)) {
             decs.add(d);
             end |= copyMissingTypeParameters(m, (Function) d, i, false, gen);
           }
         }
       }
       if (end) {
         gen.endLine(true);
       }
     }
   }
 }