本文整理汇总了Java中com.github.javaparser.ast.expr.ConditionalExpr类的典型用法代码示例。如果您正苦于以下问题:Java ConditionalExpr类的具体用法?Java ConditionalExpr怎么用?Java ConditionalExpr使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ConditionalExpr类属于com.github.javaparser.ast.expr包,在下文中一共展示了ConditionalExpr类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: visit
import com.github.javaparser.ast.expr.ConditionalExpr; //导入依赖的package包/类
@Override public Boolean visit(final ConditionalExpr n1, final Node arg) {
final ConditionalExpr n2 = (ConditionalExpr) arg;
if (!nodeEquals(n1.getCondition(), n2.getCondition())) {
return false;
}
if (!nodeEquals(n1.getThenExpr(), n2.getThenExpr())) {
return false;
}
if (!nodeEquals(n1.getElseExpr(), n2.getElseExpr())) {
return false;
}
return true;
}
示例2: visit
import com.github.javaparser.ast.expr.ConditionalExpr; //导入依赖的package包/类
@Override
public void visit(final ConditionalExpr n, final Object arg) {
printer.printLn("ConditionalExpr");
printJavaComment(n.getComment(), arg);
n.getCondition().accept(this, arg);
printer.print(" ? ");
n.getThenExpr().accept(this, arg);
printer.print(" : ");
n.getElseExpr().accept(this, arg);
}
示例3: visit
import com.github.javaparser.ast.expr.ConditionalExpr; //导入依赖的package包/类
@Override
public JCTree visit(final ConditionalExpr n, final Object arg) {
//ARG0: JCExpression cond,
JCExpression arg0 = (JCExpression) n.getCondition().accept(this, arg);
//ARG1: JCExpression thenpart
JCExpression arg1 = (JCExpression) n.getThenExpr().accept(this, arg);
//ARG2: JCExpression elsepart
JCExpression arg2 = (JCExpression) n.getElseExpr().accept(this, arg);
return new AJCConditional(make.Conditional(arg0, arg1, arg2), ((n.getComment() != null) ? n.getComment().getContent() : null));
}
示例4: doMerge
import com.github.javaparser.ast.expr.ConditionalExpr; //导入依赖的package包/类
@Override public ConditionalExpr doMerge(ConditionalExpr first, ConditionalExpr second) {
ConditionalExpr ce = new ConditionalExpr();
ce.setCondition(mergeSingle(first.getCondition(),second.getCondition()));
ce.setElseExpr(mergeSingle(first.getElseExpr(),second.getElseExpr()));
ce.setThenExpr(mergeSingle(first.getThenExpr(),second.getThenExpr()));
return ce;
}
示例5: doIsEquals
import com.github.javaparser.ast.expr.ConditionalExpr; //导入依赖的package包/类
@Override public boolean doIsEquals(ConditionalExpr first, ConditionalExpr second) {
if(!isEqualsUseMerger(first.getCondition(),second.getCondition())) return false;
if(!isEqualsUseMerger(first.getElseExpr(), second.getElseExpr())) return false;
if(!isEqualsUseMerger(first.getThenExpr(),second.getThenExpr())) return false;
return true;
}
示例6: thenLambdaInConditionalExpressionInMethodInClassIsParentOfContainedParameter
import com.github.javaparser.ast.expr.ConditionalExpr; //导入依赖的package包/类
@Then("ThenExpr in the conditional expression of the statement $statementPosition in method $methodPosition in class $classPosition is LambdaExpr")
public void thenLambdaInConditionalExpressionInMethodInClassIsParentOfContainedParameter(int statementPosition, int methodPosition, int classPosition) {
Statement statement = getStatementInMethodInClass(statementPosition, methodPosition, classPosition);
ReturnStmt returnStmt = (ReturnStmt) statement;
ConditionalExpr conditionalExpr = (ConditionalExpr)returnStmt.getExpr();
assertThat(conditionalExpr.getElseExpr().getClass().getName(), is(LambdaExpr.class.getName()));
}
示例7: visit
import com.github.javaparser.ast.expr.ConditionalExpr; //导入依赖的package包/类
@Override
public Node visit(ConditionalExpr _n, Object _arg) {
Expression condition = cloneNodes(_n.getCondition(), _arg);
Expression thenExpr = cloneNodes(_n.getThenExpr(), _arg);
Expression elseExpr = cloneNodes(_n.getElseExpr(), _arg);
Comment comment = cloneNodes(_n.getComment(), _arg);
ConditionalExpr r = new ConditionalExpr(
_n.getRange(),
condition, thenExpr, elseExpr
);
r.setComment(comment);
return r;
}
示例8: visit
import com.github.javaparser.ast.expr.ConditionalExpr; //导入依赖的package包/类
@Override public Node visit(final ConditionalExpr n, final A arg) {
visitComment(n, arg);
n.setCondition((Expression) n.getCondition().accept(this, arg));
n.setThenExpr((Expression) n.getThenExpr().accept(this, arg));
n.setElseExpr((Expression) n.getElseExpr().accept(this, arg));
return n;
}
示例9: visit
import com.github.javaparser.ast.expr.ConditionalExpr; //导入依赖的package包/类
@Override
public void visit(ConditionalExpr n, Script arg) {
}
示例10: parseExpression
import com.github.javaparser.ast.expr.ConditionalExpr; //导入依赖的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;
}
}
示例11: visit
import com.github.javaparser.ast.expr.ConditionalExpr; //导入依赖的package包/类
@Override public Node visit(final ConditionalExpr n, final A arg) {
n.setCondition((Expression) n.getCondition().accept(this, arg));
n.setThenExpr((Expression) n.getThenExpr().accept(this, arg));
n.setElseExpr((Expression) n.getElseExpr().accept(this, arg));
return n;
}
示例12: visit
import com.github.javaparser.ast.expr.ConditionalExpr; //导入依赖的package包/类
@Override public void visit(final ConditionalExpr n, final A arg) {
visitComment(n.getComment(), arg);
n.getCondition().accept(this, arg);
n.getThenExpr().accept(this, arg);
n.getElseExpr().accept(this, arg);
}
示例13: visit
import com.github.javaparser.ast.expr.ConditionalExpr; //导入依赖的package包/类
@Override
public void visit(final ConditionalExpr n, final Context ctx) {
visitNode(n, ctx);
super.visit(n, ctx);
}
示例14: visit
import com.github.javaparser.ast.expr.ConditionalExpr; //导入依赖的package包/类
@Override
public void visit(ConditionalExpr n, Void arg) {
out.println("ConditionalExpr: " + (extended ? n : ""));
super.visit(n, arg);
}
示例15: parseConditionalExpression
import com.github.javaparser.ast.expr.ConditionalExpr; //导入依赖的package包/类
/**
*
* @param condExpr
* a github javaparser ConditionalExpression
* @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
* a TernaryExpression structure
*/
private TernaryExpression parseConditionalExpression(ConditionalExpr condExpr, List<Attribute> attributes, int lineNumber) {
TernaryExpression ternaryExpr = new TernaryExpression();
ternaryExpr.setCondition(parseExpression(condExpr.getCondition(), attributes, lineNumber));
ternaryExpr.setThen(parseExpression(condExpr.getThenExpr(), attributes, lineNumber));
if (condExpr.getElseExpr() != null) {
ternaryExpr.setEls(parseExpression(condExpr.getElseExpr(), attributes, lineNumber));
}
return ternaryExpr;
}