diff --git a/java/java-impl/src/com/intellij/codeInspection/deadCode/UnusedDeclarationInspection.java b/java/java-impl/src/com/intellij/codeInspection/deadCode/UnusedDeclarationInspection.java index ef5544775adb..b01ca0a8039b 100644 --- a/java/java-impl/src/com/intellij/codeInspection/deadCode/UnusedDeclarationInspection.java +++ b/java/java-impl/src/com/intellij/codeInspection/deadCode/UnusedDeclarationInspection.java @@ -15,14 +15,11 @@ */ package com.intellij.codeInspection.deadCode; -import com.intellij.codeInspection.GlobalInspectionContext; import com.intellij.codeInspection.InspectionsBundle; -import com.intellij.codeInspection.ex.EntryPointsManager; +import com.intellij.codeInspection.ex.EntryPointsManagerImpl; import com.intellij.codeInspection.reference.EntryPoint; import com.intellij.codeInspection.unusedSymbol.UnusedSymbolLocalInspection; import com.intellij.codeInspection.unusedSymbol.UnusedSymbolLocalInspectionBase; -import com.intellij.openapi.project.Project; -import com.intellij.openapi.project.ProjectManager; import com.intellij.ui.components.JBTabbedPane; import org.jetbrains.annotations.TestOnly; @@ -53,17 +50,6 @@ public class UnusedDeclarationInspection extends UnusedDeclarationInspectionBase return tabs; } - private Project guessProject() { - final GlobalInspectionContext context = getContext(); - Project project = context == null ? null : context.getProject(); - - if (project == null) { - Project[] openProjects = ProjectManager.getInstance().getOpenProjects(); - project = openProjects.length == 0 ? ProjectManager.getInstance().getDefaultProject() : openProjects[0]; - } - return project; - } - private class OptionsPanel extends JPanel { private final JCheckBox myMainsCheckbox; private final JCheckBox myAppletToEntries; @@ -141,8 +127,7 @@ public class UnusedDeclarationInspection extends UnusedDeclarationInspectionBase gc.gridy++; add(myNonJavaCheckbox, gc); - Project project = guessProject(); - JButton configureAnnotations = EntryPointsManager.getInstance(project).createConfigureAnnotationsBtn(); + JButton configureAnnotations = EntryPointsManagerImpl.createConfigureAnnotationsButton(); gc.fill = GridBagConstraints.NONE; gc.gridy++; gc.insets.top = 10; diff --git a/java/java-impl/src/com/intellij/codeInspection/ex/EntryPointsManagerImpl.java b/java/java-impl/src/com/intellij/codeInspection/ex/EntryPointsManagerImpl.java index 209f7ef827fb..2ef2dc12829b 100644 --- a/java/java-impl/src/com/intellij/codeInspection/ex/EntryPointsManagerImpl.java +++ b/java/java-impl/src/com/intellij/codeInspection/ex/EntryPointsManagerImpl.java @@ -28,6 +28,7 @@ import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer; import com.intellij.codeInspection.util.SpecialAnnotationsUtil; import com.intellij.openapi.components.*; import com.intellij.openapi.project.Project; +import com.intellij.openapi.project.ProjectUtil; import com.intellij.openapi.ui.DialogWrapper; import org.jdom.Element; @@ -73,11 +74,15 @@ public class EntryPointsManagerImpl extends EntryPointsManagerBase implements Pe @Override public JButton createConfigureAnnotationsBtn() { + return createConfigureAnnotationsButton(); + } + + public static JButton createConfigureAnnotationsButton() { final JButton configureAnnotations = new JButton("Configure annotations..."); configureAnnotations.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { - configureAnnotations(); + getInstance(ProjectUtil.guessCurrentProject(configureAnnotations)).configureAnnotations(); } }); return configureAnnotations; diff --git a/java/java-impl/src/com/intellij/codeInspection/unusedParameters/UnusedParametersInspection.java b/java/java-impl/src/com/intellij/codeInspection/unusedParameters/UnusedParametersInspection.java index bb97f5cd78d5..9e1f28254b65 100644 --- a/java/java-impl/src/com/intellij/codeInspection/unusedParameters/UnusedParametersInspection.java +++ b/java/java-impl/src/com/intellij/codeInspection/unusedParameters/UnusedParametersInspection.java @@ -29,10 +29,10 @@ import com.intellij.codeInsight.FileModificationService; import com.intellij.codeInsight.daemon.GroupNames; import com.intellij.codeInspection.*; import com.intellij.codeInspection.ex.EntryPointsManager; +import com.intellij.codeInspection.ex.EntryPointsManagerImpl; import com.intellij.codeInspection.reference.*; import com.intellij.codeInspection.unusedSymbol.UnusedSymbolLocalInspectionBase; import com.intellij.openapi.project.Project; -import com.intellij.openapi.project.ProjectUtil; import com.intellij.openapi.util.Comparing; import com.intellij.psi.*; import com.intellij.psi.search.PsiReferenceProcessor; @@ -234,8 +234,7 @@ public class UnusedParametersInspection extends GlobalJavaBatchInspectionTool { @Override public JComponent createOptionsPanel() { final JPanel panel = new JPanel(new GridBagLayout()); - Project project = ProjectUtil.guessCurrentProject(panel); - panel.add(EntryPointsManager.getInstance(project).createConfigureAnnotationsBtn(), + panel.add(EntryPointsManagerImpl.createConfigureAnnotationsButton(), new GridBagConstraints(0, 0, 1, 1, 1, 1, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); return panel; diff --git a/platform/analysis-api/src/com/intellij/codeInspection/ex/EntryPointsManager.java b/platform/analysis-api/src/com/intellij/codeInspection/ex/EntryPointsManager.java index 14a9002d109c..02f3f3cfac1a 100644 --- a/platform/analysis-api/src/com/intellij/codeInspection/ex/EntryPointsManager.java +++ b/platform/analysis-api/src/com/intellij/codeInspection/ex/EntryPointsManager.java @@ -29,6 +29,8 @@ import com.intellij.psi.PsiElement; import org.jetbrains.annotations.NotNull; import javax.swing.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; public abstract class EntryPointsManager implements Disposable { public static EntryPointsManager getInstance(Project project) { @@ -50,6 +52,10 @@ public abstract class EntryPointsManager implements Disposable { public abstract void configureAnnotations(); + /** + * {@link com.intellij.codeInspection.ex.EntryPointsManagerImpl#createConfigureAnnotationsButton()} should be used instead + */ + @Deprecated public abstract JButton createConfigureAnnotationsBtn(); public abstract boolean isEntryPoint(@NotNull PsiElement element);