Package com.google.caja.parser.js

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


      // And recurse to the body manually so as to avoid recursing to the
      // exception declaration.
      attachScopes(AncestorChain.instance(ac, cs.getBody()), scope);
      return false;
    } else if (n instanceof Reference) {
      Reference r = (Reference) n;
      String rName = r.getIdentifierName();
      Scope definingScope = scope.s.thatDefines(rName);
      assert (definingScope != null) || scope.s.isOuter(rName) : rName;
      scope.uses.add(new Use(scope.withScope(definingScope), rName));
      if ("eval".equals(rName)) { infected = true; }
      infected = infected || "eval".equals(rName);
View Full Code Here


          Expression init = decl.getInitializer();
          Statement replacement;
          if (init != null) {
            replacement = new ExpressionStmt(toAssignment(decl));
          } else if (chain.parent.node instanceof ForEachLoop) {
            replacement = new ExpressionStmt(new Reference(id));
          } else {
            replacement = new Noop(decl.getFilePosition());
          }
          changes.add(Pair.pair(chain.cast(Statement.class), replacement));
          return true;
View Full Code Here

  }

  private static Expression toAssignment(Declaration decl) {
    return Operation.create(
        decl.getFilePosition(), Operator.ASSIGN,
        new Reference(decl.getIdentifier()), decl.getInitializer());
  }
View Full Code Here

      Expression e = ((ExpressionStmt) first).getExpression();
      if (!Operation.is(e, Operator.ASSIGN)) { break; }
      Operation op = (Operation) e;
      Expression lhs = op.children().get(0);
      if (!(lhs instanceof Reference)) { break; }
      Reference r = (Reference) lhs;
      if (!unassigned.contains(r.getIdentifier())) { break; }
      // Don't return two with the same name, because we don't want to have
      // multiple var declarations for the same name.
      //     var foo = 1, bar = 2, foo = 3;
      // might not be legal in ES5 strict mode.
      unassigned.remove(r.getIdentifier());
      extracted.add(op);
      body.removeChild(first);
    }
    return extracted;
  }
View Full Code Here

    List<ParseTreeNode> formals = new ArrayList<ParseTreeNode>();
    List<ParseTreeNode> actuals = new ArrayList<ParseTreeNode>();
    for (int i = 0; i < m.getParameters().length; i++) {
      formals.add(new FormalParam(
          new Identifier(FilePosition.UNKNOWN, makeArgName(i))));
      actuals.add(new Reference(
          new Identifier(FilePosition.UNKNOWN, makeArgName(i))));
    }
    return QuasiBuilder.substV(""
        + "function (@formals*) { return bean.@methodRef(@actuals*); }",
        "methodRef", getMethodAccessor(m),
View Full Code Here

  private Expression getPropertyDescriptorForProperty(
      GwtBeanPropertyDescriptor pd)
      throws UnableToCompleteException {
    Expression get = (pd.readMethod == null) ?
        new Reference(new Identifier(FilePosition.UNKNOWN, UNDEFINED)) :
        (Expression) QuasiBuilder.substV(""
            + "$wnd.caja.makeDefensibleFunction___(function () {"
            + "  return @taming.getJso(frame, bean.@methodRef());"
            + "})",
            "taming", getTamingObject(pd.readMethod.getReturnType()),
            "methodRef", getMethodAccessor(pd.readMethod));
    Expression set = (pd.writeMethod == null) ?
        new Reference(new Identifier(FilePosition.UNKNOWN, UNDEFINED)) :
        (Expression) QuasiBuilder.substV(""
            + "$wnd.caja.makeDefensibleFunction___(function (arg) {"
            + "  bean.@methodRef(@taming.getBean(frame, arg));"
            + "})",
            "taming", getTamingObject(
View Full Code Here

            + "  return @taming.getJso(frame, bean.@fieldRef);"
            + "})",
            "taming", getTamingObject(field.getType()),
            "fieldRef", getFieldAccessor(field));
    Expression set = field.isFinal() ?
        new Reference(new Identifier(FilePosition.UNKNOWN, UNDEFINED)) :
        (Expression) QuasiBuilder.substV(""
            + "$wnd.caja.makeDefensibleFunction___(function (arg) {"
            + "  bean.@fieldRef = @taming.getBean(frame, arg);"
            + "})",
            "taming", getTamingObject(field.getType()),
View Full Code Here

        "get", get,
        "set", set);
  }

  private Reference getMethodAccessor(JMethod m) {
    return new Reference(new Identifier(
        FilePosition.UNKNOWN, m.getJsniSignature()));
  }
View Full Code Here

    return new Reference(new Identifier(
        FilePosition.UNKNOWN, m.getJsniSignature()));
  }

  private Reference getFieldAccessor(JField field) {
    return new Reference(new Identifier(
        FilePosition.UNKNOWN,
        "@" + field.getEnclosingType().getQualifiedSourceName() + "::"
            + field.getName()));
  }
View Full Code Here

            + field.getName()));
  }
 
  public Reference getTamingGetterAccessor(JClassType beanType) {
    toGenerateTamingAccessors.add(beanType);
    return new Reference(
        new Identifier(
            FilePosition.UNKNOWN,
            "@" + tamingImplClassName
                + "::" + getTamingGetterMethodName(beanType)
                + "("
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.