本文整理汇总了Java中japa.parser.ast.stmt.ExpressionStmt类的典型用法代码示例。如果您正苦于以下问题:Java ExpressionStmt类的具体用法?Java ExpressionStmt怎么用?Java ExpressionStmt使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ExpressionStmt类属于japa.parser.ast.stmt包,在下文中一共展示了ExpressionStmt类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: extractFixtureCalls
import japa.parser.ast.stmt.ExpressionStmt; //导入依赖的package包/类
private ArrayList<FixtureCall> extractFixtureCalls(UseCase useCase,MethodDeclaration methodDeclaration) {
ArrayList<FixtureCall> fixtureCalls = new ArrayList<FixtureCall>();
if( methodDeclaration.getBody().getStmts() == null){
System.err.println("In class "+javaClass.getCanonicalName()+" method " + methodDeclaration.getName() + " don't have any fixture call.");
return fixtureCalls;
}
int line = methodDeclaration.getBody().getBeginLine();
for (Statement stmt : methodDeclaration.getBody().getStmts()) {
if (stmt instanceof ExpressionStmt) {
Expression expr = ((ExpressionStmt) stmt).getExpression();
if (expr instanceof MethodCallExpr) {
final int emptyLines = stmt.getBeginLine() - 1 - line;
fixtureCalls.add(extractFixtureCall(useCase, (MethodCallExpr) expr,emptyLines));
line= stmt.getBeginLine();
}
}
}
return fixtureCalls;
}
示例2: findRootAssignExpr
import japa.parser.ast.stmt.ExpressionStmt; //导入依赖的package包/类
private static AssignExpr findRootAssignExpr(BlockStmt body) {
if (body.getStmts() != null) {
for (Statement s : body.getStmts()) {
if (s instanceof ExpressionStmt) {
ExpressionStmt est = (ExpressionStmt) s;
if (est.getExpression() instanceof AssignExpr) {
AssignExpr ass = (AssignExpr) est.getExpression();
if (ass.getTarget() instanceof FieldAccessExpr) {
FieldAccessExpr fae = (FieldAccessExpr) ass.getTarget();
if ("root".equals(fae.getField())) {
return ass;
}
}
}
}
}
}
return null;
}
示例3: addAttachSkeleton
import japa.parser.ast.stmt.ExpressionStmt; //导入依赖的package包/类
private void addAttachSkeleton() {
List<Parameter> params = Collections.emptyList();
MethodDeclaration method = new MethodDeclaration(
ModifierSet.PUBLIC, new VoidType(), "attach", params);
AnnotationExpr override = new MarkerAnnotationExpr(new NameExpr("Override"));
method.setAnnotations(Collections.singletonList(override));
BlockStmt block = new BlockStmt();
Expression e = new MethodCallExpr(new SuperExpr(), "attach");
List<Statement> sts = Collections.singletonList((Statement)new ExpressionStmt(e));
block.setStmts(sts);
method.setBody(block);
if (getType().getMembers()==null) {
getType().setMembers(new LinkedList<BodyDeclaration>());
}
getType().getMembers().add(method);
}
示例4: addOnBecomingVisibleMethod
import japa.parser.ast.stmt.ExpressionStmt; //导入依赖的package包/类
@SuppressWarnings("unused")
private void addOnBecomingVisibleMethod() {
List<Parameter> params = Collections.emptyList();
MethodDeclaration method = new MethodDeclaration(
ModifierSet.PUBLIC, new VoidType(), "onBecomingVisible", params);
AnnotationExpr override = new MarkerAnnotationExpr(new NameExpr("Override"));
method.setAnnotations(Collections.singletonList(override));
BlockStmt block = new BlockStmt();
Expression e = new MethodCallExpr(new SuperExpr(), "onBecomingVisible");
List<Statement> sts = Collections.singletonList((Statement)new ExpressionStmt(e));
block.setStmts(sts);
method.setBody(block);
if (getType().getMembers()==null) {
getType().setMembers(new LinkedList<BodyDeclaration>());
}
getType().getMembers().add(method);
}
示例5: visit
import japa.parser.ast.stmt.ExpressionStmt; //导入依赖的package包/类
/**
* Transform a yield.
*/
@Override
public void visit(YieldStmt n, Generator s) {
// Remember the state to add the deferred jump to.
int entryState = s.getCurrentState();
s.newState();
s.addStatement(entryState, Generator.generateDeferredJump(s.getCurrentState()));
s.addStatement(entryState, new ExpressionStmt(new AssignExpr(Generator.CURRENT_VAR,
n.getExpr(),
AssignExpr.Operator.assign)));
s.addStatement(entryState, new ReturnStmt(new BooleanLiteralExpr(true)));
}
示例6: visit
import japa.parser.ast.stmt.ExpressionStmt; //导入依赖的package包/类
@Override
public Node visit(ExpressionStmt n, Map<String, TypedVariableDeclarator> arg) {
Node r = n.getExpression().accept(this, arg);
if (n.getExpression() instanceof VariableDeclarationExpr) {
// Rewrite variable declarations -- we have to turn them into
// sepcial things.
VariableDeclarationExpr expr = (VariableDeclarationExpr) n.getExpression();
List<Statement> assigns = new ArrayList<Statement>();
for (VariableDeclarator d : expr.getVars()) {
if (d.getInit() != null){
assigns.add(new ExpressionStmt(new AssignExpr(new NameExpr(this.block.getScopePrefix() + d.getId().getName()),
d.getInit(),
AssignExpr.Operator.assign)));
}
}
if (assigns.size() == 0) {
return null;
}
if (assigns.size() == 1) {
return assigns.get(0);
}
return new BlockStmt(assigns);
}
if (r == null) {
return null;
}
return new ExpressionStmt((Expression) r);
}
示例7: visit
import japa.parser.ast.stmt.ExpressionStmt; //导入依赖的package包/类
public Boolean visit(ExpressionStmt n1, Node arg) {
ExpressionStmt n2 = (ExpressionStmt) arg;
if (!nodeEquals(n1.getExpression(), n2.getExpression())) {
return Boolean.FALSE;
}
return Boolean.TRUE;
}
示例8: addNotification
import japa.parser.ast.stmt.ExpressionStmt; //导入依赖的package包/类
private void addNotification(MethodDeclaration method, String text) {
MethodCallExpr e = new MethodCallExpr(new NameExpr("Notification"), "show");
e.setArgs(Collections.singletonList((Expression)new StringLiteralExpr(text)));
Statement statement = new ExpressionStmt(e);
addToMethod(method, statement);
ensureImport("com.vaadin.ui.Notification");
}
示例9: visit
import japa.parser.ast.stmt.ExpressionStmt; //导入依赖的package包/类
@Override
public Boolean visit(ExpressionStmt n, Void arg) {
return false;
}
示例10: generateDeferredJump
import japa.parser.ast.stmt.ExpressionStmt; //导入依赖的package包/类
/**
* Generate a deferred jump. This sets the state to a given state number, but doesn't perform
* the jump.
*/
public static Statement generateDeferredJump(int state) {
return new ExpressionStmt(new AssignExpr(STATE_VAR,
new IntegerLiteralExpr("" + state),
AssignExpr.Operator.assign));
}
示例11: visit
import japa.parser.ast.stmt.ExpressionStmt; //导入依赖的package包/类
@Override
public void visit(ExpressionStmt n, Scope arg) {
super.visit(n, arg);
n.setData(arg);
}
示例12: visit
import japa.parser.ast.stmt.ExpressionStmt; //导入依赖的package包/类
@Override
public void visit(ExpressionStmt n, Void arg) {
n.getExpression().accept(new ExpressionAnalysis(), null);
}
示例13: visit
import japa.parser.ast.stmt.ExpressionStmt; //导入依赖的package包/类
public R visit(ExpressionStmt n, A arg) {
n.getExpression().accept(this, arg);
return null;
}
示例14: visit
import japa.parser.ast.stmt.ExpressionStmt; //导入依赖的package包/类
public void visit(ExpressionStmt n, Object arg) {
n.getExpression().accept(this, arg);
printer.print(";");
}
示例15: visit
import japa.parser.ast.stmt.ExpressionStmt; //导入依赖的package包/类
public void visit(ExpressionStmt n, A arg) {
n.getExpression().accept(this, arg);
}