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


Java ArrayCreationExpr类代码示例

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


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

示例1: visit

import org.walkmod.javalang.ast.expr.ArrayCreationExpr; //导入依赖的package包/类
@Override
public void visit(ArrayCreationExpr n, A arg) {
    SymbolType arrayType = ASTSymbolTypeResolver.getInstance().valueOf(n.getType());
    arrayType.setArrayCount(n.getArrayCount() > 0 ? n.getArrayCount() : 1);
    n.setSymbolData(arrayType);
    ArrayInitializerExpr expr = n.getInitializer();
    if (expr != null) {
        expr.accept(this, arg);
    }
    List<Expression> dimensions = n.getDimensions();
    if (dimensions != null) {
        for (Expression dimension : dimensions) {
            dimension.accept(this, arg);
        }
    }

    if (semanticVisitor != null) {
        n.accept(semanticVisitor, arg);
    }
}
 
开发者ID:rpau,项目名称:javalang-compiler,代码行数:21,代码来源:TypeVisitorAdapter.java

示例2: visit

import org.walkmod.javalang.ast.expr.ArrayCreationExpr; //导入依赖的package包/类
public R visit(ArrayCreationExpr n, A arg) {
    n.getType().accept(this, arg);
    if (n.getDimensions() != null) {
        for (Expression dim : n.getDimensions()) {
            dim.accept(this, arg);
        }
    } else {
        n.getInitializer().accept(this, arg);
    }
    if (n.getArraysAnnotations() != null) {
        for (List<AnnotationExpr> list : n.getArraysAnnotations()) {
            if (list != null) {
                for (AnnotationExpr ae : list) {
                    ae.accept(this, arg);
                }
            }
        }
    }
    return null;
}
 
开发者ID:rpau,项目名称:javalang,代码行数:21,代码来源:GenericVisitorAdapter.java

示例3: visit

import org.walkmod.javalang.ast.expr.ArrayCreationExpr; //导入依赖的package包/类
@Override
public Node visit(ArrayCreationExpr _n, Object _arg) {
    Type type_ = cloneNodes(_n.getType(), _arg);
    List<Expression> dimensions = visit(_n.getDimensions(), _arg);
    ArrayCreationExpr r = new ArrayCreationExpr(_n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(),
            _n.getEndColumn(), type_, dimensions, _n.getArrayCount());
    if (_n.getInitializer() != null) {
        // ArrayCreationExpr has two mutually
        // exclusive constructors
        r.setInitializer(cloneNodes(_n.getInitializer(), _arg));
    }
    List<List<AnnotationExpr>> arraysAnnotations = _n.getArraysAnnotations();
    List<List<AnnotationExpr>> _arraysAnnotations = null;
    if (arraysAnnotations != null) {
        _arraysAnnotations = new LinkedList<List<AnnotationExpr>>();
        for (List<AnnotationExpr> aux : arraysAnnotations) {
            _arraysAnnotations.add(visit(aux, _arg));
        }
    }
    r.setArraysAnnotations(_arraysAnnotations);
    return r;
}
 
开发者ID:rpau,项目名称:javalang,代码行数:23,代码来源:CloneVisitor.java

示例4: visit

import org.walkmod.javalang.ast.expr.ArrayCreationExpr; //导入依赖的package包/类
public void visit(ArrayCreationExpr n, A arg) {
    n.getType().accept(this, arg);
    if (n.getDimensions() != null) {
        for (Expression dim : n.getDimensions()) {
            dim.accept(this, arg);
        }
    } else {
        n.getInitializer().accept(this, arg);
    }
    if (n.getArraysAnnotations() != null) {
        for (List<AnnotationExpr> annList : n.getArraysAnnotations()) {
            if (annList != null) {
                for (AnnotationExpr ae : annList) {
                    ae.accept(this, arg);
                }
            }
        }
    }
}
 
开发者ID:rpau,项目名称:javalang,代码行数:20,代码来源:VoidVisitorAdapter.java

示例5: testArrayInitExprType

import org.walkmod.javalang.ast.expr.ArrayCreationExpr; //导入依赖的package包/类
@Test
public void testArrayInitExprType() throws Exception {
    String code = "public class A { void foo() { int[] c = new int[10];}} ";
    CompilationUnit cu = run(code);
    MethodDeclaration md = (MethodDeclaration) cu.getTypes().get(0).getMembers().get(0);
    ExpressionStmt stmt = (ExpressionStmt) md.getBody().getStmts().get(0);
    VariableDeclarationExpr expr = (VariableDeclarationExpr) stmt.getExpression();
    ArrayCreationExpr array = (ArrayCreationExpr) expr.getVars().get(0).getInit();
    Assert.assertNotNull(array.getDimensions().get(0).getSymbolData());
}
 
开发者ID:rpau,项目名称:javalang-compiler,代码行数:11,代码来源:SymbolVisitorAdapterTest.java

示例6: visit

import org.walkmod.javalang.ast.expr.ArrayCreationExpr; //导入依赖的package包/类
public Boolean visit(ArrayCreationExpr n1, Node arg) {
    ArrayCreationExpr n2 = (ArrayCreationExpr) arg;
    if (n1.getArrayCount() != n2.getArrayCount()) {
        return Boolean.FALSE;
    }
    if (!nodeEquals(n1.getType(), n2.getType())) {
        return Boolean.FALSE;
    }
    if (!nodeEquals(n1.getInitializer(), n2.getInitializer())) {
        return Boolean.FALSE;
    }
    if (!nodesEquals(n1.getDimensions(), n2.getDimensions())) {
        return Boolean.FALSE;
    }
    List<List<AnnotationExpr>> n1a = n1.getArraysAnnotations();
    List<List<AnnotationExpr>> n2a = n2.getArraysAnnotations();

    if (n1a != null && n2a != null) {
        if (n1a.size() != n2a.size()) {
            return Boolean.FALSE;
        } else {
            int i = 0;
            for (List<AnnotationExpr> aux : n1a) {
                if (!nodesEquals(aux, n2a.get(i))) {
                    return Boolean.FALSE;
                }
                i++;
            }
        }
    } else if (n1a != n2a) {
        return Boolean.FALSE;
    }
    return Boolean.TRUE;
}
 
开发者ID:rpau,项目名称:javalang,代码行数:35,代码来源:EqualsVisitor.java

示例7: visit

import org.walkmod.javalang.ast.expr.ArrayCreationExpr; //导入依赖的package包/类
public void visit(ArrayCreationExpr n, VisitorContext arg) {
    if (preVisitor != null) {
        preVisitor.visit(n, arg);
    }
    super.visit(n, arg);
    if (postVisitor != null) {
        postVisitor.visit(n, arg);
    }
}
 
开发者ID:rpau,项目名称:javalang,代码行数:10,代码来源:CompositeVisitor.java

示例8: visit

import org.walkmod.javalang.ast.expr.ArrayCreationExpr; //导入依赖的package包/类
public Node visit(ArrayCreationExpr n, A arg) {
    n.setType((Type) n.getType().accept(this, arg));
    if (n.getDimensions() != null) {
        List<Expression> dimensions = n.getDimensions();
        if (dimensions != null) {
            for (int i = 0; i < dimensions.size(); i++) {
                dimensions.set(i, (Expression) dimensions.get(i).accept(this, arg));
            }
            removeNulls(dimensions);
        }
    } else {
        n.setInitializer((ArrayInitializerExpr) n.getInitializer().accept(this, arg));
    }
    List<List<AnnotationExpr>> arrayAnnotations = n.getArraysAnnotations();
    if (arrayAnnotations != null) {
        for (int i = 0; i < arrayAnnotations.size(); i++) {
            final List<AnnotationExpr> annotationsA = (List<AnnotationExpr>) arrayAnnotations.get(i);
            if (annotationsA != null) {
                for (int j = 0; j < annotationsA.size(); j++) {
                    annotationsA.set(i, (AnnotationExpr) annotationsA.get(j).accept(this, arg));
                }
                removeNulls(annotationsA);
            }
            arrayAnnotations.set(i, annotationsA);
        }
        removeNulls(arrayAnnotations);
    }
    return n;
}
 
开发者ID:rpau,项目名称:javalang,代码行数:30,代码来源:ModifierVisitorAdapter.java

示例9: visit

import org.walkmod.javalang.ast.expr.ArrayCreationExpr; //导入依赖的package包/类
public void visit(ArrayCreationExpr n, VisitorContext ctx) {
    Object o = ctx.get(NODE_TO_COMPARE_KEY);
    if (o != null && o instanceof ArrayCreationExpr) {
        ArrayCreationExpr aux = (ArrayCreationExpr) o;

        boolean equals = n.getArrayCount() == aux.getArrayCount();
        if (!equals) {
            applyUpdate(n, (Node) o);
        }

        boolean backup = isUpdated();
        setIsUpdated(false);
        Position pos = popPosition();
        pushPosition(aux);
        inferASTChangesList(n.getArraysAnnotations(), aux.getArraysAnnotations());
        inferASTChanges(n.getDimensions(), aux.getDimensions());
        inferASTChanges(n.getType(), aux.getType());
        popPosition();
        pushPosition(pos);
        inferASTChanges(n.getInitializer(), aux.getInitializer());
        if (!isUpdated()) {
            if (equals) {
                increaseUnmodifiedNodes(ArrayCreationExpr.class);
            } else {
                applyUpdate(n, aux, n.getInitializer(), aux.getInitializer());
                increaseUpdatedNodes(ArrayCreationExpr.class);
            }
        } else {
            increaseUpdatedNodes(ArrayCreationExpr.class);
        }
        setIsUpdated(backup || isUpdated());
    } else if (o != null) {
        setIsUpdated(true);
        applyUpdate(n, (Node) o);
    }
}
 
开发者ID:walkmod,项目名称:walkmod-javalang-plugin,代码行数:37,代码来源:ChangeLogVisitor.java

示例10: visit

import org.walkmod.javalang.ast.expr.ArrayCreationExpr; //导入依赖的package包/类
public R visit(ArrayCreationExpr n, A arg); 
开发者ID:rpau,项目名称:javalang,代码行数:2,代码来源:GenericVisitor.java

示例11: visit

import org.walkmod.javalang.ast.expr.ArrayCreationExpr; //导入依赖的package包/类
public void visit(ArrayCreationExpr n, A arg); 
开发者ID:rpau,项目名称:javalang,代码行数:2,代码来源:VoidVisitor.java


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