Package com.google.caja.lexer

Examples of com.google.caja.lexer.FilePosition


      }
    }
    new Renderer(rc, sb, rc.markupRenderMode(), ns)
        .render(node, ns, renderUnsafe);
    TokenConsumer out = rc.getOut();
    FilePosition pos = getFilePositionFor(node);
    out.mark(FilePosition.startOf(pos));
    out.consume(sb.toString());
    out.mark(FilePosition.endOf(pos));
  }
View Full Code Here


  @Override
  public Boolean conditionResult() { return true; }

  public void render(RenderContext rc) {
    TokenConsumer out = rc.getOut();
    FilePosition pos = getFilePosition();
    out.mark(pos);
    out.consume("[");
    Expression last = null;
    for (Expression e : children()) {
      if (last != null) {
View Full Code Here

            report(MessageLevel.LINT, ex);
          }

          private void report(MessageLevel level, SAXParseException ex) {
            String message = errorMessage(ex);
            FilePosition pos = builder.getErrorLocation();
            if (message.equals(lastMessage) && pos.equals(lastPos)) { return; }
            lastMessage = message;
            lastPos = pos;
            mq.getMessages().add(new Message(
                DomParserMessageType.GENERIC_SAX_ERROR, level, pos,
                MessagePart.Factory.valueOf(message)));
View Full Code Here

        }

        AncestorChain<Reference> toReplace = read.parent.cast(Reference.class);
        Expression repl;
        if (value == null) {
          FilePosition fp = toReplace.node.getFilePosition();
          repl = Operation.create(fp, Operator.VOID, new IntegerLiteral(fp, 0));
        } else {
          repl = (Expression) value.clone();
        }
        toReplace.parent.cast(MutableParseTreeNode.class)
View Full Code Here

      tokText = tok.text;
    } else {
      tokText = String.valueOf(buf, start, length);
    }

    FilePosition pos = startTok.pos;
    String htmlText = null;
    String plainText = tokText;
    if (tok != null) {
      switch (tok.type) {
        case TEXT:
View Full Code Here

          }
        }
      }
    }
    if (attributes.getLength() != 0) {
      FilePosition pos;
      if (needsDebugData) {
        pos = FilePosition.startOf(Nodes.getFilePositionFor(el));
      } else {
        pos = null;
      }
View Full Code Here

      el = doc.createElement(localName);
    }
    addAttributesToElement(el, attributes);

    if (needsDebugData) {
      FilePosition pos;
      if (startTok == null) {
        pos = null;
      } else if (startTok.type == HtmlTokenType.TAGBEGIN
                 && tagMatchesElementName(tagName(startTok.text), localName)) {
        pos = FilePosition.span(startTok.pos, endTok.pos);
View Full Code Here

      System.err.println("popped " + ns + " : " + name + ", node=" + node
                         + " @ " + endTok.pos);
    }
    if (needsDebugData) {
      name = Html5ElementStack.canonicalElementName(name);
      FilePosition endPos;
      if (startTok.type == HtmlTokenType.TAGBEGIN
          // A start <select> tag inside a select element is treated as a close
          // select tag.  Don't ask -- there's just no good reason.
          // http://www.whatwg.org/specs/web-apps/current-work/#in-select
          //    If the insertion mode is "in select"
          //    A start tag whose tag name is "select"
          //      Parse error. Act as if the token had been an end tag
          //      with the tag name "select" instead.
          && (isEndTag(startTok.text) || "select".equals(name))
          && tagCloses(tagName(startTok.text), name)) {
        endPos = endTok.pos;
      } else {
        // Implied ending.
        endPos = FilePosition.startOf(startTok.pos);
      }
      FilePosition startPos = Nodes.getFilePositionFor(node);
      if (startPos.source().equals(InputSource.UNKNOWN)) {
        Node first = node.getFirstChild();
        if (first != null) {
          startPos = Nodes.getFilePositionFor(first);
        }
      }
      FilePosition lastPos = startPos;
      Node last;
      for (last = node.getLastChild(); last != null;
           last = last.getPreviousSibling()) {
        if (last.getNodeType() != Node.TEXT_NODE
            || !isWhitespace(last.getNodeValue())) {
          break;
        }
      }
      if (last != null) {
        lastPos = Nodes.getFilePositionFor(last);
      }
      if (DEBUG) {
        System.err.println("startPos=" + startPos + ", lastPos=" + lastPos
             + ", removed=" + removed);
      }
      if (endPos.endCharInFile() >= lastPos.endCharInFile()
          && (removed || lastPos.endCharInFile() > startPos.endCharInFile())) {
        Nodes.setFilePositionFor(node, FilePosition.span(startPos, endPos));
      }
    }
  }
View Full Code Here

      case 2: folded = foldBinaryOp(); break;
      case 3: folded = foldTernaryOp(); break;
      default: return this;
    }
    if (isFn && isFnSpecialForm(folded) && !isFnSpecialForm(this)) {
      FilePosition pos = getFilePosition();
      folded = Operation.create(
          pos, Operator.COMMA,
          new IntegerLiteral(FilePosition.startOf(pos), 0), folded);
    }
    return folded;
View Full Code Here

      default:
        break;
    }
    Object v = toLiteralValue(operand);
    if (v != null) {
      FilePosition pos = getFilePosition();
      switch (getOperator()) {
        case NEGATION:
          if (v instanceof Number) {
            if (operand instanceof IntegerLiteral) {
              long n = ((IntegerLiteral) operand).getValue().longValue();
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.