From da1fa689c2db89988de725985c2df6ed6a5e8ab1 Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Tue, 30 Apr 2013 13:38:34 +0400 Subject: [PATCH] use super where possible --- .../javaDoc/JavaDocReferenceInspection.java | 3 +-- .../codeInspection/unneededThrows/RedundantThrows.java | 3 +-- .../codeInsight/daemon/impl/LocalInspectionsPass.java | 2 +- .../actions/CleanupInspectionIntention.java | 5 ++--- .../src/com/intellij/codeInspection/ui/Browser.java | 2 +- .../codeInspection/ui/InspectionResultsView.java | 8 ++++---- .../uiDesigner/inspections/FormFileErrorCollector.java | 10 +++------- .../com/intellij/spellchecker/quickfixes/ChangeTo.java | 4 ++-- 8 files changed, 15 insertions(+), 22 deletions(-) diff --git a/java/java-impl/src/com/intellij/codeInspection/javaDoc/JavaDocReferenceInspection.java b/java/java-impl/src/com/intellij/codeInspection/javaDoc/JavaDocReferenceInspection.java index f472250e7ce9..c4e98055425d 100644 --- a/java/java-impl/src/com/intellij/codeInspection/javaDoc/JavaDocReferenceInspection.java +++ b/java/java-impl/src/com/intellij/codeInspection/javaDoc/JavaDocReferenceInspection.java @@ -24,7 +24,6 @@ import com.intellij.codeInsight.lookup.LookupElementBuilder; import com.intellij.codeInsight.lookup.LookupManager; import com.intellij.codeInspection.*; import com.intellij.codeInspection.ex.BaseLocalInspectionTool; -import com.intellij.codeInspection.ex.ProblemDescriptorImpl; import com.intellij.ide.DataManager; import com.intellij.ide.util.FQNameCellRenderer; import com.intellij.openapi.actionSystem.DataContext; @@ -307,7 +306,7 @@ public class JavaDocReferenceInspection extends BaseLocalInspectionTool { public void run(DataContext dataContext) { final Editor editor = PlatformDataKeys.EDITOR.getData(dataContext); assert editor != null; - final TextRange textRange = ((ProblemDescriptorImpl)descriptor).getTextRange(); + final TextRange textRange = ((ProblemDescriptorBase)descriptor).getTextRange(); editor.getSelectionModel().setSelection(textRange.getStartOffset(), textRange.getEndOffset()); final String word = editor.getSelectionModel().getSelectedText(); diff --git a/java/java-impl/src/com/intellij/codeInspection/unneededThrows/RedundantThrows.java b/java/java-impl/src/com/intellij/codeInspection/unneededThrows/RedundantThrows.java index 0c4605537a4d..7c748affc607 100644 --- a/java/java-impl/src/com/intellij/codeInspection/unneededThrows/RedundantThrows.java +++ b/java/java-impl/src/com/intellij/codeInspection/unneededThrows/RedundantThrows.java @@ -20,7 +20,6 @@ import com.intellij.codeInsight.ExceptionUtil; import com.intellij.codeInsight.FileModificationService; import com.intellij.codeInsight.daemon.GroupNames; import com.intellij.codeInspection.*; -import com.intellij.codeInspection.ex.ProblemDescriptorImpl; import com.intellij.codeInspection.reference.*; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.project.Project; @@ -106,7 +105,7 @@ public class RedundantThrows extends GlobalJavaInspectionTool { } if (problems != null) { - return problems.toArray(new ProblemDescriptorImpl[problems.size()]); + return problems.toArray(new ProblemDescriptorBase[problems.size()]); } } diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/LocalInspectionsPass.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/LocalInspectionsPass.java index 4406095b71c8..9693cdb95174 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/LocalInspectionsPass.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/LocalInspectionsPass.java @@ -662,7 +662,7 @@ public class LocalInspectionsPass extends ProgressableTextEditorHighlightingPass } } } - HintAction hintAction = ((ProblemDescriptorImpl)descriptor).getHintAction(); + HintAction hintAction = descriptor instanceof ProblemDescriptorImpl ? ((ProblemDescriptorImpl)descriptor).getHintAction() : null; if (hintAction != null) { QuickFixAction.registerQuickFixAction(highlightInfo, hintAction, key); needEmptyAction = false; diff --git a/platform/lang-impl/src/com/intellij/codeInspection/actions/CleanupInspectionIntention.java b/platform/lang-impl/src/com/intellij/codeInspection/actions/CleanupInspectionIntention.java index 43d045363cc2..668c0316f652 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/actions/CleanupInspectionIntention.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/actions/CleanupInspectionIntention.java @@ -24,7 +24,6 @@ import com.intellij.codeInsight.intention.IntentionAction; import com.intellij.codeInspection.*; import com.intellij.codeInspection.ex.InspectionToolWrapper; import com.intellij.codeInspection.ex.LocalInspectionToolWrapper; -import com.intellij.codeInspection.ex.ProblemDescriptorImpl; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.progress.EmptyProgressIndicator; import com.intellij.openapi.progress.ProgressManager; @@ -80,8 +79,8 @@ public class CleanupInspectionIntention implements IntentionAction, HighPriority Collections.sort(descriptions, new Comparator() { @Override public int compare(final CommonProblemDescriptor o1, final CommonProblemDescriptor o2) { - final ProblemDescriptorImpl d1 = (ProblemDescriptorImpl)o1; - final ProblemDescriptorImpl d2 = (ProblemDescriptorImpl)o2; + final ProblemDescriptorBase d1 = (ProblemDescriptorBase)o1; + final ProblemDescriptorBase d2 = (ProblemDescriptorBase)o2; return d2.getTextRange().getStartOffset() - d1.getTextRange().getStartOffset(); } }); diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ui/Browser.java b/platform/lang-impl/src/com/intellij/codeInspection/ui/Browser.java index 2aba34c63116..b3e6d6a0a973 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/ui/Browser.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/ui/Browser.java @@ -211,7 +211,7 @@ class Browser extends JPanel { if (psiElement == null) return; VirtualFile vFile = psiElement.getContainingFile().getVirtualFile(); if (vFile != null) { - TextRange range = ((ProblemDescriptorImpl)myCurrentDescriptor).getTextRange(); + TextRange range = ((ProblemDescriptorBase)myCurrentDescriptor).getTextRange(); fireClickEvent(vFile, range.getStartOffset(), range.getEndOffset()); } } diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionResultsView.java b/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionResultsView.java index 4aa80ee686d4..05c84f7683d1 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionResultsView.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionResultsView.java @@ -663,8 +663,8 @@ public class InspectionResultsView extends JPanel implements Disposable, Occuren @Nullable private Navigatable getSelectedNavigatable(final CommonProblemDescriptor descriptor, final PsiElement psiElement) { - if (descriptor instanceof ProblemDescriptorImpl) { - Navigatable navigatable = ((ProblemDescriptorImpl) descriptor).getNavigatable(); + if (descriptor instanceof ProblemDescriptorBase) { + Navigatable navigatable = ((ProblemDescriptorBase) descriptor).getNavigatable(); if (navigatable != null) { return navigatable; } @@ -675,8 +675,8 @@ public class InspectionResultsView extends JPanel implements Disposable, Occuren if (virtualFile != null) { int startOffset = psiElement.getTextOffset(); - if (descriptor instanceof ProblemDescriptorImpl) { - final TextRange textRange = ((ProblemDescriptorImpl)descriptor).getTextRangeForNavigation(); + if (descriptor instanceof ProblemDescriptorBase) { + final TextRange textRange = ((ProblemDescriptorBase)descriptor).getTextRangeForNavigation(); if (textRange != null) { if (virtualFile instanceof VirtualFileWindow) { virtualFile = ((VirtualFileWindow)virtualFile).getDelegate(); diff --git a/plugins/ui-designer/src/com/intellij/uiDesigner/inspections/FormFileErrorCollector.java b/plugins/ui-designer/src/com/intellij/uiDesigner/inspections/FormFileErrorCollector.java index 7edb83f9242f..3fc8ceb9fa1a 100644 --- a/plugins/ui-designer/src/com/intellij/uiDesigner/inspections/FormFileErrorCollector.java +++ b/plugins/ui-designer/src/com/intellij/uiDesigner/inspections/FormFileErrorCollector.java @@ -15,11 +15,7 @@ */ package com.intellij.uiDesigner.inspections; -import com.intellij.codeInspection.InspectionManager; -import com.intellij.codeInspection.LocalQuickFix; -import com.intellij.codeInspection.ProblemDescriptor; -import com.intellij.codeInspection.ProblemHighlightType; -import com.intellij.codeInspection.ex.ProblemDescriptorImpl; +import com.intellij.codeInspection.*; import com.intellij.openapi.util.JDOMUtil; import com.intellij.psi.PsiFile; import com.intellij.uiDesigner.lw.IComponent; @@ -52,10 +48,10 @@ public class FormFileErrorCollector extends FormErrorCollector { final ProblemDescriptor problemDescriptor = myManager.createProblemDescriptor(myFile, JDOMUtil.escapeText(errorMessage), (LocalQuickFix)null, ProblemHighlightType.GENERIC_ERROR_OR_WARNING, myOnTheFly); - if (problemDescriptor instanceof ProblemDescriptorImpl && component != null) { + if (problemDescriptor instanceof ProblemDescriptorBase && component != null) { FormElementNavigatable navigatable = new FormElementNavigatable(myFile.getProject(), myFile.getVirtualFile(), component.getId()); - ((ProblemDescriptorImpl) problemDescriptor).setNavigatable(navigatable); + ((ProblemDescriptorBase) problemDescriptor).setNavigatable(navigatable); } myProblems.add(problemDescriptor); } diff --git a/spellchecker/src/com/intellij/spellchecker/quickfixes/ChangeTo.java b/spellchecker/src/com/intellij/spellchecker/quickfixes/ChangeTo.java index 666e3a1c8751..df01f03c5054 100644 --- a/spellchecker/src/com/intellij/spellchecker/quickfixes/ChangeTo.java +++ b/spellchecker/src/com/intellij/spellchecker/quickfixes/ChangeTo.java @@ -19,7 +19,7 @@ import com.intellij.codeInsight.lookup.LookupElement; import com.intellij.codeInsight.lookup.LookupElementBuilder; import com.intellij.codeInsight.lookup.LookupManager; import com.intellij.codeInspection.ProblemDescriptor; -import com.intellij.codeInspection.ex.ProblemDescriptorImpl; +import com.intellij.codeInspection.ProblemDescriptorBase; import com.intellij.openapi.actionSystem.Anchor; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.project.Project; @@ -65,7 +65,7 @@ public class ChangeTo extends ShowSuggestions implements SpellCheckerQuickFix { return; } - TextRange textRange = ((ProblemDescriptorImpl)descriptor).getTextRange(); + TextRange textRange = ((ProblemDescriptorBase)descriptor).getTextRange(); editor.getSelectionModel().setSelection(textRange.getStartOffset(), textRange.getEndOffset()); String word = editor.getSelectionModel().getSelectedText();