Beispiel #1
0
  private void printResult(IRascalResult result) throws IOException {
    if (result == null) {
      return;
    }
    PrintWriter out = getOutputWriter();
    IValue value = result.getValue();
    if (value == null) {
      out.println("ok");
      out.flush();
      return;
    }
    Type type = result.getType();

    if (type.isAbstractData() && type.isStrictSubtypeOf(RascalValueFactory.Tree)) {
      out.print(type.toString());
      out.print(": ");
      // we unparse the tree
      out.print("(" + type.toString() + ") `");
      TreeAdapter.yield((IConstructor) result.getValue(), true, out);
      out.print("`");
    } else {
      out.print(type.toString());
      out.print(": ");
      // limit both the lines and the characters
      try (Writer wrt = new LimitedWriter(new LimitedLineWriter(out, LINE_LIMIT), CHAR_LIMIT)) {
        indentedPrettyPrinter.write(value, wrt);
      } catch (IOLimitReachedException e) {
        // ignore since this is what we wanted
      }
    }
    out.println();
    out.flush();
  }
 @SuppressWarnings("unchecked")
 @Override
 protected <U extends IValue> Result<U> addString(StringResult that) {
   // Note the reverse concat.
   return (Result<U>)
       new ConcatStringResult(
           getType(),
           that,
           new StringResult(
               that.getType(), ctx.getValueFactory().string(TreeAdapter.yield(getValue())), ctx),
           ctx);
 }