Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,13 @@ public J.ClassDeclaration visitClassDeclaration(
J.ClassDeclaration classDecl, ExecutionContext ctx) {
J.ClassDeclaration cd = super.visitClassDeclaration(classDecl, ctx);

if (cd.getType() == null || !typeMatchesOrImplements(cd.getType())) {
JavaType.FullyQualified type = cd.getType();
if (type == null || !typeMatchesOrImplements(type)) {
return cd;
}

// Mutate the type info in place to remove the method from the declared methods list,
// so all AST nodes sharing this type reference stay consistent.
var type = cd.getType();
if (type instanceof JavaType.Class classType) {
var updatedMethods =
classType.getMethods().stream().filter(m -> !m.getName().equals(methodName)).toList();
Expand All @@ -90,11 +90,16 @@ public J.MethodDeclaration visitMethodDeclaration(
}

J.ClassDeclaration classDecl = getCursor().firstEnclosing(J.ClassDeclaration.class);
if (classDecl == null || classDecl.getType() == null) {
if (classDecl == null) {
return super.visitMethodDeclaration(method, ctx);
}

if (typeMatchesOrImplements(classDecl.getType())) {
JavaType.FullyQualified type = classDecl.getType();
if (type == null) {
return super.visitMethodDeclaration(method, ctx);
}

if (typeMatchesOrImplements(type)) {
//noinspection DataFlowIssue
return null;
}
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
<git-commit-id-maven-plugin.version>10.0.0</git-commit-id-maven-plugin.version>
<jib-maven-plugin.version>3.5.1</jib-maven-plugin.version>
<spotless.version>3.8.0</spotless.version>
<spotbugs-maven-plugin.version>4.9.8.3</spotbugs-maven-plugin.version>
<spotbugs-maven-plugin.version>4.10.2.0</spotbugs-maven-plugin.version>
</properties>

<dependencyManagement>
Expand Down
Loading