Examples of FilePosition


Examples of com.google.caja.lexer.FilePosition

        }
        return true;
      }
    }, null);
    List<Declaration> decls = Lists.newArrayList();
    FilePosition pos = FilePosition.startOf(body.getFilePosition());
    for (LitVal v : uses.values()) {
      // Size now = canonLen * nUses.
      // Size after = "var aa=".length + canonLen + ";".length + "aa" * nUses
      // Switch if now > after;
      //           canonLen * nUses > 8 + canonLen + 2 * nUses
 
View Full Code Here

Examples of com.google.caja.lexer.FilePosition

      }
      if (attrsFile == null) {
        throw new IOException("No JSON whitelist for HTML attributes");
      }

      FilePosition elements = FilePosition.startOfFile(new InputSource(
          elementsFile.getAbsoluteFile().toURI()));
      FilePosition attrs = FilePosition.startOfFile(new InputSource(
          attrsFile.getAbsoluteFile().toURI()));

      MessageContext mc = new MessageContext();
      mc.addInputSource(elements.source());
      mc.addInputSource(attrs.source());
      MessageQueue mq = new EchoingMessageQueue(
          new PrintWriter(new OutputStreamWriter(System.err), true), mc, false);

      Set<File> inputsAndDeps = new HashSet<File>();
      for (File f : inputs) { inputsAndDeps.add(f.getAbsoluteFile()); }
      for (File f : deps) { inputsAndDeps.add(f.getAbsoluteFile()); }

      ImportResolver resolver = new AllowedFileResolver(inputsAndDeps);

      HtmlSchema schema;
      try {
        schema = new HtmlSchema(
            ConfigUtil.loadWhiteListFromJson(
                elements.source().getUri(), resolver, mq),
            ConfigUtil.loadWhiteListFromJson(
                attrs.source().getUri(), resolver, mq));
      } catch (ParseException ex) {
        ex.toMessageQueue(mq);
        throw (IOException) new IOException("Failed to parse schema")
            .initCause(ex);
      }
View Full Code Here

Examples of com.google.caja.lexer.FilePosition

      stmts.addAll(em.sources);
    }
    // Impose an order on output not dependent on hashing
    Collections.sort(stmts, new Comparator<Statement>() {
      public int compare(Statement a, Statement b) {
        FilePosition pa = a.getFilePosition(), pb = b.getFilePosition();
        int delta = pa.source().toString().compareTo(pb.source().toString());
        if (delta != 0) { return delta; }
        return pa.startCharInFile() - pb.startCharInFile();
      }
    });
    return Collections.unmodifiableSet(Sets.newLinkedHashSet(stmts));
  }
View Full Code Here

Examples of com.google.caja.lexer.FilePosition

        }
        // Sort positionless parts after ones with a position.
        long aSPos = Integer.MAX_VALUE + 1L, aEPos = Integer.MAX_VALUE + 1L;
        long bSPos = Integer.MAX_VALUE + 1L, bEPos = Integer.MAX_VALUE + 1L;
        if (a0 instanceof FilePosition) {
          FilePosition pos = (FilePosition) a0;
          aSPos = pos.startCharInFile();
          aEPos = pos.endCharInFile();
        } else if (a0 instanceof InputSource) {
          // sort file level messages before messages within file
          aSPos = aEPos = -1;
        }
        if (b0 instanceof FilePosition) {
          FilePosition pos = (FilePosition) b0;
          bSPos = pos.startCharInFile();
          bEPos = pos.endCharInFile();
        } else if (b0 instanceof InputSource) {
          // sort file level messages before messages within file
          bSPos = bEPos = -1;
        }
        int delta = Long.signum(aSPos - bSPos);
View Full Code Here

Examples of com.google.caja.lexer.FilePosition

      }
      if (functionsFile == null) {
        throw new IOException("No JSON whitelist for CSS Functions");
      }

      FilePosition sps = FilePosition.startOfFile(new InputSource(
          symbolsAndPropertiesFile.getAbsoluteFile().toURI()));
      FilePosition fns = FilePosition.startOfFile(new InputSource(
          functionsFile.getAbsoluteFile().toURI()));

      MessageContext mc = new MessageContext();
      mc.addInputSource(sps.source());
      mc.addInputSource(fns.source());
      MessageQueue mq = new EchoingMessageQueue(
          new PrintWriter(new OutputStreamWriter(System.err), true), mc, false);

      Set<File> inputsAndDeps = Sets.newHashSet();
      for (File f : inputs) { inputsAndDeps.add(f.getAbsoluteFile()); }
      for (File f : deps) { inputsAndDeps.add(f.getAbsoluteFile()); }

      ImportResolver resolver = new AllowedFileResolver(inputsAndDeps);

      CssSchema schema;
      try {
        schema = new CssSchema(
            ConfigUtil.loadWhiteListFromJson(
                sps.source().getUri(), resolver, mq),
            ConfigUtil.loadWhiteListFromJson(
                fns.source().getUri(), resolver, mq));
      } catch (ParseException ex) {
        ex.toMessageQueue(mq);
        throw (IOException) new IOException("Failed to parse schema")
            .initCause(ex);
      }
View Full Code Here

Examples of com.google.caja.lexer.FilePosition

                  : (Expression) tjChildren.get(0);
              joined = joined == null ? e : commaOp(joined, e);
            }
            Statement newChild;
            assert joined != null// because start < end, loop assigns it
            FilePosition exprPos = joined.getFilePosition();
            if (s instanceof ReturnStmt) {
              newChild = new ReturnStmt(exprPos, joined);
            } else if (s instanceof ThrowStmt) {
              newChild = new ThrowStmt(exprPos, joined);
            } else {
View Full Code Here

Examples of com.google.caja.lexer.FilePosition

    }

    while (pos > 0) {
      Expression clause = expressionChildOf(condParts.get(--pos));
      Expression cond = (Expression) condParts.get(--pos);
      FilePosition fpos = FilePosition.span(
          cond.getFilePosition(), e.getFilePosition());
      if (clause instanceof BooleanLiteral && e instanceof BooleanLiteral) {
        BooleanLiteral a = (BooleanLiteral) clause,
            b = (BooleanLiteral) e;
        if (a.getValue() == b.getValue()) {
View Full Code Here

Examples of com.google.caja.lexer.FilePosition

  private static Expression expressionChildOf(
      ParseTreeNode returnThrowOrExprStmt) {
    List<? extends ParseTreeNode> children = returnThrowOrExprStmt.children();
    assert children.size() < 2;
    if (children.isEmpty()) {
      FilePosition pos = FilePosition.endOf(
          returnThrowOrExprStmt.getFilePosition());
      return Operation.create(pos, Operator.VOID, new IntegerLiteral(pos, 0));
    }
    return (Expression) children.get(0);
  }
View Full Code Here

Examples of com.google.caja.lexer.FilePosition

        }
        newOperands[i] = newOperand;
      }
    }
    Operator oper = op.getOperator();
    FilePosition pos = e.getFilePosition();
    if (oper != Operator.TERNARY) {
      return newOperands == null ? e : Operation.create(pos, oper, newOperands);
    }
    // (c ? x,z : y,z) -> (c ? x:y),z
    Expression[] ternaryOperands = newOperands != null
View Full Code Here

Examples of com.google.caja.lexer.FilePosition

  }

  private static Block combine(Block a, Block b) {
    if (b.children().isEmpty()) { return a; }
    if (a.children().isEmpty()) { return b; }
    FilePosition pos = FilePosition.span(
        a.getFilePosition(), b.getFilePosition());
    Statement s = combine(pos, a, b);
    if (s instanceof Block) {
      return (Block) s;
    } else if (s instanceof Noop) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.