diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTMethod.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTMethod.java index 72eff5e483..d64ea031a4 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTMethod.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTMethod.java @@ -92,9 +92,9 @@ public final class ASTMethod extends AbstractApexNode implements ApexQualifiable @Override public String getImage() { if (isConstructor()) { - ASTUserClass classNode = getFirstParentOfType(ASTUserClass.class); - if (classNode != null) { - return classNode.getSimpleName(); + BaseApexClass baseClassNode = ancestors(BaseApexClass.class).first(); + if (baseClassNode != null) { + return baseClassNode.getSimpleName(); } } return getCanonicalName();