Package com.google.caja.parser.js

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


    FilePosition unk = FilePosition.UNKNOWN;
    // The html4[@k] assignment is an explicit export for Closure Compiler
    return (Statement) QuasiBuilder.substV(
            "{ html4.@i = @e; html4[@k] = html4.@i; }",
            "i", new Reference(new Identifier(unk, key)),
            "k", new StringLiteral(unk, key),
            "e", e);
  }
View Full Code Here


    List<IntegerLiteral> values = Lists.newArrayList();
    for (U e : entries) {
      // Since enum values are public, we don't want Closure compiler
      // to rewrite them, so we need quoted keys.
      String quoted = StringLiteral.toQuotedValue(keyMaker.apply(e));
      keys.add(new StringLiteral(unk, quoted));
      values.add(new IntegerLiteral(unk, valueMaker.apply(e)));
    }
    return export(key, (Expression) QuasiBuilder.substV(
        "({ @k*: @v* })",
        "i", new Reference(new Identifier(unk, key)),
View Full Code Here

    definitions.appendChild(mapFromMap(
        einterfaces,
        "ELEMENT_DOM_INTERFACES",
        new Function<String, Expression>() {
          public Expression apply(String domInterface) {
            return new StringLiteral(unk, domInterface);
          }
        })
    );

    definitions.appendChild(mapFromEnum(
View Full Code Here

          new Declaration(unk, new Identifier(unk, "L"),
              new ArrayConstructor(unk, literalSetArrs)));
    }

    List<ValueProperty> cssSchemaProps = Lists.newArrayList();
    StringLiteral propbitsObjKey = new StringLiteral(unk, "cssPropBits");
    StringLiteral litgroupObjKey = new StringLiteral(unk, "cssLitGroup");
    StringLiteral fnsObjKey = new StringLiteral(unk, "cssFns");

    // Keep track of the JS we generate so we can reuse data-objects for
    // CSS properties whose filtering schemes are functionally equivalent.
    Map<String, String> dataJsToKey = Maps.newHashMap();
    boolean hasAliases = false;
View Full Code Here

                      Operation.createTernary(
                          c, xoperands.get(1), yoperands.get(1))));
            } else {
              Reference xref = (Reference) xoperands.get(1);
              Reference yref = (Reference) yoperands.get(1);
              StringLiteral xname = StringLiteral.valueOf(
                  xref.getFilePosition(), xref.getIdentifierName());
              StringLiteral yname = StringLiteral.valueOf(
                  yref.getFilePosition(), yref.getIdentifierName());
              return Operation.create(
                  pos, Operator.SQUARE_BRACKET,
                  xoperands.get(0),
                  optimizeExpressionFlow(
View Full Code Here

      Expression value = vprop.getValueExpr().fold(false); // fold negative nums
      if (!(value instanceof Literal)) {
        // True for "*useragent*" property inserted by JSKB.
        continue;
      }
      StringLiteral sl = vprop.getPropertyNameNode();
      String rawExpr = sl.getValue();
      rawExpr = " " + rawExpr.substring(1, rawExpr.length() - 1) + " ";
      CharProducer valueCp = CharProducer.Factory.fromJsString(
          CharProducer.Factory.fromString(rawExpr, sl.getFilePosition()));
      try {
        Expression expr = jsExpr(valueCp, DevNullMessageQueue.singleton());
        optimizer.addFact(expr, Fact.is((Literal) value));
      } catch (ParseException ex) {
        continue// Triggered for browser specific extensions such as for each
View Full Code Here

      if (subsSizeKey == subsSize + 1
          && substitutes.get(subsSize) instanceof StringLiteral) {
        if (getValue().createSubstitutes(substitutes, bindings)) {
          int subsSizeValue = substitutes.size();
          if (subsSizeValue == subsSizeKey + 1) {
            StringLiteral key = (StringLiteral) substitutes.get(subsSize);
            Expression value = (Expression) substitutes.get(subsSize + 1);
            substitutes.subList(subsSize, substitutes.size()).clear();
            substitutes.add(new ValueProperty(key, value));
            return true;
          }
View Full Code Here

    if (n instanceof DirectivePrologue) {
      return buildDirectivePrologueMatchNode(((DirectivePrologue) n).getDirectives());
    }

    if (n instanceof StringLiteral) {
      StringLiteral lit = (StringLiteral) n;
      String ident = quasiIdent(lit);
      if (ident != null
          // Make sure it doesn't end in * or ?.
          && Character.isJavaIdentifierPart(ident.charAt(ident.length() - 1))) {
        return new StringLiteralQuasiNode(ident.substring(1));
View Full Code Here

  }

  private static QuasiNode buildObjectConstructorNode(ObjectConstructor obj) {
    List<QuasiNode> propQuasis = Lists.newArrayList();
    for (ObjProperty prop : obj.children()) {
      StringLiteral key = prop.getPropertyNameNode();
      if (prop instanceof ValueProperty) {
        Expression value = ((ValueProperty) prop).getValueExpr();
        String keyIdent = quasiIdent(key);
        if (value instanceof Reference) {
          String valueStr = ((Reference) value).getIdentifierName();
View Full Code Here

    List<StringLiteral> keys = new ArrayList<StringLiteral>();
    List<Expression> vals = new ArrayList<Expression>();
    Map<String, Set<JMethod>> methodGroups =
        getMethodGroups(beanInfo.getMethods());
    for (String name : methodGroups.keySet()) {
      keys.add(new StringLiteral(FilePosition.UNKNOWN, name));
      vals.add(getPropertyDescriptorForMethodGroup(methodGroups.get(name)));
    }
    for (GwtBeanPropertyDescriptor pd : beanInfo.getProperties()) {
      keys.add(new StringLiteral(FilePosition.UNKNOWN, pd.name));
      vals.add(getPropertyDescriptorForProperty(pd));
    }
    for (JField field : beanInfo.getPublicInstanceFields()) {
      keys.add(new StringLiteral(FilePosition.UNKNOWN, field.getName()));
      vals.add(getPropertyDescriptorForField(field));
    }
    return QuasiBuilder.substV(
        "return $wnd.caja.makeDefensibleObject___({ @keys*: @vals* });",
        "keys"new ParseTreeNodeContainer(keys),
View Full Code Here

TOP

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

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.