Package com.google.caja.parser.js

Examples of com.google.caja.parser.js.Block.children()


      Block lastBody = last.getBody();
      boolean changedOne = false;
      if (!lastBody.children().isEmpty()) {
        // Eliminate trailing break statement.
        List<? extends Statement> stmts = lastBody.children();
        int n = stmts.size();
        if (n > 0 && isBlankBreak(stmts.get(n - 1))) {
          stmts = stmts.subList(0, n - 1);
          Block newBody = new Block(lastBody.getFilePosition(), stmts);
          newChildren.set(newChildren.size() - 1, withBody(last, newBody));
View Full Code Here


  }

  private static boolean isBlankBreak(Statement s) {
    while (s instanceof Block) {
      Block block = (Block) s;
      if (block.children().size() != 1) { return false; }
      s = block.children().get(0);
    }
    return s instanceof BreakStmt && "".equals(((BreakStmt) s).getLabel());
  }
View Full Code Here

  private static boolean isBlankBreak(Statement s) {
    while (s instanceof Block) {
      Block block = (Block) s;
      if (block.children().size() != 1) { return false; }
      s = block.children().get(0);
    }
    return s instanceof BreakStmt && "".equals(((BreakStmt) s).getLabel());
  }

  private static Block combine(Block a, Block b) {
View Full Code Here

        break;
      case SCRIPT:
        String handlerFnName = handlerCache.get(value);
        if (handlerFnName == null) {
          Block b = jsFromAttrib(attr);
          if (b == null || b.children().isEmpty()) { return noResult(attr); }
          rewriteEventHandlerReferences(b);

          handlerFnName = meta.generateUniqueName("c");
          Declaration handler = (Declaration) QuasiBuilder.substV(
              ""
View Full Code Here

              + "var @handlerName = ___./*@synthetic*/markFuncFreeze("
              + "    /*@synthetic*/function ("
              + "        event, " + ReservedNames.THIS_NODE + ") { @body*; });",
              "handlerName", SyntheticNodes.s(
                  new Identifier(FilePosition.UNKNOWN, handlerFnName)),
              "body", new ParseTreeNodeContainer(b.children()));
          handlers.add(new EventHandler(attr.env, handler));
          handlerCache.put(value, handlerFnName);
        }

        FunctionConstructor eventAdapter
View Full Code Here

        }
        break;
      case URI:
        if (attributeContent.containsKey(attr.src)) {  // A javascript: URI
          Block b = this.jsFromAttrib(attr);
          if (b == null || b.children().isEmpty()) { return noResult(attr); }

          String handlerIndexName = meta.generateUniqueName("c");
          Identifier handlerIndex = SyntheticNodes.s(new Identifier(
              FilePosition.UNKNOWN, handlerIndexName));
          Statement handler = (Statement) QuasiBuilder.substV(
View Full Code Here

              + "    ___./*@synthetic*/markFuncFreeze("
              // There is no node or event object available to code in
              // javascript: URIs.
              + "        /*@synthetic*/function () { @body*; })) - 1;",
              "handlerIndex", handlerIndex,
              "body", new ParseTreeNodeContainer(b.children()));
          handlers.add(new EventHandler(attr.env, handler));
          handlerCache.put(value, handlerIndexName);

          Operation urlAdapter = (Operation) QuasiBuilder.substV(
              ""
View Full Code Here

  public static void main(String[] args) {
    HtmlSchema schema = HtmlSchema.getDefault(new SimpleMessageQueue());
    Block node = generateJavascriptDefinitions(schema);
    RenderContext rc = new RenderContext(node.makeRenderer(System.out, null));
    for (Statement s : node.children()) {
      s.render(rc);
      if (!s.isTerminal()) { rc.getOut().consume(";"); }
    }
    rc.getOut().noMoreTokens();
  }
View Full Code Here

        out.write("// @provides html4\n");
        Block node = generateJavascriptDefinitions(schema);
        RenderContext rc = new RenderContext(node.makeRenderer(out, null))
            .withPropertyNameQuotingMode(
                PropertyNameQuotingMode.PRESERVE_QUOTES);
        for (Statement s : node.children()) {
          s.render(rc);
          if (!s.isTerminal()) { rc.getOut().consume(";"); }
        }
        rc.getOut().noMoreTokens();
        out.write("\n");
View Full Code Here

      handler = (Block) c.parse(jobs.getPluginMeta().getUriFetcher(), mq);
    } catch (ParseException ex) {
      ex.toMessageQueue(mq);
      return;
    }
    if (handler != null && !handler.children().isEmpty()) {
      Element placeholder = placeholderFor(onload, handler);
      body.appendChild(placeholder);
    }
  }
}
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.