diff --git a/java/java-impl/src/com/intellij/spi/SPIGotoSuperHandler.java b/java/java-impl/src/com/intellij/spi/SPIGotoSuperHandler.java index 966a7a3422ea..4be83981446e 100644 --- a/java/java-impl/src/com/intellij/spi/SPIGotoSuperHandler.java +++ b/java/java-impl/src/com/intellij/spi/SPIGotoSuperHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2015 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,13 +20,14 @@ import com.intellij.psi.PsiElement; import com.intellij.psi.PsiFile; import com.intellij.psi.util.PsiTreeUtil; import com.intellij.spi.psi.SPIClassProviderReferenceElement; +import org.jetbrains.annotations.NotNull; /** * User: anna */ public class SPIGotoSuperHandler extends JavaGotoSuperHandler { @Override - protected PsiElement getElement(PsiFile file, int offset) { + protected PsiElement getElement(@NotNull PsiFile file, int offset) { final SPIClassProviderReferenceElement providerElement = PsiTreeUtil.getParentOfType(super.getElement(file, offset), SPIClassProviderReferenceElement.class); if (providerElement != null) { diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/PsiElementListNavigator.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/PsiElementListNavigator.java index 57f65283fd2f..4eeca2b71704 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/PsiElementListNavigator.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/PsiElementListNavigator.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2015 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -37,6 +37,7 @@ import com.intellij.ui.popup.HintUpdateSupply; import com.intellij.usages.UsageView; import com.intellij.util.Consumer; import com.intellij.util.Processor; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import javax.swing.*; @@ -88,12 +89,12 @@ public class PsiElementListNavigator { } @Nullable - public static JBPopup navigateOrCreatePopup(final NavigatablePsiElement[] targets, + public static JBPopup navigateOrCreatePopup(@NotNull final NavigatablePsiElement[] targets, final String title, final String findUsagesTitle, final ListCellRenderer listRenderer, @Nullable final ListBackgroundUpdaterTask listUpdaterTask, - final Consumer consumer) { + @NotNull final Consumer consumer) { if (targets.length == 0) return null; if (targets.length == 1) { consumer.consume(targets); diff --git a/platform/lang-impl/src/com/intellij/codeInsight/hint/actions/ShowImplementationsAction.java b/platform/lang-impl/src/com/intellij/codeInsight/hint/actions/ShowImplementationsAction.java index 7c3a0ced14d7..c48ae61e93c6 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/hint/actions/ShowImplementationsAction.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/hint/actions/ShowImplementationsAction.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2015 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -105,7 +105,7 @@ public class ShowImplementationsAction extends AnAction implements PopupAction { } - protected Editor getEditor(DataContext dataContext) { + protected static Editor getEditor(@NotNull DataContext dataContext) { Editor editor = CommonDataKeys.EDITOR.getData(dataContext); if (editor == null) { @@ -123,7 +123,7 @@ public class ShowImplementationsAction extends AnAction implements PopupAction { return editor; } - public void performForContext(DataContext dataContext, boolean invokedByShortcut) { + public void performForContext(@NotNull DataContext dataContext, boolean invokedByShortcut) { final Project project = CommonDataKeys.PROJECT.getData(dataContext); if (project == null) return; PsiDocumentManager.getInstance(project).commitAllDocuments(); @@ -185,7 +185,7 @@ public class ShowImplementationsAction extends AnAction implements PopupAction { showImplementations(impls, project, text, editor, file, element, isInvokedFromEditor, invokedByShortcut); } - protected static PsiElement getElement(Project project, PsiFile file, Editor editor, PsiElement element) { + protected static PsiElement getElement(@NotNull Project project, PsiFile file, Editor editor, PsiElement element) { if (element == null && editor != null) { element = TargetElementUtil.findTargetElement(editor, TargetElementUtil.getInstance().getAllAccepted()); final PsiElement adjustedElement = @@ -200,6 +200,7 @@ public class ShowImplementationsAction extends AnAction implements PopupAction { return element; } + @NotNull protected static ImplementationSearcher createImplementationsSearcher() { if (ApplicationManager.getApplication().isUnitTestMode()) { return new ImplementationSearcher() { @@ -209,18 +210,16 @@ public class ShowImplementationsAction extends AnAction implements PopupAction { } }; } - else { - return new ImplementationSearcher.FirstImplementationsSearcher() { - @Override - protected PsiElement[] filterElements(PsiElement element, PsiElement[] targetElements, final int offset) { - return ShowImplementationsAction.filterElements(targetElements); - } - }; - } + return new ImplementationSearcher.FirstImplementationsSearcher() { + @Override + protected PsiElement[] filterElements(PsiElement element, PsiElement[] targetElements, final int offset) { + return ShowImplementationsAction.filterElements(targetElements); + } + }; } - protected void updateElementImplementations(final PsiElement element, final Editor editor, final Project project, final PsiFile file) { - PsiElement[] impls = null; + private void updateElementImplementations(final PsiElement element, final Editor editor, @NotNull Project project, final PsiFile file) { + PsiElement[] impls = {}; String text = ""; if (element != null) { // if (element instanceof PsiPackage) return; @@ -234,10 +233,15 @@ public class ShowImplementationsAction extends AnAction implements PopupAction { showImplementations(impls, project, text, editor, file, element, false, false); } - protected void showImplementations(final PsiElement[] impls, final Project project, final String text, final Editor editor, final PsiFile file, + protected void showImplementations(@NotNull PsiElement[] impls, + @NotNull final Project project, + final String text, + final Editor editor, + final PsiFile file, final PsiElement element, - boolean invokedFromEditor, boolean invokedByShortcut) { - if (impls == null || impls.length == 0) return; + boolean invokedFromEditor, + boolean invokedByShortcut) { + if (impls.length == 0) return; FeatureUsageTracker.getInstance().triggerFeatureUsed(CODEASSISTS_QUICKDEFINITION_FEATURE); if (LookupManager.getInstance(project).getActiveLookup() != null) { @@ -317,7 +321,7 @@ public class ShowImplementationsAction extends AnAction implements PopupAction { } } - private static boolean cancelTask(ImplementationsUpdaterTask task) { + private static boolean cancelTask(@Nullable ImplementationsUpdaterTask task) { if (task != null) { ProgressIndicator indicator = task.myIndicator; if (indicator != null) { @@ -330,9 +334,10 @@ public class ShowImplementationsAction extends AnAction implements PopupAction { private void updateInBackground(Editor editor, @Nullable PsiElement element, - ImplementationViewComponent component, + @NotNull ImplementationViewComponent component, String title, - AbstractPopup popup, Ref usageView) { + @NotNull AbstractPopup popup, + @NotNull Ref usageView) { final ImplementationsUpdaterTask updaterTask = SoftReference.dereference(myTaskRef); cancelTask(updaterTask); @@ -348,15 +353,17 @@ public class ShowImplementationsAction extends AnAction implements PopupAction { return true; } + @NotNull private static PsiElement[] getSelfAndImplementations(Editor editor, - PsiElement element, - final ImplementationSearcher handler) { + @NotNull PsiElement element, + @NotNull ImplementationSearcher handler) { return getSelfAndImplementations(editor, element, handler, !(element instanceof PomTargetPsiElement)); } + @NotNull protected static PsiElement[] getSelfAndImplementations(Editor editor, - PsiElement element, - final ImplementationSearcher handler, + @NotNull PsiElement element, + @NotNull ImplementationSearcher handler, final boolean includeSelfAlways) { int offset = editor == null ? 0 : editor.getCaretModel().getOffset(); final PsiElement[] handlerImplementations = handler.searchImplementations(element, editor, offset, includeSelfAlways, true); @@ -367,17 +374,18 @@ public class ShowImplementationsAction extends AnAction implements PopupAction { // Magically, it's null for ant property declarations. element = element.getNavigationElement(); psiFile = element.getContainingFile(); - if (psiFile == null) return PsiElement.EMPTY_ARRAY; + if (psiFile == null) { + return PsiElement.EMPTY_ARRAY; + } } if (psiFile.getVirtualFile() != null && (element.getTextRange() != null || element instanceof PsiFile)) { return new PsiElement[]{element}; } - else { - return PsiElement.EMPTY_ARRAY; - } + return PsiElement.EMPTY_ARRAY; } - private static PsiElement[] filterElements(final PsiElement[] targetElements) { + @NotNull + private static PsiElement[] filterElements(@NotNull final PsiElement[] targetElements) { final Set unique = new LinkedHashSet(Arrays.asList(targetElements)); for (final PsiElement elt : targetElements) { ApplicationManager.getApplication().runReadAction(new Runnable() { @@ -410,12 +418,13 @@ public class ShowImplementationsAction extends AnAction implements PopupAction { private static class ImplementationsUpdaterTask extends BackgroundUpdaterTask { private final String myCaption; private final Editor myEditor; + @NotNull private final PsiElement myElement; private final boolean myIncludeSelf; private PsiElement[] myElements; private volatile ProgressIndicator myIndicator; - public ImplementationsUpdaterTask(final PsiElement element, final Editor editor, final String caption, boolean includeSelf) { + private ImplementationsUpdaterTask(@NotNull PsiElement element, final Editor editor, final String caption, boolean includeSelf) { super(element.getProject(), ImplementationSearcher.SEARCHING_FOR_IMPLEMENTATIONS); myCaption = caption; myEditor = editor; diff --git a/platform/lang-impl/src/com/intellij/codeInsight/navigation/BackgroundUpdaterTask.java b/platform/lang-impl/src/com/intellij/codeInsight/navigation/BackgroundUpdaterTask.java index 397889c8e1cf..85cd0952c0ad 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/navigation/BackgroundUpdaterTask.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/navigation/BackgroundUpdaterTask.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 JetBrains s.r.o. + * Copyright 2000-2015 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,8 +21,6 @@ import com.intellij.openapi.progress.PerformInBackgroundOption; import com.intellij.openapi.progress.ProgressIndicator; import com.intellij.openapi.progress.Task; import com.intellij.openapi.project.Project; -import com.intellij.openapi.ui.popup.JBPopupAdapter; -import com.intellij.openapi.ui.popup.LightweightWindowEvent; import com.intellij.openapi.util.Ref; import com.intellij.psi.PsiElement; import com.intellij.ui.popup.AbstractPopup; @@ -69,7 +67,7 @@ public abstract class BackgroundUpdaterTask extends Task.Backgroundable { super(project, title, canBeCancelled, backgroundOption); } - public void init(@NotNull AbstractPopup popup, T component, Ref usageView) { + public void init(@NotNull AbstractPopup popup, @NotNull T component, @NotNull Ref usageView) { myPopup = popup; myComponent = component; myUsageView = usageView;