deprecation inspection fix: make it available if 2 tags reference to the same method

This commit is contained in:
Dmitry Batkovich
2017-09-22 15:30:08 +03:00
parent 738df244fa
commit 25f5306bf9
3 changed files with 46 additions and 1 deletions
@@ -44,6 +44,7 @@ import org.jetbrains.annotations.Nullable;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.Objects;
abstract class DeprecationInspectionBase extends BaseJavaBatchLocalInspectionTool {
public boolean IGNORE_IN_SAME_OUTERMOST_CLASS;
@@ -356,10 +357,14 @@ abstract class DeprecationInspectionBase extends BaseJavaBatchLocalInspectionToo
String name = t.getName();
return "link".equals(name) || "see".equals(name);
})
.collect(MoreCollectors.onlyOne())
.map(tag -> tag.getValueElement())
.filter(Objects::nonNull)
.map(value -> value.getReference())
.filter(Objects::nonNull)
.map(reference -> reference.resolve())
.filter(Objects::nonNull)
.distinct()
.collect(MoreCollectors.onlyOne())
.filter(resolved -> resolved instanceof PsiMethod)
.orElse(null);
return tagMethod == null || tagMethod.isDeprecated() || tagMethod.isEquivalentTo(method) || !areReplaceable(method, tagMethod, call)
@@ -0,0 +1,20 @@
// "Replace method call with Test.mmm1" "true"
class Test {
static void example() {
Test t = new Test();
Test.mmm1("");
}
/**
* {@link Test#mmm1(String)}
*
* @see Test#mmm1(String)
*/
@Deprecated
void mmm(String t) {
}
static void mmm1(String string) {
}
}
@@ -0,0 +1,20 @@
// "Replace method call with Test.mmm1" "true"
class Test {
static void example() {
Test t = new Test();
t.m<caret>mm("");
}
/**
* {@link Test#mmm1(String)}
*
* @see Test#mmm1(String)
*/
@Deprecated
void mmm(String t) {
}
static void mmm1(String string) {
}
}