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


Java MethodDeclaration.getBody方法代码示例

本文整理汇总了Java中japa.parser.ast.body.MethodDeclaration.getBody方法的典型用法代码示例。如果您正苦于以下问题:Java MethodDeclaration.getBody方法的具体用法?Java MethodDeclaration.getBody怎么用?Java MethodDeclaration.getBody使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在japa.parser.ast.body.MethodDeclaration的用法示例。


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

示例1: isGetterMethod

import japa.parser.ast.body.MethodDeclaration; //导入方法依赖的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

示例2: isSetterMethod

import japa.parser.ast.body.MethodDeclaration; //导入方法依赖的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

示例3: visit

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

    if (n.getBody() != null) {
        needsProcessing = n.getBody().accept(this, arg);
    }

    if (needsProcessing) {
        NodeAnnotation nodeAnnotation = new NodeAnnotation(true);
        n.setData(nodeAnnotation);
    }
    return needsProcessing;
}
 
开发者ID:rfw,项目名称:genja,代码行数:15,代码来源:NodeAnnotator.java

示例4: visit

import japa.parser.ast.body.MethodDeclaration; //导入方法依赖的package包/类
public R visit(MethodDeclaration n, A arg) {
    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);
        }
    }
    n.getType().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);
        }
    }
    if (n.getBody() != null) {
        n.getBody().accept(this, arg);
    }
    return null;
}
 
开发者ID:rfw,项目名称:genja,代码行数:31,代码来源:GenericVisitorAdapter.java

示例5: visit

import japa.parser.ast.body.MethodDeclaration; //导入方法依赖的package包/类
public void visit(MethodDeclaration n, A arg) {
    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);
        }
    }
    n.getType().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);
        }
    }
    if (n.getBody() != null) {
        n.getBody().accept(this, arg);
    }
}
 
开发者ID:rfw,项目名称:genja,代码行数:30,代码来源:VoidVisitorAdapter.java

示例6: visit

import japa.parser.ast.body.MethodDeclaration; //导入方法依赖的package包/类
public Node visit(MethodDeclaration n, A arg) {
    if (n.getJavaDoc() != null) {
        n.setJavaDoc((JavadocComment) n.getJavaDoc().accept(this, arg));
    }
    List<AnnotationExpr> annotations = n.getAnnotations();
    if (annotations != null) {
        for (int i = 0; i < annotations.size(); i++) {
            annotations.set(i, (AnnotationExpr) annotations.get(i).accept(this, arg));
        }
        removeNulls(annotations);
    }
    List<TypeParameter> typeParameters = n.getTypeParameters();
    if (typeParameters != null) {
        for (int i = 0; i < typeParameters.size(); i++) {
            typeParameters.set(i, (TypeParameter) typeParameters.get(i).accept(this, arg));
        }
        removeNulls(typeParameters);
    }
    n.setType((Type) n.getType().accept(this, arg));
    List<Parameter> parameters = n.getParameters();
    if (parameters != null) {
        for (int i = 0; i < parameters.size(); i++) {
            parameters.set(i, (Parameter) parameters.get(i).accept(this, arg));
        }
        removeNulls(parameters);
    }
    List<NameExpr> throwz = n.getThrows();
    if (throwz != null) {
        for (int i = 0; i < throwz.size(); i++) {
            throwz.set(i, (NameExpr) throwz.get(i).accept(this, arg));
        }
        removeNulls(throwz);
    }
    if (n.getBody() != null) {
        n.setBody((BlockStmt) n.getBody().accept(this, arg));
    }
    return n;
}
 
开发者ID:rfw,项目名称:genja,代码行数:39,代码来源:ModifierVisitorAdapter.java

示例7: addCommentToTheBeginningOfMethod

import japa.parser.ast.body.MethodDeclaration; //导入方法依赖的package包/类
private static boolean addCommentToTheBeginningOfMethod(MethodDeclaration method, String comment) {
	if (method.getBody()==null || method.getBody().getStmts()==null || method.getBody().getStmts().isEmpty()) {
		return false;
	}
	setComment(method.getBody().getStmts().get(0), comment);
	return true;
}
 
开发者ID:ahn,项目名称:mideaas,代码行数:8,代码来源:ControllerCode.java

示例8: visit

import japa.parser.ast.body.MethodDeclaration; //导入方法依赖的package包/类
@Override
   public void visit(MethodDeclaration 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);
           }
       }
       n.getType().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);
           }
       }
       if(n.getBody() != null)
       {	BlockStmt block = n.getBody();
       	for(int i=0;i<indentLevel;i++)
			System.out.print("..");
       	System.out.println("Analyse de la méthode "+currentMethod);
       	checkBlock(block);  
       	block.accept(this, arg);
       }
       
       currentMethod = prevMethod;
   	indentLevel--;
}
 
开发者ID:vlabatut,项目名称:totalboumboum,代码行数:43,代码来源:AiVisitor.java

示例9: visit

import japa.parser.ast.body.MethodDeclaration; //导入方法依赖的package包/类
@Override
    public void visit(MethodDeclaration 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);
            }
        }
        n.getType().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);
            }
        }
        if(n.getBody() != null)
        {	BlockStmt block = n.getBody();
//if(name.equals("getZoneArray"))
//	System.out.println();
        	for(int i=0;i<indentLevel;i++)
				System.out.print("..");
        	System.out.println("Analyse de la méthode "+currentMethod);
        	checkBlock(block);  
        	block.accept(this, arg);
        }
        
        currentMethod = prevMethod;
    	indentLevel--;
  }
 
开发者ID:vlabatut,项目名称:totalboumboum,代码行数:45,代码来源:AiVisitor.java

示例10: visit

import japa.parser.ast.body.MethodDeclaration; //导入方法依赖的package包/类
@Override
   public void visit(MethodDeclaration 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);
           }
       }
       n.getType().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);
           }
       }
       if(n.getBody() != null)
       {	BlockStmt block = n.getBody();
       	for(int i=0;i<indentLevel;i++)
			System.out.print("..");
       	System.out.println("Analyse de la méthode "+currentMethod);
       	checkBlock(block);  
       	block.accept(this, arg);
       }
       
       currentMethod = prevMethod;
   	indentLevel--;
 }
 
开发者ID:vlabatut,项目名称:totalboumboum,代码行数:43,代码来源:AiVisitor.java

示例11: visit

import japa.parser.ast.body.MethodDeclaration; //导入方法依赖的package包/类
public void visit(MethodDeclaration n, Object arg) {
    printJavadoc(n.getJavaDoc(), arg);
    printMemberAnnotations(n.getAnnotations(), arg);
    printModifiers(n.getModifiers());

    printTypeParameters(n.getTypeParameters(), arg);
    if (n.getTypeParameters() != null) {
        printer.print(" ");
    }

    n.getType().accept(this, arg);
    if (n.isGenerator()) {
        printer.print("*");
    }
    printer.print(" ");
    printer.print(n.getName());

    printer.print("(");
    if (n.getParameters() != null) {
        for (Iterator<Parameter> i = n.getParameters().iterator(); i.hasNext();) {
            Parameter p = i.next();
            p.accept(this, arg);
            if (i.hasNext()) {
                printer.print(", ");
            }
        }
    }
    printer.print(")");

    for (int i = 0; i < n.getArrayCount(); i++) {
        printer.print("[]");
    }

    if (n.getThrows() != null) {
        printer.print(" throws ");
        for (Iterator<NameExpr> i = n.getThrows().iterator(); i.hasNext();) {
            NameExpr name = i.next();
            name.accept(this, arg);
            if (i.hasNext()) {
                printer.print(", ");
            }
        }
    }
    if (n.getBody() == null) {
        printer.print(";");
    } else {
        printer.print(" ");
        n.getBody().accept(this, arg);
    }
}
 
开发者ID:rfw,项目名称:genja,代码行数:51,代码来源:DumpVisitor.java


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