diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTCatchBlockStatement.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTCatchBlockStatement.java index ec45ee34cb..d051b1743b 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTCatchBlockStatement.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTCatchBlockStatement.java @@ -27,6 +27,6 @@ public final class ASTCatchBlockStatement extends AbstractApexCommentContainerNo } public ASTBlockStatement getBody() { - return getFirstChildOfType(ASTBlockStatement.class); + return firstChild(ASTBlockStatement.class); } } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/AbstractApexNode.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/AbstractApexNode.java index e8bb3413cd..a86b7b0d34 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/AbstractApexNode.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/AbstractApexNode.java @@ -184,7 +184,7 @@ abstract class AbstractApexNode extends AbstractNode baseNode = this instanceof BaseApexClass ? (BaseApexClass) this : getFirstParentOfType(BaseApexClass.class); + BaseApexClass baseNode = this instanceof BaseApexClass ? (BaseApexClass) this : ancestors(BaseApexClass.class).first(); if (baseNode != null) { return baseNode.getQualifiedName().toString(); } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ApexQualifiedName.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ApexQualifiedName.java index 8422de05a1..b23bd36032 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ApexQualifiedName.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ApexQualifiedName.java @@ -161,7 +161,7 @@ public final class ApexQualifiedName { StringBuilder sb = new StringBuilder(); sb.append(node.getImage()).append('('); - List paramTypes = node.findChildrenOfType(ASTParameter.class).stream() + List paramTypes = node.children(ASTParameter.class).toStream() .map(ASTParameter::getType) .collect(Collectors.toList()); diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ApexTreeBuilder.kt b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ApexTreeBuilder.kt index 5a94f06a14..c48f2ad0cd 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ApexTreeBuilder.kt +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ApexTreeBuilder.kt @@ -769,7 +769,7 @@ class ApexTreeBuilder(val task: ParserTask, val proc: ApexLanguageProcessor) { root: AbstractApexNode, nodeType: KClass ): List = - root.findDescendantsOfType(nodeType.java, true) + (if (root is T) listOf(root) else emptyList()) + root.descendants(nodeType.java).crossFindBoundaries().toList() + (if (root is T) listOf(root) else emptyList()) /** Generates [ASTField] nodes for the [ASTFieldDeclarationStatements]. */ private fun generateFields(node: ASTFieldDeclarationStatements) {