Package com.google.caja.parser.js

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


                + ")"));
  }

  private Reference getNewArrayAccessor(JType type) {
    toArrayCreateAndAssign.add(type);
    return new Reference(
        new Identifier(
            FilePosition.UNKNOWN,
            "@" + tamingImplClassName + "::"
                + getArrayCreationMethodName(type)
                + "("
View Full Code Here


                + ")"));
  }

  private Reference getArrayAssignmentAccessor(JType type) {
    toArrayCreateAndAssign.add(type);
    return new Reference(
        new Identifier(
            FilePosition.UNKNOWN,
            "@" + tamingImplClassName + "::"
                + getArrayAssignmentMethodName(type)
                + "("
View Full Code Here

                + ")"));
  }

  private Reference getArrayLengthQueryAccessor(JType type) {
    toArrayCreateAndAssign.add(type);
    return new Reference(
        new Identifier(
            FilePosition.UNKNOWN,
            "@" + tamingImplClassName + "::"
                + getArrayLengthQueryMethodName(type)
                + "("
View Full Code Here

                + ")"));
  }

  private Reference getArrayItemQueryAccessor(JType type) {
    toArrayCreateAndAssign.add(type);
    return new Reference(
        new Identifier(
            FilePosition.UNKNOWN,
            "@" + tamingImplClassName + "::"
                + getArrayItemQueryMethodName(type)
                + "("
View Full Code Here

                + "I"
                + ")"));
  }

  private Reference getMethodDispatcherAccessor() {
    return new Reference(
        new Identifier(
            FilePosition.UNKNOWN,
            "@" + TAMING_COMMON_BASE_CLASS + "::"
                + "getMethodDispatcher"
                + "("
View Full Code Here

                + "("
                + ")"));
  }

  private Reference getGetJsoAccessor() {
    return new Reference(
        new Identifier(
            FilePosition.UNKNOWN,
            "@" + TAMING_INTERFACE + "::"
                + "getJso"
                + "("
View Full Code Here

                + ")"));

  }

  private Reference getGetBeanAccessor() {
    return new Reference(
        new Identifier(
            FilePosition.UNKNOWN,
            "@" + TAMING_INTERFACE + "::"
                + "getBean"
                + "("
View Full Code Here

            + "(/*@synthetic*/ function (event) {"
            + "  return /*@synthetic*/ (___.plugin_dispatchEvent___("
            + "      /*@synthetic*/this, event, "
            + "      ___./*@synthetic*/getId(IMPORTS___), @tail));"
            + "})",
            "tail", new Reference(SyntheticNodes.s(
                new Identifier(pos, handlerFnName))));
        eventAdapter.setFilePosition(pos);
        eventAdapter.getAttributes().set(HANDLER_NAME, handlerFnName);
        dynamicValue = eventAdapter;
        break;
      case STYLE:
        CssTree.DeclarationGroup decls = styleFromAttrib(attr);
        if (decls == null || decls.children().isEmpty()) {
          return noResult(attr);
        }

        // The validator will check that property values are well-formed,
        // marking those that aren't, and identifies all URLs.
        CssValidator v = new CssValidator(cssSchema, htmlSchema, mq)
            .withInvalidNodeMessageLevel(MessageLevel.WARNING);
        v.validateCss(AncestorChain.instance(decls));
        // The rewriter will remove any unsafe constructs.
        // and put URLs in the proper filename namespace
        new CssRewriter(meta.getUriPolicy(), cssSchema, htmlSchema, mq)
            .withInvalidNodeMessageLevel(MessageLevel.WARNING)
            .rewrite(AncestorChain.instance(decls));
        new CssDynamicExpressionRewriter(meta).rewriteCss(decls);
        ArrayConstructor jsValue = CssDynamicExpressionRewriter.cssToJs(decls);

        if (jsValue.children().size() == 0) {
          // No declarations remain after sanitizing
          return noResult(attr);
        } else if (jsValue.children().size() == 1) {
          // Declarations have been reduced to a single, statically known
          // StringLiteral or dynamically computed Expression
          dynamicValue = jsValue.children().get(0);
        } else {
          throw new SomethingWidgyHappenedError(
              "Rewriter thinks STYLE attribute should contain plugin ID");
        }
        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(
              ""
              + "var @handlerIndex = IMPORTS___.handlers___.push("
              + "    ___./*@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(
              ""
              + "'javascript:' + /*@synthetic*/encodeURIComponent("
              + "   'try{void ___.plugin_dispatchToHandler___('"
              + "    + ___./*@synthetic*/getId(IMPORTS___)"
              + "    + ',' + @handlerIndex + ',[{}])}catch(_){}')",
              "handlerIndex", new Reference(handlerIndex));
          urlAdapter.setFilePosition(pos);
          urlAdapter.getAttributes().set(HANDLER_NAME, handlerIndexName);
          dynamicValue = urlAdapter;
        } else {
          URI uri;
View Full Code Here

        new ParseTreeNodeVisitor() {
          public boolean visit(ParseTreeNode node) {
            // Do not recurse into closures.
            if (node instanceof FunctionConstructor) { return false; }
            if (node instanceof Reference) {
              Reference r = (Reference) node;
              if (Keyword.THIS.toString().equals(r.getIdentifierName())) {
                Identifier oldRef = r.getIdentifier();
                Identifier thisNode = new Identifier(
                    oldRef.getFilePosition(), ReservedNames.THIS_NODE);
                r.replaceChild(SyntheticNodes.s(thisNode), oldRef);
              }
              return false;
            }
            return true;
          }
View Full Code Here

    // Emit a statement to attach the dynamic attribute.
    if (dynamicValue instanceof FunctionConstructor) {
      emitStatement(
          quasiStmt(
              "el___.@name = @eventAdapter;",
              "name", new Reference(
                  SyntheticNodes.s(new Identifier(pos, name))),
              "eventAdapter", dynamicValue),
          source);
    } else {
      emitStatement(
View Full Code Here

TOP

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

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.