Package com.google.gwt.dev.util

Examples of com.google.gwt.dev.util.DefaultTextOutput


    } catch (IllegalNameException e) {
      logger.log(TreeLogger.ERROR, e.getMessage(), e);
      throw new UnableToCompleteException();
    }

    DefaultTextOutput out = new DefaultTextOutput(outputOption.shouldMinimize());
    JsSourceGenerationVisitor v = new JsSourceGenerationVisitor(out);
    v.accept(jsProgram);
    return out.toString();
  }
View Full Code Here


    program.getGlobalBlock().getStatements().addAll(statements);
    return program;
  }

  private static String serializeJs(JsProgram program1) {
    TextOutput text = new DefaultTextOutput(true);
    JsVisitor generator = new JsSourceGenerationVisitor(text);
    generator.accept(program1);
    return text.toString();
  }
View Full Code Here

    code.append("  public static void onModuleLoad() {}\n");
    code.append("}\n");

    // Compiles EntryPoint to JS.
    compileSnippet(code.toString());
    TextOutput text = new DefaultTextOutput(true);
    JsSourceGenerationVisitor jsSourceGenerationVisitor = new JsSourceGenerationVisitor(text);
    jsSourceGenerationVisitor.accept(jsProgram);

    // Verifies that the EntryPoint class, SomeInterface interface and some other classes were
    // delimited in the output by getClassRanges().
    List<NamedRange> classRanges = jsSourceGenerationVisitor.getClassRanges();
    Map<String, NamedRange> classRangesByName = Maps.newHashMap();
    for (NamedRange classRange : classRanges) {
      classRangesByName.put(classRange.getName(), classRange);
    }
    assertTrue(classRangesByName.containsKey("test.EntryPoint"));
    assertTrue(classRangesByName.containsKey("test.EntryPoint$SomeInterface"));
    assertTrue(classRangesByName.size() > 2);

    NamedRange programClassRange = jsSourceGenerationVisitor.getProgramClassRange();
    // Verifies there is a preamble before the program class range.
    assertTrue(programClassRange.getStartPosition() > 0);
    // Verifies there is an epilogue after the program class range.
    assertTrue(programClassRange.getEndPosition() < text.getPosition());
  }
View Full Code Here

    for (Class<?> clazz : toExec) {
      Method m = clazz.getMethod("exec", JsProgram.class);
      m.invoke(null, program);
    }

    TextOutput text = new DefaultTextOutput(true);
    JsVisitor generator = new JsSourceGenerationVisitor(text);

    generator.accept(program);
    return text.toString();
  }
View Full Code Here

    program.getGlobalBlock().getStatements().addAll(statements);
    return program;
  }

  private static String serializeJs(JsProgram program1) {
    TextOutput text = new DefaultTextOutput(true);
    JsVisitor generator = new JsSourceGenerationVisitor(text);
    generator.accept(program1);
    return text.toString();
  }
View Full Code Here

    program.getGlobalBlock().getStatements().addAll(expected);

    JsCoerceIntShift.exec(program, logger, oracles);

    TextOutput text = new DefaultTextOutput(true);
    JsVisitor generator = new JsSourceGenerationVisitor(text);

    generator.accept(program);
    return text.toString();
  }
View Full Code Here

    return program;
  }

  private void checkMappings(String ...expectedLines)
      throws IOException, JsParserException {
    DefaultTextOutput text = new DefaultTextOutput(compact);
    JsReportGenerationVisitor generator = new JsReportGenerationVisitor(text,
        JavaToJavaScriptMap.EMPTY, false) {
      @Override
      boolean surroundsInJavaSource(SourceInfo parent, SourceInfo child) {
        // The Rhino-based JavaScript parser doesn't provide character ranges
        // in SourceInfo. Therefore we can't test this method directly
        // and have to mock it out.
        return !includeInlinedRanges;
      }
    };
    generator.accept(program);
    String actual = dumpMappings(text.toString(), generator.getSourceInfoMap());

    StringBuilder expected = new StringBuilder();
    expected.append("Mappings:\n");
    for (String line : expectedLines) {
      expected.append(escape(line));
View Full Code Here

    assertEquals(expected, actual);
  }

  private List<JsStatement> parse(List<JsStatement> expected, boolean compact)
      throws Exception {
    TextOutput text = new DefaultTextOutput(compact);
    JsVisitor generator = new JsSourceGenerationVisitor(text);
    generator.acceptList(expected);
    return JsParser.parse(SourceOrigin.UNKNOWN, new JsProgram().getScope(),
        new StringReader(text.toString()));
  }
View Full Code Here

  }

  private String parse(String js) throws Exception {
    List<JsStatement> statements = JsParser.parse(SourceOrigin.UNKNOWN,
        new JsProgram().getScope(), new StringReader(js));
    TextOutput text = new DefaultTextOutput(true);
    JsVisitor generator = new JsToStringGenerationVisitor(text);
    generator.acceptList(statements);
    return text.toString();
  }
View Full Code Here

    assert onModuleLoad.getStaticRef() instanceof JsFunction;
    assertEquals(expectedJavascript, serializeJs(onModuleLoad.getStaticRef()));
  }

  private static String serializeJs(JsVisitable node) {
    TextOutput text = new DefaultTextOutput(true);
    JsVisitor generator = new JsSourceGenerationVisitor(text);
    generator.accept(node);
    return text.toString();
  }
View Full Code Here

TOP

Related Classes of com.google.gwt.dev.util.DefaultTextOutput

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.