Esempio n. 1
0
 private static void closeMPL(List<MplData> mpl, Type rt, GenerateJsVisitor gen) {
   for (int i = mpl.size() - 1; i > 0; i--) {
     final MplData pl = mpl.get(i);
     gen.endBlock(true, true);
     pl.outputMetamodelAndReturn(gen, rt);
     if (i > 1) {
       rt =
           ModelUtil.appliedType(
               pl.n.getUnit().getCallableDeclaration(), rt, pl.tupleFromParameterList());
     }
   }
 }
Esempio n. 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);
       }
     }
   }
 }