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


Java TypeDeclaration.getMembers方法代码示例

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


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

示例1: getJavaMethods

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

示例2: getDeclaration

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

示例3: getNode

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

示例4: find

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

示例5: feedTestClass

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

示例6: countAccessorMethods

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

示例7: getAttributesNames

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

示例8: changeMethods

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

示例9: ensureClaraFieldExists

import japa.parser.ast.body.TypeDeclaration; //导入方法依赖的package包/类
public int[] ensureClaraFieldExists(String id, String className) {
	
	List<TypeDeclaration> types = cu.getTypes();
	for (TypeDeclaration type : types) {
		List<BodyDeclaration> members = type.getMembers();
		if (members==null) {
			break;
		}
		for (BodyDeclaration member : members) {
			if (member instanceof FieldDeclaration) {
				FieldDeclaration field = (FieldDeclaration) member;
				if (isClaraField(field, id, className)) {
					return getMemberRowCol(field);
				}
			}
		}
	}
	
	FieldDeclaration fd = addClaraField(id, className);
	
	reparse();
	String name = fd.getVariables().get(0).getId().getName();
	int[] hmm = getFieldRowCol(name);
	
	return hmm;
}
 
开发者ID:ahn,项目名称:mideaas,代码行数:27,代码来源:ControllerCode.java

示例10: Declaration

import japa.parser.ast.body.TypeDeclaration; //导入方法依赖的package包/类
public Declaration(TypeDeclaration decl) {
    className = decl.getName();
    methods = new ArrayList<String>();
    attributes = new HashSet<String>();
    processAnnotations(decl);
    for (BodyDeclaration method : decl.getMembers()) {
        processAnnotations(method);
        if (method instanceof MethodDeclaration)
            methods.add(((MethodDeclaration)method).getName());
    }
}
 
开发者ID:amritbhat786,项目名称:DocIT,代码行数:12,代码来源:Fact.java

示例11: insertBuilder

import japa.parser.ast.body.TypeDeclaration; //导入方法依赖的package包/类
private static List<String> insertBuilder( TypeDeclaration builderParentDecl , File javaFile ) throws Exception
{
	List<String> lines = readLines( javaFile );
	
	String[ ] classNames = getNestedClassNames( builderParentDecl );
	
	List<BodyDeclaration> members = builderParentDecl.getMembers( );
	
	for( int m = members.size( ) - 1 ; m >= 0 ; m-- )
	{
		BodyDeclaration decl = members.get( m );
		
		// re-parse after every insertion, since the end line of the
		// destination type will have changed
		CompilationUnit compunit = parse( lines );
		
		TypeDeclaration destType = find( compunit , classNames );
		
		BodyDeclaration toReplace = null;
		if( decl instanceof MethodDeclaration )
		{
			toReplace = find( destType , ( MethodDeclaration ) decl );
		}
		else if( decl instanceof TypeDeclaration )
		{
			toReplace = find( destType , ( ( TypeDeclaration ) decl ).getName( ) );
		}
		
		if( toReplace != null )
		{
			replace( lines , getTotalLineRegion( toReplace ) , decl.toString( ) );
		}
		else
		{
			insert( lines , destType.getEndLine( ) - 1 , destType.getEndColumn( ) - 1 , decl.toString( ) );
		}
	}
	
	return lines;
}
 
开发者ID:jedwards1211,项目名称:breakout,代码行数:41,代码来源:BuilderGenerator.java

示例12: feedHelperClass

import japa.parser.ast.body.TypeDeclaration; //导入方法依赖的package包/类
private void feedHelperClass(TypeDeclaration type, Helper helper) {
    for (BodyDeclaration bodyDeclaration : type.getMembers()) {
        if (bodyDeclaration instanceof MethodDeclaration) {
            MethodDeclaration methodDeclaration = (MethodDeclaration) bodyDeclaration;
            feedTestFixture(methodDeclaration, helper);
        }
    }
}
 
开发者ID:slezier,项目名称:SimpleFunctionalTest,代码行数:9,代码来源:HelperJavaParser.java

示例13: addMember

import japa.parser.ast.body.TypeDeclaration; //导入方法依赖的package包/类
/**
 * Adds the given declaration to the specified type. The list of members
 * will be initialized if it is <code>null</code>.
 * 
 * @param type
 *            type declaration
 * @param decl
 *            member declaration
 */
public static void addMember(TypeDeclaration type, BodyDeclaration decl) {
    List<BodyDeclaration> members = type.getMembers();
    if (members == null) {
        members = new ArrayList<BodyDeclaration>();
        type.setMembers(members);
    }
    members.add(decl);
}
 
开发者ID:rfw,项目名称:genja,代码行数:18,代码来源:ASTHelper.java


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