From 3874a741fefe8a4d39658ba108c5111fdab37fca Mon Sep 17 00:00:00 2001 From: "Gregory.Shrago" Date: Wed, 20 Mar 2019 11:38:43 +0300 Subject: [PATCH] inline getPredefinedScopes() used only once --- .../find/findUsages/FindUsagesOptions.java | 34 ++++++++----------- .../search/PredefinedSearchScopeProvider.java | 15 -------- 2 files changed, 15 insertions(+), 34 deletions(-) diff --git a/platform/analysis-impl/src/com/intellij/find/findUsages/FindUsagesOptions.java b/platform/analysis-impl/src/com/intellij/find/findUsages/FindUsagesOptions.java index 7501b6a4e803..7a21935bd556 100644 --- a/platform/analysis-impl/src/com/intellij/find/findUsages/FindUsagesOptions.java +++ b/platform/analysis-impl/src/com/intellij/find/findUsages/FindUsagesOptions.java @@ -43,31 +43,27 @@ public class FindUsagesOptions implements Cloneable { } public FindUsagesOptions(@NotNull Project project, @Nullable final DataContext dataContext) { - this(calcScope(project, dataContext)); - } - - @NotNull - private static SearchScope calcScope(@NotNull Project project, @Nullable DataContext dataContext) { - String defaultScopeName = FindSettings.getInstance().getDefaultScopeName(); - List predefined = PredefinedSearchScopeProvider.getInstance().getPredefinedScopes(project, dataContext, true, false, false, - false); - SearchScope resultScope = null; - for (SearchScope scope : predefined) { - if (scope.getDisplayName().equals(defaultScopeName)) { - resultScope = scope; - break; - } - } - if (resultScope == null) { - resultScope = ProjectScope.getProjectScope(project); - } - return resultScope; + this(findScopeByName(project, dataContext, FindSettings.getInstance().getDefaultScopeName())); } public FindUsagesOptions(@NotNull SearchScope searchScope) { this.searchScope = searchScope; } + @NotNull + private static SearchScope findScopeByName(@NotNull Project project, + @Nullable DataContext dataContext, + @Nullable String scopeName) { + List predefined = PredefinedSearchScopeProvider.getInstance().getPredefinedScopes( + project, dataContext, true, false, false, false, false); + for (SearchScope scope : predefined) { + if (scope.getDisplayName().equals(scopeName)) { + return scope; + } + } + return ProjectScope.getProjectScope(project); + } + @Override public FindUsagesOptions clone() { try { diff --git a/platform/analysis-impl/src/com/intellij/psi/search/PredefinedSearchScopeProvider.java b/platform/analysis-impl/src/com/intellij/psi/search/PredefinedSearchScopeProvider.java index 1da60759d671..d11a23740756 100644 --- a/platform/analysis-impl/src/com/intellij/psi/search/PredefinedSearchScopeProvider.java +++ b/platform/analysis-impl/src/com/intellij/psi/search/PredefinedSearchScopeProvider.java @@ -28,19 +28,4 @@ public abstract class PredefinedSearchScopeProvider { boolean currentSelection, boolean usageView, boolean showEmptyScopes); - - public final List getPredefinedScopes(@NotNull final Project project, - @Nullable final DataContext dataContext, - boolean suggestSearchInLibs, - boolean prevSearchFiles, - boolean currentSelection, - boolean usageView) { - return getPredefinedScopes(project, - dataContext, - suggestSearchInLibs, - prevSearchFiles, - currentSelection, - usageView, - false); - } }