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


Java BlockStmt类代码示例

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


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

示例1: visit

import japa.parser.ast.stmt.BlockStmt; //导入依赖的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

示例2: findRootAssignExpr

import japa.parser.ast.stmt.BlockStmt; //导入依赖的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

示例3: addAttachSkeleton

import japa.parser.ast.stmt.BlockStmt; //导入依赖的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

示例4: addOnBecomingVisibleMethod

import japa.parser.ast.stmt.BlockStmt; //导入依赖的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

示例5: addClaraHandler

import japa.parser.ast.stmt.BlockStmt; //导入依赖的package包/类
private MethodDeclaration addClaraHandler(String id, String className) {
	ensureImport(className);
	String shortName = className.substring(className.lastIndexOf(".")+1);
	String handlerName = generateHandlerNameFor(id, shortName);
	
	Parameter p = new Parameter(new ClassOrInterfaceType(shortName), new VariableDeclaratorId("event"));
	MethodDeclaration handler = new MethodDeclaration(
			ModifierSet.PUBLIC, new VoidType(), handlerName, Collections.singletonList(p));
	handler.setBody(new BlockStmt());
	handler.setAnnotations(createClaraHandlerAnnotations(id));
	
	addNotification(handler, shortName+" on "+id);		
	
	addMember(handler);
	return handler;
}
 
开发者ID:ahn,项目名称:mideaas,代码行数:17,代码来源:ControllerCode.java

示例6: visit

import japa.parser.ast.stmt.BlockStmt; //导入依赖的package包/类
@Override
  public void visit(ConstructorDeclaration n, Object arg)
  {	String prevMethod = currentMethod;
  	currentMethod = n.getName();
  	indentLevel++;
  	
  	if (n.getJavaDoc() != null)
  	{	n.getJavaDoc().accept(this, arg);
      }
      if(n.getAnnotations() != null)
      {	for (AnnotationExpr a : n.getAnnotations())
      	{	a.accept(this, arg);
          }
      }
      if(n.getTypeParameters() != null)
      {	for (TypeParameter t : n.getTypeParameters())
      	{	t.accept(this, arg);
          }
      }
      if(n.getParameters() != null)
      {	for (Parameter p : n.getParameters())
      	{	p.accept(this, arg);
          }
      }
      if(n.getThrows() != null)
      {	for (NameExpr name : n.getThrows())
      	{	name.accept(this, arg);
          }
      }
      BlockStmt block = n.getBlock();
      for(int i=0;i<indentLevel;i++)
	System.out.print("..");
System.out.println("Analyse du constructeur "+currentMethod);
  	if(checkConstructor)
  		checkBlock(block);
      block.accept(this, arg);
      
      currentMethod = prevMethod;
  	indentLevel--;
 }
 
开发者ID:vlabatut,项目名称:totalboumboum,代码行数:41,代码来源:AiVisitor.java

示例7: buildUnit

import japa.parser.ast.stmt.BlockStmt; //导入依赖的package包/类
public static void buildUnit() {
    CompilationUnit compUnit = new CompilationUnit();
    
    compUnit.setPackage(new PackageDeclaration(ASTHelper
                                               .createNameExpr("compiladores.aula")));
    
    // create the type declaration
    ClassOrInterfaceDeclaration type = new ClassOrInterfaceDeclaration(
                                                                       ModifierSet.PUBLIC, false, "AulaJavaParser");
    ASTHelper.addTypeDeclaration(compUnit, type);
    
    // create a method
    MethodDeclaration method = new MethodDeclaration(ModifierSet.PUBLIC,
                                                     ASTHelper.VOID_TYPE, "main");
    method.setModifiers(ModifierSet.addModifier(method.getModifiers(),
                                                ModifierSet.STATIC));
    ASTHelper.addMember(type, method);
    
    // add a parameter to the method
    Parameter param = ASTHelper.createParameter(
                                                ASTHelper.createReferenceType("String", 0), "args");
    param.setVarArgs(true); //makes the parameter a ",,," array
    ASTHelper.addParameter(method, param);
    
    // add a body to the method
    BlockStmt block = new BlockStmt();
    method.setBody(block);
    
    // add a statement do the method body
    NameExpr clazz = new NameExpr("System");
    FieldAccessExpr field = new FieldAccessExpr(clazz, "out");
    MethodCallExpr call = new MethodCallExpr(field, "println");
    ASTHelper.addArgument(call, new StringLiteralExpr("Hello World!"));
    ASTHelper.addStmt(block, call);
    
    System.out.println(compUnit.toString());
}
 
开发者ID:damorim,项目名称:compilers-cin,代码行数:38,代码来源:ParserExample.java

示例8: visit

import japa.parser.ast.stmt.BlockStmt; //导入依赖的package包/类
@Override
public void visit(BlockStmt n, Generator s) {
    if (n.getStmts() == null) return;

    // Either add statements from the block into the transformer state, or process them because
    // we have yields in them.
    for (Statement stmt : n.getStmts()) {
        if (stmt.getData() instanceof NodeAnnotation && ((NodeAnnotation) stmt.getData()).needsProcessing) {
            stmt.accept(this, s);
        } else {
            s.addStatement(stmt);
        }
    }

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

示例9: visit

import japa.parser.ast.stmt.BlockStmt; //导入依赖的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

示例10: generateJump

import japa.parser.ast.stmt.BlockStmt; //导入依赖的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

示例11: visit

import japa.parser.ast.stmt.BlockStmt; //导入依赖的package包/类
@Override
public Node visit(BlockStmt n, Map<String, TypedVariableDeclarator> arg) {
    this.enter();
    Node r = super.visit(n, arg);
    this.exit();
    return r;
}
 
开发者ID:rfw,项目名称:genja,代码行数:8,代码来源:ScopeMangleTransform.java

示例12: visit

import japa.parser.ast.stmt.BlockStmt; //导入依赖的package包/类
@Override
public void visit(BlockStmt n, Scope arg) {
    Scope subScope = new Scope(Scope.Type.BLOCK);
    subScope.backs.add(arg);
    super.visit(n, subScope);
    n.setData(arg);
}
 
开发者ID:rfw,项目名称:genja,代码行数:8,代码来源:ScopeCollector.java

示例13: ConstructorDeclaration

import japa.parser.ast.stmt.BlockStmt; //导入依赖的package包/类
public ConstructorDeclaration(JavadocComment javaDoc, int modifiers, List<AnnotationExpr> annotations, List<TypeParameter> typeParameters, String name, List<Parameter> parameters, List<NameExpr> throws_, BlockStmt block) {
    super(annotations, javaDoc);
    this.modifiers = modifiers;
    this.typeParameters = typeParameters;
    this.name = name;
    this.parameters = parameters;
    this.throws_ = throws_;
    this.block = block;
}
 
开发者ID:rfw,项目名称:genja,代码行数:10,代码来源:ConstructorDeclaration.java

示例14: MethodDeclaration

import japa.parser.ast.stmt.BlockStmt; //导入依赖的package包/类
public MethodDeclaration(JavadocComment javaDoc, int modifiers, List<AnnotationExpr> annotations, List<TypeParameter> typeParameters, Type type, String name, List<Parameter> parameters, int arrayCount, List<NameExpr> throws_, boolean generator, BlockStmt block) {
    super(annotations, javaDoc);
    this.modifiers = modifiers;
    this.typeParameters = typeParameters;
    this.type = type;
    this.name = name;
    this.parameters = parameters;
    this.arrayCount = arrayCount;
    this.throws_ = throws_;
    this.generator = generator;
    this.body = block;
}
 
开发者ID:rfw,项目名称:genja,代码行数:13,代码来源:MethodDeclaration.java

示例15: visit

import japa.parser.ast.stmt.BlockStmt; //导入依赖的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.BlockStmt类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。