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

项目:incubator-netbeans    文件:CasualDiff.java   
protected int diffIndexed(JCArrayAccess oldT, JCArrayAccess newT, int[] bounds) {
    int localPointer = bounds[0];
    // indexed
    int[] indexedBounds = getBounds(oldT.indexed);
    copyTo(localPointer, indexedBounds[0]);
    localPointer = diffTree(oldT.indexed, newT.indexed, indexedBounds);
    // index
    int[] indexBounds = getBounds(oldT.index);
    indexBounds[0] = copyUpTo(localPointer, indexBounds[0]);
    localPointer = diffTree(oldT.index, newT.index, indexBounds);
    localPointer = copyUpTo(localPointer, bounds[1]);

    return localPointer;
}
项目:javaparser2jctree    文件:PrintAstVisitor.java   
public void visitIndexed(JCArrayAccess that) {
    try {
        print("JCArrayAccess:");
    } catch (Exception e) {
    }
    super.visitIndexed(that);
}
项目:EasyMPermission    文件:PrettyCommentsPrinter.java   
public void visitIndexed(JCArrayAccess tree) {
    try {
        printExpr(tree.indexed, TreeInfo.postfixPrec);
        print("[");
        printExpr(tree.index);
        print("]");
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
}
项目:error-prone    文件:PlaceholderUnificationVisitor.java   
@Override
public Choice<State<JCArrayAccess>> visitArrayAccess(final ArrayAccessTree node, State<?> state) {
  return chooseSubtrees(
      state,
      s -> unifyExpression(node.getExpression(), s),
      s -> unifyExpression(node.getIndex(), s),
      maker()::Indexed);
}
项目:s4j    文件:Pretty.java   
public void visitIndexed(JCArrayAccess tree) {
    try {
        printExpr(tree.indexed, TreeInfo.postfixPrec);
        print("[");
        printExpr(tree.index);
        print("]");
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
}
项目:s4j    文件:Attr.java   
public void visitIndexed(JCArrayAccess tree) {
    Type owntype = types.createErrorType(tree.type);
    Type atype = attribExpr(tree.indexed, env);
    attribExpr(tree.index, env, syms.intType);
    if (types.isArray(atype))
        owntype = types.elemtype(atype);
    else if (atype.tag != ERROR)
        log.error(tree.pos(), "array.req.but.found", atype);
    if ((pkind & VAR) == 0) owntype = capture(owntype);
    result = check(tree, owntype, VAR, pkind, pt);
}
项目:lombok    文件:PrettyCommentsPrinter.java   
public void visitIndexed(JCArrayAccess tree) {
    try {
        printExpr(tree.indexed, TreeInfo.postfixPrec);
        print("[");
        printExpr(tree.index);
        print("]");
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
}
项目:incubator-netbeans    文件:CasualDiff.java   
private boolean matchIndexed(JCArrayAccess t1, JCArrayAccess t2) {
    return treesMatch(t1.indexed, t2.indexed) && treesMatch(t1.index, t2.index);
}
项目:lombok-ianchiu    文件:JavacTreeMaker.java   
public JCArrayAccess Indexed(JCExpression indexed, JCExpression index) {
    return invoke(Indexed, indexed, index);
}
项目:lombok-ianchiu    文件:PrettyPrinter.java   
@Override public void visitIndexed(JCArrayAccess tree) {
    print(tree.indexed);
    print("[");
    print(tree.index);
    print("]");
}
项目:javaparser2jctree    文件:AJCArrayAccess.java   
public AJCArrayAccess(JCArrayAccess ltree) {
    super(ltree.indexed, ltree.index);
}
项目:javaparser2jctree    文件:AJCArrayAccess.java   
public AJCArrayAccess(JCArrayAccess ltree, String lcomment) {
    this(ltree);
    setComment(lcomment);
}
项目:EasyMPermission    文件:JavacTreeMaker.java   
public JCArrayAccess Indexed(JCExpression indexed, JCExpression index) {
    return invoke(Indexed, indexed, index);
}
项目:refactor-faster    文件:ExpressionTemplate.java   
/**
 * Returns the precedence level appropriate for unambiguously printing
 * leaf as a subexpression of its parent.
 */
private static int getPrecedence(JCTree leaf, Context context) {
  JCCompilationUnit comp = context.get(JCCompilationUnit.class);
  JCTree parent = TreeInfo.pathFor(leaf, comp).get(1);

  // In general, this should match the logic in com.sun.tools.javac.tree.Pretty.
  //
  // TODO(mdempsky): There are probably cases where we could omit parentheses
  // by tweaking the returned precedence, but they need careful review.
  // For example, consider a template to replace "add(a, b)" with "a + b",
  // which applied to "x + add(y, z)" would result in "x + (y + z)".
  // In most cases, we'd likely prefer "x + y + z" instead, but those aren't
  // always equivalent: "0L + (Integer.MIN_VALUE + Integer.MIN_VALUE)" yields
  // a different value than "0L + Integer.MIN_VALUE + Integer.MIN_VALUE" due
  // to integer promotion rules.

  if (parent instanceof JCConditional) {
    // This intentionally differs from Pretty, because Pretty appears buggy:
    // http://mail.openjdk.java.net/pipermail/compiler-dev/2013-September/007303.html
    JCConditional conditional = (JCConditional) parent;
    return TreeInfo.condPrec + ((conditional.cond == leaf) ? 1 : 0);
  } else if (parent instanceof JCAssign) {
    JCAssign assign = (JCAssign) parent;
    return TreeInfo.assignPrec + ((assign.lhs == leaf) ? 1 : 0);
  } else if (parent instanceof JCAssignOp) {
    JCAssignOp assignOp = (JCAssignOp) parent;
    return TreeInfo.assignopPrec + ((assignOp.lhs == leaf) ? 1 : 0);
  } else if (parent instanceof JCUnary) {
    return TreeInfo.opPrec(parent.getTag());
  } else if (parent instanceof JCBinary) {
    JCBinary binary = (JCBinary) parent;
    return TreeInfo.opPrec(parent.getTag()) + ((binary.rhs == leaf) ? 1 : 0);
  } else if (parent instanceof JCTypeCast) {
    JCTypeCast typeCast = (JCTypeCast) parent;
    return (typeCast.expr == leaf) ? TreeInfo.prefixPrec : TreeInfo.noPrec;
  } else if (parent instanceof JCInstanceOf) {
    JCInstanceOf instanceOf = (JCInstanceOf) parent;
    return TreeInfo.ordPrec + ((instanceOf.clazz == leaf) ? 1 : 0);
  } else if (parent instanceof JCArrayAccess) {
    JCArrayAccess arrayAccess = (JCArrayAccess) parent;
    return (arrayAccess.indexed == leaf) ? TreeInfo.postfixPrec : TreeInfo.noPrec;
  } else if (parent instanceof JCFieldAccess) {
    JCFieldAccess fieldAccess = (JCFieldAccess) parent;
    return (fieldAccess.selected == leaf) ? TreeInfo.postfixPrec : TreeInfo.noPrec;
  } else {
    return TreeInfo.noPrec;
  }
}
项目:refactor-faster    文件:UArrayAccess.java   
@Override
public JCArrayAccess inline(Inliner inliner) throws CouldNotResolveImportException {
  return inliner.maker().Indexed(getExpression().inline(inliner), getIndex().inline(inliner));
}
项目:android-retrolambda-lombok    文件:JcTreePrinter.java   
@Override public void visitIndexed(JCArrayAccess tree) {
    printNode(tree);
    child("indexed", tree.indexed);
    child("index", tree.index);
    indent--;
}
项目:android-retrolambda-lombok    文件:JcTreeConverter.java   
@Override public void visitIndexed(JCArrayAccess node) {
    ArrayAccess aa = new ArrayAccess();
    aa.rawIndexExpression(toTree(node.getIndex()));
    aa.rawOperand(toTree(node.getExpression()));
    set(node, aa);
}
项目:error-prone    文件:ExpressionTemplate.java   
/**
 * Returns the precedence level appropriate for unambiguously printing leaf as a subexpression of
 * its parent.
 */
private static int getPrecedence(JCTree leaf, Context context) {
  JCCompilationUnit comp = context.get(JCCompilationUnit.class);
  JCTree parent = TreeInfo.pathFor(leaf, comp).get(1);

  // In general, this should match the logic in com.sun.tools.javac.tree.Pretty.
  //
  // TODO(mdempsky): There are probably cases where we could omit parentheses
  // by tweaking the returned precedence, but they need careful review.
  // For example, consider a template to replace "add(a, b)" with "a + b",
  // which applied to "x + add(y, z)" would result in "x + (y + z)".
  // In most cases, we'd likely prefer "x + y + z" instead, but those aren't
  // always equivalent: "0L + (Integer.MIN_VALUE + Integer.MIN_VALUE)" yields
  // a different value than "0L + Integer.MIN_VALUE + Integer.MIN_VALUE" due
  // to integer promotion rules.

  if (parent instanceof JCConditional) {
    // This intentionally differs from Pretty, because Pretty appears buggy:
    // http://mail.openjdk.java.net/pipermail/compiler-dev/2013-September/007303.html
    JCConditional conditional = (JCConditional) parent;
    return TreeInfo.condPrec + ((conditional.cond == leaf) ? 1 : 0);
  } else if (parent instanceof JCAssign) {
    JCAssign assign = (JCAssign) parent;
    return TreeInfo.assignPrec + ((assign.lhs == leaf) ? 1 : 0);
  } else if (parent instanceof JCAssignOp) {
    JCAssignOp assignOp = (JCAssignOp) parent;
    return TreeInfo.assignopPrec + ((assignOp.lhs == leaf) ? 1 : 0);
  } else if (parent instanceof JCUnary) {
    return TreeInfo.opPrec(parent.getTag());
  } else if (parent instanceof JCBinary) {
    JCBinary binary = (JCBinary) parent;
    return TreeInfo.opPrec(parent.getTag()) + ((binary.rhs == leaf) ? 1 : 0);
  } else if (parent instanceof JCTypeCast) {
    JCTypeCast typeCast = (JCTypeCast) parent;
    return (typeCast.expr == leaf) ? TreeInfo.prefixPrec : TreeInfo.noPrec;
  } else if (parent instanceof JCInstanceOf) {
    JCInstanceOf instanceOf = (JCInstanceOf) parent;
    return TreeInfo.ordPrec + ((instanceOf.clazz == leaf) ? 1 : 0);
  } else if (parent instanceof JCArrayAccess) {
    JCArrayAccess arrayAccess = (JCArrayAccess) parent;
    return (arrayAccess.indexed == leaf) ? TreeInfo.postfixPrec : TreeInfo.noPrec;
  } else if (parent instanceof JCFieldAccess) {
    JCFieldAccess fieldAccess = (JCFieldAccess) parent;
    return (fieldAccess.selected == leaf) ? TreeInfo.postfixPrec : TreeInfo.noPrec;
  } else {
    return TreeInfo.noPrec;
  }
}
项目:error-prone    文件:UArrayAccess.java   
@Override
public JCArrayAccess inline(Inliner inliner) throws CouldNotResolveImportException {
  return inliner.maker().Indexed(getExpression().inline(inliner), getIndex().inline(inliner));
}
项目:Refaster    文件:ExpressionTemplate.java   
/**
 * Returns the precedence level appropriate for unambiguously printing
 * leaf as a subexpression of its parent.
 */
private static int getPrecedence(JCTree leaf, Context context) {
  JCCompilationUnit comp = context.get(JCCompilationUnit.class);
  JCTree parent = TreeInfo.pathFor(leaf, comp).get(1);

  // In general, this should match the logic in com.sun.tools.javac.tree.Pretty.
  //
  // TODO(mdempsky): There are probably cases where we could omit parentheses
  // by tweaking the returned precedence, but they need careful review.
  // For example, consider a template to replace "add(a, b)" with "a + b",
  // which applied to "x + add(y, z)" would result in "x + (y + z)".
  // In most cases, we'd likely prefer "x + y + z" instead, but those aren't
  // always equivalent: "0L + (Integer.MIN_VALUE + Integer.MIN_VALUE)" yields
  // a different value than "0L + Integer.MIN_VALUE + Integer.MIN_VALUE" due
  // to integer promotion rules.

  if (parent instanceof JCConditional) {
    // This intentionally differs from Pretty, because Pretty appears buggy:
    // http://mail.openjdk.java.net/pipermail/compiler-dev/2013-September/007303.html
    JCConditional conditional = (JCConditional) parent;
    return TreeInfo.condPrec + ((conditional.cond == leaf) ? 1 : 0);
  } else if (parent instanceof JCAssign) {
    JCAssign assign = (JCAssign) parent;
    return TreeInfo.assignPrec + ((assign.lhs == leaf) ? 1 : 0);
  } else if (parent instanceof JCAssignOp) {
    JCAssignOp assignOp = (JCAssignOp) parent;
    return TreeInfo.assignopPrec + ((assignOp.lhs == leaf) ? 1 : 0);
  } else if (parent instanceof JCUnary) {
    return TreeInfo.opPrec(parent.getTag());
  } else if (parent instanceof JCBinary) {
    JCBinary binary = (JCBinary) parent;
    return TreeInfo.opPrec(parent.getTag()) + ((binary.rhs == leaf) ? 1 : 0);
  } else if (parent instanceof JCTypeCast) {
    JCTypeCast typeCast = (JCTypeCast) parent;
    return (typeCast.expr == leaf) ? TreeInfo.prefixPrec : TreeInfo.noPrec;
  } else if (parent instanceof JCInstanceOf) {
    JCInstanceOf instanceOf = (JCInstanceOf) parent;
    return TreeInfo.ordPrec + ((instanceOf.clazz == leaf) ? 1 : 0);
  } else if (parent instanceof JCArrayAccess) {
    JCArrayAccess arrayAccess = (JCArrayAccess) parent;
    return (arrayAccess.indexed == leaf) ? TreeInfo.postfixPrec : TreeInfo.noPrec;
  } else if (parent instanceof JCFieldAccess) {
    JCFieldAccess fieldAccess = (JCFieldAccess) parent;
    return (fieldAccess.selected == leaf) ? TreeInfo.postfixPrec : TreeInfo.noPrec;
  } else {
    return TreeInfo.noPrec;
  }
}
项目:Refaster    文件:UArrayAccess.java   
@Override
public JCArrayAccess inline(Inliner inliner) throws CouldNotResolveImportException {
  return inliner.maker().Indexed(getExpression().inline(inliner), getIndex().inline(inliner));
}