Ejemplo n.º 1
0
 public void writeLineNumbers(File filename) throws IOException {
   DataOutputStream dataOut = null;
   try {
     dataOut = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(filename)));
     int lineNumbersCount = out.getCurrentLineNumber() - 1;
     int[] lineNumbers = out.getLineNumbers();
     dataOut.writeInt(lineNumbersCount);
     for (int i = 0; i < lineNumbersCount; i++) {
       dataOut.writeInt(lineNumbers[i]);
     }
   } finally {
     SpringIOUtils.closeQuietly(dataOut);
   }
 }
Ejemplo n.º 2
0
  /**
   * Adds the line numbers array to the end of the generated Groovy ModuleNode in a way suitable for
   * the LineNumberTransform AST transform to operate on it
   */
  private void addLineNumbers() {
    out.println();
    out.println("@LineNumber(");
    out.print("\tlines = [");
    // get the line numbers here.  this will mean that the last 2 lines will not be captured in the
    // line number information, but that's OK since a user cannot set a breakpoint there anyway.
    int[] lineNumbers = filterTrailing0s(out.getLineNumbers());

    for (int i = 0; i < lineNumbers.length; i++) {
      out.print(lineNumbers[i]);
      if (i < lineNumbers.length - 1) {
        out.print(", ");
      }
    }
    out.println("],");
    out.println("\tsourceName = \"" + sourceName + "\"");
    out.println(")");
    out.println("class ___LineNumberPlaceholder { }");
  }
Ejemplo n.º 3
0
 public int[] getLineNumberMatrix() {
   return out.getLineNumbers();
 }