This commit is contained in:
Alexey Kudravtsev
2014-06-19 13:39:32 +04:00
parent b21e515794
commit 3b16bbb193
8 changed files with 28 additions and 14 deletions
@@ -757,6 +757,7 @@ public class JavaFindUsagesHandler extends FindUsagesHandler{
}
@NotNull
@Override
public Collection<PsiReference> findReferencesToHighlight(@NotNull final PsiElement target, @NotNull final SearchScope searchScope) {
if (target instanceof PsiMethod) {
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* Copyright 2000-2014 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.
@@ -27,17 +27,14 @@ import java.util.concurrent.atomic.AtomicReference;
public class TooManyUsagesStatus {
private static final Key<TooManyUsagesStatus> KEY = Key.create("TooManyUsagesStatus");
private static final Null NULL = new Null();
private static final NullStatus NULL_STATUS = new NullStatus();
@NotNull
public static TooManyUsagesStatus getFrom(@Nullable ProgressIndicator indicator) {
TooManyUsagesStatus data = null;
if (indicator instanceof UserDataHolder) {
data = ((UserDataHolder)indicator).getUserData(KEY);
}
if (data == null) data = NULL;
return data;
TooManyUsagesStatus data = indicator instanceof UserDataHolder ? ((UserDataHolder)indicator).getUserData(KEY) : null;
return data == null ? NULL_STATUS : data;
}
public static TooManyUsagesStatus createFor(@NotNull ProgressIndicator indicator) {
TooManyUsagesStatus data = null;
if (indicator instanceof UserDataHolder) {
@@ -76,7 +73,7 @@ public class TooManyUsagesStatus {
}
}
private static class Null extends TooManyUsagesStatus {
private static class NullStatus extends TooManyUsagesStatus {
@Override
public boolean switchTooManyUsagesStatus() {
return false;
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2014 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.
@@ -143,6 +143,7 @@ public abstract class AbstractFindUsagesDialog extends DialogWrapper {
return panel;
}
@NotNull
public final FindUsagesOptions calcFindUsagesOptions() {
calcFindUsagesOptions(myFindUsagesOptions);
return myFindUsagesOptions;
@@ -47,6 +47,7 @@ import java.util.Collections;
*/
public abstract class FindUsagesHandler {
// return this handler if you want to cancel the search
@NotNull
public static final FindUsagesHandler NULL_HANDLER = new FindUsagesHandler(PsiUtilCore.NULL_PSI_ELEMENT){};
private final PsiElement myPsiElement;
@@ -204,6 +205,7 @@ public abstract class FindUsagesHandler {
return false;
}
@NotNull
public Collection<PsiReference> findReferencesToHighlight(@NotNull PsiElement target, @NotNull SearchScope searchScope) {
return ReferencesSearch.search(target, searchScope, false).findAll();
}
@@ -116,6 +116,7 @@ public class PsiElement2UsageTargetAdapter
return getElement();
}
@Override
public String toString() {
return getPresentableText();
}
@@ -209,7 +210,7 @@ public class PsiElement2UsageTargetAdapter
@Override
public String getLongDescriptiveName() {
SearchScope searchScope = myOptions.searchScope;
String scopeString = searchScope == null ? null : searchScope.getDisplayName();
String scopeString = searchScope.getDisplayName();
PsiElement psiElement = getElement();
return psiElement == null ? UsageViewBundle.message("node.invalid") :
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2014 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.
@@ -55,10 +55,12 @@ public class BackgroundableProcessIndicator extends ProgressWindow {
if (myDumbModeAction == DumbModeAction.CANCEL) {
task.getProject().getMessageBus().connect(this).subscribe(DumbService.DUMB_MODE, new DumbService.DumbModeListener() {
@Override
public void enteredDumbMode() {
cancel();
}
@Override
public void exitDumbMode() {
}
});
@@ -69,6 +71,7 @@ public class BackgroundableProcessIndicator extends ProgressWindow {
super(info.isCancellable(), true, project, info.getCancelText());
if (project != null) {
final ProjectManagerAdapter myListener = new ProjectManagerAdapter() {
@Override
public void projectClosing(Project closingProject) {
if (isRunning()) {
cancel();
@@ -107,23 +110,28 @@ public class BackgroundableProcessIndicator extends ProgressWindow {
@Nls final String cancelButtonText,
@Nls final String backgroundStopTooltip, final boolean cancellable) {
this(project, new TaskInfo() {
@Override
public String getProcessId() {
return "<unknown>";
}
@Override
@NotNull
public String getTitle() {
return progressTitle;
}
@Override
public String getCancelText() {
return cancelButtonText;
}
@Override
public String getCancelTooltipText() {
return backgroundStopTooltip;
}
@Override
public boolean isCancellable() {
return cancellable;
}
@@ -134,6 +142,7 @@ public class BackgroundableProcessIndicator extends ProgressWindow {
return myDumbModeAction;
}
@Override
protected void showDialog() {
if (myDisposed) return;
@@ -144,6 +153,7 @@ public class BackgroundableProcessIndicator extends ProgressWindow {
super.showDialog();
}
@Override
public void background() {
if (myDisposed) return;
@@ -158,6 +168,7 @@ public class BackgroundableProcessIndicator extends ProgressWindow {
}
}
@Override
public void dispose() {
super.dispose();
myDisposed = true;
@@ -174,7 +174,7 @@ public class UsageViewManagerImpl extends UsageViewManager {
final SearchForUsagesRunnable runnable = new SearchForUsagesRunnable(myProject, usageView, presentation, searchFor, searcherFactory, processPresentation, listener);
final Factory<ProgressIndicator> progressIndicatorFactory = processPresentation.getProgressIndicatorFactory();
final ProgressIndicator progressIndicator = progressIndicatorFactory != null ? progressIndicatorFactory.create() : null;
final ProgressIndicator progressIndicator = progressIndicatorFactory == null ? null : progressIndicatorFactory.create();
final AtomicBoolean findUsagesStartedShown = new AtomicBoolean();
ApplicationManager.getApplication().executeOnPooledThread(new Runnable() {
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* Copyright 2000-2014 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.
@@ -72,6 +72,7 @@ public class PyModuleFindUsagesHandler extends FindUsagesHandler {
};
}
@NotNull
@Override
public Collection<PsiReference> findReferencesToHighlight(@NotNull PsiElement target, @NotNull SearchScope searchScope) {
if (target instanceof PyImportedModule) {