Package com.google.caja.parser.js

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


  public void append(FilePosition pos, String s) {
    append(StringLiteral.valueOf(pos, s));
  }

  public void append(Expression e) {
    StringLiteral sl = Emitter.asStringLiteral(e);
    if (sl != null && sl.getUnquotedValue().length() == 0) { return; }
    if (Emitter.is(e, Operator.ADDITION)) {
      List<? extends Expression> operands = ((Operation) e).children();
      if (Emitter.isStringy(operands.get(0), false)
          || Emitter.isStringy(operands.get(1), false)) {
        append(operands.get(0));
View Full Code Here


          both.add(combined);
        } else if (alwaysFold) {
          FilePosition pos = sep.e.getFilePosition();
          parts.set(i, new StringPart(Operation.create(
              pos, Operator.COMMA, sep.e,
              new StringLiteral(FilePosition.endOf(pos), ""))));
        }
      }
    }
  }
View Full Code Here

    NamedNodeMap attrMap = el.getAttributes();
    int attrLen = attrMap.getLength();
    for (int i = 0; i < attrLen; ++i) {
      Attr attr = (Attr) attrMap.item(i);
      if (attr.getLocalName().startsWith("data-caja-")) {
        scriptsPerNode.put(attr, new StringLiteral(
            Nodes.getFilePositionForValue(attr),
            attr.getValue()));
      }
    }
    scriptsPerNode.put(el, null);
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

    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 new ExpressionStmt(unk,
        (Expression) QuasiBuilder.substV(
            "html4.@i = { @k*: @v* };",
 
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

    } else if (node instanceof Declaration) {
      ident = ((Declaration) node).getIdentifier();
    } else {
      ident = (Identifier) node;
    }
    return new StringLiteral(
        ident.getFilePosition(), StringLiteral.toQuotedValue(ident.getName()));
  }
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.