From e33fe924e9daf13a44156954ba0d927103598197 Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Thu, 9 Nov 2023 09:38:21 +0100 Subject: [PATCH] [apex] Fix ApexDoc for interface methods Interface methods are implicit public and abstract Refs #4722 --- .../pmd/lang/apex/ast/ASTModifierNode.java | 6 ++++++ .../apex/rule/documentation/xml/ApexDoc.xml | 17 +++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTModifierNode.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTModifierNode.java index 2be88accaf..2a95b5ca50 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTModifierNode.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTModifierNode.java @@ -45,6 +45,12 @@ public final class ASTModifierNode extends AbstractApexNode.Many imple .mapToInt(mod -> OPCODES.get(mod.getKeyword())) .reduce(0, (current, bit) -> current | bit); + // interface methods are implicit public and abstract + ApexNode classOrInterface = ancestors().get(1); + if (nodes.isEmpty() && classOrInterface instanceof ASTUserInterface) { + modifiers |= PUBLIC | ABSTRACT; + } + if ((modifiers & PUBLIC) > 0) { // Remove PROTECTED and PRIVATE if PUBLIC modifiers &= ~PROTECTED; diff --git a/pmd-apex/src/test/resources/net/sourceforge/pmd/lang/apex/rule/documentation/xml/ApexDoc.xml b/pmd-apex/src/test/resources/net/sourceforge/pmd/lang/apex/rule/documentation/xml/ApexDoc.xml index 3f0bc23b07..40033e4938 100644 --- a/pmd-apex/src/test/resources/net/sourceforge/pmd/lang/apex/rule/documentation/xml/ApexDoc.xml +++ b/pmd-apex/src/test/resources/net/sourceforge/pmd/lang/apex/rule/documentation/xml/ApexDoc.xml @@ -160,6 +160,23 @@ public interface Foo { } ]]> + + public method in interface should have comment + 1 + 5 + + Missing ApexDoc comment + + + + public method should have comment 1