예제 #1
0
 public StringBuffer printStatement(int tab, StringBuffer output) {
   printIndent(tab, output);
   output.append("assert "); // $NON-NLS-1$
   this.assertExpression.printExpression(0, output);
   if (this.exceptionArgument != null) {
     output.append(": "); // $NON-NLS-1$
     this.exceptionArgument.printExpression(0, output);
   }
   return output.append(';');
 }
  public StringBuffer printExpression(int indent, StringBuffer output) {

    output.append("new "); // $NON-NLS-1$
    type.print(0, output);
    for (int i = 0; i < dimensions.length; i++) {
      if (dimensions[i] == null) output.append("[]"); // $NON-NLS-1$
      else {
        output.append('[');
        dimensions[i].printExpression(0, output);
        output.append(']');
      }
    }
    if (initializer != null) initializer.printExpression(0, output);
    return output;
  }
  public StringBuffer printBody(int indent, StringBuffer output) {

    if (isAbstract() || (this.modifiers & ExtraCompilerModifiers.AccSemicolonBody) != 0)
      return output.append(';');

    output.append(" {"); // $NON-NLS-1$
    if (this.statements != null) {
      for (int i = 0; i < this.statements.length; i++) {
        output.append('\n');
        this.statements[i].printStatement(indent, output);
      }
    }
    output.append('\n');
    printIndent(indent == 0 ? 0 : indent - 1, output).append('}');
    return output;
  }
예제 #4
0
파일: ASTNode.java 프로젝트: beefeather/ohl
 public static StringBuffer printAnnotations(Annotation[] annotations, StringBuffer output) {
   int length = annotations.length;
   for (int i = 0; i < length; i++) {
     annotations[i].print(0, output);
     output.append(" "); // $NON-NLS-1$
   }
   return output;
 }
 public StringBuffer printExpression(int indent, StringBuffer output) {
   if (this.type != null) { // type null for enum constant initializations
     output.append("new "); // $NON-NLS-1$
   }
   if (this.typeArguments != null) {
     output.append('<');
     int max = this.typeArguments.length - 1;
     for (int j = 0; j < max; j++) {
       this.typeArguments[j].print(0, output);
       output.append(", "); // $NON-NLS-1$
     }
     this.typeArguments[max].print(0, output);
     output.append('>');
   }
   if (this.type != null) { // type null for enum constant initializations
     this.type.printExpression(0, output);
   }
   output.append('(');
   if (this.arguments != null) {
     for (int i = 0; i < this.arguments.length; i++) {
       if (i > 0) output.append(", "); // $NON-NLS-1$
       this.arguments[i].printExpression(0, output);
     }
   }
   return output.append(')');
 }
예제 #6
0
  public StringBuffer printExpression(int indent, StringBuffer output) {

    output.append('{');
    if (this.expressions != null) {
      int j = 20;
      for (int i = 0; i < this.expressions.length; i++) {
        if (i > 0) output.append(", "); // $NON-NLS-1$
        this.expressions[i].printExpression(0, output);
        j--;
        if (j == 0) {
          output.append('\n');
          printIndent(indent + 1, output);
          j = 20;
        }
      }
    }
    return output.append('}');
  }
예제 #7
0
파일: ASTNode.java 프로젝트: beefeather/ohl
  public static StringBuffer printModifiers(int modifiers, StringBuffer output) {

    if ((modifiers & ClassFileConstants.AccPublic) != 0) output.append("public "); // $NON-NLS-1$
    if ((modifiers & ClassFileConstants.AccPrivate) != 0) output.append("private "); // $NON-NLS-1$
    if ((modifiers & ClassFileConstants.AccProtected) != 0)
      output.append("protected "); // $NON-NLS-1$
    if ((modifiers & ClassFileConstants.AccStatic) != 0) output.append("static "); // $NON-NLS-1$
    if ((modifiers & ClassFileConstants.AccFinal) != 0) output.append("final "); // $NON-NLS-1$
    if ((modifiers & ClassFileConstants.AccSynchronized) != 0)
      output.append("synchronized "); // $NON-NLS-1$
    if ((modifiers & ClassFileConstants.AccVolatile) != 0)
      output.append("volatile "); // $NON-NLS-1$
    if ((modifiers & ClassFileConstants.AccTransient) != 0)
      output.append("transient "); // $NON-NLS-1$
    if ((modifiers & ClassFileConstants.AccNative) != 0) output.append("native "); // $NON-NLS-1$
    if ((modifiers & ClassFileConstants.AccAbstract) != 0)
      output.append("abstract "); // $NON-NLS-1$
    return output;
  }
예제 #8
0
  public StringBuffer printStatement(int indent, StringBuffer output) {
    printIndent(indent, output).append("try \n"); // $NON-NLS-1$
    this.tryBlock.printStatement(indent + 1, output);

    // catches
    if (this.catchBlocks != null)
      for (int i = 0; i < this.catchBlocks.length; i++) {
        output.append('\n');
        printIndent(indent, output).append("catch ("); // $NON-NLS-1$
        this.catchArguments[i].print(0, output).append(") "); // $NON-NLS-1$
        this.catchBlocks[i].printStatement(indent + 1, output);
      }
    // finally
    if (this.finallyBlock != null) {
      output.append('\n');
      printIndent(indent, output).append("finally\n"); // $NON-NLS-1$
      this.finallyBlock.printStatement(indent + 1, output);
    }
    return output;
  }
  public StringBuffer print(int tab, StringBuffer output) {

    if (this.javadoc != null) {
      this.javadoc.print(tab, output);
    }
    printIndent(tab, output);
    printModifiers(this.modifiers, output);
    if (this.annotations != null) {
      printAnnotations(this.annotations, output);
      output.append(' ');
    }

    TypeParameter[] typeParams = typeParameters();
    if (typeParams != null) {
      output.append('<');
      int max = typeParams.length - 1;
      for (int j = 0; j < max; j++) {
        typeParams[j].print(0, output);
        output.append(", "); // $NON-NLS-1$
      }
      typeParams[max].print(0, output);
      output.append('>');
    }

    printReturnType(0, output).append(this.selector).append('(');
    if (this.receiver != null) {
      this.receiver.print(0, output);
    }
    if (this.arguments != null) {
      for (int i = 0; i < this.arguments.length; i++) {
        if (i > 0 || this.receiver != null) output.append(", "); // $NON-NLS-1$
        this.arguments[i].print(0, output);
      }
    }
    output.append(')');
    if (this.thrownExceptions != null) {
      output.append(" throws "); // $NON-NLS-1$
      for (int i = 0; i < this.thrownExceptions.length; i++) {
        if (i > 0) output.append(", "); // $NON-NLS-1$
        this.thrownExceptions[i].print(0, output);
      }
    }
    printBody(tab + 1, output);
    return output;
  }
 /** @return char[][] */
 public char[][] getParameterizedTypeName() {
   StringBuffer buffer = new StringBuffer(5);
   buffer.append(this.token).append('<');
   for (int i = 0, length = this.typeArguments.length; i < length; i++) {
     if (i > 0) buffer.append(',');
     buffer.append(
         CharOperation.concatWith(this.typeArguments[i].getParameterizedTypeName(), '.'));
   }
   buffer.append('>');
   int nameLength = buffer.length();
   char[] name = new char[nameLength];
   buffer.getChars(0, nameLength, name, 0);
   int dim = this.dimensions;
   if (dim > 0) {
     char[] dimChars = new char[dim * 2];
     for (int i = 0; i < dim; i++) {
       int index = i * 2;
       dimChars[index] = '[';
       dimChars[index + 1] = ']';
     }
     name = CharOperation.concat(name, dimChars);
   }
   return new char[][] {name};
 }
 public StringBuffer printExpression(int indent, StringBuffer output) {
   if (this.annotations != null && this.annotations[0] != null) {
     printAnnotations(this.annotations[0], output);
     output.append(' ');
   }
   output.append(this.token);
   output.append("<"); // $NON-NLS-1$
   int length = this.typeArguments.length;
   if (length > 0) {
     int max = length - 1;
     for (int i = 0; i < max; i++) {
       this.typeArguments[i].print(0, output);
       output.append(", "); // $NON-NLS-1$
     }
     this.typeArguments[max].print(0, output);
   }
   output.append(">"); // $NON-NLS-1$
   if ((this.bits & IsVarArgs) != 0) {
     for (int i = 0; i < this.dimensions - 1; i++) {
       if (this.annotationsOnDimensions != null && this.annotationsOnDimensions[i] != null) {
         output.append(" "); // $NON-NLS-1$
         printAnnotations(this.annotationsOnDimensions[i], output);
         output.append(" "); // $NON-NLS-1$
       }
       output.append("[]"); // $NON-NLS-1$
     }
     if (this.annotationsOnDimensions != null
         && this.annotationsOnDimensions[this.dimensions - 1] != null) {
       output.append(" "); // $NON-NLS-1$
       printAnnotations(this.annotationsOnDimensions[this.dimensions - 1], output);
       output.append(" "); // $NON-NLS-1$
     }
     output.append("..."); // $NON-NLS-1$
   } else {
     for (int i = 0; i < this.dimensions; i++) {
       if (this.annotationsOnDimensions != null && this.annotationsOnDimensions[i] != null) {
         output.append(" "); // $NON-NLS-1$
         printAnnotations(this.annotationsOnDimensions[i], output);
         output.append(" "); // $NON-NLS-1$
       }
       output.append("[]"); // $NON-NLS-1$
     }
   }
   return output;
 }
예제 #12
0
파일: ASTNode.java 프로젝트: beefeather/ohl
  public static StringBuffer printIndent(int indent, StringBuffer output) {

    for (int i = indent; i > 0; i--) output.append("  "); // $NON-NLS-1$
    return output;
  }