• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Statement类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: extractFixtureCalls

import japa.parser.ast.stmt.Statement; //导入依赖的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;
}
 
开发者ID:slezier,项目名称:SimpleFunctionalTest,代码行数:20,代码来源:UseCaseJavaParser.java


示例2: isGetterMethod

import japa.parser.ast.stmt.Statement; //导入依赖的package包/类
private boolean isGetterMethod(MethodDeclaration method)
{
    if ((method.getBody() != null) && (method.getBody().getStmts() != null))
    {
        LinkedList<String> attNames = getAttributesNames();
        
        if (attNames.size() == 0)
            return false;
        
        List<Statement> stmts = method.getBody().getStmts();        

        for (Statement stmt : stmts)
            for (String name : attNames)
                if ((stmt.toString().matches("(.*)return(\\s+)" + name + "(\\s*);")) && (method.getModifiers() == ModifierSet.PUBLIC) && (method.getParameters() == null))
                    return true;
    }
    
    return false;
}
 
开发者ID:gems-uff,项目名称:oceano,代码行数:20,代码来源:NumberOfAccessorMethods.java


示例3: isSetterMethod

import japa.parser.ast.stmt.Statement; //导入依赖的package包/类
private boolean isSetterMethod(MethodDeclaration method)
{
    if ((method.getBody() != null) && (method.getBody().getStmts() != null))
    {
        LinkedList<String> attNames = getAttributesNames();
        
        if (attNames.size() == 0)
            return false;
        
        List<Statement> stmts = method.getBody().getStmts();        

        for (Statement stmt : stmts)
            for (String name : attNames)
                if ((method.getModifiers() == ModifierSet.PUBLIC) && (method.getParameters() != null) && (method.getParameters().size() == 1) && (method.getType().equals(new VoidType())) && (stmt.toString().matches("(.*)"+name+"(\\s*)=(.*)"+method.getParameters().get(0).getId().getName()+"(.*);")))
                    return true;
    }
    
    return false;
}
 
开发者ID:gems-uff,项目名称:oceano,代码行数:20,代码来源:NumberOfAccessorMethods.java


示例4: visit

import japa.parser.ast.stmt.Statement; //导入依赖的package包/类
@Override
public Boolean visit(BlockStmt n, Void arg) {
    boolean needsProcessing = false;

    if (n.getStmts() != null) {
        for (Statement s : n.getStmts()) {
            needsProcessing = s.accept(this, arg) || needsProcessing;
        }
    }
    if (needsProcessing) {
        NodeAnnotation nodeAnnotation = new NodeAnnotation(true);
        n.setData(nodeAnnotation);
    }
    return needsProcessing;

}
 
开发者ID:rfw,项目名称:genja,代码行数:17,代码来源:NodeAnnotator.java


示例5: addStatement

import japa.parser.ast.stmt.Statement; //导入依赖的package包/类
/**
 * Add a statement to the given state.
 */
void addStatement(int state, Statement stmt) {
    List<Statement> stmts = this.states.get(state).getStmts();

    if (stmts.size() > 0) {
        Statement lastStmt = stmts.get(stmts.size() - 1);
        // Preemptively eliminate dead code.
        if (lastStmt.getClass().equals(ReturnStmt.class) ||
            lastStmt.getClass().equals(ThrowStmt.class) ||
            lastStmt.getClass().equals(BreakStmt.class) ||
            lastStmt.getClass().equals(ContinueStmt.class)) {
            return;
        }
    }

    stmts.add(stmt);
}
 
开发者ID:rfw,项目名称:genja,代码行数:20,代码来源:Generator.java


示例6: visit

import japa.parser.ast.stmt.Statement; //导入依赖的package包/类
public void visit(SwitchEntryStmt n, Object arg) {
    if (n.getLabel() != null) {
        printer.print("case ");
        n.getLabel().accept(this, arg);
        printer.print(":");
    } else {
        printer.print("default:");
    }
    printer.printLn();
    printer.indent();
    if (n.getStmts() != null) {
        for (Statement s : n.getStmts()) {
            s.accept(this, arg);
            printer.printLn();
        }
    }
    printer.unindent();
}
 
开发者ID:rfw,项目名称:genja,代码行数:19,代码来源:DumpVisitor.java


示例7: visit

import japa.parser.ast.stmt.Statement; //导入依赖的package包/类
public Node visit(ForStmt n, A arg) {
    List<Expression> init = n.getInit();
    if (init != null) {
        for (int i = 0; i < init.size(); i++) {
            init.set(i, (Expression) init.get(i).accept(this, arg));
        }
        removeNulls(init);
    }
    if (n.getCompare() != null) {
        n.setCompare((Expression) n.getCompare().accept(this, arg));
    }
    List<Expression> update = n.getUpdate();
    if (update != null) {
        for (int i = 0; i < update.size(); i++) {
            update.set(i, (Expression) update.get(i).accept(this, arg));
        }
        removeNulls(update);
    }
    n.setBody((Statement) n.getBody().accept(this, arg));
    return n;
}
 
开发者ID:rfw,项目名称:genja,代码行数:22,代码来源:ModifierVisitorAdapter.java


示例8: findRootAssignExpr

import japa.parser.ast.stmt.Statement; //导入依赖的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;
}
 
开发者ID:ahn,项目名称:mideaas,代码行数:20,代码来源:JavaUtil.java


示例9: addAttachSkeleton

import japa.parser.ast.stmt.Statement; //导入依赖的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);
}
 
开发者ID:ahn,项目名称:mideaas,代码行数:19,代码来源:ControllerCode.java


示例10: addOnBecomingVisibleMethod

import japa.parser.ast.stmt.Statement; //导入依赖的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);
}
 
开发者ID:ahn,项目名称:mideaas,代码行数:20,代码来源:ControllerCode.java


示例11: visit

import japa.parser.ast.stmt.Statement; //导入依赖的package包/类
@Override
public void visit(DoStmt n, Object arg)
{	Statement statement = n.getBody();
	checkBlock(statement);
	statement.accept(this, arg);
       n.getCondition().accept(this, arg);
   }
 
开发者ID:vlabatut,项目名称:totalboumboum,代码行数:8,代码来源:AiVisitor.java


示例12: visit

import japa.parser.ast.stmt.Statement; //导入依赖的package包/类
@Override
public void visit(SwitchEntryStmt n, Generator arg) {
    if (n.getStmts() == null) {
        // We need to generate an implicit jump to the next state.
        // XXX: I'm not sure if this is safe...
        arg.addStatement(Generator.generateDeferredJump(arg.getCurrentState() + 1));
    } else {
        for (Statement stmt : n.getStmts()) {
            stmt.accept(this, arg);
        }
    }
}
 
开发者ID:rfw,项目名称:genja,代码行数:13,代码来源:LinearizeTransform.java


示例13: makeLoopCondition

import japa.parser.ast.stmt.Statement; //导入依赖的package包/类
/**
 * Make a loop condition enforced.
 */
private static Statement makeLoopCondition(Expression cond) {
    if (cond == null) return null;

    return new IfStmt(new UnaryExpr(cond, UnaryExpr.Operator.not),
                      new BreakStmt(null), null);
}
 
开发者ID:rfw,项目名称:genja,代码行数:10,代码来源:LoopDesugarTransform.java


示例14: visit

import japa.parser.ast.stmt.Statement; //导入依赖的package包/类
@Override
public Node visit(DoStmt n, Void arg) {
    super.visit(n, arg);

    // Reword the loop.
    List<Statement> stmts = new ArrayList<Statement>();
    stmts.add(n.getBody());
    stmts.add(makeLoopCondition(n.getCondition()));
    BlockStmt b = new BlockStmt(stmts);
    return makeLoopStmt(b);
}
 
开发者ID:rfw,项目名称:genja,代码行数:12,代码来源:LoopDesugarTransform.java


示例15: generateJump

import japa.parser.ast.stmt.Statement; //导入依赖的package包/类
/**
 * Generate an immediate jump.
 */
public static Statement generateJump(int state) {
    List<Statement> stmts = new ArrayList<Statement>();
    stmts.add(generateDeferredJump(state));
    stmts.add(new BreakStmt(null));
    return new BlockStmt(stmts);
}
 
开发者ID:rfw,项目名称:genja,代码行数:10,代码来源:Generator.java


示例16: generate

import japa.parser.ast.stmt.Statement; //导入依赖的package包/类
/**
 * Generate the statements for the generator.
 */
public List<Statement> generate() {
    List<Statement> stmts = new ArrayList<Statement>();
    Statement innerLoop = LoopDesugarTransform.makeLoopStmt(new SwitchStmt(STATE_VAR,
                                                            this.states));
    stmts.add(innerLoop);
    return stmts;
}
 
开发者ID:rfw,项目名称:genja,代码行数:11,代码来源:Generator.java


示例17: visit

import japa.parser.ast.stmt.Statement; //导入依赖的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);
}
 
开发者ID:rfw,项目名称:genja,代码行数:35,代码来源:ScopeMangleTransform.java


示例18: visit

import japa.parser.ast.stmt.Statement; //导入依赖的package包/类
public R visit(BlockStmt n, A arg) {
    if (n.getStmts() != null) {
        for (Statement s : n.getStmts()) {
            s.accept(this, arg);
        }
    }
    return null;

}
 
开发者ID:rfw,项目名称:genja,代码行数:10,代码来源:GenericVisitorAdapter.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ConstantTransformer类代码示例发布时间:2022-05-23
下一篇:
Java GetVolume类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap