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


Java JCNewArray类代码示例

本文整理汇总了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);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:15,代码来源:ArrayCreationTree.java

示例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("}");
	}
}
 
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:29,代码来源:PrettyPrinter.java

示例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);
}
 
开发者ID:pcgomes,项目名称:javaparser2jctree,代码行数:8,代码来源:PrintAstVisitor.java

示例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);
	}
}
 
开发者ID:mobmead,项目名称:EasyMPermission,代码行数:28,代码来源:PrettyCommentsPrinter.java

示例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());
}
 
开发者ID:typetools,项目名称:annotation-tools,代码行数:16,代码来源:TreeFinder.java

示例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()));
}
 
开发者ID:sivakumar-kailasam,项目名称:refactor-faster,代码行数:10,代码来源:UNewArray.java

示例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--;
}
 
开发者ID:evant,项目名称:android-retrolambda-lombok,代码行数:8,代码来源:JcTreePrinter.java

示例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));
}
 
开发者ID:google,项目名称:error-prone,代码行数:9,代码来源:PlaceholderUnificationVisitor.java

示例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()));
}
 
开发者ID:google,项目名称:error-prone,代码行数:12,代码来源:UNewArray.java

示例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);
    }
}
 
开发者ID:sebastianoe,项目名称:s4j,代码行数:28,代码来源:Pretty.java

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

示例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);
    }
}
 
开发者ID:redundent,项目名称:lombok,代码行数:28,代码来源:PrettyCommentsPrinter.java

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

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

示例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);
}
 
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:4,代码来源:JavacTreeMaker.java


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