mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
unused declaration: report methods directly called from test sources (IDEA-160530)
This commit is contained in:
+5
@@ -122,6 +122,11 @@ public class UnusedDeclarationPresentation extends DefaultInspectionToolPresenta
|
||||
final int problemCount = super.getElementProblemCount(refElement);
|
||||
if (problemCount > - 1) return problemCount;
|
||||
if (!((RefElementImpl)refElement).hasSuspiciousCallers() || ((RefJavaElementImpl)refElement).isSuspiciousRecursive()) return 1;
|
||||
|
||||
for (RefElement element : refElement.getInReferences()) {
|
||||
if (((UnusedDeclarationInspectionBase)myTool).isEntryPoint(element)) return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,5 +10,15 @@
|
||||
<line>1</line>
|
||||
<description>Class has one instantiation but it is not reachable from entry points.</description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>Test.java</file>
|
||||
<line>2</line>
|
||||
<description><ul><li>Method owner class is never instantiated OR</li><li>An instantiation is not reachable from entry points.</li></ul></description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>Test.java</file>
|
||||
<line>1</line>
|
||||
<description>Class has one instantiation but it is not reachable from entry points.</description>
|
||||
</problem>
|
||||
</problems>
|
||||
|
||||
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<problems>
|
||||
<problem>
|
||||
<file>Test.java</file>
|
||||
<line>2</line>
|
||||
<description>Method has one usage but it is not reachable from entry points.</description>
|
||||
</problem>
|
||||
|
||||
<problem>
|
||||
<file>Main.java</file>
|
||||
<line>6</line>
|
||||
<description>Method is never used.</description>
|
||||
</problem>
|
||||
|
||||
</problems>
|
||||
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
public class Test {
|
||||
public static void doSmth() {}
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
public class Main {
|
||||
public static void main(String[] args) {
|
||||
Test.doSmth();
|
||||
}
|
||||
|
||||
public static void unusedInTestScope() {
|
||||
System.out.println("hey");
|
||||
}
|
||||
}
|
||||
+10
@@ -37,6 +37,16 @@ public class UnusedDeclarationInProjectTest extends AbstractUnusedDeclarationTes
|
||||
}
|
||||
}
|
||||
|
||||
public void testInstantiatedInTestOnlyStatic() throws Exception {
|
||||
myTool.setTestEntryPoints(false);
|
||||
try {
|
||||
doTest();
|
||||
}
|
||||
finally {
|
||||
myTool.setTestEntryPoints(true);
|
||||
}
|
||||
}
|
||||
|
||||
public void testIgnoreUnusedFields() throws Exception {
|
||||
myTool.getSharedLocalInspectionTool().FIELD = false;
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user