Package com.google.caja.lexer

Examples of com.google.caja.lexer.TokenConsumer.noMoreTokens()


  public final void testRenderPostRemove2() {
    doRemove(1);
    StringBuilder sb = new StringBuilder();
    TokenConsumer tc = new JsPrettyPrinter(sb);
    root.render(new RenderContext(tc));
    tc.noMoreTokens();
    assertEquals(
        "$0: {\n"
        + "  $5: {\n"
        + "    6;\n"
        + "    7;\n"
View Full Code Here


      throws Exception {
    StringBuilder sb = new StringBuilder();
    TokenConsumer tc = new JsPrettyPrinter(sb);
    RenderContext rc = new RenderContext(tc);
    js(fromString(code)).children().get(0).render(rc);
    tc.noMoreTokens();
    assertEquals(code, expectedRendering, sb.toString());
  }

  private void assertMinified(String code, String expectedRendering)
      throws Exception {
View Full Code Here

      throws Exception {
    StringBuilder sb = new StringBuilder();
    TokenConsumer tc = new JsMinimalPrinter(sb);
    RenderContext rc = new RenderContext(tc);
    js(fromString(code)).children().get(0).render(rc);
    tc.noMoreTokens();
    assertEquals(code, expectedRendering, sb.toString());
  }

  private void log(String testName, String code) {
    System.err.println();
View Full Code Here

    StringBuilder sb = new StringBuilder();
    TokenConsumer tc = new JsPrettyPrinter(sb);
    RenderContext rc = new RenderContext(tc);
    parseTree.render(rc);
    tc.noMoreTokens();
    sb.append('\n');

    String golden = TestUtil.readResource(getClass(), goldenFile);
    String actual = sb.toString();
    assertEquals(actual, golden, actual);
View Full Code Here

  private static String render(ParseTreeNode node) {
    StringBuilder sb = new StringBuilder();
    TokenConsumer tc = node.makeRenderer(sb, null);
    node.render(new RenderContext(tc));
    tc.noMoreTokens();
    return sb.toString();
  }

  /** Encapsulates information about a single input to the linter. */
  public static final class LintJob {
View Full Code Here

              }
            } else {
              StringBuilder rendered = new StringBuilder();
              TokenConsumer tc = new CssPrettyPrinter(rendered);
              node.render(new RenderContext(tc));
              tc.noMoreTokens();
              mq.addMessage(PluginMessageType.UNSAFE_CSS_PSEUDO_SELECTOR,
                            invalidNodeMessageLevel, node.getFilePosition(),
                            MessagePart.Factory.valueOf(rendered.toString()));
              remove = true;
            }
View Full Code Here

    } else {
      tc = new JsPrettyPrinter(new Concatenator(buf));
    }
    RenderContext rc = new RenderContext(tc);
    n.render(rc);
    tc.noMoreTokens();
    return buf.toString();
  }
}
View Full Code Here

        + "})();",
        "poolDecls", poolDecls,
        "cssSchema", cssSchema);
    TokenConsumer tc = js.makeRenderer(out, null);
    js.render(new RenderContext(tc));
    tc.noMoreTokens();
    out.append(";\n");
  }

  private static Expression makeRegexp(
      Map<String, Integer> commonSubstrings, String regex) {
View Full Code Here

    for (JobEnvelope env : jobs.getJobs()) {
      StringBuilder sb = new StringBuilder();
      ParseTreeNode node = env.job.getRoot();
      TokenConsumer tc = node.makeRenderer(sb, null);
      node.render(new RenderContext(tc));
      tc.noMoreTokens();
      actualJobs.add(new JobStub(sb.toString(), env.job.getType()));
    }
    // HACK DEBUG
    if (!Arrays.asList(outputJobs).equals(actualJobs)) {
      assertEquals(
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.