本文整理汇总了Java中com.sun.tools.javac.tree.JCTree.JCArrayTypeTree类的典型用法代码示例。如果您正苦于以下问题:Java JCArrayTypeTree类的具体用法?Java JCArrayTypeTree怎么用?Java JCArrayTypeTree使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
JCArrayTypeTree类属于com.sun.tools.javac.tree.JCTree包,在下文中一共展示了JCArrayTypeTree类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: visitArrayType
import com.sun.tools.javac.tree.JCTree.JCArrayTypeTree; //导入依赖的package包/类
@Override
public Pair<ASTRecord, Integer> visitArrayType(ArrayTypeTree node, Insertion ins) {
dbug.debug("TypePositionFinder.visitArrayType(%s)%n", node);
JCArrayTypeTree att = (JCArrayTypeTree) node;
dbug.debug("TypePositionFinder.visitArrayType(%s) preferred = %s%n",
node, att.getPreferredPosition());
// If the code has a type like "String[][][]", then this gets called
// three times: for String[][][], String[][], and String[]
// respectively. For each of the three, call String[][][] "largest".
ArrayTypeTree largest = largestContainingArray(node);
int largestLevels = arrayLevels(largest);
int levels = arrayLevels(node);
int start = arrayContentType(att).getPreferredPosition() + 1;
int end = att.getEndPosition(tree.endPositions);
int pos = arrayInsertPos(start, end);
dbug.debug(" levels=%d largestLevels=%d%n", levels, largestLevels);
for (int i=levels; i<largestLevels; i++) {
pos = getFirstInstanceAfter('[', pos+1);
dbug.debug(" pos %d at i=%d%n", pos, i);
}
return Pair.of(astRecord(node), pos);
}
示例2: dimension
import com.sun.tools.javac.tree.JCTree.JCArrayTypeTree; //导入依赖的package包/类
private int dimension(JCTree t, int afterPos) {
if (t.getKind() != Kind.ARRAY_TYPE) {
return 0;
}
int add;
if (afterPos >= 0) {
final int[] bounds = getBounds(t);
add = afterPos < bounds[1] ? 1 : 0;
} else {
add = 1;
}
return add + dimension (((JCTree.JCArrayTypeTree)t).getType(), afterPos);
}
示例3: diffTypeArray
import com.sun.tools.javac.tree.JCTree.JCArrayTypeTree; //导入依赖的package包/类
protected int diffTypeArray(JCArrayTypeTree oldT, JCArrayTypeTree newT, int[] bounds) {
int localPointer = bounds[0];
int[] elemtypeBounds = getBounds(oldT.elemtype);
localPointer = diffTree(oldT.elemtype, newT.elemtype, elemtypeBounds);
copyTo(localPointer, bounds[1]);
return bounds[1];
}
示例4: dims
import com.sun.tools.javac.tree.JCTree.JCArrayTypeTree; //导入依赖的package包/类
private int dims(JCExpression vartype) {
if (vartype instanceof JCArrayTypeTree) {
return 1 + dims(((JCArrayTypeTree) vartype).elemtype);
}
return 0;
}
示例5: printVarDef0
import com.sun.tools.javac.tree.JCTree.JCArrayTypeTree; //导入依赖的package包/类
private void printVarDef0(JCVariableDecl tree) {
boolean varargs = (tree.mods.flags & VARARGS) != 0;
if (varargs && tree.vartype instanceof JCArrayTypeTree) {
print(((JCArrayTypeTree) tree.vartype).elemtype);
print("...");
} else {
print(tree.vartype);
}
print(" ");
print(tree.name);
if (tree.init != null) {
print(" = ");
print(tree.init);
}
}
示例6: visitNewArray
import com.sun.tools.javac.tree.JCTree.JCArrayTypeTree; //导入依赖的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("}");
}
}
示例7: visitTypeArray
import com.sun.tools.javac.tree.JCTree.JCArrayTypeTree; //导入依赖的package包/类
public void visitTypeArray(JCArrayTypeTree that) {
try {
print("JCArrayTypeTree:");
} catch (Exception e) {
}
super.visitTypeArray(that);
}
示例8: visitVarDef
import com.sun.tools.javac.tree.JCTree.JCArrayTypeTree; //导入依赖的package包/类
public void visitVarDef(JCVariableDecl tree) {
try {
boolean suppressSemi = suppressFinalAndSemicolonsInTry;
if (getJavadocFor(tree) != null) {
println(); align();
}
printDocComment(tree);
if ((tree.mods.flags & ENUM) != 0) {
printEnumMember(tree);
} else {
printExpr(tree.mods);
if ((tree.mods.flags & VARARGS) != 0) {
printExpr(((JCArrayTypeTree) tree.vartype).elemtype);
print("... " + tree.name);
} else {
printExpr(tree.vartype);
print(" " + tree.name);
}
if (tree.init != null) {
print(" = ");
printExpr(tree.init);
}
if (prec == TreeInfo.notExpression && !suppressSemi) print(";");
}
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
示例9: visitNewArray
import com.sun.tools.javac.tree.JCTree.JCArrayTypeTree; //导入依赖的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);
}
}
示例10: visitTypeArray
import com.sun.tools.javac.tree.JCTree.JCArrayTypeTree; //导入依赖的package包/类
public void visitTypeArray(JCArrayTypeTree tree) {
try {
printBaseElementType(tree);
printBrackets(tree);
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
示例11: printBaseElementType
import com.sun.tools.javac.tree.JCTree.JCArrayTypeTree; //导入依赖的package包/类
private void printBaseElementType(JCArrayTypeTree tree) throws IOException {
JCTree elem = tree.elemtype;
while (elem instanceof JCWildcard)
elem = ((JCWildcard) elem).inner;
if (elem instanceof JCArrayTypeTree)
printBaseElementType((JCArrayTypeTree) elem);
else
printExpr(elem);
}
示例12: arrayContentType
import com.sun.tools.javac.tree.JCTree.JCArrayTypeTree; //导入依赖的package包/类
private JCTree arrayContentType(JCArrayTypeTree att) {
JCTree node = att;
do {
node = ((JCArrayTypeTree) node).getType();
} while (node.getKind() == Tree.Kind.ARRAY_TYPE);
return node;
}
示例13: countDims
import com.sun.tools.javac.tree.JCTree.JCArrayTypeTree; //导入依赖的package包/类
private static int countDims(JCExpression type) {
int dims = 0;
while (type instanceof JCArrayTypeTree) {
type = ((JCArrayTypeTree) type).elemtype;
dims++;
}
return dims;
}
示例14: visitTypeArray
import com.sun.tools.javac.tree.JCTree.JCArrayTypeTree; //导入依赖的package包/类
@Override public void visitTypeArray(JCArrayTypeTree node) {
TypeReference ref = (TypeReference) toTree(node.getType(), FlagKey.TYPE_REFERENCE);
int currentDim = ref.astArrayDimensions();
ref.astArrayDimensions(currentDim + 1);
setConversionPositionInfo(ref, "[]" + currentDim, getPosition(node));
set(node, ref);
}
示例15: visitNewArray
import com.sun.tools.javac.tree.JCTree.JCArrayTypeTree; //导入依赖的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);
}
}