Search in sources :

Example 1 with ClassNameDeclaration

use of net.sourceforge.pmd.lang.java.symboltable.ClassNameDeclaration in project pmd by pmd.

the class AccessorMethodGenerationRule method analyzeScope.

private void analyzeScope(final AbstractJavaScope file, final Object data) {
    for (final ClassNameDeclaration classDecl : file.getDeclarations(ClassNameDeclaration.class).keySet()) {
        final ClassScope classScope = (ClassScope) classDecl.getScope();
        // Check fields
        for (final Map.Entry<VariableNameDeclaration, List<NameOccurrence>> varDecl : classScope.getVariableDeclarations().entrySet()) {
            final ASTFieldDeclaration field = varDecl.getKey().getNode().getFirstParentOfType(ASTFieldDeclaration.class);
            analyzeMember(field, varDecl.getValue(), classScope, data);
        }
        // Check methods
        for (final Map.Entry<MethodNameDeclaration, List<NameOccurrence>> methodDecl : classScope.getMethodDeclarations().entrySet()) {
            final ASTMethodDeclaration method = methodDecl.getKey().getNode().getFirstParentOfType(ASTMethodDeclaration.class);
            analyzeMember(method, methodDecl.getValue(), classScope, data);
        }
        // Check inner classes
        analyzeScope(classScope, data);
    }
}
Also used : MethodNameDeclaration(net.sourceforge.pmd.lang.java.symboltable.MethodNameDeclaration) ASTMethodDeclaration(net.sourceforge.pmd.lang.java.ast.ASTMethodDeclaration) VariableNameDeclaration(net.sourceforge.pmd.lang.java.symboltable.VariableNameDeclaration) ASTFieldDeclaration(net.sourceforge.pmd.lang.java.ast.ASTFieldDeclaration) ClassNameDeclaration(net.sourceforge.pmd.lang.java.symboltable.ClassNameDeclaration) List(java.util.List) Map(java.util.Map) ClassScope(net.sourceforge.pmd.lang.java.symboltable.ClassScope)

Aggregations

List (java.util.List)1 Map (java.util.Map)1 ASTFieldDeclaration (net.sourceforge.pmd.lang.java.ast.ASTFieldDeclaration)1 ASTMethodDeclaration (net.sourceforge.pmd.lang.java.ast.ASTMethodDeclaration)1 ClassNameDeclaration (net.sourceforge.pmd.lang.java.symboltable.ClassNameDeclaration)1 ClassScope (net.sourceforge.pmd.lang.java.symboltable.ClassScope)1 MethodNameDeclaration (net.sourceforge.pmd.lang.java.symboltable.MethodNameDeclaration)1 VariableNameDeclaration (net.sourceforge.pmd.lang.java.symboltable.VariableNameDeclaration)1