当前位置: 首页>>代码示例>>Java>>正文


Java NewArrayTree.getType方法代码示例

本文整理汇总了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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:13,代码来源:SemanticHighlighterBase.java

示例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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:39,代码来源:CreateElementUtilities.java

示例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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:14,代码来源:Move.java

示例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;
    }
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:33,代码来源:JavaInputAstVisitor.java

示例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);
}
 
开发者ID:reprogrammer,项目名称:checker-framework,代码行数:12,代码来源:BaseTypeVisitor.java

示例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;
}
 
开发者ID:reprogrammer,项目名称:checker-framework,代码行数:16,代码来源:TypeFromTree.java


注:本文中的com.sun.source.tree.NewArrayTree.getType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。