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


Java BodyDeclaration类代码示例

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


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

示例1: findAnnotation

import japa.parser.ast.body.BodyDeclaration; //导入依赖的package包/类
private AnnotationExpr findAnnotation(final BodyDeclaration n, String fullyQualifiedName, boolean foundAnnImport) {
    final String simpleName = ClassUtils.getShortClassName(fullyQualifiedName);
    final List<AnnotationExpr> annotations = n.getAnnotations() != null ? n.getAnnotations() : new ArrayList<AnnotationExpr>();

    for (AnnotationExpr ae : annotations) {
        final String name = ae.getName().toString();
        if ((simpleName.equals(name) && foundAnnImport)) {
            LOG.info("found " + ae + " on " + getTypeOrFieldNameForMsg(n) + ".");
            return ae;
        }

        if (fullyQualifiedName.equals(name)) {
            LOG.info("found " + ae + " on " + getTypeOrFieldNameForMsg(n) + ".");
            return ae;
        }
    }
    return null;
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:19,代码来源:AnnotationHelper.java

示例2: getTypeOrFieldNameForMsg

import japa.parser.ast.body.BodyDeclaration; //导入依赖的package包/类
private String getTypeOrFieldNameForMsg(final BodyDeclaration n) {
    if (n instanceof TypeDeclaration) {
        return ((TypeDeclaration) n).getName();
    } else if (n instanceof FieldDeclaration) {
        final FieldDeclaration fd = (FieldDeclaration) n;
        //this wont work for nested classes but we should be in nexted classes at this point
        final CompilationUnit unit = getCompilationUnit(n);
        final TypeDeclaration parent = unit.getTypes().get(0);
        Collection<String> variableNames = new ArrayList<String>();
        if (fd.getVariables() != null) {
            for (VariableDeclarator vd : fd.getVariables()) {
                variableNames.add(vd.getId().getName());
            }
        }
        return variableNames.size() == 1 ?
                parent.getName() + "." + variableNames.iterator().next() :
                parent.getName() + "." + variableNames.toString();

    }
    return null;
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:22,代码来源:AnnotationHelper.java

示例3: getJavaMethods

import japa.parser.ast.body.BodyDeclaration; //导入依赖的package包/类
private void getJavaMethods (ArrayList<JavaMethod> methods, TypeDeclaration type) {
	classStack.push(type);
	if (type.getMembers() != null) {
		for (BodyDeclaration member : type.getMembers()) {
			if (member instanceof ClassOrInterfaceDeclaration || member instanceof EnumDeclaration) {
				getJavaMethods(methods, (TypeDeclaration)member);
			} else {
				if (member instanceof MethodDeclaration) {
					MethodDeclaration method = (MethodDeclaration)member;
					if (!ModifierSet.hasModifier(((MethodDeclaration)member).getModifiers(), ModifierSet.NATIVE)) continue;
					methods.add(createMethod(method));
				}
			}
		}
	}
	classStack.pop();
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:18,代码来源:RobustJavaMethodParser.java

示例4: getDeclaration

import japa.parser.ast.body.BodyDeclaration; //导入依赖的package包/类
public static FieldDeclaration getDeclaration(CompilationUnit unit, Field field) {
	TypeDeclaration typeDecl = getDeclaration(unit, field.getDeclaringClass());
	if (typeDecl == null) {
		return null;
	}
	for (BodyDeclaration decl : typeDecl.getMembers()) {
		if (decl instanceof FieldDeclaration) {
			FieldDeclaration fieldDecl = (FieldDeclaration) decl;
			List<VariableDeclarator> variables = fieldDecl.getVariables();
			if (variables.size() != 1) {
				continue;
			}
			if (field.getName().equals(variables.get(0).getId().getName())) {
				return fieldDecl;
			}
		}
	}
	return null;
}
 
开发者ID:jedwards1211,项目名称:breakout,代码行数:20,代码来源:JavaParserUtils.java

示例5: getNode

import japa.parser.ast.body.BodyDeclaration; //导入依赖的package包/类
public static Node getNode(TypeDeclaration typeDecl, String name) {
	if (typeDecl.getMembers() == null) {
		return null;
	}
	for (BodyDeclaration bodyDecl : typeDecl.getMembers()) {
		String bodyDeclName = getName(bodyDecl);
		if (bodyDeclName != null && name.startsWith(bodyDeclName)) {
			if (name.length() == bodyDeclName.length()) {
				return bodyDecl;
			}
			else if (bodyDecl instanceof MethodDeclaration || bodyDecl instanceof ConstructorDeclaration) {
				if (signatureMatches(bodyDecl, name.substring(bodyDeclName.length()))) {
					return bodyDecl;
				}
			}
			else if (bodyDecl instanceof TypeDeclaration) {
				return getNode((TypeDeclaration) bodyDecl, name.substring(bodyDeclName.length() + 1));
			}
		}
	}
	return null;
}
 
开发者ID:jedwards1211,项目名称:breakout,代码行数:23,代码来源:JavaParserUtils.java

示例6: find

import japa.parser.ast.body.BodyDeclaration; //导入依赖的package包/类
private static MethodDeclaration find( TypeDeclaration decl , MethodDeclaration analogous )
{
	for( BodyDeclaration bodyDecl : decl.getMembers( ) )
	{
		if( bodyDecl instanceof MethodDeclaration )
		{
			MethodDeclaration methodDecl = ( MethodDeclaration ) bodyDecl;
			if( methodDecl.getName( ).equals( analogous.getName( ) )
					&& methodDecl.getModifiers( ) == analogous.getModifiers( )
					&& sameTypes( methodDecl.getParameters( ) , analogous.getParameters( ) ) )
			{
				return methodDecl;
			}
		}
	}
	return null;
}
 
开发者ID:jedwards1211,项目名称:breakout,代码行数:18,代码来源:BuilderGenerator.java

示例7: getTotalLineRegion

import japa.parser.ast.body.BodyDeclaration; //导入依赖的package包/类
private static LineRegion getTotalLineRegion( BodyDeclaration decl )
{
	LineRegion region = getLineRegion( decl );
	if( decl.getJavaDoc( ) != null )
	{
		region = region.union( getLineRegion( decl.getJavaDoc( ) ) );
	}
	if( decl.getAnnotations( ) != null )
	{
		for( AnnotationExpr annotation : decl.getAnnotations( ) )
		{
			region = region.union( getLineRegion( annotation ) );
		}
	}
	return region;
}
 
开发者ID:jedwards1211,项目名称:breakout,代码行数:17,代码来源:BuilderGenerator.java

示例8: feedTestClass

import japa.parser.ast.body.BodyDeclaration; //导入依赖的package包/类
private void feedTestClass(TypeDeclaration type, UseCase useCase) throws IOException {
    if (type.getComment() != null) {
        useCase.setComment(type.getComment().getContent());
    }
    int scenarioIndex = 0;
    for (BodyDeclaration bodyDeclaration : type.getMembers()) {
        if (bodyDeclaration instanceof MethodDeclaration) {
            MethodDeclaration methodDeclaration = (MethodDeclaration) bodyDeclaration;
            if (containsAnnotation(methodDeclaration, "Test")) {
                feedAndOrderScenario(scenarioIndex, methodDeclaration, useCase);
                scenarioIndex++;
            } else if (containsAnnotation(methodDeclaration, "BeforeClass")) {
                feedTestContext(methodDeclaration, useCase.beforeUseCase,useCase);
            } else if (containsAnnotation(methodDeclaration, "AfterClass")) {
                feedTestContext(methodDeclaration, useCase.afterUseCase,useCase);
            } else if (containsAnnotation(methodDeclaration, "Before")) {
                feedTestContext(methodDeclaration, useCase.beforeScenario,useCase);
            } else if (containsAnnotation(methodDeclaration, "After")) {
                feedTestContext(methodDeclaration, useCase.afterScenario,useCase);
            } else {
                feedTestFixture(methodDeclaration, useCase);
            }
        }
    }
    useCase.helpers.completeDescriptionFromSource(configuration);
}
 
开发者ID:slezier,项目名称:SimpleFunctionalTest,代码行数:27,代码来源:UseCaseJavaParser.java

示例9: countAccessorMethods

import japa.parser.ast.body.BodyDeclaration; //导入依赖的package包/类
private int countAccessorMethods()
{        
    int count = 0;
    
    List<TypeDeclaration> types = compUnit.getTypes();
    
    if (types != null)
        for (TypeDeclaration type : types)
        {
            List<BodyDeclaration> members = type.getMembers();
            if (members != null)                
                for (BodyDeclaration member : members)
                {
                    if (member instanceof MethodDeclaration)
                    {
                        MethodDeclaration method = (MethodDeclaration) member;                   

                        if (isAccessorMethod(method))
                            ++count;         
                    }
                }
            
        }
    
    return count;
}
 
开发者ID:gems-uff,项目名称:oceano,代码行数:27,代码来源:NumberOfAccessorMethods.java

示例10: getAttributesNames

import japa.parser.ast.body.BodyDeclaration; //导入依赖的package包/类
private LinkedList<String> getAttributesNames()
{
    List<TypeDeclaration> types = compUnit.getTypes();
    LinkedList<String> attNames = new LinkedList<String>();
    
    if (types != null)
    {
        for (TypeDeclaration type : types)
        {
            List<BodyDeclaration> members = type.getMembers();
            if (members != null)
                for (BodyDeclaration member : members)
                    if (member instanceof FieldDeclaration)
                    {
                        FieldDeclaration t = (FieldDeclaration) member;
                        List<VariableDeclarator> variables = t.getVariables();
                        for (VariableDeclarator v : variables)
                            attNames.add(v.getId().getName());
                    }
        }
    }
    
    return attNames;
}
 
开发者ID:gems-uff,项目名称:oceano,代码行数:25,代码来源:NumberOfAccessorMethods.java

示例11: visit

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

示例12: visit

import japa.parser.ast.body.BodyDeclaration; //导入依赖的package包/类
public void visit(EnumConstantDeclaration 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.getArgs() != null) {
        for (Expression e : n.getArgs()) {
            e.accept(this, arg);
        }
    }
    if (n.getClassBody() != null) {
        for (BodyDeclaration member : n.getClassBody()) {
            member.accept(this, arg);
        }
    }
}
 
开发者ID:rfw,项目名称:genja,代码行数:21,代码来源:VoidVisitorAdapter.java

示例13: visit

import japa.parser.ast.body.BodyDeclaration; //导入依赖的package包/类
public Node visit(AnnotationDeclaration 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<BodyDeclaration> members = n.getMembers();
    if (members != null) {
        for (int i = 0; i < members.size(); i++) {
            members.set(i, (BodyDeclaration) members.get(i).accept(this, arg));
        }
        removeNulls(members);
    }
    return n;
}
 
开发者ID:rfw,项目名称:genja,代码行数:21,代码来源:ModifierVisitorAdapter.java

示例14: changeMethods

import japa.parser.ast.body.BodyDeclaration; //导入依赖的package包/类
private static void changeMethods(CompilationUnit cu, String rootClass) {
    addImport(cu, rootClass);
    String rootClassShort = rootClass
            .substring(rootClass.lastIndexOf(".") + 1);

    List<TypeDeclaration> types = cu.getTypes();
    for (TypeDeclaration type : types) {
        List<BodyDeclaration> members = type.getMembers();
        for (BodyDeclaration member : members) {
            if (member instanceof MethodDeclaration) {
                MethodDeclaration method = (MethodDeclaration) member;
                if (isSetRootComponentMethod(method)) {
                    changeSetRootMethod(method, rootClassShort);
                }
            } else if (member instanceof FieldDeclaration) {
                FieldDeclaration field = (FieldDeclaration) member;
                if (isRootField(field)) {
                    changeRootField(field, rootClassShort);
                }
            }
        }
    }
}
 
开发者ID:ahn,项目名称:mideaas,代码行数:24,代码来源:JavaUtil.java

示例15: addAttachSkeleton

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


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