org.eclipse.jdt.core.dom.ArrayCreation#dimensions ( )源码实例Demo

下面列出了org.eclipse.jdt.core.dom.ArrayCreation#dimensions ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: SimFix   文件: CodeBlock.java
private ArrayCreate visit(ArrayCreation node) {
	int startLine = _cunit.getLineNumber(node.getStartPosition());
	int endLine = _cunit.getLineNumber(node.getStartPosition() + node.getLength());
	ArrayCreate arrayCreate = new ArrayCreate(startLine, endLine, node);
	
	arrayCreate.setArrayType(node.getType());
	arrayCreate.setType(node.getType());
	
	List<Expr> dimension = new ArrayList<>();
	for(Object object : node.dimensions()){
		Expr dim = (Expr) process((ASTNode) object);
		dim.setParent(arrayCreate);
		dimension.add(dim);
	}
	arrayCreate.setDimension(dimension);
	
	if(node.getInitializer() != null){
		ArrayInitial arrayInitializer = (ArrayInitial) process(node.getInitializer());
		arrayInitializer.setParent(arrayCreate);
		arrayCreate.setInitializer(arrayInitializer);
	}
	
	return arrayCreate;
}
 
源代码2 项目: RefactoringMiner   文件: ObjectCreation.java
public ObjectCreation(CompilationUnit cu, String filePath, ArrayCreation creation) {
	this.locationInfo = new LocationInfo(cu, filePath, creation, CodeElementType.ARRAY_CREATION);
	this.isArray = true;
	this.type = UMLType.extractTypeObject(cu, filePath, creation.getType(), 0);
	this.typeArguments = creation.dimensions().size();
	this.arguments = new ArrayList<String>();
	List<Expression> args = creation.dimensions();
	for(Expression argument : args) {
		this.arguments.add(argument.toString());
	}
	if(creation.getInitializer() != null) {
		this.anonymousClassDeclaration = creation.getInitializer().toString();
	}
}
 
源代码3 项目: JDeodorant   文件: BindingSignatureVisitor.java
public boolean visit(ArrayCreation expr) {
	handleType(expr.getType());
	List dimensions = expr.dimensions();
	for (int i = 0; i < dimensions.size(); i++) {
		handleExpression((Expression) dimensions.get(i));
	}
	if(expr.getInitializer() != null) {
		visit(expr.getInitializer());
	}
	return false;
}
 
源代码4 项目: juniversal   文件: ArrayCreationWriter.java
@Override
public void write(ArrayCreation arrayCreation) {
    // TODO: C# doesn't support an exact equivalent to Integer[], with boxed integers (or other primitive types).
    // Consider disallowing arrays of that type to be created, instead forcing the dev to either create an
    // Object[] if they want boxed types or an int[] if they want primitive types

    List<?> dimensions = arrayCreation.dimensions();
    // TODO: Support multidimensional arrays
    if (dimensions.size() > 1)
        throw new JUniversalException("Multidimensional arrays not currently supported");

    matchAndWrite("new");

    copySpaceAndComments();
    writeNode(arrayCreation.getType().getElementType());

    copySpaceAndComments();
    matchAndWrite("[");

    writeNodes(arrayCreation.dimensions());

    copySpaceAndComments();
    matchAndWrite("]");

    // TODO: Check all syntax combinations here
    @Nullable ArrayInitializer arrayInitializer = arrayCreation.getInitializer();
    if (arrayInitializer != null) {
        copySpaceAndComments();
        writeNode(arrayInitializer);
    }
}
 
源代码5 项目: juniversal   文件: ArrayCreationWriter.java
@Override
public void write(ArrayCreation arrayCreation) {
	matchAndWrite("new");

	List<?> dimensions = arrayCreation.dimensions();
	// TODO: Support multidimensional arrays
	if (dimensions.size() > 1)
		throw new JUniversalException("Multidimensional arrays not currently supported");

	// TODO: Support array initializers
	if (arrayCreation.getInitializer() != null)
		throw new JUniversalException("Array initializers not currently supported");

	Expression dimensionSizeExpression = (Expression) dimensions.get(0);

	setPosition(dimensionSizeExpression.getStartPosition());

	write("(");
       writeNode(dimensionSizeExpression);
	copySpaceAndComments();
	write(") ");

	ArrayType arrayType = arrayCreation.getType();
	setPosition(arrayType.getStartPosition());

	write("Array<");
       writeNode(arrayType.getElementType());
	skipSpaceAndComments();
	write(">");

	setPosition(ASTUtil.getEndPosition(dimensionSizeExpression));
	skipSpaceAndComments();
	match("]");
}
 
源代码6 项目: xtext-xtend   文件: JavaASTFlattener.java
@Override
public boolean visit(final ArrayCreation node) {
  ArrayType at = node.getType();
  int dims = at.getDimensions();
  if ((dims > 1)) {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("/* FIXME Only one dimensional arrays are supported. ");
    _builder.append(node);
    _builder.append("*/");
    this.appendToBuffer(_builder.toString());
    this.addProblem(node, "Only one dimension arrays are supported.");
    return false;
  }
  ArrayInitializer _initializer = node.getInitializer();
  boolean _tripleNotEquals = (_initializer != null);
  if (_tripleNotEquals) {
    if (this.fallBackStrategy) {
      this.appendToBuffer("(");
    }
    node.getInitializer().accept(this);
    if (this.fallBackStrategy) {
      this.appendToBuffer(" as ");
      at.accept(this);
      this.appendToBuffer(")");
    }
  } else {
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("new");
    String _xifexpression = null;
    boolean _isPrimitiveType = node.getType().getElementType().isPrimitiveType();
    if (_isPrimitiveType) {
      Type _elementType = node.getType().getElementType();
      _xifexpression = StringExtensions.toFirstUpper(((PrimitiveType) _elementType).getPrimitiveTypeCode().toString());
    }
    _builder_1.append(_xifexpression);
    _builder_1.append("ArrayOfSize(");
    this.appendToBuffer(_builder_1.toString());
    List _dimensions = node.dimensions();
    (((Expression[])Conversions.unwrapArray(((Iterable<Expression>) _dimensions), Expression.class))[0]).accept(this);
    this.appendToBuffer(")");
  }
  return false;
}