Search in sources :

Example 26 with ASTVisitor

use of org.eclipse.jdt.core.dom.ASTVisitor in project eclipse-pmd by acanda.

the class SuppressWarningsQuickFix method findBodyDeclaration.

private BodyDeclaration findBodyDeclaration(final ASTNode node) {
    final BodyDeclaration[] bodyDeclaration = new BodyDeclaration[1];
    node.accept(new ASTVisitor() {

        @Override
        public boolean visit(final EnumDeclaration node) {
            bodyDeclaration[0] = node;
            return false;
        }

        @Override
        public boolean visit(final TypeDeclaration node) {
            bodyDeclaration[0] = node;
            return false;
        }

        @Override
        public boolean visit(final AnnotationTypeDeclaration node) {
            bodyDeclaration[0] = node;
            return false;
        }
    });
    return bodyDeclaration[0];
}
Also used : AnnotationTypeDeclaration(org.eclipse.jdt.core.dom.AnnotationTypeDeclaration) BodyDeclaration(org.eclipse.jdt.core.dom.BodyDeclaration) AnnotationTypeDeclaration(org.eclipse.jdt.core.dom.AnnotationTypeDeclaration) AbstractTypeDeclaration(org.eclipse.jdt.core.dom.AbstractTypeDeclaration) TypeDeclaration(org.eclipse.jdt.core.dom.TypeDeclaration) ASTVisitor(org.eclipse.jdt.core.dom.ASTVisitor) EnumDeclaration(org.eclipse.jdt.core.dom.EnumDeclaration)

Aggregations

ASTVisitor (org.eclipse.jdt.core.dom.ASTVisitor)26 SimpleName (org.eclipse.jdt.core.dom.SimpleName)14 ICompilationUnit (org.eclipse.jdt.core.ICompilationUnit)10 ASTNode (org.eclipse.jdt.core.dom.ASTNode)9 CompilationUnit (org.eclipse.jdt.core.dom.CompilationUnit)9 ArrayList (java.util.ArrayList)8 Name (org.eclipse.jdt.core.dom.Name)7 EnhancedForStatement (org.eclipse.jdt.core.dom.EnhancedForStatement)5 ForStatement (org.eclipse.jdt.core.dom.ForStatement)5 IBinding (org.eclipse.jdt.core.dom.IBinding)5 LinkedList (java.util.LinkedList)4 ArrayType (org.eclipse.jdt.core.dom.ArrayType)4 Expression (org.eclipse.jdt.core.dom.Expression)4 ITypeBinding (org.eclipse.jdt.core.dom.ITypeBinding)4 IVariableBinding (org.eclipse.jdt.core.dom.IVariableBinding)4 MethodDeclaration (org.eclipse.jdt.core.dom.MethodDeclaration)4 ParameterizedType (org.eclipse.jdt.core.dom.ParameterizedType)4 SimpleType (org.eclipse.jdt.core.dom.SimpleType)4 Statement (org.eclipse.jdt.core.dom.Statement)4 TypeDeclaration (org.eclipse.jdt.core.dom.TypeDeclaration)4