mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-21 22:11:40 +07:00
Java: No deprecation warning when declaration and usage are within the same top-level class, JLS 9.6.4.6 (IDEA-131480)
This commit is contained in:
@@ -31,7 +31,7 @@ import java.util.Objects;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public abstract class DeprecationInspectionBase extends LocalInspectionTool {
|
||||
public boolean IGNORE_IN_SAME_OUTERMOST_CLASS;
|
||||
public boolean IGNORE_IN_SAME_OUTERMOST_CLASS = true;
|
||||
|
||||
@Override
|
||||
public boolean isEnabledByDefault() {
|
||||
|
||||
@@ -21,10 +21,6 @@ import javax.swing.*;
|
||||
|
||||
public class MarkedForRemovalInspection extends DeprecationInspectionBase {
|
||||
|
||||
{
|
||||
IGNORE_IN_SAME_OUTERMOST_CLASS = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder, boolean isOnTheFly) {
|
||||
|
||||
@@ -26,7 +26,7 @@ class b extends a {
|
||||
}
|
||||
|
||||
b() {
|
||||
<warning descr="'b(int)' is deprecated">this</warning>(1);
|
||||
this(1);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -39,6 +39,10 @@ class b extends a {
|
||||
}
|
||||
|
||||
class c extends b {
|
||||
c(int i) {
|
||||
<warning descr="'b(int)' is deprecated">super</warning>(i);
|
||||
}
|
||||
|
||||
// b.f is not deprecated
|
||||
void f() {}
|
||||
}
|
||||
@@ -83,6 +87,12 @@ class Anonym {
|
||||
public Anonym(String sss) {
|
||||
System.out.println(sss);
|
||||
}
|
||||
public void foo() {
|
||||
new Anonym("asdasd") {};
|
||||
}
|
||||
}
|
||||
|
||||
class UseAnonym {
|
||||
public void foo() {
|
||||
new <warning descr="'Anonym(java.lang.String)' is deprecated">Anonym</warning>("asdasd") {};
|
||||
}
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<problems>
|
||||
<problem>
|
||||
<file>Test.java</file>
|
||||
<line>21</line>
|
||||
<description>'field' is deprecated</description>
|
||||
</problem>
|
||||
|
||||
<problem>
|
||||
<file>Test.java</file>
|
||||
<line>22</line>
|
||||
<description>'method()' is deprecated</description>
|
||||
</problem>
|
||||
</problems>
|
||||
@@ -0,0 +1,24 @@
|
||||
class C {
|
||||
@Deprecated
|
||||
int field;
|
||||
|
||||
@Deprecated
|
||||
void C() { }
|
||||
|
||||
@Deprecated
|
||||
void method() { }
|
||||
|
||||
static void bar() {
|
||||
C c = new C();
|
||||
c.field = 1;
|
||||
c.method();
|
||||
}
|
||||
}
|
||||
|
||||
class AnotherTopLevel {
|
||||
static void bar() {
|
||||
C c = new C();
|
||||
c.field = 1;
|
||||
c.method();
|
||||
}
|
||||
}
|
||||
@@ -43,11 +43,14 @@ public class SuppressNonInspectionsTest extends LightQuickFixParameterizedTestCa
|
||||
@NotNull
|
||||
@Override
|
||||
protected LocalInspectionTool[] configureLocalInspectionTools() {
|
||||
DeprecationInspection deprecationInspection = new DeprecationInspection();
|
||||
deprecationInspection.IGNORE_IN_SAME_OUTERMOST_CLASS = false;
|
||||
|
||||
return new LocalInspectionTool[]{
|
||||
new RedundantThrowsDeclarationLocalInspection(),
|
||||
new SillyAssignmentInspection(),
|
||||
new AccessStaticViaInstance(),
|
||||
new DeprecationInspection(),
|
||||
deprecationInspection,
|
||||
new JavaDocReferenceInspection(),
|
||||
new UncheckedWarningLocalInspection()
|
||||
};
|
||||
|
||||
@@ -24,7 +24,9 @@ public class DeprecationInspectionFixTest extends LightQuickFixParameterizedTest
|
||||
@NotNull
|
||||
@Override
|
||||
protected LocalInspectionTool[] configureLocalInspectionTools() {
|
||||
return new LocalInspectionTool[]{new DeprecationInspection()};
|
||||
DeprecationInspection inspection = new DeprecationInspection();
|
||||
inspection.IGNORE_IN_SAME_OUTERMOST_CLASS = false;
|
||||
return new LocalInspectionTool[]{inspection};
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -42,7 +42,9 @@ public class DeprecationInspectionTest extends InspectionTestCase {
|
||||
}
|
||||
|
||||
private void doTest() {
|
||||
doTest("deprecation/" + getTestName(true), new DeprecationInspection());
|
||||
DeprecationInspection tool = new DeprecationInspection();
|
||||
tool.IGNORE_IN_SAME_OUTERMOST_CLASS = false;
|
||||
doTest("deprecation/" + getTestName(true), tool);
|
||||
}
|
||||
|
||||
public void testDeprecatedMethod() {
|
||||
@@ -91,6 +93,11 @@ public class DeprecationInspectionTest extends InspectionTestCase {
|
||||
doTest("deprecation/" + getTestName(true), tool);
|
||||
}
|
||||
|
||||
public void testIgnoreInSameOutermostClass() {
|
||||
final DeprecationInspection tool = new DeprecationInspection();
|
||||
doTest("deprecation/" + getTestName(true), tool);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected LightProjectDescriptor getProjectDescriptor() {
|
||||
|
||||
Reference in New Issue
Block a user