本文整理汇总了Java中com.sun.source.tree.NewArrayTree.getType方法的典型用法代码示例。如果您正苦于以下问题:Java NewArrayTree.getType方法的具体用法?Java NewArrayTree.getType怎么用?Java NewArrayTree.getType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sun.source.tree.NewArrayTree
的用法示例。
在下文中一共展示了NewArrayTree.getType方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: visitNewArray
import com.sun.source.tree.NewArrayTree; //导入方法依赖的package包/类
@Override
public Void visitNewArray(NewArrayTree tree, EnumSet<UseTypes> d) {
if (tree.getType() != null) {
handlePossibleIdentifier(new TreePath(getCurrentPath(), tree.getType()), EnumSet.of(UseTypes.CLASS_USE));
}
scan(tree.getType(), null);
scan(tree.getDimensions(), EnumSet.of(UseTypes.READ));
scan(tree.getInitializers(), EnumSet.of(UseTypes.READ));
return null;
}
示例2: computeNewArray
import com.sun.source.tree.NewArrayTree; //导入方法依赖的package包/类
private static List<? extends TypeMirror> computeNewArray(Set<ElementKind> types, CompilationInfo info, TreePath parent, Tree error, int offset) {
NewArrayTree nat = (NewArrayTree) parent.getLeaf();
if (nat.getType() == error) {
types.add(ElementKind.CLASS);
types.add(ElementKind.ENUM);
types.add(ElementKind.INTERFACE);
return null;
}
for (Tree dimension : nat.getDimensions()) {
if (dimension == error) {
types.add(ElementKind.PARAMETER);
types.add(ElementKind.LOCAL_VARIABLE);
types.add(ElementKind.FIELD);
return Collections.singletonList(info.getTypes().getPrimitiveType(TypeKind.INT));
}
}
for (Tree init : nat.getInitializers()) {
if (init == error) {
TypeMirror whole = info.getTrees().getTypeMirror(parent);
if (whole == null || whole.getKind() != TypeKind.ARRAY)
return null;
types.add(ElementKind.PARAMETER);
types.add(ElementKind.LOCAL_VARIABLE);
types.add(ElementKind.FIELD);
return Collections.singletonList(((ArrayType) whole).getComponentType());
}
}
return null;
}
示例3: transformInitializer
import com.sun.source.tree.NewArrayTree; //导入方法依赖的package包/类
private ExpressionTree transformInitializer(ExpressionTree initializer, Tree type, TreeMaker make) {
if(initializer.getKind() == Tree.Kind.NEW_ARRAY) {
NewArrayTree nat = (NewArrayTree) initializer;
if(nat.getType() == null) {
if(type.getKind() == Tree.Kind.ARRAY_TYPE) {
ArrayTypeTree arrayTypeTree = (ArrayTypeTree) type;
type = arrayTypeTree.getType();
}
return make.NewArray(type, nat.getDimensions(), nat.getInitializers());
}
}
return initializer;
}
示例4: visitNewArray
import com.sun.source.tree.NewArrayTree; //导入方法依赖的package包/类
@Override
public Void visitNewArray(NewArrayTree node, Void unused) {
if (node.getType() != null) {
builder.open(plusFour);
token("new");
builder.space();
TypeWithDims extractedDims = DimensionHelpers.extractDims(node.getType(), SortedDims.YES);
Tree base = extractedDims.node;
Deque<ExpressionTree> dimExpressions = new ArrayDeque<>(node.getDimensions());
Deque<List<AnnotationTree>> annotations = new ArrayDeque<>();
// TODO: 22-Jul-17 missing method java8
// annotations.add(ImmutableList.copyOf(node.getAnnotations()));
// annotations.addAll((List<List<AnnotationTree>>) node.getDimAnnotations());
annotations.addAll(extractedDims.dims);
scan(base, null);
builder.open(ZERO);
maybeAddDims(dimExpressions, annotations);
builder.close();
builder.close();
}
if (node.getInitializers() != null) {
if (node.getType() != null) {
builder.space();
}
visitArrayInitializer(node.getInitializers());
}
return null;
}
示例5: visitNewArray
import com.sun.source.tree.NewArrayTree; //导入方法依赖的package包/类
@Override
public Void visitNewArray(NewArrayTree node, Void p) {
boolean valid = validateTypeOf(node);
if (valid && node.getType() != null && node.getInitializers() != null) {
AnnotatedArrayType arrayType = atypeFactory.getAnnotatedType(node);
checkArrayInitialization(arrayType.getComponentType(),
node.getInitializers());
}
return super.visitNewArray(node, p);
}
示例6: visitNewArray
import com.sun.source.tree.NewArrayTree; //导入方法依赖的package包/类
@Override
public AnnotatedTypeMirror visitNewArray(NewArrayTree node,
AnnotatedTypeFactory f) {
// Don't use fromTypeTree here, because node.getType() is not an
// array type!
AnnotatedArrayType result = (AnnotatedArrayType)f.type(node);
if (node.getType() == null) // e.g., byte[] b = {(byte)1, (byte)2};
return result;
annotateArrayAsArray(result, node, f);
return result;
}