Package com.google.caja.parser.js

Examples of com.google.caja.parser.js.CajoledModule


        compiler.setGoals(
            compiler.getGoals().without(PipelineMaker.HTML_SAFE_STATIC));
      }
      passed = compiler.run();

      CajoledModule outputJs = passed ? compiler.getJavascript() : null;

      StringBuilder jsOut = new StringBuilder();
      TokenConsumer printer;
      if ("1".equals(req.getParam("debug"))) {
        printer = new JsPrettyPrinter(new Concatenator(jsOut));
      } else {
        printer = new JsMinimalPrinter(new Concatenator(jsOut));
      }

      RenderContext renderContext = new RenderContext(printer).withEmbeddable(true);

      if (outputJs != null) {
        outputJs.render(renderContext);
      }

      renderContext.getOut().noMoreTokens();
      resp.setContent(jsOut.toString());
    } finally {
View Full Code Here


        compiler.setGoals(
            compiler.getGoals().without(PipelineMaker.HTML_SAFE_STATIC));
      }
      passed = compiler.run();

      CajoledModule outputJs = passed ? compiler.getJavascript() : null;

      StringBuilder jsOut = new StringBuilder();
      TokenConsumer printer;
      if ("1".equals(req.getParam("debug"))) {
        printer = new JsPrettyPrinter(new Concatenator(jsOut));
      } else {
        printer = new JsMinimalPrinter(new Concatenator(jsOut));
      }

      RenderContext renderContext = new RenderContext(printer).withEmbeddable(true);

      if (outputJs != null) {
        outputJs.render(renderContext);
      }

      renderContext.getOut().noMoreTokens();
      resp.setContent(jsOut.toString());
    } finally {
View Full Code Here

      try {
        if (!compiler.run()) {
          throw new GadgetRewriteException("Gadget has compile errors");
        }
        StringBuilder scriptBody = new StringBuilder();
        CajoledModule cajoled = compiler.getJavascript();
        TokenConsumer tc = debug
            ? new JsPrettyPrinter(new Concatenator(scriptBody))
            : new JsMinimalPrinter(new Concatenator(scriptBody));
        cajoled.render(new RenderContext(tc)
          .withAsciiOnly(true)
          .withEmbeddable(true));

        tc.noMoreTokens();
View Full Code Here

        compiler.setGoals(
            compiler.getGoals().without(PipelineMaker.HTML_SAFE_STATIC));
      }
      passed = compiler.run();

      CajoledModule outputJs = passed ? compiler.getJavascript() : null;

      StringBuilder jsOut = new StringBuilder();
      TokenConsumer printer;
      if ("1".equals(req.getParam("debug"))) {
        printer = new JsPrettyPrinter(new Concatenator(jsOut));
      } else {
        printer = new JsMinimalPrinter(new Concatenator(jsOut));
      }

      RenderContext renderContext = new RenderContext(printer).withEmbeddable(true);

      if (outputJs != null) {
        outputJs.render(renderContext);
      }

      renderContext.getOut().noMoreTokens();
      resp.setContent(jsOut.toString());
    } finally {
View Full Code Here

    FilePosition unk = FilePosition.UNKNOWN;

    FilePosition pos = bone.body.getFilePosition();
    String sourcePath = mc.abbreviate(pos.source());
    if (bone.source.fromCache) {
      CajoledModule scriptFromCache = (CajoledModule) bone.body;
      finishBlock();
      this.js.add(new SafeJsChunk(bone.source, scriptFromCache));
    } else {
      Block scriptToWrapAndProcess = (Block) bone.body;
      emitStatement(quasiStmt(
View Full Code Here

    // Try looking for the script in the precajole map
    PrecajoleMap precajoled = jobs.getPluginMeta().getPrecajoleMap();
    if (precajoled != null) {
      String sourceText = c.getContent(fetcher).toString();
      boolean minify = pm.getPrecajoleMinify();
      CajoledModule m = precajoled.lookupSource(sourceText, minify);
      if (m != null) {
        substitutePlaceholder(c, m, root);
        return;
      }
    }
View Full Code Here

      try {
        if (!compiler.run()) {
          throw new GadgetRewriteException("Gadget has compile errors");
        }
        StringBuilder scriptBody = new StringBuilder();
        CajoledModule cajoled = compiler.getJavascript();
        TokenConsumer tc = debug
            ? new JsPrettyPrinter(new Concatenator(scriptBody))
            : new JsMinimalPrinter(new Concatenator(scriptBody));
        cajoled.render(new RenderContext(tc)
          .withAsciiOnly(true)
          .withEmbeddable(true));

        tc.noMoreTokens();
       
View Full Code Here

      File f = new File(specDir, name);
      if (f.exists() && f.lastModified() < map.getModTime()) {
        return;
      }
      String text = readFile(f);
      CajoledModule cajoled = cajole(text, name);
      map.put(uris, text, cajoled);
    }
View Full Code Here

    // Try looking for the script in the precajole map
    PrecajoleMap precajoled = jobs.getPluginMeta().getPrecajoleMap();
    if (precajoled != null) {
      String sourceText = c.getContent(fetcher).toString();
      boolean minify = pm.getPrecajoleMinify();
      CajoledModule m = precajoled.lookupSource(sourceText, minify);
      if (m != null) {
        Element placeholder = placeholderFor(scriptEl, m);
        if (c.isDeferred()) {
          parent.removeChild(scriptEl);
          root.appendChild(placeholder);
View Full Code Here

        "moduleInvocations", moduleInvocations,
        "cajolerName", StringLiteral.valueOf(unk, "com.google.caja"),
        "cajolerVersion", StringLiteral.valueOf(
            unk, buildInfo.getBuildVersion()),
        "cajoledDate", new IntegerLiteral(unk, buildInfo.getCurrentTime()));
    return new CajoledModule(oc);
  }
View Full Code Here

TOP

Related Classes of com.google.caja.parser.js.CajoledModule

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.