org.mozilla.javascript.Parser.addStrictWarning()方法的使用及代码示例

x33g5p2x  于2022-01-26 转载在 JavaScript  
字(9.1k)|赞(0)|评价(0)|浏览(315)

本文整理了Java中org.mozilla.javascript.Parser.addStrictWarning()方法的一些代码示例,展示了Parser.addStrictWarning()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Parser.addStrictWarning()方法的具体详情如下:
包路径:org.mozilla.javascript.Parser
类名称:Parser
方法名:addStrictWarning

Parser.addStrictWarning介绍

暂无

代码示例

代码示例来源:origin: io.apigee/rhino

void addStrictWarning(String messageId, String messageArg) {
  int beg = -1, end = -1;
  if (ts != null) {
    beg = ts.tokenBeg;
    end = ts.tokenEnd - ts.tokenBeg;
  }
  addStrictWarning(messageId, messageArg, beg, end);
}

代码示例来源:origin: geogebra/geogebra

void addStrictWarning(String messageId, String messageArg) {
  int beg = -1, end = -1;
  if (ts != null) {
    beg = ts.tokenBeg;
    end = ts.tokenEnd - ts.tokenBeg;
  }
  addStrictWarning(messageId, messageArg, beg, end);
}

代码示例来源:origin: ro.isdc.wro4j/rhino

void addStrictWarning(String messageId, String messageArg) {
  int beg = -1, end = -1;
  if (ts != null) {
    beg = ts.tokenBeg;
    end = ts.tokenEnd - ts.tokenBeg;
  }
  addStrictWarning(messageId, messageArg, beg, end);
}

代码示例来源:origin: com.github.tntim96/rhino

void addStrictWarning(String messageId, String messageArg) {
  int beg = -1, end = -1;
  if (ts != null) {
    beg = ts.tokenBeg;
    end = ts.tokenEnd - ts.tokenBeg;
  }
  addStrictWarning(messageId, messageArg, beg, end);
}

代码示例来源:origin: com.github.tntim96/rhino

private void warnMissingSemi(int pos, int end) {
  // Should probably change this to be a CompilerEnvirons setting,
  // with an enum Never, Always, Permissive, where Permissive means
  // don't warn for 1-line functions like function (s) {return x+2}
  if (compilerEnv.isStrictMode()) {
    int beg = Math.max(pos, lineBeginningFor(end));
    if (end == -1)
      end = ts.cursor;
    addStrictWarning("msg.missing.semi", "",
             beg, end - beg);
  }
}

代码示例来源:origin: io.apigee/rhino

private void warnMissingSemi(int pos, int end) {
  // Should probably change this to be a CompilerEnvirons setting,
  // with an enum Never, Always, Permissive, where Permissive means
  // don't warn for 1-line functions like function (s) {return x+2}
  if (compilerEnv.isStrictMode()) {
    int beg = Math.max(pos, lineBeginningFor(end));
    if (end == -1)
      end = ts.cursor;
    addStrictWarning("msg.missing.semi", "",
             beg, end - beg);
  }
}

代码示例来源:origin: ro.isdc.wro4j/rhino

private void warnMissingSemi(int pos, int end) {
  // Should probably change this to be a CompilerEnvirons setting,
  // with an enum Never, Always, Permissive, where Permissive means
  // don't warn for 1-line functions like function (s) {return x+2}
  if (compilerEnv.isStrictMode()) {
    int beg = Math.max(pos, lineBeginningFor(end));
    if (end == -1)
      end = ts.cursor;
    addStrictWarning("msg.missing.semi", "",
             beg, end - beg);
  }
}

代码示例来源:origin: com.yahoo/yuicompressor

private Node expr(boolean inForInit)
  throws IOException, ParserException
{
  Node pn = assignExpr(inForInit);
  while (matchToken(Token.COMMA)) {
    decompiler.addToken(Token.COMMA);
    if (compilerEnv.isStrictMode() && !pn.hasSideEffects())
      addStrictWarning("msg.no.side.effects", "");
    pn = nf.createBinary(Token.COMMA, pn, assignExpr(inForInit));
  }
  return pn;
}

代码示例来源:origin: com.sun.phobos/phobos-rhino

private Node expr(boolean inForInit)
  throws IOException, ParserException
{
  Node pn = assignExpr(inForInit);
  while (matchToken(Token.COMMA)) {
    decompiler.addToken(Token.COMMA);
    if (compilerEnv.isStrictMode() && !pn.hasSideEffects())
      addStrictWarning("msg.no.side.effects", "");
    pn = nf.createBinary(Token.COMMA, pn, assignExpr(inForInit));
  }
  return pn;
}

代码示例来源:origin: geogebra/geogebra

private ConditionData condition()
  throws IOException
{
  ConditionData data = new ConditionData();
  if (mustMatchToken(Token.LP, "msg.no.paren.cond"))
    data.lp = ts.tokenBeg;
  data.condition = expr();
  if (mustMatchToken(Token.RP, "msg.no.paren.after.cond"))
    data.rp = ts.tokenBeg;
  // Report strict warning on code like "if (a = 7) ...". Suppress the
  // warning if the condition is parenthesized, like "if ((a = 7)) ...".
  if (data.condition instanceof Assignment) {
    addStrictWarning("msg.equal.as.assign", "",
             data.condition.getPosition(),
             data.condition.getLength());
  }
  return data;
}

代码示例来源:origin: ro.isdc.wro4j/rhino

private ConditionData condition()
  throws IOException
{
  ConditionData data = new ConditionData();
  if (mustMatchToken(Token.LP, "msg.no.paren.cond"))
    data.lp = ts.tokenBeg;
  data.condition = expr();
  if (mustMatchToken(Token.RP, "msg.no.paren.after.cond"))
    data.rp = ts.tokenBeg;
  // Report strict warning on code like "if (a = 7) ...". Suppress the
  // warning if the condition is parenthesized, like "if ((a = 7)) ...".
  if (data.condition instanceof Assignment) {
    addStrictWarning("msg.equal.as.assign", "",
             data.condition.getPosition(),
             data.condition.getLength());
  }
  return data;
}

代码示例来源:origin: io.apigee/rhino

private ConditionData condition()
  throws IOException
{
  ConditionData data = new ConditionData();
  if (mustMatchToken(Token.LP, "msg.no.paren.cond"))
    data.lp = ts.tokenBeg;
  data.condition = expr();
  if (mustMatchToken(Token.RP, "msg.no.paren.after.cond"))
    data.rp = ts.tokenBeg;
  // Report strict warning on code like "if (a = 7) ...". Suppress the
  // warning if the condition is parenthesized, like "if ((a = 7)) ...".
  if (data.condition instanceof Assignment) {
    addStrictWarning("msg.equal.as.assign", "",
             data.condition.getPosition(),
             data.condition.getLength());
  }
  return data;
}

代码示例来源:origin: com.github.tntim96/rhino

private ConditionData condition()
  throws IOException
{
  ConditionData data = new ConditionData();
  if (mustMatchToken(Token.LP, "msg.no.paren.cond"))
    data.lp = ts.tokenBeg;
  data.condition = expr();
  if (mustMatchToken(Token.RP, "msg.no.paren.after.cond"))
    data.rp = ts.tokenBeg;
  // Report strict warning on code like "if (a = 7) ...". Suppress the
  // warning if the condition is parenthesized, like "if ((a = 7)) ...".
  if (data.condition instanceof Assignment) {
    addStrictWarning("msg.equal.as.assign", "",
             data.condition.getPosition(),
             data.condition.getLength());
  }
  return data;
}

代码示例来源:origin: rhino/js

private Node expr(boolean inForInit)
  throws IOException, ParserException
{
  Node pn = assignExpr(inForInit);
  while (matchToken(Token.COMMA)) {
    decompiler.addToken(Token.COMMA);
    if (compilerEnv.isStrictMode() && !pn.hasSideEffects())
      addStrictWarning("msg.no.side.effects", "");
    if (peekToken() == Token.YIELD) {
     reportError("msg.yield.parenthesized");
    }
    pn = nf.createBinary(Token.COMMA, pn, assignExpr(inForInit));
  }
  return pn;
}

代码示例来源:origin: rhino/js

private Node condition()
  throws IOException, ParserException
{
  mustMatchToken(Token.LP, "msg.no.paren.cond");
  decompiler.addToken(Token.LP);
  Node pn = expr(false);
  mustMatchToken(Token.RP, "msg.no.paren.after.cond");
  decompiler.addToken(Token.RP);
  // Report strict warning on code like "if (a = 7) ...". Suppress the
  // warning if the condition is parenthesized, like "if ((a = 7)) ...".
  if (pn.getProp(Node.PARENTHESIZED_PROP) == null &&
    (pn.getType() == Token.SETNAME || pn.getType() == Token.SETPROP ||
     pn.getType() == Token.SETELEM))
  {
    addStrictWarning("msg.equal.as.assign", "");
  }
  return pn;
}

代码示例来源:origin: com.yahoo/yuicompressor

private Node condition()
  throws IOException, ParserException
{
  mustMatchToken(Token.LP, "msg.no.paren.cond");
  decompiler.addToken(Token.LP);
  Node pn = expr(false);
  mustMatchToken(Token.RP, "msg.no.paren.after.cond");
  decompiler.addToken(Token.RP);
  // Report strict warning on code like "if (a = 7) ...". Suppress the
  // warning if the condition is parenthesized, like "if ((a = 7)) ...".
  if (pn.getProp(Node.PARENTHESIZED_PROP) == null &&
    (pn.getType() == Token.SETNAME || pn.getType() == Token.SETPROP ||
     pn.getType() == Token.SETELEM))
  {
    addStrictWarning("msg.equal.as.assign", "");
  }
  return pn;
}

代码示例来源:origin: com.github.tntim96/rhino

private AstNode expr()
  throws IOException
{
  AstNode pn = assignExpr();
  int pos = pn.getPosition();
  while (matchToken(Token.COMMA)) {
    int opPos = ts.tokenBeg;
    if (compilerEnv.isStrictMode() && !pn.hasSideEffects())
      addStrictWarning("msg.no.side.effects", "",
               pos, nodeEnd(pn) - pos);
    if (peekToken() == Token.YIELD)
      reportError("msg.yield.parenthesized");
    pn = new InfixExpression(Token.COMMA, pn, assignExpr(), opPos);
  }
  return pn;
}

代码示例来源:origin: geogebra/geogebra

private AstNode expr()
  throws IOException
{
  AstNode pn = assignExpr();
  int pos = pn.getPosition();
  while (matchToken(Token.COMMA)) {
    int opPos = ts.tokenBeg;
    if (compilerEnv.isStrictMode() && !pn.hasSideEffects())
      addStrictWarning("msg.no.side.effects", "",
               pos, nodeEnd(pn) - pos);
    if (peekToken() == Token.YIELD)
      reportError("msg.yield.parenthesized");
    pn = new InfixExpression(Token.COMMA, pn, assignExpr(), opPos);
  }
  return pn;
}

代码示例来源:origin: io.apigee/rhino

private AstNode expr()
  throws IOException
{
  AstNode pn = assignExpr();
  int pos = pn.getPosition();
  while (matchToken(Token.COMMA)) {
    int opPos = ts.tokenBeg;
    if (compilerEnv.isStrictMode() && !pn.hasSideEffects())
      addStrictWarning("msg.no.side.effects", "",
               pos, nodeEnd(pn) - pos);
    if (peekToken() == Token.YIELD)
      reportError("msg.yield.parenthesized");
    pn = new InfixExpression(Token.COMMA, pn, assignExpr(), opPos);
  }
  return pn;
}

代码示例来源:origin: ro.isdc.wro4j/rhino

private AstNode expr()
  throws IOException
{
  AstNode pn = assignExpr();
  int pos = pn.getPosition();
  while (matchToken(Token.COMMA)) {
    int opPos = ts.tokenBeg;
    if (compilerEnv.isStrictMode() && !pn.hasSideEffects())
      addStrictWarning("msg.no.side.effects", "",
               pos, nodeEnd(pn) - pos);
    if (peekToken() == Token.YIELD)
      reportError("msg.yield.parenthesized");
    pn = new InfixExpression(Token.COMMA, pn, assignExpr(), opPos);
  }
  return pn;
}

相关文章

Parser类方法