mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
deprecation inspection fix: make it available if 2 tags reference to the same method
This commit is contained in:
+6
-1
@@ -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) {
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user