当前位置: 首页>>代码示例>>Java>>正文


Java Token.WITH属性代码示例

本文整理汇总了Java中com.google.javascript.rhino.Token.WITH属性的典型用法代码示例。如果您正苦于以下问题:Java Token.WITH属性的具体用法?Java Token.WITH怎么用?Java Token.WITH使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在com.google.javascript.rhino.Token的用法示例。


在下文中一共展示了Token.WITH属性的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: isControlStructure

/**
 * Determines whether the given node is a FOR, DO, WHILE, WITH, or IF node.
 */
static boolean isControlStructure(Node n) {
  switch (n.getType()) {
    case Token.FOR:
    case Token.DO:
    case Token.WHILE:
    case Token.WITH:
    case Token.IF:
    case Token.LABEL:
    case Token.TRY:
    case Token.CATCH:
    case Token.SWITCH:
    case Token.CASE:
    case Token.DEFAULT:
      return true;
    default:
      return false;
  }
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:21,代码来源:NodeUtil.java

示例2: isControlStructureCodeBlock

/**
 * Determines whether the given node is code node for FOR, DO,
 * WHILE, WITH, or IF node.
 */
static boolean isControlStructureCodeBlock(Node parent, Node n) {
  switch (parent.getType()) {
    case Token.FOR:
    case Token.WHILE:
    case Token.LABEL:
    case Token.WITH:
      return parent.getLastChild() == n;
    case Token.DO:
      return parent.getFirstChild() == n;
    case Token.IF:
      return parent.getFirstChild() != n;
    case Token.TRY:
      return parent.getFirstChild() == n || parent.getLastChild() == n;
    case Token.CATCH:
      return parent.getLastChild() == n;
    case Token.SWITCH:
    case Token.CASE:
      return parent.getFirstChild() != n;
    case Token.DEFAULT:
      return true;
    default:
      Preconditions.checkState(isControlStructure(parent));
      return false;
  }
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:29,代码来源:NodeUtil.java

示例3: consumesDanglingElse

/**
 * Does a statement consume a 'dangling else'? A statement consumes
 * a 'dangling else' if an 'else' token following the statement
 * would be considered by the parser to be part of the statement.
 */
private boolean consumesDanglingElse(Node n) {
  while (true) {
    switch (n.getType()) {
      case Token.IF:
        if (n.getChildCount() < 3) return true;
        // This IF node has no else clause.
        n = n.getLastChild();
        continue;
      case Token.WITH:
      case Token.WHILE:
      case Token.FOR:
        n = n.getLastChild();
        continue;
      default:
        return false;
    }
  }
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:23,代码来源:FoldConstants.java

示例4: check

/**
 * Reports errors for any invalid use of control structures.
 *
 * @param node Current node to check.
 */
private void check(Node node) {
  switch (node.getType()) {
    case Token.WITH:
      JSDocInfo info = node.getJSDocInfo();
      boolean allowWith =
          info != null && info.getSuppressions().contains("with");
      if (!allowWith) {
        report(node, USE_OF_WITH);
      }
      break;

    case Token.SCRIPT:
      // Remember the source file name in case we need to report an error.
      sourceName = (String) node.getProp(Node.SOURCENAME_PROP);
      break;
  }

  for (Node bChild = node.getFirstChild(); bChild != null;) {
    Node next = bChild.getNext();
    check(bChild);
    bChild = next;
  }
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:28,代码来源:ControlStructureCheck.java

示例5: visit

@Override public void visit(NodeTraversal t, Node n, Node parent) {
  if (n.getType() == Token.WITH) {
    t.report(n, WITH_DISALLOWED);
  } else if (n.getType() == Token.NAME) {
    if (!NodeUtil.isLabelName(n) && !isDeclaration(n)) {
      checkNameUse(t, n);
    }
  } else if (n.getType() == Token.ASSIGN) {
    checkAssignment(t, n);
  } else if (n.getType() == Token.DELPROP) {
    checkDelete(t, n);
  } else if (n.getType() == Token.OBJECTLIT) {
    checkObjectLiteral(t, n);
  } else if (n.getType() == Token.LABEL) {
    checkLabel(t, n);
  }
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:17,代码来源:StrictModeCheck.java

示例6: isBlockBoundary

/**
 * @return true if this node marks the start of a new basic block
 */
private static boolean isBlockBoundary(Node n, Node parent) {
  if (parent != null) {
    switch (parent.getType()) {
      case Token.DO:
      case Token.FOR:
      case Token.TRY:
      case Token.WHILE:
      case Token.WITH:
        // NOTE: TRY has up to 3 child blocks:
        // TRY
        //   BLOCK
        //   BLOCK
        //     CATCH
        //   BLOCK
        // Note that there is an explcit CATCH token but no explicit
        // FINALLY token. For simplicity, we consider each BLOCK
        // a separate basic BLOCK.
        return true;
      case Token.AND:
      case Token.HOOK:
      case Token.IF:
      case Token.OR:
        // The first child of a conditional is not a boundary,
        // but all the rest of the children are.
        return n != parent.getFirstChild();

    }
  }

  return n.getType() == Token.CASE;
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:34,代码来源:ReferenceCollectingCallback.java

示例7: processWithStatement

@Override
Node processWithStatement(WithStatement statementNode) {
  return new Node(
      Token.WITH,
      transform(statementNode.getExpression()),
      transform(statementNode.getStatement()));
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:7,代码来源:IRFactory.java

示例8: isEnteringNewCfgNode

/**
 * @return True if n should be represented by a new CFG node in the control
 * flow graph.
 */
public static boolean isEnteringNewCfgNode(Node n) {
  Node parent = n.getParent();
  switch (parent.getType()) {
    case Token.BLOCK:
    case Token.SCRIPT:
    case Token.TRY:
    case Token.FINALLY:
      return true;
    case Token.FUNCTION:
      // A function node represents the start of a function where the name
      // is bleed into the local scope and parameters has been assigned
      // to the formal argument names. The node includes the name of the
      // function and the LP list since we assume the whole set up process
      // is atomic without change in control flow. The next change of
      // control is going into the function's body represent by the second
      // child.
      return n != parent.getFirstChild().getNext();
    case Token.WHILE:
    case Token.DO:
    case Token.IF:
      // Theses control structure is represented by its node that holds the
      // condition. Each of them is a branch node based on its condition.
      return NodeUtil.getConditionExpression(parent) != n;
      
    case Token.FOR:
      // The FOR(;;) node differs from other control structure in that
      // it has a initialization and a increment statement. Those
      // two statements have its corresponding CFG nodes to represent them.
      // The FOR node represents the condition check for each iteration.
      // That way the following:
      // for(var x = 0; x < 10; x++) { } has a graph that is isomorphic to
      // var x = 0; while(x<10) {  x++; }
      if (NodeUtil.isForIn(parent)) {
        return n == parent.getLastChild(); 
      } else {
        return NodeUtil.getConditionExpression(parent) != n;
      }
    case Token.SWITCH:
    case Token.CASE:
    case Token.CATCH:
    case Token.WITH:
      return n != parent.getFirstChild();
    default:
      return false;
  }
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:50,代码来源:ControlFlowGraph.java

示例9: shouldTraverse

@Override
public boolean shouldTraverse(
    NodeTraversal nodeTraversal, Node n, Node parent) {
  astPosition.put(n, astPositionCounter++);

  switch (n.getType()) {
    case Token.FUNCTION:
      if (shouldTraverseFunctions || n == cfg.getEntry().getValue()) {
        exceptionHandler.push(n);
        return true;
      }
      return false;
    case Token.TRY:
      exceptionHandler.push(n);
      return true;
  }

  /*
   * We are going to stop the traversal depending on what the node's parent
   * is.
   *
   * We are only interested in adding edges between nodes that change control
   * flow. The most obvious ones are loops and IF-ELSE's. A statement
   * transfers control to its next sibling.
   *
   * In case of an expression tree, there is no control flow within the tree
   * even when there are short circuited operators and conditionals. When we
   * are doing data flow analysis, we will simply synthesize lattices up the
   * expression tree by finding the meet at each expression node.
   *
   * For example: within a Token.SWITCH, the expression in question does not
   * change the control flow and need not to be considered.
   */
  if (parent != null) {
    switch (parent.getType()) {
      case Token.FOR:
        // Only traverse the body of the for loop.
        return n == parent.getLastChild();

      // Skip the conditions.
      case Token.IF:
      case Token.WHILE:
      case Token.WITH:
        return n != parent.getFirstChild();
      case Token.DO:
        return n != parent.getFirstChild().getNext();
      // Only traverse the body of the cases
      case Token.SWITCH:
      case Token.CASE:
      case Token.CATCH:
      case Token.LABEL:
        return n != parent.getFirstChild();
      case Token.FUNCTION:
        return n == parent.getFirstChild().getNext().getNext();
      case Token.CONTINUE:
      case Token.BREAK:
      case Token.EXPR_RESULT:
      case Token.VAR:
      case Token.RETURN:
      case Token.THROW:
        return false;
      case Token.TRY:
        /* Just before we are about to visit the second child of the TRY node,
         * we know that we will be visiting either the CATCH or the FINALLY.
         * In other words, we know that the post order traversal of the TRY
         * block has been finished, no more exceptions can be caught by the
         * handler at this TRY block and should be taken out of the stack.
         */
        if (n == parent.getFirstChild().getNext()) {
          Preconditions.checkState(exceptionHandler.peek() == parent);
          exceptionHandler.pop();
        }
    }
  }
  return true;
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:76,代码来源:ControlFlowAnalysis.java

示例10: visit

@Override
public void visit(NodeTraversal t, Node n, Node parent) {
  switch (n.getType()) {
    case Token.IF:
      handleIf(n);
      return;
    case Token.WHILE:
      handleWhile(n);
      return;
    case Token.DO:
      handleDo(n);
      return;
    case Token.FOR:
      handleFor(n);
      return;
    case Token.SWITCH:
      handleSwitch(n);
      return;
    case Token.CASE:
      handleCase(n);
      return;
    case Token.DEFAULT:
      handleDefault(n);
      return;
    case Token.BLOCK:
    case Token.SCRIPT:
      handleStmtList(n);
      return;
    case Token.FUNCTION:
      handleFunction(n);
      return;
    case Token.EXPR_RESULT:
      handleExpr(n);
      return;
    case Token.THROW:
      handleThrow(n);
      return;
    case Token.TRY:
      handleTry(n);
      return;
    case Token.CATCH:
      handleCatch(n);
      return;
    case Token.BREAK:
      handleBreak(n);
      return;
    case Token.CONTINUE:
      handleContinue(n);
      return;
    case Token.RETURN:
      handleReturn(n);
      return;
    case Token.WITH:
      handleWith(n);
      return;
    case Token.LABEL:
      return;
    default:
      handleStmt(n);
      return;
  }
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:62,代码来源:ControlFlowAnalysis.java


注:本文中的com.google.javascript.rhino.Token.WITH属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。