Update rule ConstructorCallsOverridableMethod

This commit is contained in:
Clément Fournier committed 2021-06-22 20:23:50 +02:00
1 parent 2656e62d89
commit de2212c93b
4 files changed
+44 -1055

No files matched your search

@@ -6,6 +6,8 @@ package net.sourceforge.pmd.lang.java.ast.internal;
import static net.sourceforge.pmd.internal.util.AssertionUtil.shouldNotReachHere;
import org.checkerframework.checker.nullness.qual.NonNull;
import net.sourceforge.pmd.lang.java.ast.ASTAmbiguousName;
import net.sourceforge.pmd.lang.java.ast.ASTAnnotationTypeDeclaration;
import net.sourceforge.pmd.lang.java.ast.ASTAnyTypeDeclaration;
@@ -20,6 +22,7 @@ import net.sourceforge.pmd.lang.java.ast.ASTFormalParameters;
import net.sourceforge.pmd.lang.java.ast.ASTImportDeclaration;
import net.sourceforge.pmd.lang.java.ast.ASTIntersectionType;
import net.sourceforge.pmd.lang.java.ast.ASTList;
import net.sourceforge.pmd.lang.java.ast.ASTMethodCall;
import net.sourceforge.pmd.lang.java.ast.ASTMethodDeclaration;
import net.sourceforge.pmd.lang.java.ast.ASTMethodOrConstructorDeclaration;
import net.sourceforge.pmd.lang.java.ast.ASTPrimitiveType;
@@ -33,6 +36,7 @@ import net.sourceforge.pmd.lang.java.ast.ASTVariableDeclaratorId;
import net.sourceforge.pmd.lang.java.ast.ASTVoidType;
import net.sourceforge.pmd.lang.java.ast.ASTWildcardType;
import net.sourceforge.pmd.lang.java.ast.JavaNode;
import net.sourceforge.pmd.lang.java.types.TypePrettyPrint;
import net.sourceforge.pmd.util.CollectionUtil;
/**
@@ -197,4 +201,10 @@ public final class PrettyPrintingUtil {
return name;
}
/**
* Pretty print the selected overload.
*/
public static @NonNull String prettyPrintOverload(ASTMethodCall it) {
return TypePrettyPrint.prettyPrintWithSimpleNames(it.getOverloadSelectionInfo().getMethodType());
}
}
@@ -6,7 +6,6 @@ package net.sourceforge.pmd.lang.java.rule.errorprone;
import net.sourceforge.pmd.testframework.PmdRuleTst;
@org.junit.Ignore("Rule has not been updated yet")
public class ConstructorCallsOverridableMethodTest extends PmdRuleTst {
// no additional unit tests
}
@@ -91,11 +91,12 @@ public class Foo {
<code><![CDATA[
public class Foo {
public Foo(String s) {
addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {bar();}
addRunnable(new Runnable() {
public void run() {bar();}
});
}
public void bar() {}
final void addRunnable(Runnable r) {}
}
]]></code>
</test-code>