This commit is contained in:
Alexey Kudravtsev
2012-08-31 11:51:17 +04:00
parent ab20a93bc9
commit 77a7550046
16 changed files with 108 additions and 58 deletions
@@ -20,10 +20,12 @@ import com.intellij.psi.presentation.java.ClassPresentationUtil;
import org.jetbrains.annotations.Nullable;
public class PsiClassListCellRenderer extends PsiElementListCellRenderer<PsiClass> {
@Override
public String getElementText(PsiClass element) {
return ClassPresentationUtil.getNameForClass(element, false);
}
@Override
protected String getContainerText(PsiClass element, final String name) {
return getContainerTextStatic(element);
}
@@ -33,12 +35,13 @@ public class PsiClassListCellRenderer extends PsiElementListCellRenderer<PsiClas
PsiFile file = element.getContainingFile();
if (file instanceof PsiClassOwner) {
String packageName = ((PsiClassOwner)file).getPackageName();
if (packageName.length() == 0) return null;
if (packageName.isEmpty()) return null;
return "(" + packageName + ")";
}
return null;
}
@Override
protected int getIconFlags() {
return 0;
}
@@ -204,6 +204,7 @@ public abstract class FindManager {
*
* @param element the element to find the usages for.
* @param showDialog true if find usages settings dialog needs to be shown.
* @since idea 12
*/
public abstract void findUsages(@NotNull PsiElement element, boolean showDialog);
@@ -30,6 +30,7 @@ import com.intellij.openapi.project.DumbAware;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Comparing;
import com.intellij.psi.PsiFile;
import org.jetbrains.annotations.NotNull;
public class ShowErrorDescriptionAction extends BaseCodeInsightAction implements DumbAware {
private static int width;
@@ -58,7 +59,7 @@ public class ShowErrorDescriptionAction extends BaseCodeInsightAction implements
}
@Override
public void beforeActionPerformedUpdate(final AnActionEvent e) {
public void beforeActionPerformedUpdate(@NotNull final AnActionEvent e) {
super.beforeActionPerformedUpdate(e);
changeState();
}
@@ -40,7 +40,7 @@ import com.intellij.openapi.util.Comparing;
import com.intellij.openapi.vcs.FileStatusManager;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.*;
import com.intellij.psi.util.PsiUtilBase;
import com.intellij.psi.util.PsiUtilCore;
import com.intellij.ui.IdeBorderFactory;
import com.intellij.ui.ListCellRendererWrapper;
import com.intellij.ui.SideBorder;
@@ -52,6 +52,7 @@ import com.intellij.usages.UsageViewManager;
import com.intellij.usages.UsageViewPresentation;
import com.intellij.util.PairFunction;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.TestOnly;
@@ -177,7 +178,7 @@ public class ImplementationViewComponent extends JPanel {
update(elements, new PairFunction<PsiElement[], List<FileDescriptor>, Boolean>() {
@Override
public Boolean fun(final PsiElement[] psiElements, final List<FileDescriptor> fileDescriptors) {
if (psiElements == null || psiElements.length == 0) return false;
if (psiElements.length == 0) return false;
myElements = psiElements;
myIndex = index < myElements.length ? index : 0;
@@ -201,6 +202,7 @@ public class ImplementationViewComponent extends JPanel {
updateRenderer(project);
myFileChooser.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
int index = myFileChooser.getSelectedIndex();
if (myIndex != index) {
@@ -270,11 +272,11 @@ public class ImplementationViewComponent extends JPanel {
return result;
}
public void update(final PsiElement[] elements, final int index) {
public void update(@NotNull final PsiElement[] elements, final int index) {
update(elements, new PairFunction<PsiElement[], List<FileDescriptor>, Boolean>() {
@Override
public Boolean fun(PsiElement[] psiElements, List<FileDescriptor> fileDescriptors) {
if (psiElements == null || psiElements.length == 0) return false;
if (psiElements.length == 0) return false;
final Project project = psiElements[0].getProject();
myElements = psiElements;
@@ -326,7 +328,7 @@ public class ImplementationViewComponent extends JPanel {
}
private static void update(final PsiElement[] elements, final PairFunction<PsiElement[], List<FileDescriptor>, Boolean> fun) {
private static void update(@NotNull PsiElement[] elements, @NotNull PairFunction<PsiElement[], List<FileDescriptor>, Boolean> fun) {
List<PsiElement> candidates = new ArrayList<PsiElement>(elements.length);
List<FileDescriptor> files = new ArrayList<FileDescriptor>(elements.length);
final Set<String> names = new HashSet<String>();
@@ -343,7 +345,7 @@ public class ImplementationViewComponent extends JPanel {
candidates.add(element.getNavigationElement());
}
fun.fun(PsiUtilBase.toPsiElementArray(candidates), files);
fun.fun(PsiUtilCore.toPsiElementArray(candidates), files);
}
private static Icon getIconForFile(PsiFile psiFile) {
@@ -405,8 +407,10 @@ public class ImplementationViewComponent extends JPanel {
final String newText = getNewText(elt);
if (newText == null || Comparing.strEqual(newText, myEditor.getDocument().getText())) return;
CommandProcessor.getInstance().runUndoTransparentAction(new Runnable() {
@Override
public void run() {
ApplicationManager.getApplication().runWriteAction(new Runnable() {
@Override
public void run() {
Document fragmentDoc = myEditor.getDocument();
fragmentDoc.setReadOnly(false);
@@ -445,6 +449,7 @@ public class ImplementationViewComponent extends JPanel {
return psiFile.getOriginalFile();
}
@Override
public void removeNotify() {
super.removeNotify();
EditorFactory.getInstance().releaseEditor(myEditor);
@@ -507,11 +512,13 @@ public class ImplementationViewComponent extends JPanel {
super(CodeInsightBundle.message("quick.definition.back"), null, AllIcons.Actions.Back);
}
@Override
public void actionPerformed(AnActionEvent e) {
goBack();
}
@Override
public void update(AnActionEvent e) {
Presentation presentation = e.getPresentation();
presentation.setEnabled(myIndex > 0);
@@ -523,10 +530,12 @@ public class ImplementationViewComponent extends JPanel {
super(CodeInsightBundle.message("quick.definition.forward"), null, AllIcons.Actions.Forward);
}
@Override
public void actionPerformed(AnActionEvent e) {
goForward();
}
@Override
public void update(AnActionEvent e) {
Presentation presentation = e.getPresentation();
presentation.setEnabled(myElements != null && myIndex < myElements.length - 1);
@@ -560,10 +569,12 @@ public class ImplementationViewComponent extends JPanel {
myFocusEditor = focusEditor;
}
@Override
public void update(AnActionEvent e) {
e.getPresentation().setEnabled(myFileChooser == null || !myFileChooser.isPopupVisible());
}
@Override
public void actionPerformed(AnActionEvent e) {
PsiElement element = myElements[myIndex];
PsiElement navigationElement = element.getNavigationElement();
@@ -617,6 +628,6 @@ public class ImplementationViewComponent extends JPanel {
result.add(element);
}
}
return PsiUtilBase.toPsiElementArray(result);
return PsiUtilCore.toPsiElementArray(result);
}
}
@@ -17,10 +17,10 @@ package com.intellij.codeInsight.hint.actions;
import com.intellij.codeInsight.CodeInsightBundle;
import com.intellij.codeInsight.TargetElementUtilBase;
import com.intellij.codeInsight.navigation.BackgroundUpdaterTask;
import com.intellij.codeInsight.documentation.DocumentationManager;
import com.intellij.codeInsight.hint.ImplementationViewComponent;
import com.intellij.codeInsight.lookup.LookupManager;
import com.intellij.codeInsight.navigation.BackgroundUpdaterTask;
import com.intellij.codeInsight.navigation.ImplementationSearcher;
import com.intellij.featureStatistics.FeatureUsageTracker;
import com.intellij.ide.DataManager;
@@ -41,7 +41,7 @@ import com.intellij.pom.PomTargetPsiElement;
import com.intellij.psi.*;
import com.intellij.psi.presentation.java.SymbolPresentationUtil;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.psi.util.PsiUtilBase;
import com.intellij.psi.util.PsiUtilCore;
import com.intellij.ui.popup.AbstractPopup;
import com.intellij.ui.popup.NotLookupOrSearchCondition;
import com.intellij.ui.popup.PopupPositionManager;
@@ -64,6 +64,7 @@ public class ShowImplementationsAction extends AnAction implements PopupAction {
setInjectedContext(true);
}
@Override
public void actionPerformed(AnActionEvent e) {
performForContext(e.getDataContext());
}
@@ -96,10 +97,6 @@ public class ShowImplementationsAction extends AnAction implements PopupAction {
PsiFile containingFile = element != null ? element.getContainingFile() : file;
if (containingFile == null || !containingFile.getViewProvider().isPhysical()) return;
String text = "";
PsiElement[] impls = new PsiElement[0];
PsiReference ref = null;
final PsiElement adjustedElement =
TargetElementUtilBase.getInstance().adjustElement(editor, TargetElementUtilBase.getInstance().getAllAccepted(), element, null);
if (adjustedElement != null) {
@@ -108,6 +105,7 @@ public class ShowImplementationsAction extends AnAction implements PopupAction {
element = DocumentationManager.getInstance(project).getElementFromLookup(editor, file);
}
PsiReference ref = null;
if (editor != null) {
ref = TargetElementUtilBase.findReference(editor, editor.getCaretModel().getOffset());
if (element == null && ref != null) {
@@ -115,6 +113,8 @@ public class ShowImplementationsAction extends AnAction implements PopupAction {
}
}
String text = "";
PsiElement[] impls = new PsiElement[0];
if (element != null) {
//if (element instanceof PsiPackage) return;
@@ -146,17 +146,18 @@ public class ShowImplementationsAction extends AnAction implements PopupAction {
}
private static ImplementationSearcher createImplementationsSearcher() {
if (!ApplicationManager.getApplication().isUnitTestMode()) {
return new ImplementationSearcher.FirstImplementationsSearcher() {
protected PsiElement[] filterElements(PsiElement element, PsiElement[] targetElements, final int offset) {
if (ApplicationManager.getApplication().isUnitTestMode()) {
return new ImplementationSearcher() {
@Override
protected PsiElement[] filterElements(PsiElement element, PsiElement[] targetElements, int offset) {
return ShowImplementationsAction.filterElements(targetElements);
}
};
}
else {
return new ImplementationSearcher() {
return new ImplementationSearcher.FirstImplementationsSearcher() {
@Override
protected PsiElement[] filterElements(PsiElement element, PsiElement[] targetElements, int offset) {
protected PsiElement[] filterElements(PsiElement element, PsiElement[] targetElements, final int offset) {
return ShowImplementationsAction.filterElements(targetElements);
}
};
@@ -213,6 +214,7 @@ public class ShowImplementationsAction extends AnAction implements PopupAction {
final ImplementationViewComponent component = new ImplementationViewComponent(impls, index);
if (component.hasElementsToShow()) {
final PopupUpdateProcessor updateProcessor = new PopupUpdateProcessor(project) {
@Override
public void updatePopup(Object lookupItemObject) {
final PsiElement element = lookupItemObject instanceof PsiElement ? (PsiElement)lookupItemObject : DocumentationManager.getInstance(project).getElementFromLookup(editor, file);
updateElementImplementations(element, editor, project, file);
@@ -302,7 +304,7 @@ public class ShowImplementationsAction extends AnAction implements PopupAction {
break;
}
}
return PsiUtilBase.toPsiElementArray(unique);
return PsiUtilCore.toPsiElementArray(unique);
}
@Override
@@ -341,12 +343,12 @@ public class ShowImplementationsAction extends AnAction implements PopupAction {
final int startIdx = elements.length - includeSelfIdx;
final PsiElement[] result = new PsiElement[data.size() + includeSelfIdx];
System.arraycopy(elements, 0, result, 0, elements.length);
System.arraycopy(data.toArray(PsiElement.EMPTY_ARRAY), startIdx, result, elements.length, data.size() - startIdx);
System.arraycopy(PsiUtilCore.toPsiElementArray(data), startIdx, result, elements.length, data.size() - startIdx);
myComponent.update(result, myComponent.getIndex());
}
@Override
public void run(final @NotNull ProgressIndicator indicator) {
public void run(@NotNull final ProgressIndicator indicator) {
super.run(indicator);
myElements =
getSelfAndImplementations(myEditor, myElement, new ImplementationSearcher.BackgroundableImplementationSearcher() {
@@ -39,9 +39,9 @@ import java.util.List;
public abstract class BackgroundUpdaterTask<T> extends Task.Backgroundable {
protected AbstractPopup myPopup;
protected T myComponent;
private List<PsiElement> myData = new ArrayList<PsiElement>();
private final List<PsiElement> myData = new ArrayList<PsiElement>();
private Alarm myAlarm = new Alarm(Alarm.ThreadToUse.SWING_THREAD);
private final Alarm myAlarm = new Alarm(Alarm.ThreadToUse.SWING_THREAD);
private final Object lock = new Object();
private volatile boolean myCanceled = false;
@@ -61,7 +61,7 @@ public abstract class BackgroundUpdaterTask<T> extends Task.Backgroundable {
super(project, title, canBeCancelled, backgroundOption);
}
public void init(AbstractPopup popup, T component) {
public void init(@NotNull AbstractPopup popup, T component) {
myPopup = popup;
myComponent = component;
@@ -34,10 +34,12 @@ import java.util.Collections;
import java.util.Map;
public class GotoImplementationHandler extends GotoTargetHandler {
@Override
protected String getFeatureUsedKey() {
return "navigation.goto.implementation";
}
@Override
@Nullable
public GotoData getSourceAndTargetElements(Editor editor, PsiFile file) {
int offset = editor.getCaretModel().getOffset();
@@ -55,6 +57,7 @@ public class GotoImplementationHandler extends GotoTargetHandler {
return gotoData;
}
@Override
protected String getChooserTitle(PsiElement sourceElement, String name, int length) {
return CodeInsightBundle.message("goto.implementation.chooserTitle", name, length);
}
@@ -65,9 +68,9 @@ public class GotoImplementationHandler extends GotoTargetHandler {
}
private class ImplementationsUpdaterTask extends ListBackgroundUpdaterTask {
private Editor myEditor;
private int myOffset;
private GotoData myGotoData;
private final Editor myEditor;
private final int myOffset;
private final GotoData myGotoData;
private final Map<Object, PsiElementListCellRenderer> renderers = new HashMap<Object, PsiElementListCellRenderer>();
public ImplementationsUpdaterTask(GotoData gotoData, Editor editor, int offset) {
@@ -78,7 +81,7 @@ public class GotoImplementationHandler extends GotoTargetHandler {
}
@Override
public void run(final @NotNull ProgressIndicator indicator) {
public void run(@NotNull final ProgressIndicator indicator) {
super.run(indicator);
for (PsiElement element : myGotoData.targets) {
if (!updateComponent(element, createComparator(renderers, myGotoData))) {
@@ -86,6 +89,7 @@ public class GotoImplementationHandler extends GotoTargetHandler {
}
}
new ImplementationSearcher.BackgroundableImplementationSearcher() {
@Override
protected void processElement(PsiElement element) {
if (myGotoData.addTarget(element)) {
if (!updateComponent(element, createComparator(renderers, myGotoData))) {
@@ -43,7 +43,6 @@ import com.intellij.ui.popup.AbstractPopup;
import com.intellij.util.ArrayUtil;
import com.intellij.util.Function;
import com.intellij.util.containers.HashSet;
import gnu.trove.THashMap;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -54,13 +53,15 @@ import java.util.*;
import java.util.List;
public abstract class GotoTargetHandler implements CodeInsightActionHandler {
private static PsiElementListCellRenderer ourDefaultTargetElementRenderer = new DefaultPsiElementListCellRenderer();
private DefaultListCellRenderer myActionElementRenderer = new ActionCellRenderer();
private static final PsiElementListCellRenderer ourDefaultTargetElementRenderer = new DefaultPsiElementListCellRenderer();
private final DefaultListCellRenderer myActionElementRenderer = new ActionCellRenderer();
@Override
public boolean startInWriteAction() {
return false;
}
@Override
public void invoke(@NotNull Project project, @NotNull Editor editor, @NotNull PsiFile file) {
FeatureUsageTracker.getInstance().triggerFeatureUsed(getFeatureUsedKey());
@@ -116,7 +117,7 @@ public abstract class GotoTargetHandler implements CodeInsightActionHandler {
Collections.addAll(allElements, targets);
allElements.addAll(additionalActions);
final JBListWithHintProvider list = new JBListWithHintProvider(new CollectionListModel(allElements)) {
final JBListWithHintProvider list = new JBListWithHintProvider(new CollectionListModel<Object>(allElements)) {
@Override
protected PsiElement getPsiElementForHint(final Object selectedValue) {
return selectedValue instanceof PsiElement ? (PsiElement) selectedValue : null;
@@ -136,6 +137,7 @@ public abstract class GotoTargetHandler implements CodeInsightActionHandler {
});
final Runnable runnable = new Runnable() {
@Override
public void run() {
int[] ids = list.getSelectedIndices();
if (ids == null || ids.length == 0) return;
@@ -289,7 +291,7 @@ public abstract class GotoTargetHandler implements CodeInsightActionHandler {
final String name = ApplicationManager.getApplication().runReadAction(new Computable<String>() {
@Override
public String compute() {
return ((PsiNamedElement)element).getName();
return ((PsiNamedElement)element).getName();
}
});
myNames.add(name);
@@ -304,6 +306,7 @@ public abstract class GotoTargetHandler implements CodeInsightActionHandler {
}
private static class DefaultPsiElementListCellRenderer extends PsiElementListCellRenderer {
@Override
public String getElementText(final PsiElement element) {
if (element instanceof PsiNamedElement) {
String name = ((PsiNamedElement)element).getName();
@@ -314,6 +317,7 @@ public abstract class GotoTargetHandler implements CodeInsightActionHandler {
return element.getContainingFile().getName();
}
@Override
protected String getContainerText(final PsiElement element, final String name) {
if (element instanceof NavigationItem) {
final ItemPresentation presentation = ((NavigationItem)element).getPresentation();
@@ -323,12 +327,13 @@ public abstract class GotoTargetHandler implements CodeInsightActionHandler {
return null;
}
@Override
protected int getIconFlags() {
return 0;
}
}
private class ActionCellRenderer extends DefaultListCellRenderer {
private static class ActionCellRenderer extends DefaultListCellRenderer {
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
Component result = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
@@ -24,14 +24,17 @@ import com.intellij.openapi.project.DumbAware;
import com.intellij.psi.search.searches.DefinitionsSearch;
public class GotoImplementationAction extends BaseCodeInsightAction implements DumbAware {
@Override
protected CodeInsightActionHandler getHandler(){
return new GotoImplementationHandler();
}
@Override
protected boolean isValidForLookup() {
return true;
}
@Override
public void update(final AnActionEvent event) {
if (!DefinitionsSearch.INSTANCE.hasAnyExecutors()) {
event.getPresentation().setVisible(false);
@@ -38,7 +38,6 @@ import com.intellij.usages.UsageView;
import org.jetbrains.annotations.NotNull;
public class FindUsagesAction extends AnAction {
public FindUsagesAction() {
setInjectedContext(true);
}
@@ -58,6 +58,7 @@ public abstract class PsiElementListCellRenderer<T extends PsiElement> extends J
super(new BorderLayout());
}
@Override
public void setPatternMatcher(final Matcher matcher) {
myMatcher = matcher;
}
@@ -88,6 +89,7 @@ public abstract class PsiElementListCellRenderer<T extends PsiElement> extends J
myMatcher = matcher;
}
@Override
protected void customizeCellRenderer(JList list, Object value, int index, boolean selected, boolean hasFocus) {
Color bgColor = UIUtil.getListBackground();
Color color = list.getForeground();
@@ -163,6 +165,7 @@ public abstract class PsiElementListCellRenderer<T extends PsiElement> extends J
return attributes;
}
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
removeAll();
DefaultListCellRenderer rightRenderer = getRightCellRenderer(value);
@@ -223,6 +226,7 @@ public abstract class PsiElementListCellRenderer<T extends PsiElement> extends J
public Comparator<T> getComparator() {
return new Comparator<T>() {
@Override
public int compare(T o1, T o2) {
return getComparingObject(o1).compareTo(getComparingObject(o2));
}
@@ -242,9 +246,10 @@ public abstract class PsiElementListCellRenderer<T extends PsiElement> extends J
public void installSpeedSearch(PopupChooserBuilder builder, final boolean includeContainerText) {
builder.setFilteringEnabled(new Function<Object, String>() {
@Override
public String fun(Object o) {
if (o instanceof PsiElement) {
final String elementText = PsiElementListCellRenderer.this.getElementText((T)o);
final String elementText = getElementText((T)o);
if (includeContainerText) {
return elementText + " " + getContainerText((T)o, elementText);
}
@@ -263,6 +268,7 @@ public abstract class PsiElementListCellRenderer<T extends PsiElement> extends J
@Deprecated
public void installSpeedSearch(JList list) {
new ListSpeedSearch(list) {
@Override
protected String getElementText(Object o) {
if (o instanceof PsiElement) {
final String elementText = PsiElementListCellRenderer.this.getElementText((T)o);
@@ -162,6 +162,7 @@ public abstract class AnAction implements PossiblyDumbAware {
public final void registerCustomShortcutSet(@NotNull ShortcutSet shortcutSet, @NotNull final JComponent component, @NotNull Disposable parentDisposable) {
registerCustomShortcutSet(shortcutSet, component);
Disposer.register(parentDisposable, new Disposable() {
@Override
public void dispose() {
unregisterCustomShortcutSet(component);
}
@@ -191,7 +192,7 @@ public abstract class AnAction implements PossiblyDumbAware {
copyShortcutFrom(sourceAction);
}
public final void copyShortcutFrom(final AnAction sourceAction) {
public final void copyShortcutFrom(@NotNull AnAction sourceAction) {
myShortcutSet = sourceAction.myShortcutSet;
}
@@ -235,7 +236,7 @@ public abstract class AnAction implements PossiblyDumbAware {
*
* @param e Carries information on the invocation place and data available
*/
public void beforeActionPerformedUpdate(AnActionEvent e) {
public void beforeActionPerformedUpdate(@NotNull AnActionEvent e) {
boolean worksInInjected = isInInjectedContext();
e.setInjectedContext(worksInInjected);
update(e);
@@ -251,11 +252,13 @@ public abstract class AnAction implements PossiblyDumbAware {
*
* @return template presentation
*/
@NotNull
public final Presentation getTemplatePresentation() {
if (myTemplatePresentation == null){
myTemplatePresentation = new Presentation();
Presentation presentation = myTemplatePresentation;
if (presentation == null){
myTemplatePresentation = presentation = new Presentation();
}
return myTemplatePresentation;
return presentation;
}
/**
@@ -269,13 +272,13 @@ public abstract class AnAction implements PossiblyDumbAware {
myShortcutSet = shortcutSet;
}
public static String createTooltipText(String s, AnAction action) {
String toolTipText = s != null ? s : "";
public static String createTooltipText(String s, @NotNull AnAction action) {
String toolTipText = s == null ? "" : s;
while (StringUtil.endsWithChar(toolTipText, '.')) {
toolTipText = toolTipText.substring(0, toolTipText.length() - 1);
}
String shortcutsText = KeymapUtil.getFirstKeyboardShortcutText(action);
if (shortcutsText.length() > 0) {
if (!shortcutsText.isEmpty()) {
toolTipText += " (" + shortcutsText + ")";
}
return toolTipText;
@@ -309,12 +312,12 @@ public abstract class AnAction implements PossiblyDumbAware {
return this instanceof TransparentUpdate;
}
@Override
public boolean isDumbAware() {
return this instanceof DumbAware;
}
public interface TransparentUpdate {
}
@Nullable
@@ -19,6 +19,7 @@ package com.intellij.openapi.actionSystem;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.DumbAware;
import com.intellij.util.ConcurrencyUtil;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import java.util.concurrent.ExecutorService;
@@ -64,7 +65,7 @@ public abstract class AsyncUpdateAction<T> extends AnAction {
}
// Sync update
public final void beforeActionPerformedUpdate(AnActionEvent e) {
public final void beforeActionPerformedUpdate(@NotNull AnActionEvent e) {
performUpdate(e.getPresentation(), prepareDataFromContext(e));
}
@@ -171,14 +171,15 @@ public class KeymapUtil {
}
final String keyModifiersText = KeyEvent.getKeyModifiersText(modifiers);
if (!keyModifiersText.isEmpty()) {
return keyModifiersText + "+";
} else {
if (keyModifiersText.isEmpty()) {
return keyModifiersText;
}
else {
return keyModifiersText + "+";
}
}
public static String getFirstKeyboardShortcutText(AnAction action) {
public static String getFirstKeyboardShortcutText(@NotNull AnAction action) {
Shortcut[] shortcuts = action.getShortcutSet().getShortcuts();
for (Shortcut shortcut : shortcuts) {
if (shortcut instanceof KeyboardShortcut) {
@@ -17,6 +17,7 @@
package com.intellij.ui;
import com.intellij.util.ui.EditableModel;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
@@ -36,10 +37,12 @@ public class CollectionListModel<T> extends AbstractListModel implements Editabl
myItems = new ArrayList<T>(Arrays.asList(items));
}
@Override
public int getSize() {
return myItems.size();
}
@Override
public T getElementAt(final int index) {
return myItems.get(index);
}
@@ -51,8 +54,7 @@ public class CollectionListModel<T> extends AbstractListModel implements Editabl
}
public void add(@NotNull final List<? extends T> elements) {
if (elements.isEmpty())
return;
if (elements.isEmpty()) return;
int i = myItems.size();
myItems.addAll(elements);
fireIntervalAdded(this, i, i + elements.size() - 1);
@@ -121,6 +123,7 @@ public class CollectionListModel<T> extends AbstractListModel implements Editabl
return true;
}
@NonNls
@Override
public String toString() {
return getClass().getName() + " (" + getSize() + " elements)";
@@ -95,6 +95,7 @@ public class GroovyMarkerTypes {
return builder.toString();
}
}, new LineMarkerNavigator() {
@Override
public void browse(MouseEvent e, PsiElement element) {
PsiElement parent = element.getParent();
if (!(parent instanceof GrField)) return;
@@ -104,7 +105,7 @@ public class GroovyMarkerTypes {
for (GrAccessorMethod method : accessors) {
Collections.addAll(superMethods, method.findSuperMethods(false));
}
if (superMethods.size() == 0) return;
if (superMethods.isEmpty()) return;
final PsiMethod[] supers = ContainerUtil.toArray(superMethods, new PsiMethod[superMethods.size()]);
boolean showMethodNames = !PsiUtil.allMethodsHaveSameSignature(supers);
PsiElementListNavigator.openTargets(e, supers, DaemonBundle.message("navigation.title.super.method", field.getName()),
@@ -153,6 +154,7 @@ public class GroovyMarkerTypes {
final CommonProcessors.CollectProcessor<PsiMethod> collectProcessor = new CommonProcessors.CollectProcessor<PsiMethod>(new THashSet<PsiMethod>());
if (!ProgressManager.getInstance().runProcessWithProgressSynchronously(new Runnable() {
@Override
public void run() {
for (GrAccessorMethod method : GroovyPropertyUtils.getFieldAccessors(field)) {
OverridingMethodsSearch.search(method, true).forEach(collectProcessor);
@@ -173,13 +175,14 @@ public class GroovyMarkerTypes {
}
);
public static final MarkerType OVERRIDING_METHOD = new MarkerType(new NullableFunction<PsiElement, String>() {
@Override
public String fun(PsiElement element) {
PsiElement parent = element.getParent();
if (!(parent instanceof GrMethod)) return null;
GrMethod method = (GrMethod)parent;
Set<PsiMethod> superMethods = collectSuperMethods(method);
if (superMethods.size() == 0) return null;
if (superMethods.isEmpty()) return null;
PsiMethod superMethod = superMethods.iterator().next();
boolean isAbstract = method.hasModifierProperty(PsiModifier.ABSTRACT);
@@ -196,13 +199,14 @@ public class GroovyMarkerTypes {
return GutterIconTooltipHelper.composeText(superMethods, "", DaemonBundle.message(key));
}
}, new LineMarkerNavigator(){
@Override
public void browse(MouseEvent e, PsiElement element) {
PsiElement parent = element.getParent();
if (!(parent instanceof GrMethod)) return;
GrMethod method = (GrMethod)parent;
Set<PsiMethod> superMethods = collectSuperMethods(method);
if (superMethods.size() == 0) return;
if (superMethods.isEmpty()) return;
PsiElementListNavigator.openTargets(e, superMethods.toArray(new NavigatablePsiElement[superMethods.size()]),
DaemonBundle.message("navigation.title.super.method", method.getName()),
new MethodCellRenderer(true));
@@ -210,6 +214,7 @@ public class GroovyMarkerTypes {
}
});
public static final MarkerType OVERRIDEN_METHOD = new MarkerType(new NullableFunction<PsiElement, String>() {
@Override
public String fun(PsiElement element) {
PsiElement parent = element.getParent();
if (!(parent instanceof GrMethod)) return null;
@@ -238,6 +243,7 @@ public class GroovyMarkerTypes {
return GutterIconTooltipHelper.composeText(overridings, start, pattern);
}
}, new LineMarkerNavigator(){
@Override
public void browse(MouseEvent e, PsiElement element) {
PsiElement parent = element.getParent();
if (!(parent instanceof GrMethod)) return;
@@ -252,6 +258,7 @@ public class GroovyMarkerTypes {
final PsiElementProcessor.CollectElementsWithLimit<PsiMethod> collectProcessor =
new PsiElementProcessor.CollectElementsWithLimit<PsiMethod>(2, new THashSet<PsiMethod>());
if (!ProgressManager.getInstance().runProcessWithProgressSynchronously(new Runnable() {
@Override
public void run() {
for (GrMethod m : PsiImplUtil.getMethodOrReflectedMethods(method)) {
OverridingMethodsSearch.search(m, true).forEach(new ReadActionProcessor<PsiMethod>() {
@@ -333,7 +340,7 @@ public class GroovyMarkerTypes {
}
@Override
public void run(final @NotNull ProgressIndicator indicator) {
public void run(@NotNull final ProgressIndicator indicator) {
super.run(indicator);
for (PsiMethod method : PsiImplUtil.getMethodOrReflectedMethods(myMethod)) {
OverridingMethodsSearch.search(method, true).forEach(