mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
unused: search for main in inner classes (IDEA-178721)
This commit is contained in:
+13
-1
@@ -400,7 +400,9 @@ public class UnusedDeclarationInspectionBase extends GlobalInspectionTool {
|
||||
if (isAddServletEnabled() && servlet != null && aClass.isInheritor(servlet, true)) {
|
||||
return true;
|
||||
}
|
||||
if (isAddMainsEnabled() && PsiMethodUtil.hasMainMethod(aClass)) return true;
|
||||
if (isAddMainsEnabled()) {
|
||||
if (hasMainMethodDeep(aClass)) return true;
|
||||
}
|
||||
}
|
||||
if (element instanceof PsiModifierListOwner) {
|
||||
final EntryPointsManager entryPointsManager = EntryPointsManager.getInstance(project);
|
||||
@@ -414,6 +416,16 @@ public class UnusedDeclarationInspectionBase extends GlobalInspectionTool {
|
||||
return RefUtil.isImplicitUsage(element);
|
||||
}
|
||||
|
||||
private static boolean hasMainMethodDeep(PsiClass aClass) {
|
||||
if (PsiMethodUtil.hasMainMethod(aClass)) return true;
|
||||
for (PsiClass innerClass : aClass.getInnerClasses()) {
|
||||
if (innerClass.hasModifierProperty(PsiModifier.STATIC) && PsiMethodUtil.hasMainMethod(innerClass)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isGlobalEnabledInEditor() {
|
||||
return myEnabledInEditor;
|
||||
}
|
||||
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
class Test {
|
||||
static class NestedTest {
|
||||
public static void main(String[] args) {
|
||||
new Test();
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
@@ -35,6 +35,7 @@ public class UnusedSymbolLocalTest extends DaemonAnalyzerTestCase {
|
||||
}
|
||||
|
||||
public void testInnerClass() throws Exception { doTest(); }
|
||||
public void testInnerClassWithMainMethod() throws Exception { doTest(); }
|
||||
public void testInnerUsesSelf() throws Exception { doTest(); }
|
||||
public void testLocalClass() throws Exception { doTest(); }
|
||||
public void testPrivateConstructor() throws Exception { doTest(); }
|
||||
|
||||
Reference in New Issue
Block a user