Package com.google.caja.lexer

Examples of com.google.caja.lexer.FilePosition


  /** May be overridden to affect CSS {@link EmbeddedContent#parse parsing}. */
  protected MessageLevel getCssTolerance() { return MessageLevel.WARNING; }

  Parser makeJsParser(CharProducer cp, MessageQueue mq) {
    boolean quasis = shouldAllowJsQuasis();
    FilePosition p = cp.filePositionForOffsets(cp.getOffset(), cp.getLimit());
    JsLexer lexer = new JsLexer(cp, quasis);
    JsTokenQueue tq = new JsTokenQueue(lexer, p.source());
    tq.setInputRange(p);
    Parser parser = new Parser(tq, mq, quasis);
    parser.setRecoverFromFailure(shouldJsRecover());
    return parser;
  }
View Full Code Here


    if (r == null) {
      mq.addMessage(Messages.NO_PARENT, Nodes.getFilePositionFor(el));
      return el;
    }
    String id = getPlaceholderId(r);
    FilePosition pos = Nodes.getFilePositionFor(el);
    Expression e = (Expression) QuasiBuilder.substV(
        ""
        + "IMPORTS___.htmlEmitter___."
        + "/*@synthetic*/ handleEmbed({"
        + " id: @id,"
View Full Code Here

    if (empty(height)) {
      height = params.get("height");
    }

    String id = getPlaceholderId(r);
    FilePosition pos = Nodes.getFilePositionFor(el);
    Expression e = (Expression) QuasiBuilder.substV(
        ""
        + "IMPORTS___.htmlEmitter___."
        + "/*@synthetic*/ handleEmbed({"
        + " id: @id,"
View Full Code Here

        input,
        js(fromString("var dis___ = IMPORTS___; ___.iM([]).foo;")));
  }

  public final void testSyntheticFormals() throws Exception {
    FilePosition unk = FilePosition.UNKNOWN;
    FunctionConstructor fc = new FunctionConstructor(
        unk,
        new Identifier(unk, "f"),
        Arrays.asList(
            new FormalParam(new Identifier(unk, "x")),
View Full Code Here

              HtmlAttributeRewriter.SanitizedAttr sanitized
                  = rw.sanitizeStringValue(HtmlAttributeRewriter.fromAttr(
                      classAttr, htmlSchema.lookupAttribute(BODY_CLASS),
                      source));
              if (sanitized.isSafe) {
                FilePosition pos = Nodes.getFilePositionForValue(classAttr);
                Expression e = sanitized.result;
                if (e == null) { e = StringLiteral.valueOf(pos, identifiers); }
                Statement s = new ExpressionStmt(
                    (Expression) QuasiBuilder.substV(
                         ""
View Full Code Here

  /** Constructs a string expression. */
  @OverridingMethodsMustInvokeSuper
  protected Expression endPartialJsStringLiteral() {
    String s = partialJsStringLiteral.toString();
    partialJsStringLiteral.setLength(0);
    FilePosition pos = positionAtStartOfStringLiteral != null
        ? FilePosition.span(positionAtStartOfStringLiteral, last)
        : FilePosition.UNKNOWN;
    positionAtStartOfStringLiteral = null;
    inJsString = false;
    return StringLiteral.valueOf(pos, s);
View Full Code Here

    // Accumulates dynamic CSS that will be added to the JS.
    List<Expression> cssParts = Lists.newArrayList();
    // Accumulate static CSS that can be embedded in the DOM.
    StringBuilder css = new StringBuilder();
    FilePosition staticPos = null, dynamicPos = null;
    for (ValidatedStylesheet ss : validatedStylesheets) {
      ArrayConstructor ac = CssDynamicExpressionRewriter.cssToJs(ss.ss);
      List<? extends Expression> children = ac.children();
      if (children.isEmpty()) { continue; }
      FilePosition acPos = ac.getFilePosition();
      Expression child0 = children.get(0);
      // The CssDynamicExpressionRewriter gets to distinguish between static and
      // dynamic. If the output is a single string, then joining it on the
      // idClass would not add any information, so we can put it in the static
      // HTML.
View Full Code Here

                PluginMessageType.MALFORMED_URL,
                Nodes.getFilePositionForValue(a),
                MessagePart.Factory.valueOf(value));
          }
          if (uri != null && uri.isAbsolute()) {
            FilePosition valuePos = Nodes.getFilePositionForValue(a);
            a.setValue(base.resolve(uri).toString());
            Nodes.setFilePositionForValue(a, valuePos);
          }
        }
      }
View Full Code Here

    }
  }

  public static AttrValue fromAttr(
      final Attr a, HTML.Attribute attr, JobEnvelope source) {
    FilePosition pos = a.getValue() != null ?
        Nodes.getFilePositionForValue(a) : FilePosition.UNKNOWN;
    return new AttrValue(source, a, pos, attr) {
      @Override
      Expression getValueExpr() {
        return StringLiteral.valueOf(valuePos, getPlainValue());
View Full Code Here

    }
  }

  public SanitizedAttr sanitizeStringValue(AttrValue attr) {
    Expression dynamicValue = null;
    FilePosition pos = attr.valuePos;
    String value = attr.getPlainValue();
    // There are two cases for name handling.
    // 1. For names that have local scope or names that can't be mangled,
    //    we pass them through unchanged, except we deny the '__' suffix
    //    as reserved for use by the container.
View Full Code Here

TOP

Related Classes of com.google.caja.lexer.FilePosition

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.