// Declared in VariableDeclaration.jrag at line 124
 private FieldDeclaration rewriteRule0() {
   {
     FieldDeclaration decl =
         getVariableDecl(0).createFieldDeclarationFrom(getModifiers(), getTypeAccess());
     decl.setStart(start); // copy location information
     decl.setEnd(end); // copy location information
     return decl;
   }
 }
Example #2
0
  // Declared in AnonymousClasses.jrag at line 52
  private AnonymousDecl rewriteRule0() {
    {
      setModifiers(new Modifiers(new List().add(new Modifier("final"))));

      ConstructorDecl constructor = new ConstructorDecl();
      addBodyDecl(constructor);

      constructor.setModifiers((Modifiers) constructorDecl().getModifiers().fullCopy());
      String name = "Anonymous" + nextAnonymousIndex();
      setID(name);
      constructor.setID(name);

      List parameterList = new List();
      for (int i = 0; i < constructorDecl().getNumParameter(); i++) {
        parameterList.add(
            new ParameterDeclaration(
                constructorDecl().getParameter(i).type().createBoundAccess(),
                constructorDecl().getParameter(i).name()));
      }
      constructor.setParameterList(parameterList);

      List argList = new List();
      for (int i = 0; i < constructor.getNumParameter(); i++)
        argList.add(new VarAccess(constructor.getParameter(i).name()));
      constructor.setConstructorInvocation(
          new ExprStmt(new SuperConstructorAccess("super", argList)));
      constructor.setBlock(new Block());

      HashSet set = new HashSet();
      for (int i = 0; i < getNumBodyDecl(); i++) {
        if (getBodyDecl(i) instanceof InstanceInitializer) {
          InstanceInitializer init = (InstanceInitializer) getBodyDecl(i);
          set.addAll(init.exceptions());
        } else if (getBodyDecl(i) instanceof FieldDeclaration) {
          FieldDeclaration f = (FieldDeclaration) getBodyDecl(i);
          if (f.isInstanceVariable()) {
            set.addAll(f.exceptions());
          }
        }
      }
      List exceptionList = new List();
      for (Iterator iter = set.iterator(); iter.hasNext(); ) {
        TypeDecl exceptionType = (TypeDecl) iter.next();
        if (exceptionType.isNull()) exceptionType = typeNullPointerException();
        exceptionList.add(exceptionType.createQualifiedAccess());
      }
      constructor.setExceptionList(exceptionList);
      return this;
    }
  }
 // Declared in VariableDeclaration.jrag at line 135
 private List rewriteTypeDecl_getBodyDecl() {
   {
     List varList = new List();
     for (int j = 0; j < getNumVariableDecl(); j++) {
       FieldDeclaration f =
           getVariableDecl(j)
               .createFieldDeclarationFrom(
                   (Modifiers) getModifiers().fullCopy(), (Access) getTypeAccess().fullCopy());
       if (j == 0) f.setStart(start);
       else {
         f.getModifiersNoTransform().clearLocations();
         f.getTypeAccessNoTransform().clearLocations();
       }
       f.setFieldDecl(this);
       varList.add(f);
     }
     return varList;
   }
 }