本文整理汇总了Java中com.sun.tools.javac.tree.JCTree.JCNewArray类的典型用法代码示例。如果您正苦于以下问题:Java JCNewArray类的具体用法?Java JCNewArray怎么用?Java JCNewArray使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
JCNewArray类属于com.sun.tools.javac.tree.JCTree包,在下文中一共展示了JCNewArray类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: visitNewArray
import com.sun.tools.javac.tree.JCTree.JCNewArray; //导入依赖的package包/类
public Void visitNewArray(NewArrayTree node, Void ignore) {
// the Tree API hasn't been updated to expose annotations yet
JCNewArray newArray = (JCNewArray)node;
int totalLength = node.getDimensions().size()
+ arrayLength(node.getType())
+ ((newArray.getInitializers() != null) ? 1 : 0);
testAnnotations(newArray.annotations, totalLength);
int count = 0;
for (List<? extends AnnotationTree> annos : newArray.dimAnnotations) {
testAnnotations(annos, totalLength - count);
count++;
}
return super.visitNewArray(node, ignore);
}
示例2: visitNewArray
import com.sun.tools.javac.tree.JCTree.JCNewArray; //导入依赖的package包/类
@Override public void visitNewArray(JCNewArray tree) {
JCTree elem = tree.elemtype;
int dims = 0;
if (elem != null) {
print("new ");
while (elem instanceof JCArrayTypeTree) {
dims++;
elem = ((JCArrayTypeTree) elem).elemtype;
}
print(elem);
for (JCExpression expr : tree.dims) {
print("[");
print(expr);
print("]");
}
}
for (int i = 0; i < dims; i++) print("[]");
if (tree.elems != null) {
if (elem != null) print("[] ");
print("{");
print(tree.elems, ", ");
print("}");
}
}
示例3: visitNewArray
import com.sun.tools.javac.tree.JCTree.JCNewArray; //导入依赖的package包/类
public void visitNewArray(JCNewArray that) {
try {
print("JCNewArray:");
} catch (Exception e) {
}
super.visitNewArray(that);
}
示例4: visitNewArray
import com.sun.tools.javac.tree.JCTree.JCNewArray; //导入依赖的package包/类
public void visitNewArray(JCNewArray tree) {
try {
if (tree.elemtype != null) {
print("new ");
JCTree elem = tree.elemtype;
if (elem instanceof JCArrayTypeTree)
printBaseElementType((JCArrayTypeTree) elem);
else
printExpr(elem);
for (List<JCExpression> l = tree.dims; l.nonEmpty(); l = l.tail) {
print("[");
printExpr(l.head);
print("]");
}
if (elem instanceof JCArrayTypeTree)
printBrackets((JCArrayTypeTree) elem);
}
if (tree.elems != null) {
if (tree.elemtype != null) print("[]");
print("{");
printExprs(tree.elems);
print("}");
}
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
示例5: addNewType
import com.sun.tools.javac.tree.JCTree.JCNewArray; //导入依赖的package包/类
private void addNewType(TreePath path, NewInsertion neu,
NewArrayTree newArray) {
DeclaredType baseType = neu.getBaseType();
if (baseType.getName().isEmpty()) {
List<String> annotations = neu.getType().getAnnotations();
Type newType = Insertions.TypeTree.javacTypeToType(
((JCTree.JCNewArray) newArray).type);
for (String ann : annotations) {
newType.addAnnotation(ann);
}
neu.setType(newType);
}
Insertion.decorateType(neu.getInnerTypeInsertions(), neu.getType(),
neu.getCriteria().getASTPath());
}
示例6: inline
import com.sun.tools.javac.tree.JCTree.JCNewArray; //导入依赖的package包/类
@Override
public JCNewArray inline(Inliner inliner) throws CouldNotResolveImportException {
return inliner.maker().NewArray(
(getType() == null) ? null : getType().inline(inliner),
(getDimensions() == null) ? null :
inliner.<JCExpression, UExpression>inlineList(getDimensions()),
(getInitializers() == null) ? null :
inliner.<JCExpression, UExpression>inlineList(getInitializers()));
}
示例7: visitNewArray
import com.sun.tools.javac.tree.JCTree.JCNewArray; //导入依赖的package包/类
@Override public void visitNewArray(JCNewArray tree) {
printNode(tree);
child("elemtype", tree.elemtype);
children("dims", tree.dims);
children("elems", tree.elems);
indent--;
}
示例8: visitNewArray
import com.sun.tools.javac.tree.JCTree.JCNewArray; //导入依赖的package包/类
@Override
public Choice<State<JCNewArray>> visitNewArray(final NewArrayTree node, State<?> state) {
return chooseSubtrees(
state,
s -> unifyExpressions(node.getDimensions(), s),
s -> unifyExpressions(node.getInitializers(), s),
(dims, inits) -> maker().NewArray((JCExpression) node.getType(), dims, inits));
}
示例9: inline
import com.sun.tools.javac.tree.JCTree.JCNewArray; //导入依赖的package包/类
@Override
public JCNewArray inline(Inliner inliner) throws CouldNotResolveImportException {
return inliner
.maker()
.NewArray(
(getType() == null) ? null : getType().inline(inliner),
(getDimensions() == null) ? null : inliner.<JCExpression>inlineList(getDimensions()),
(getInitializers() == null)
? null
: inliner.<JCExpression>inlineList(getInitializers()));
}
示例10: visitNewArray
import com.sun.tools.javac.tree.JCTree.JCNewArray; //导入依赖的package包/类
public void visitNewArray(JCNewArray tree) {
try {
if (tree.elemtype != null) {
print("new ");
JCTree elem = tree.elemtype;
if (elem.getTag() == JCTree.TYPEARRAY)
printBaseElementType((JCArrayTypeTree) elem);
else
printExpr(elem);
for (List<JCExpression> l = tree.dims; l.nonEmpty(); l = l.tail) {
print("[");
printExpr(l.head);
print("]");
}
if (elem instanceof JCArrayTypeTree)
printBrackets((JCArrayTypeTree) elem);
}
if (tree.elems != null) {
if (tree.elemtype != null) print("[]");
print("{");
printExprs(tree.elems);
print("}");
}
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
示例11: visitNewArray
import com.sun.tools.javac.tree.JCTree.JCNewArray; //导入依赖的package包/类
@Override
public Void visitNewArray(NewArrayTree node, Void p) {
insert(((JCNewArray)node).annotations);
insert("|");
insert(((JCNewArray)node).dimAnnotations);
return super.visitNewArray(node, p);
}
示例12: visitNewArray
import com.sun.tools.javac.tree.JCTree.JCNewArray; //导入依赖的package包/类
public void visitNewArray(JCNewArray tree) {
try {
if (tree.elemtype != null) {
print("new ");
JCTree elem = tree.elemtype;
if (elem instanceof JCArrayTypeTree)
printBaseElementType((JCArrayTypeTree) elem);
else
printExpr(elem);
for (List<JCExpression> l = tree.dims; l.nonEmpty(); l = l.tail) {
print("[");
printExpr(l.head);
print("]");
}
if (elem instanceof JCArrayTypeTree)
printBrackets((JCArrayTypeTree) elem);
}
if (tree.elems != null) {
if (tree.elemtype != null) print("[]");
print("{");
printExprs(tree.elems);
print("}");
}
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
示例13: diffNewArray
import com.sun.tools.javac.tree.JCTree.JCNewArray; //导入依赖的package包/类
protected int diffNewArray(JCNewArray oldT, JCNewArray newT, int[] bounds) {
int localPointer = bounds[0];
// elemtype
if (newT.elemtype != null) {
if (oldT.elemtype != null) {
int[] elemtypeBounds = getBounds(oldT.elemtype);
copyTo(localPointer, elemtypeBounds[0]);
localPointer = diffTree(oldT.elemtype, newT.elemtype, elemtypeBounds);
}
if (!listsMatch(oldT.dims, newT.dims) && !newT.dims.isEmpty()) {
// solved just for the change, not insert and delete
for (com.sun.tools.javac.util.List<JCExpression> l1 = oldT.dims, l2 = newT.dims;
l1.nonEmpty(); l1 = l1.tail, l2 = l2.tail) {
int[] span = getBounds(l1.head);
copyTo(localPointer, span[0]);
localPointer = diffTree(l1.head, l2.head, span);
}
}
} else if (oldT.elemtype != null) {
//remove new <type><dimensions>
copyTo(localPointer, getOldPos(oldT));
if (oldT.elems != null) {
localPointer = oldT.dims != null && !oldT.dims.isEmpty() ? endPos(oldT.dims) : endPos(oldT.elemtype);
moveFwdToToken(tokenSequence, localPointer, JavaTokenId.LBRACE);
localPointer = tokenSequence.offset();
} else {
localPointer = endPos(oldT);
}
}
if (oldT.elems != null) {
if (oldT.elems.head != null) {
copyTo(localPointer, getOldPos(oldT.elems.head));
localPointer = diffParameterList(oldT.elems, newT.elems, null, getOldPos(oldT.elems.head), Measure.ARGUMENT);
} else if (newT.elems != null && !newT.elems.isEmpty()) {
//empty initializer array, adding the first element to it
//find {:
moveFwdToToken(tokenSequence, localPointer, JavaTokenId.LBRACE);
tokenSequence.moveNext();
copyTo(localPointer, localPointer = tokenSequence.offset());
localPointer = diffParameterList(oldT.elems, newT.elems, null, localPointer, Measure.ARGUMENT);
}
} else if (newT.elems != null && !newT.elems.isEmpty()) {
//empty initializer array, adding the first element to it
//find {:
if (newT.elemtype != null) printer.print("[]");
printer.print("{");
localPointer = diffParameterList(Collections.<JCTree>emptyList(), newT.elems, null, localPointer, Measure.ARGUMENT);
printer.print("}");
moveFwdToToken(tokenSequence, localPointer, JavaTokenId.SEMICOLON);
tokenSequence.moveNext();
localPointer = bounds[1];
// copyTo(localPointer, localPointer = tokenSequence.offset());
}
copyTo(localPointer, bounds[1]);
return bounds[1];
}
示例14: matchNewArray
import com.sun.tools.javac.tree.JCTree.JCNewArray; //导入依赖的package包/类
private boolean matchNewArray(JCNewArray t1, JCNewArray t2) {
return treesMatch(t1.elemtype, t2.elemtype) &&
listsMatch(t1.dims, t2.dims) && listsMatch(t1.elems, t2.elems);
}
示例15: NewArray
import com.sun.tools.javac.tree.JCTree.JCNewArray; //导入依赖的package包/类
public JCNewArray NewArray(JCExpression elemtype, List<JCExpression> dims, List<JCExpression> elems) {
return invoke(NewArray, elemtype, dims, elems);
}