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


Java Token.DEFAULT属性代码示例

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


在下文中一共展示了Token.DEFAULT属性的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: isInThrowExpression

/**
 * Is the {@link Node} currently within a 'throw' expression?
 */
private static boolean isInThrowExpression(Node n) {
  // Look up the traversal stack to find a THROW node
  for (Node ancestor : n.getAncestors()) {
    switch (ancestor.getType()) {
      case Token.THROW:
        return true;
      case Token.IF:
      case Token.WHILE:
      case Token.DO:
      case Token.FOR:
      case Token.SWITCH:
      case Token.CASE:
      case Token.DEFAULT:
      case Token.BLOCK:
      case Token.SCRIPT:
      case Token.FUNCTION:
      case Token.TRY:
      case Token.CATCH:
      case Token.RETURN:
      case Token.EXPR_RESULT:
        // early exit - these nodes types can't be within a THROW
        return false;
    }
  }
  return false;
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:29,代码来源:AliasStrings.java

示例4: findExpressionRoot

/**
 * @return The statement containing the expression. null if subExpression
 *     is not contain by in by a Node where inlining is known to be possible.
 *     For example, a WHILE node condition expression.
 */
static Node findExpressionRoot(Node subExpression) {
  Node child = subExpression;
  for (Node parent : child.getAncestors()) {
    int parentType = parent.getType();
    switch (parentType) {
      // Supported expression roots:
      // SWITCH and IF can have multiple children, but the CASE, DEFAULT,
      // or BLOCK will be encountered first for any of the children other
      // than the condition.
      case Token.EXPR_RESULT:
      case Token.IF:
      case Token.SWITCH:
      case Token.RETURN:
      case Token.VAR:
        Preconditions.checkState(child == parent.getFirstChild());
        return parent;
      // Any of these indicate an unsupported expression:
      case Token.SCRIPT:
      case Token.BLOCK:
      case Token.LABEL:
      case Token.CASE:
      case Token.DEFAULT:
        return null;
    }
    child = parent;
  }

  throw new IllegalStateException("Unexpected AST structure.");
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:34,代码来源:ExpressionDecomposer.java

示例5: isSwitchCase

/** Whether the node is part of a switch statement. */
static boolean isSwitchCase(Node n) {
  return n.getType() == Token.CASE || n.getType() == Token.DEFAULT;
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:4,代码来源:NodeUtil.java

示例6: 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

示例7: handleStmtList

private void handleStmtList(Node node) {
  Node parent = node.getParent();
  // Special case, don't add a block of empty CATCH block to the graph.
  if (node.getType() == Token.BLOCK && parent != null &&
      parent.getType() == Token.TRY &&
      NodeUtil.getCatchBlock(parent) == node &&
      !NodeUtil.hasCatchHandler(node)) {
    return;
  }

  // A block transfer control to its first child if it is not empty.
  Node child = node.getFirstChild();

  // Function declarations are skipped since control doesn't go into that
  // function (unless it is called)
  while (child != null && child.getType() == Token.FUNCTION) {
    child = child.getNext();
  }

  if (child != null) {
    createEdge(node, Branch.UNCOND, computeFallThrough(child));
  } else {
    createEdge(node, Branch.UNCOND, computeFollowNode(node));
  }

  // Synthetic blocks
  if (parent != null) {
    switch (parent.getType()) {
      case Token.DEFAULT:
      case Token.CASE:
      case Token.TRY:
        break;
      default:
        if (node.getType() == Token.BLOCK && node.isSyntheticBlock()) {
          Node next = node.getLastChild();
          if (next != null) {
            createEdge(node, Branch.SYN_BLOCK, computeFallThrough(next));
          }
        }
        break;
    }
  }
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:43,代码来源:ControlFlowAnalysis.java

示例8: getCodeString

public String getCodeString() { 
	
	if(node.getType() == Token.DEFAULT) return "default";
	else return "case " + getCFGNodeFor(node.getChildAtIndex(0)).getCodeString();
	
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:6,代码来源:CFGCaseNode.java


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