Java 类com.sun.tools.javac.tree.JCTree.JCEnhancedForLoop 实例源码

项目:incubator-netbeans    文件:CasualDiff.java   
protected int diffForeachLoop(JCEnhancedForLoop oldT, JCEnhancedForLoop newT, int[] bounds) {
    int localPointer = bounds[0];
    // variable
    int[] varBounds = getBounds(oldT.var);
    copyTo(localPointer, varBounds[0]);
    localPointer = diffTree(oldT.var, newT.var, varBounds);
    // expression
    int[] exprBounds = getBounds(oldT.expr);
    copyTo(localPointer, exprBounds[0]);
    localPointer = diffTree(oldT.expr, newT.expr, exprBounds);
    // body
    int[] bodyBounds = new int[] { localPointer, endPos(oldT.body) };
    int oldIndent = newT.body.hasTag(Tag.BLOCK) ? -1 : printer.indent();
    localPointer = diffTree(oldT.body, newT.body, bodyBounds, oldT.getKind());
    if (!newT.body.hasTag(Tag.BLOCK))
        printer.undent(oldIndent);
    copyTo(localPointer, bounds[1]);

    return bounds[1];
}
项目:lombok-ianchiu    文件:PrettyPrinter.java   
@Override public void visitForeachLoop(JCEnhancedForLoop tree) {
    aPrint("for (");
    printVarDefInline(tree.var);
    print(" : ");
    print(tree.expr);
    print(") ");
    print(tree.body);
}
项目:javaparser2jctree    文件:PrintAstVisitor.java   
public void visitForeachLoop(JCEnhancedForLoop that) {
    try {
        print("JCEnhancedForLoop:");
    } catch (Exception e) {
    }
    super.visitForeachLoop(that);
}
项目:EasyMPermission    文件:PrettyCommentsPrinter.java   
public void visitForeachLoop(JCEnhancedForLoop tree) {
    try {
        print("for (");
        printExpr(tree.var);
        print(" : ");
        printExpr(tree.expr);
        print(") ");
        printStat(tree.body);
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
}
项目:refactor-faster    文件:UEnhancedForLoop.java   
@Override
public JCEnhancedForLoop inline(Inliner inliner) throws CouldNotResolveImportException {
  return inliner.maker().ForeachLoop(
      getVariable().inline(inliner),
      getExpression().inline(inliner),
      getStatement().inline(inliner));
}
项目:android-retrolambda-lombok    文件:JcTreePrinter.java   
@Override public void visitForeachLoop(JCEnhancedForLoop tree) {
    printNode(tree);
    child("var", tree.var);
    child("expr", tree.expr);
    child("body", tree.body);
    indent--;
}
项目:android-retrolambda-lombok    文件:JcTreeConverter.java   
@Override public void visitForeachLoop(JCEnhancedForLoop node) {
    ForEach fe = new ForEach();
    fe.rawIterable(toTree(node.getExpression()));
    fe.rawStatement(toTree(node.getStatement()));
    fe.rawVariable(toTree(node.getVariable(), FlagKey.VARDEF_IS_DEFINITION));
    set(node, fe);
}
项目:error-prone    文件:UEnhancedForLoop.java   
@Override
public JCEnhancedForLoop inline(Inliner inliner) throws CouldNotResolveImportException {
  return inliner
      .maker()
      .ForeachLoop(
          getVariable().inline(inliner),
          getExpression().inline(inliner),
          getStatement().inline(inliner));
}
项目:error-prone    文件:PlaceholderUnificationVisitor.java   
@Override
public Choice<State<JCEnhancedForLoop>> visitEnhancedForLoop(
    final EnhancedForLoopTree node, State<?> state) {
  return chooseSubtrees(
      state,
      s -> unifyExpression(node.getExpression(), s),
      s -> unifyStatement(node.getStatement(), s),
      (expr, stmt) -> maker().ForeachLoop((JCVariableDecl) node.getVariable(), expr, stmt));
}
项目:s4j    文件:Pretty.java   
public void visitForeachLoop(JCEnhancedForLoop tree) {
    try {
        print("for (");
        printExpr(tree.var);
        print(" : ");
        printExpr(tree.expr);
        print(") ");
        printStat(tree.body);
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
}
项目:s4j    文件:Attr.java   
public void visitForeachLoop(JCEnhancedForLoop tree) {
    Env<AttrContext> loopEnv =
        env.dup(env.tree, env.info.dup(env.info.scope.dup()));
    attribStat(tree.var, loopEnv);
    Type exprType = types.upperBound(attribExpr(tree.expr, loopEnv));
    chk.checkNonVoid(tree.pos(), exprType);
    Type elemtype = types.elemtype(exprType); // perhaps expr is an array?
    if (elemtype == null) {
        // or perhaps expr implements Iterable<T>?
        Type base = types.asSuper(exprType, syms.iterableType.tsym);
        if (base == null) {
            log.error(tree.expr.pos(),
                    "foreach.not.applicable.to.type",
                    exprType,
                    diags.fragment("type.req.array.or.iterable"));
            elemtype = types.createErrorType(exprType);
        } else {
            List<Type> iterableParams = base.allparams();
            elemtype = iterableParams.isEmpty()
                ? syms.objectType
                : types.upperBound(iterableParams.head);
        }
    }
    chk.checkType(tree.expr.pos(), elemtype, tree.var.sym.type);
    loopEnv.tree = tree; // before, we were not in loop!
    attribStat(tree.body, loopEnv);
    loopEnv.info.scope.leave();
    result = null;
}
项目:Refaster    文件:UEnhancedForLoop.java   
@Override
public JCEnhancedForLoop inline(Inliner inliner) throws CouldNotResolveImportException {
  return inliner.maker().ForeachLoop(
      getVariable().inline(inliner),
      getExpression().inline(inliner),
      getStatement().inline(inliner));
}
项目:lombok    文件:PrettyCommentsPrinter.java   
public void visitForeachLoop(JCEnhancedForLoop tree) {
    try {
        print("for (");
        printExpr(tree.var);
        print(" : ");
        printExpr(tree.expr);
        print(") ");
        printStat(tree.body);
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
}
项目:incubator-netbeans    文件:CasualDiff.java   
private boolean matchForeachLoop(JCEnhancedForLoop t1, JCEnhancedForLoop t2) {
    return treesMatch(t1.var, t2.var) && treesMatch(t1.expr, t2.expr) &&
           treesMatch(t1.body, t2.body);
}
项目:openjdk-jdk10    文件:Analyzer.java   
@Override
public void visitForeachLoop(JCEnhancedForLoop tree) {
    //skip body (to prevents same statements to be analyzed twice)
    scan(tree.getExpression());
}
项目:openjdk9    文件:Analyzer.java   
@Override
public void visitForeachLoop(JCEnhancedForLoop tree) {
    scan(tree.getExpression());
}
项目:lombok-ianchiu    文件:JavacTreeMaker.java   
public JCEnhancedForLoop ForeachLoop(JCVariableDecl var, JCExpression expr, JCStatement body) {
    return invoke(ForeachLoop, var, expr, body);
}
项目:javaparser2jctree    文件:AJCEnhancedForLoop.java   
public AJCEnhancedForLoop(JCEnhancedForLoop ltree) {
    super(ltree.var, ltree.expr, ltree.body);
}
项目:javaparser2jctree    文件:AJCEnhancedForLoop.java   
public AJCEnhancedForLoop(JCEnhancedForLoop ltree, String lcomment) {
    this(ltree);
    setComment(lcomment);
}
项目:EasyMPermission    文件:JavacTreeMaker.java   
public JCEnhancedForLoop ForeachLoop(JCVariableDecl var, JCExpression expr, JCStatement body) {
    return invoke(ForeachLoop, var, expr, body);
}