GitOrigin-RevId: 5ea5ad0b8ea51bdf9f474ace20644e355dae034e
This commit is contained in:
Alexey Kudravtsev
2019-06-10 16:08:40 +03:00
committed by intellij-monorepo-bot
parent 9290536f4a
commit 7c297749c5
6 changed files with 11 additions and 13 deletions
@@ -52,7 +52,8 @@ public class JavaFindUsagesHandlerFactory extends FindUsagesHandlerFactory {
if (operationMode == OperationMode.USAGES_WITH_DEFAULT_OPTIONS &&
Registry.is("java.find.usages.always.use.top.hierarchy.methods")) {
methods = SuperMethodWarningUtil.getTargetMethodCandidates(method, Collections.emptyList());
} else {
}
else {
methods = SuperMethodWarningUtil.checkSuperMethods(method, JavaFindUsagesHandler.ACTION_STRING);
}
@@ -61,6 +61,7 @@ public class OverridingMethodsSearch extends ExtensibleQueryFactory<PsiMethod, O
private OverridingMethodsSearch() {
}
@NotNull
public static Query<PsiMethod> search(@NotNull PsiMethod method, @NotNull SearchScope scope, final boolean checkDeep) {
if (ReadAction.compute(() -> !PsiUtil.canBeOverridden(method))) return EmptyQuery.getEmptyQuery(); // Optimization
return INSTANCE.createUniqueResultsQuery(new SearchParameters(method, scope, checkDeep));
@@ -83,7 +83,9 @@ public class GotoDeclarationAction extends BaseCodeInsightAction implements Code
if (elements.length != 1) {
if (elements.length == 0 && suggestCandidates(TargetElementUtil.findReference(editor, offset)).isEmpty()) {
PsiElement element = findElementToShowUsagesOf(editor, editor.getCaretModel().getOffset());
if (startFindUsages(editor, project, element)) {
if (element != null) {
startFindUsages(editor, project, element);
return;
}
@@ -95,8 +97,8 @@ public class GotoDeclarationAction extends BaseCodeInsightAction implements Code
}
PsiElement element = elements[0];
if (element == findElementToShowUsagesOf(editor, editor.getCaretModel().getOffset()) &&
startFindUsages(editor, project, element)) {
if (element == findElementToShowUsagesOf(editor, editor.getCaretModel().getOffset())) {
startFindUsages(editor, project, element);
return;
}
@@ -114,10 +116,7 @@ public class GotoDeclarationAction extends BaseCodeInsightAction implements Code
}
}
private static boolean startFindUsages(@NotNull Editor editor, @NotNull Project project, PsiElement element) {
if (element == null) {
return false;
}
public static void startFindUsages(@NotNull Editor editor, @NotNull Project project, @NotNull PsiElement element) {
if (DumbService.getInstance(project).isDumb()) {
AnAction action = ActionManager.getInstance().getAction(ShowUsagesAction.ID);
String name = action.getTemplatePresentation().getText();
@@ -127,7 +126,6 @@ public class GotoDeclarationAction extends BaseCodeInsightAction implements Code
RelativePoint popupPosition = JBPopupFactory.getInstance().guessBestPopupLocation(editor);
new ShowUsagesAction().startFindUsages(element, popupPosition, editor, ShowUsagesAction.getUsagesPageSize());
}
return true;
}
static <T> T underModalProgress(@NotNull Project project,
@@ -20,7 +20,6 @@ public interface GotoDeclarationHandler {
*
* @param sourceElement input PSI element
* @param offset offset in the file
* @param editor
* @return all target declarations as an array of {@code PsiElement} or null if none were found
*/
@Nullable
@@ -20,7 +20,6 @@ import com.intellij.openapi.editor.Document;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.fileEditor.FileEditor;
import com.intellij.openapi.fileEditor.TextEditor;
import com.intellij.openapi.fileEditor.TextEditorLocation;
import com.intellij.openapi.keymap.KeymapUtil;
import com.intellij.openapi.progress.ProcessCanceledException;
import com.intellij.openapi.progress.ProgressIndicator;
@@ -157,7 +156,7 @@ public class FindUsagesManager {
}
@Nullable
public FindUsagesHandler getFindUsagesHandler(@NotNull PsiElement element, OperationMode operationMode) {
public FindUsagesHandler getFindUsagesHandler(@NotNull PsiElement element, @NotNull OperationMode operationMode) {
for (FindUsagesHandlerFactory factory : FindUsagesHandlerFactory.EP_NAME.getExtensions(myProject)) {
if (factory.canFindUsages(element)) {
final FindUsagesHandler handler = factory.createFindUsagesHandler(element, operationMode);
@@ -971,7 +971,7 @@ public class FileUtil extends FileUtilRt {
}
@NotNull
public static String sanitizeFileName(@NotNull String name, boolean strict, String replacement) {
public static String sanitizeFileName(@NotNull String name, boolean strict, @NotNull String replacement) {
StringBuilder result = null;
int last = 0;