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


Java ArrayTypeTree类代码示例

本文整理汇总了Java中com.sun.source.tree.ArrayTypeTree的典型用法代码示例。如果您正苦于以下问题:Java ArrayTypeTree类的具体用法?Java ArrayTypeTree怎么用?Java ArrayTypeTree使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ArrayTypeTree类属于com.sun.source.tree包,在下文中一共展示了ArrayTypeTree类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: moveToEnd

import com.sun.source.tree.ArrayTypeTree; //导入依赖的package包/类
public void moveToEnd(Tree t) {
    if (t == null) {
        return ;
    }

    long end = sourcePositions.getEndPosition(info.getCompilationUnit(), t);

    if (end == (-1))
        return ;

    if (t.getKind() == Kind.ARRAY_TYPE) {
        moveToEnd(((ArrayTypeTree) t).getType());
        return ;
    }
    moveToOffset(end);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:TokenList.java

示例2: visitArrayType

import com.sun.source.tree.ArrayTypeTree; //导入依赖的package包/类
@Override
public Mirror visitArrayType(ArrayTypeTree arg0, EvaluationContext evaluationContext) {
    Mirror arrayType = arg0.getType().accept(this, evaluationContext);
    if (!(arrayType instanceof Type)) {
        return arrayType;
    }
    Type type = (Type) arrayType;
    String arrayClassName = type.name()+"[]";
    ReferenceType aType = getOrLoadClass(type.virtualMachine(), arrayClassName, evaluationContext);
    if (aType != null) {
        return aType;
    } else {
        Assert.error(arg0, "unknownType", arrayClassName);
        return null;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:EvaluatorVisitor.java

示例3: extractDims

import com.sun.source.tree.ArrayTypeTree; //导入依赖的package包/类
/**
 * Accumulates a flattened list of array dimensions specifiers with type annotations, and returns
 * the base type.
 * <p>
 * <p>Given {@code int @A @B [][] @C []}, adds {@code [[@A, @B], [@C]]} to dims and returns {@code
 * int}.
 */
private static Tree extractDims(Deque<List<AnnotationTree>> dims, Tree node) {
    switch (node.getKind()) {
        case ARRAY_TYPE:
            return extractDims(dims, ((ArrayTypeTree) node).getType());
        // TODO: 22-Jul-17 missing type
       /* case ANNOTATED_TYPE:
            AnnotatedTypeTree annotatedTypeTree = (AnnotatedTypeTree) node;
            if (annotatedTypeTree.getUnderlyingType().getKind() != Tree.Kind.ARRAY_TYPE) {
                return node;
            }
            node = extractDims(dims, annotatedTypeTree.getUnderlyingType());
            dims.addFirst(ImmutableList.<AnnotationTree>copyOf(annotatedTypeTree.getAnnotations()));
            return node;*/
        default:
            return node;
    }
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:25,代码来源:DimensionHelpers.java

示例4: visitArrayType

import com.sun.source.tree.ArrayTypeTree; //导入依赖的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);
}
 
开发者ID:typetools,项目名称:annotation-tools,代码行数:24,代码来源:TreeFinder.java

示例5: visitArrayType

import com.sun.source.tree.ArrayTypeTree; //导入依赖的package包/类
@Override
public Tree visitArrayType(ArrayTypeTree tree, Void p) {
    ArrayTypeTree n = make.ArrayType(tree.getType());
    model.setType(n, model.getType(tree));
    comments.copyComments(tree, n);
    model.setPos(n, model.getPos(tree));
    return n;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:9,代码来源:TreeDuplicator.java

示例6: visitArrayType

import com.sun.source.tree.ArrayTypeTree; //导入依赖的package包/类
public Boolean visitArrayType(ArrayTypeTree node, TreePath p) {
    if (p == null) {
        super.visitArrayType(node, p);
        return false;
    }

    ArrayTypeTree at = (ArrayTypeTree) p.getLeaf();

    return scan(node.getType(), at.getType(), p);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:CopyFinder.java

示例7: visitArrayType

import com.sun.source.tree.ArrayTypeTree; //导入依赖的package包/类
@Override
public Void visitArrayType(ArrayTypeTree node, EnumSet<UseTypes> p) {
    if (node.getType() != null) {
        handlePossibleIdentifier(new TreePath(getCurrentPath(), node.getType()), EnumSet.of(UseTypes.CLASS_USE));
    }
    return super.visitArrayType(node, p);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:8,代码来源:SemanticHighlighterBase.java

示例8: normalizeLastLeftTree

import com.sun.source.tree.ArrayTypeTree; //导入依赖的package包/类
private static Tree normalizeLastLeftTree(Tree lastLeft) {
    while (lastLeft != null && lastLeft.getKind() == Kind.ARRAY_TYPE) {
        lastLeft = ((ArrayTypeTree) lastLeft).getType();
    }
    
    return lastLeft;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:8,代码来源:Utilities.java

示例9: ReplaceConstructorWithBuilderUI

import com.sun.source.tree.ArrayTypeTree; //导入依赖的package包/类
private ReplaceConstructorWithBuilderUI(TreePathHandle constructor, CompilationInfo info) {
    this.refactoring = new ReplaceConstructorWithBuilderRefactoring(constructor);
    ExecutableElement contructorElement = (ExecutableElement) constructor.resolveElement(info);
    this.name = contructorElement.getSimpleName().toString();
    MethodTree constTree = (MethodTree) constructor.resolve(info).getLeaf();
    paramaterNames = new ArrayList<String>();
    parameterTypes = new ArrayList<String>();
    parameterTypeVars = new ArrayList<Boolean>();
    boolean varargs = contructorElement.isVarArgs();
    List<? extends VariableElement> parameterElements = contructorElement.getParameters();
    List<? extends VariableTree> parameters = constTree.getParameters();
    for (int i = 0; i < parameters.size(); i++) {
        VariableTree var = parameters.get(i);
        paramaterNames.add(var.getName().toString());
        String type = contructorElement.getParameters().get(i).asType().toString();
        if(varargs && i+1 == parameters.size()) {
            if(var.getType().getKind() == Tree.Kind.ARRAY_TYPE) {
                ArrayTypeTree att = (ArrayTypeTree) var.getType();
                type = att.getType().toString();
                type += "..."; //NOI18N
            }
        }
        parameterTypes.add(type);
        parameterTypeVars.add(parameterElements.get(i).asType().getKind() == TypeKind.TYPEVAR);
    }
    TypeElement typeEl = (TypeElement) contructorElement.getEnclosingElement();
    if(typeEl.getNestingKind() != NestingKind.TOP_LEVEL) {
        PackageElement packageOf = info.getElements().getPackageOf(typeEl);
        builderFQN = packageOf.toString() + "." + typeEl.getSimpleName().toString();
    } else {
        builderFQN = typeEl.getQualifiedName().toString();
    }
    buildMethodName = "create" + typeEl.getSimpleName();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:35,代码来源:ReplaceConstructorWithBuilderUI.java

示例10: visitArrayType

import com.sun.source.tree.ArrayTypeTree; //导入依赖的package包/类
@Override
public Void visitArrayType(ArrayTypeTree tree, List<Node> d) {
    List<Node> below = new ArrayList<Node>();
    
    addCorrespondingElement(below);
    addCorrespondingType(below);
    addCorrespondingComments(below);
    
    super.visitArrayType(tree, below);
    
    d.add(new TreeNode(info, getCurrentPath(), below));
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:14,代码来源:TreeNode.java

示例11: transformInitializer

import com.sun.source.tree.ArrayTypeTree; //导入依赖的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

示例12: createType

import com.sun.source.tree.ArrayTypeTree; //导入依赖的package包/类
private String createType(VariableTree tree) {
    Tree returnType = tree.getType();

    if (returnType instanceof ParameterizedTypeTree || returnType instanceof ArrayTypeTree) {
        return returnType.toString();
    } else {
        return TreeUtils.getTokenFromIdentifierTree(returnType).getImage();
    }
}
 
开发者ID:fundacionjala,项目名称:oblivion-netbeans-plugin,代码行数:10,代码来源:VariableMutableTreeNode.java

示例13: createDataType

import com.sun.source.tree.ArrayTypeTree; //导入依赖的package包/类
private String createDataType(Tree returnType) {
    if (returnType instanceof ParameterizedTypeTree || returnType instanceof ArrayTypeTree) {
        return returnType.toString();
    } else {
        return TreeUtils.getTokenFromIdentifierTree(returnType).getImage();
    }
}
 
开发者ID:fundacionjala,项目名称:oblivion-netbeans-plugin,代码行数:8,代码来源:MethodMutableTreeNode.java

示例14: arrayLevels

import com.sun.source.tree.ArrayTypeTree; //导入依赖的package包/类
private int arrayLevels(Tree node) {
  int result = 0;
  while (node.getKind() == Tree.Kind.ARRAY_TYPE) {
    result++;
    node = ((ArrayTypeTree) node).getType();
  }
  return result;
}
 
开发者ID:typetools,项目名称:annotation-tools,代码行数:9,代码来源:TreeFinder.java

示例15: checkTypePath

import com.sun.source.tree.ArrayTypeTree; //导入依赖的package包/类
private boolean checkTypePath(int i, Tree typeTree) {
        try {
loop:       while (typeTree != null && i < astPath.size()) {
                ASTPath.ASTEntry entry = astPath.get(i);
                Tree.Kind kind = entry.getTreeKind();
                switch (kind) {
                case ANNOTATED_TYPE:
                    typeTree = ((AnnotatedTypeTree) typeTree)
                        .getUnderlyingType();
                    continue;
                case ARRAY_TYPE:
                    typeTree = ((ArrayTypeTree) typeTree).getType();
                    break;
                case MEMBER_SELECT:
                    typeTree = ((MemberSelectTree) typeTree).getExpression();
                    break;
                case PARAMETERIZED_TYPE:
                    if (entry.childSelectorIs(ASTPath.TYPE_ARGUMENT)) {
                        int arg = entry.getArgument();
                        typeTree = ((ParameterizedTypeTree) typeTree)
                                .getTypeArguments().get(arg);
                    } else {  // TYPE
                        typeTree = ((ParameterizedTypeTree) typeTree).getType();
                    }
                    break;
                default:
                    if (isWildcard(kind)) {
                        return ++i == astPath.size();  // ???
                    }
                    break loop;
                }
                ++i;
            }
        } catch (RuntimeException ex) {}
        return false;
    }
 
开发者ID:typetools,项目名称:annotation-tools,代码行数:37,代码来源:ASTPathCriterion.java


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