本文整理汇总了Java中com.github.javaparser.ast.expr.ArrayCreationExpr类的典型用法代码示例。如果您正苦于以下问题:Java ArrayCreationExpr类的具体用法?Java ArrayCreationExpr怎么用?Java ArrayCreationExpr使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ArrayCreationExpr类属于com.github.javaparser.ast.expr包,在下文中一共展示了ArrayCreationExpr类的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getInputOrOutputSocketBody
import com.github.javaparser.ast.expr.ArrayCreationExpr; //导入依赖的package包/类
private BlockStmt getInputOrOutputSocketBody(List<DefinedParamType> paramTypes,
ClassOrInterfaceType socketType, String
inputOrOutputPostfix) {
List<Expression> passedExpressions = new ArrayList<>();
for (DefinedParamType inputParam : paramTypes) {
if (inputParam.isIgnored()) {
continue;
}
passedExpressions.add(getSocketListParam(inputParam, socketType, inputOrOutputPostfix));
}
BlockStmt returnStatement = new BlockStmt(
Arrays.asList(new ReturnStmt(
new ArrayCreationExpr(socketType, 1, new ArrayInitializerExpr(passedExpressions)))
)
);
return returnStatement;
}
开发者ID:WPIRoboticsProjects,项目名称:GRIP,代码行数:18,代码来源:SocketHintDeclarationCollection.java
示例2: visit
import com.github.javaparser.ast.expr.ArrayCreationExpr; //导入依赖的package包/类
@Override public Boolean visit(final ArrayCreationExpr n1, final Node arg) {
final ArrayCreationExpr n2 = (ArrayCreationExpr) arg;
if (!nodeEquals(n1.getType(), n2.getType())) {
return false;
}
if (!nodesEquals(n1.getLevels(), n2.getLevels())) {
return false;
}
if (!nodeEquals(n1.getInitializer(), n2.getInitializer())) {
return false;
}
return true;
}
开发者ID:javaparser,项目名称:javasymbolsolver,代码行数:18,代码来源:EqualsVisitor.java
示例3: visit
import com.github.javaparser.ast.expr.ArrayCreationExpr; //导入依赖的package包/类
@Override
public ResultType visit( MethodDeclaration declaration, MethodDeclaration arg ) {
List<Statement> statements = declaration.getBody().getStmts();
Statement lastStatement = statements.get( statements.size() - 1 );
if ( lastStatement instanceof ReturnStmt ) try {
Expression expr = ( ( ReturnStmt ) lastStatement ).getExpr();
if ( expr instanceof ClassExpr )
// we could return the correct class type here, but that would cause misleading auto-completions
// because the runtime of the expression is a Class without with the type parameter erased
return new ResultType( Class.class, false );
else if ( expr instanceof ObjectCreationExpr )
return new ResultType( typeDiscoverer.classForName(
( ( ObjectCreationExpr ) expr ).getType().getName() ), false );
else if ( expr instanceof ArrayCreationExpr )
return new ResultType( Array.class, false );
else if ( expr.getClass().equals( StringLiteralExpr.class ) )
return new ResultType( String.class, false );
else if ( expr.getClass().equals( NameExpr.class ) ) {
Map<String, Class<?>> typeByVariableName = typeDiscoverer.getTypesByVariableName( statements );
String name = ( ( NameExpr ) expr ).getName();
@Nullable Class<?> variableType = typeByVariableName.get( name );
if ( variableType == null ) {
// attempt to return a class matching the apparent-variable name
return new ResultType( typeDiscoverer.classForName( name ), true );
} else {
return new ResultType( variableType, false );
}
} else
return ResultType.VOID;
} catch ( ClassNotFoundException ignore ) {
// class does not exist
}
return ResultType.VOID;
}
开发者ID:renatoathaydes,项目名称:osgiaas,代码行数:38,代码来源:LastStatementTypeDiscoverer.java
示例4: visit
import com.github.javaparser.ast.expr.ArrayCreationExpr; //导入依赖的package包/类
@Override
public JCTree visit(final ArrayCreationExpr n, final Object arg) {
//ARG0: JCExpression elemtype
JCExpression arg0 = (JCExpression) n.getType().accept(this, arg);
// TODO - An array may be initialized with dimentions or assiginig elements.
// Java Parser treats these options as mutual exclusive but JCTree don't.
// Confirm which is correct.
//ARG1: List<JCExpression> dims
List<JCExpression> arg1 = List.<JCExpression>nil();
if (n.getDimensions() != null) {
for (final Expression dim : n.getDimensions()) {
arg1 = arg1.append((JCExpression) dim.accept(this, arg));
}
}
//ARG2: List<JCExpression> elems
List<JCExpression> arg2 = List.<JCExpression>nil();
if (n.getInitializer().getValues() != null) {
for (final Expression expr : n.getInitializer().getValues()) {
arg2 = arg2.append((JCExpression) expr.accept(this, arg));
}
}
return new AJCNewArray(make.NewArray(arg0, arg1, arg2), ((n.getComment() != null) ? n.getComment().getContent() : null));
}
开发者ID:pcgomes,项目名称:javaparser2jctree,代码行数:28,代码来源:JavaParser2JCTree.java
示例5: doIsEquals
import com.github.javaparser.ast.expr.ArrayCreationExpr; //导入依赖的package包/类
@Override public boolean doIsEquals(ArrayCreationExpr first, ArrayCreationExpr second) {
if(!isEqualsUseMerger(first.getType(), second.getType())) return false;
if(first.getArrayCount() != second.getArrayCount()) return false;
if(!isEqualsUseMerger(first.getInitializer(),second.getInitializer())) return false;
if(!isEqualsUseMerger(first.getDimensions(),second.getDimensions())) return false;
return true;
}
开发者ID:beihaifeiwu,项目名称:dolphin,代码行数:9,代码来源:ArrayCreationExprMerger.java
示例6: visit
import com.github.javaparser.ast.expr.ArrayCreationExpr; //导入依赖的package包/类
@Override public Node visit(final ArrayCreationExpr n, final A arg) {
n.setType((Type) n.getType().accept(this, arg));
if (n.getDimensions() != null) {
final 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));
}
return n;
}
开发者ID:plum-umd,项目名称:java-sketch,代码行数:16,代码来源:ModifierVisitorAdapter.java
示例7: createDomainValueExpression
import com.github.javaparser.ast.expr.ArrayCreationExpr; //导入依赖的package包/类
/**
* Creates a domain value expression given a list of expressions.
*
* @return The expression for the domain.
*/
private Expression createDomainValueExpression(Expression... expressions) {
return new ArrayCreationExpr(type.toBoxedType(), 1,
new ArrayInitializerExpr(
Arrays.asList(expressions)
)
);
}
开发者ID:WPIRoboticsProjects,项目名称:GRIP,代码行数:13,代码来源:PrimitiveDefaultValue.java
示例8: visit
import com.github.javaparser.ast.expr.ArrayCreationExpr; //导入依赖的package包/类
@Override
public Node visit(ArrayCreationExpr _n, Object _arg) {
Type<?> type_ = cloneNodes(_n.getType(), _arg);
List<ArrayCreationLevel> levels_ = visit(_n.getLevels(), _arg);
ArrayInitializerExpr initializer_ = cloneNodes(_n.getInitializer(), _arg);
ArrayCreationExpr r = new ArrayCreationExpr(_n.getRange(), type_, levels_, initializer_);
Comment comment = cloneNodes(_n.getComment(), _arg);
r.setComment(comment);
return r;
}
开发者ID:javaparser,项目名称:javasymbolsolver,代码行数:13,代码来源:CloneVisitor.java
示例9: visit
import com.github.javaparser.ast.expr.ArrayCreationExpr; //导入依赖的package包/类
@Override public void visit(final ArrayCreationExpr n, final A arg) {
visitComment(n.getComment(), arg);
n.getType().accept(this, arg);
for (ArrayCreationLevel level : n.getLevels()) {
level.accept(this, arg);
}
if (n.getInitializer() != null) {
n.getInitializer().accept(this, arg);
}
}
开发者ID:javaparser,项目名称:javasymbolsolver,代码行数:11,代码来源:VoidVisitorAdapter.java
示例10: visit
import com.github.javaparser.ast.expr.ArrayCreationExpr; //导入依赖的package包/类
@Override public Node visit(final ArrayCreationExpr n, final A arg) {
visitComment(n, arg);
n.setType((Type) n.getType().accept(this, arg));
final List<ArrayCreationLevel> values = n.getLevels();
for (int i = 0; i < values.size(); i++) {
values.set(i, (ArrayCreationLevel) values.get(i).accept(this, arg));
}
removeNulls(values);
if (n.getInitializer() != null) {
n.setInitializer((ArrayInitializerExpr) n.getInitializer().accept(this, arg));
}
return n;
}
开发者ID:javaparser,项目名称:javasymbolsolver,代码行数:16,代码来源:ModifierVisitorAdapter.java
示例11: visit
import com.github.javaparser.ast.expr.ArrayCreationExpr; //导入依赖的package包/类
@Override
public void visit(ArrayCreationExpr n, Script arg) {
}
开发者ID:Nosorog,项目名称:nosorog-core,代码行数:4,代码来源:NoOpVisitor.java
示例12: parseExpression
import com.github.javaparser.ast.expr.ArrayCreationExpr; //导入依赖的package包/类
/**
*
* @param expression
* a github javaparser Expression
* @param attributes
* the list of attributes of the class,
* to potentially get a type from the name
* @param lineNumber
* the starting line number of the parse method or constructor
* @return
* an Expression structure
*/
public Expr parseExpression(Expression expression, List<Attribute> attributes, int lineNumber) {
if (expression instanceof AssignExpr) { // this.bar = "bar";
AssignExpr assExpr = (AssignExpr) expression;
return parseExpression(assExpr.getTarget(), attributes, lineNumber);
} else if (expression instanceof MethodCallExpr) {
MethodCallExpr mcEx = (MethodCallExpr) expression;
return parseMethodCallExpression(mcEx, attributes, lineNumber);
} else if (expression instanceof NameExpr) { // ident
NameExpr nEx = (NameExpr) expression;
Ident nameExpr = new Ident(nEx.getName());
return nameExpr;
} else if (expression instanceof LiteralExpr) { // basic lit
return parseLiteralExpr((LiteralExpr) expression);
} else if (expression instanceof FieldAccessExpr) {
FieldAccessExpr fieldExpr = (FieldAccessExpr) expression;
Ident ident = new Ident(ParserUtils.parseTarget(expression.toString()).get("name"));
AttributeRef attrRef = new AttributeRef(ident);
return attrRef;
} else if (expression instanceof ObjectCreationExpr) {
ObjectCreationExpr objConExpr = (ObjectCreationExpr) expression;
return parseObjectCreationExpression(objConExpr, attributes, lineNumber);
} else if (expression instanceof ArrayAccessExpr) {
ArrayAccessExpr arryExpr = (ArrayAccessExpr) expression;
return parseArrayAccessExpression(arryExpr);
} else if (expression instanceof UnaryExpr) {
UnaryExpr unExpr = (UnaryExpr) expression;
return parseUnaryExpression(unExpr, attributes, lineNumber);
} else if (expression instanceof ConditionalExpr) {
ConditionalExpr condExpr = (ConditionalExpr) expression;
return parseConditionalExpression(condExpr, attributes, lineNumber);
} else if (expression instanceof CastExpr) {
CastExpr castExpr = (CastExpr) expression;
return parseExpression(castExpr.getExpr(), attributes, lineNumber);
} else if (expression instanceof BinaryExpr) {
BinaryExpr binEx = (BinaryExpr) expression;
return parseBinaryExpression(binEx, attributes, lineNumber);
} else if (expression instanceof EnclosedExpr) {
EnclosedExpr enclosedExpr = (EnclosedExpr) expression;
return parseExpression(enclosedExpr.getInner(), attributes, lineNumber);
} else if (expression instanceof InstanceOfExpr) {
InstanceOfExpr intExpr = (InstanceOfExpr) expression;
return parseInstanceOfExpression(intExpr, attributes, lineNumber);
} else if (expression instanceof ArrayCreationExpr) {
ArrayCreationExpr arryCreaExpr = (ArrayCreationExpr) expression;
return parseArrayCreationExpression(arryCreaExpr, attributes, lineNumber);
} else if (expression instanceof ArrayInitializerExpr) {
ArrayInitializerExpr arryInEx = (ArrayInitializerExpr) expression;
return parseArrayInitializerExpression(arryInEx, attributes, lineNumber);
} else if (expression instanceof ThisExpr) {
return new Ident("this");
} else if (expression instanceof SuperExpr) {
return new Ident("super");
} else if (expression instanceof ClassExpr) {
return new Ident(expression.toString());
} else if (expression instanceof VariableDeclarationExpr) { // int foo = 42;
// should be parsed by parseVariableDeclarationExpression()
Log.e(TAG, "Unreachable case :: expression : ".concat(expression.toString()));
return null;
} else {
Log.e(TAG, "The type of expression '".concat(expression.getClass().toString()).concat("' is not managed by the parser"));
return null;
}
}
开发者ID:DevMine,项目名称:parsers,代码行数:76,代码来源:Parser.java
示例13: doMerge
import com.github.javaparser.ast.expr.ArrayCreationExpr; //导入依赖的package包/类
@Override public ArrayCreationExpr doMerge(ArrayCreationExpr first, ArrayCreationExpr second) {
ArrayCreationExpr ace = new ArrayCreationExpr();
ace.setType(mergeSingle(first.getType(),second.getType()));
return ace;
}
开发者ID:beihaifeiwu,项目名称:dolphin,代码行数:7,代码来源:ArrayCreationExprMerger.java
示例14: iTakeTheArrayCreationExpr
import com.github.javaparser.ast.expr.ArrayCreationExpr; //导入依赖的package包/类
@When("I take the ArrayCreationExpr")
public void iTakeTheArrayCreationExpr() {
setSelectedNodeFromCompilationUnit(ArrayCreationExpr.class);
}
开发者ID:plum-umd,项目名称:java-sketch,代码行数:5,代码来源:ParsingSteps.java
示例15: visit
import com.github.javaparser.ast.expr.ArrayCreationExpr; //导入依赖的package包/类
@Override
public void visit(final ArrayCreationExpr n, final Context ctx) {
visitNode(n, ctx);
super.visit(n, ctx);
}
开发者ID:jooby-project,项目名称:jooby,代码行数:6,代码来源:LocalVariableCollector.java
示例16: visit
import com.github.javaparser.ast.expr.ArrayCreationExpr; //导入依赖的package包/类
@Override
public void visit(ArrayCreationExpr n, Void arg) {
out.println("ArrayCreationExpr: " + (extended ? n : ""));
super.visit(n, arg);
}
开发者ID:JCTools,项目名称:JCTools,代码行数:6,代码来源:TraceVisitor.java
注:本文中的com.github.javaparser.ast.expr.ArrayCreationExpr类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论