mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-08 15:09:39 +07:00
Cleanup (minor optimization; dead code; typos; formatting)
GitOrigin-RevId: 35e754f16a3e6509fee308d661eeb0a1bbc37daf
This commit is contained in:
committed by
intellij-monorepo-bot
parent
21d7383ff5
commit
ae617f6f8f
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.execution.util;
|
||||
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.JavaModuleGraphUtil;
|
||||
@@ -64,14 +64,18 @@ public final class JavaParametersUtil {
|
||||
}
|
||||
|
||||
@MagicConstant(valuesFromClass = JavaParameters.class)
|
||||
public static int getClasspathType(final RunConfigurationModule configurationModule, final String mainClassName,
|
||||
final boolean classMustHaveSource) throws CantRunException {
|
||||
@SuppressWarnings("unused")
|
||||
public static int getClasspathType(@NotNull RunConfigurationModule configurationModule,
|
||||
@NotNull String mainClassName,
|
||||
boolean classMustHaveSource) throws CantRunException {
|
||||
return getClasspathType(configurationModule, mainClassName, classMustHaveSource, false);
|
||||
}
|
||||
|
||||
@MagicConstant(valuesFromClass = JavaParameters.class)
|
||||
public static int getClasspathType(final RunConfigurationModule configurationModule, final String mainClassName,
|
||||
final boolean classMustHaveSource, final boolean includeProvidedDependencies) throws CantRunException {
|
||||
public static int getClasspathType(@NotNull RunConfigurationModule configurationModule,
|
||||
@NotNull String mainClassName,
|
||||
boolean classMustHaveSource,
|
||||
boolean includeProvidedDependencies) throws CantRunException {
|
||||
final Module module = configurationModule.getModule();
|
||||
if (module == null) throw CantRunException.noModuleConfigured(configurationModule.getModuleName());
|
||||
Boolean inProduction = isClassInProductionSources(mainClassName, module);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.java.psi.resolve
|
||||
|
||||
import com.intellij.openapi.application.WriteAction
|
||||
@@ -24,6 +24,8 @@ import com.intellij.testFramework.fixtures.JavaCodeInsightFixtureTestCase
|
||||
import com.intellij.testFramework.fixtures.MavenDependencyUtil
|
||||
import groovy.transform.CompileStatic
|
||||
|
||||
import java.util.stream.Stream
|
||||
|
||||
class ResolveInLibrariesTest extends JavaCodeInsightFixtureTestCase {
|
||||
void "test inheritance transitivity"() {
|
||||
def protobufJar = IntelliJProjectConfiguration.getJarFromSingleJarProjectLibrary("protobuf")
|
||||
@@ -144,9 +146,10 @@ class ResolveInLibrariesTest extends JavaCodeInsightFixtureTestCase {
|
||||
def pkg = facade.findPackage("")
|
||||
assert pkg.classes.size() == 1
|
||||
|
||||
Collection<VirtualFile> pkgDirs = pkg.directories.collect { it.virtualFile }
|
||||
Collection<VirtualFile> pkgChildren = pkgDirs.collect { it.children as List }.flatten()
|
||||
VirtualFile javaSrc = pkgChildren.find { it.name == 'LibraryClass.java' }
|
||||
def javaSrc = Stream.of(pkg.directories)
|
||||
.flatMap {Stream.of(it.virtualFile.children) }
|
||||
.filter {it.name == 'LibraryClass.java' }
|
||||
.findFirst().orElseThrow()
|
||||
checkFileIsNotLoadedAndHasNoIndexedStub(javaSrc)
|
||||
|
||||
assert pkg.containsClassNamed('LibraryClass')
|
||||
@@ -305,7 +308,7 @@ public abstract class Child<T> extends Parent<T> {
|
||||
IdeaTestUtil.compileFile(VfsUtil.virtualToIoFile(libSrc), VfsUtil.virtualToIoFile(classesDir))
|
||||
VfsUtil.markDirtyAndRefresh(false, true, true, classesDir)
|
||||
|
||||
WriteAction.run { libSrc.delete() }
|
||||
WriteAction.run { libSrc.delete(null) }
|
||||
|
||||
assert myFixture.findClass("p.Parent")
|
||||
assert myFixture.findClass("p.Child")
|
||||
|
||||
@@ -1,18 +1,4 @@
|
||||
/*
|
||||
* Copyright 2000-2017 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.java.psi.search;
|
||||
|
||||
import com.intellij.JavaTestUtil;
|
||||
@@ -37,6 +23,8 @@ import com.intellij.util.Processor;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import static org.junit.Assert.assertNotEquals;
|
||||
|
||||
public class SearchInLibsTest extends JavaPsiTestCase {
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
@@ -96,7 +84,7 @@ public class SearchInLibsTest extends JavaPsiTestCase {
|
||||
|
||||
List<UsageInfo> usages = Collections.synchronizedList(new ArrayList<>());
|
||||
Processor<UsageInfo> consumer = new CommonProcessors.CollectProcessor<>(usages);
|
||||
FindUsagesProcessPresentation presentation = FindInProjectUtil.setupProcessPresentation(getProject(), false, FindInProjectUtil.setupViewPresentation(false, model));
|
||||
FindUsagesProcessPresentation presentation = FindInProjectUtil.setupProcessPresentation(false, FindInProjectUtil.setupViewPresentation(false, model));
|
||||
FindInProjectUtil.findUsages(model, getProject(), consumer, presentation);
|
||||
|
||||
assertSize(2, usages);
|
||||
@@ -114,7 +102,7 @@ public class SearchInLibsTest extends JavaPsiTestCase {
|
||||
|
||||
List<UsageInfo> usages = Collections.synchronizedList(new ArrayList<>());
|
||||
Processor<UsageInfo> consumer = new CommonProcessors.CollectProcessor<>(usages);
|
||||
FindUsagesProcessPresentation presentation = FindInProjectUtil.setupProcessPresentation(getProject(), false, FindInProjectUtil.setupViewPresentation(false, model));
|
||||
FindUsagesProcessPresentation presentation = FindInProjectUtil.setupProcessPresentation(false, FindInProjectUtil.setupViewPresentation(false, model));
|
||||
FindInProjectUtil.findUsages(model, getProject(), consumer, presentation);
|
||||
|
||||
assertEquals(3, usages.size());
|
||||
@@ -126,7 +114,7 @@ public class SearchInLibsTest extends JavaPsiTestCase {
|
||||
assertNotNull(aClass);
|
||||
String classDirPath = aClass.getContainingFile().getContainingDirectory().getVirtualFile().getPath();
|
||||
String sourceDirPath = ((PsiFile)aClass.getContainingFile().getNavigationElement()).getContainingDirectory().getVirtualFile().getPath();
|
||||
assertFalse(classDirPath.equals(sourceDirPath));
|
||||
assertNotEquals(classDirPath, sourceDirPath);
|
||||
model.setDirectoryName(sourceDirPath);
|
||||
model.setCaseSensitive(true);
|
||||
model.setCustomScope(false);
|
||||
@@ -135,7 +123,7 @@ public class SearchInLibsTest extends JavaPsiTestCase {
|
||||
|
||||
List<UsageInfo> usages = Collections.synchronizedList(new ArrayList<>());
|
||||
CommonProcessors.CollectProcessor<UsageInfo> consumer = new CommonProcessors.CollectProcessor<>(usages);
|
||||
FindUsagesProcessPresentation presentation = FindInProjectUtil.setupProcessPresentation(getProject(), false, FindInProjectUtil.setupViewPresentation(false, model));
|
||||
FindUsagesProcessPresentation presentation = FindInProjectUtil.setupProcessPresentation(false, FindInProjectUtil.setupViewPresentation(false, model));
|
||||
FindInProjectUtil.findUsages(model, getProject(), consumer, presentation);
|
||||
|
||||
UsageInfo info = assertOneElement(usages);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.openapi.vfs.newvfs;
|
||||
|
||||
import com.intellij.analysis.AnalysisBundle;
|
||||
@@ -22,7 +22,7 @@ import java.util.function.Function;
|
||||
import static com.intellij.openapi.util.Pair.pair;
|
||||
|
||||
/**
|
||||
* Common interface of archive-based file systems (jar://, phar:// etc).
|
||||
* Common interface of archive-based file systems (jar://, phar://, etc.).
|
||||
*/
|
||||
public abstract class ArchiveFileSystem extends NewVirtualFileSystem {
|
||||
private static final Key<VirtualFile> LOCAL_FILE = Key.create("vfs.archive.local.file");
|
||||
|
||||
@@ -96,9 +96,9 @@ find.replace.invalid.replacement.string.title=Replace Error
|
||||
find.highlight.no.more.highlights.found=No more highlights found
|
||||
find.scope.all.project.classes=All Project Classes
|
||||
find.usage.view.tab.text=Occurrences of ''{0}''{1}
|
||||
replace.usage.view.tab.text=Replace occurrences of ''{0}'' with ''{1}''{2}
|
||||
replace.usage.view.tab.text=Replace Occurrences of ''{0}'' with ''{1}''{2}
|
||||
find.usage.view.toolwindow.title=Occurrences of ''{0}'' in {1}{2}
|
||||
replace.usage.view.toolwindow.title=Replace occurrences of ''{0}'' with ''{1}'' in {2}{3}
|
||||
replace.usage.view.toolwindow.title=Replace Occurrences of ''{0}'' with ''{1}'' in {2}{3}
|
||||
|
||||
find.replace.command=Replace
|
||||
find.replace.all.action=Replace &All
|
||||
@@ -111,7 +111,7 @@ find.replace.all.local.history.action=Replace all ''{0}'' in file with ''{1}''
|
||||
find.usages.ambiguous.title=Find Usages Of
|
||||
show.usages.ambiguous.title=Show Usages Of
|
||||
0.occurrences.replaced={0,choice,0#No|1#{0}} {0,choice,0#occurrences|1#occurrence|2#occurrences} replaced
|
||||
found.occurrences=Found Occurrences
|
||||
found.occurrences=Found occurrences
|
||||
find.new.line=New Line
|
||||
find.search.history=Search History
|
||||
find.replace.history=Replace History
|
||||
@@ -180,4 +180,4 @@ show.usages.more.usages.label=more usages
|
||||
show.usages.current.usage.label=Current
|
||||
|
||||
search.everywhere.group.name=Text
|
||||
se.text.header.action.all.filetypes=All file types
|
||||
se.text.header.action.all.filetypes=All file types
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
// Copyright 2000-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.find.findInProject;
|
||||
|
||||
import com.intellij.find.FindManager;
|
||||
@@ -81,8 +80,7 @@ public class FindInProjectManager {
|
||||
findManager.getFindInProjectModel().copyFrom(findModel);
|
||||
FindModel findModelCopy = findModel.clone();
|
||||
UsageViewPresentation presentation = FindInProjectUtil.setupViewPresentation(findModelCopy);
|
||||
FindUsagesProcessPresentation processPresentation =
|
||||
FindInProjectUtil.setupProcessPresentation(myProject, presentation);
|
||||
FindUsagesProcessPresentation processPresentation = FindInProjectUtil.setupProcessPresentation(presentation);
|
||||
ConfigurableUsageTarget usageTarget = new FindInProjectUtil.StringUsageTarget(myProject, findModel);
|
||||
|
||||
((FindManagerImpl)FindManager.getInstance(myProject)).getFindUsagesManager().addToHistory(usageTarget);
|
||||
|
||||
@@ -117,7 +117,7 @@ public final class FindInProjectUtil {
|
||||
if (editor == null) {
|
||||
directoryName = parent.getPresentableUrl();
|
||||
}
|
||||
else {
|
||||
else if (project != null) {
|
||||
FindInProjectSettings.getInstance(project).addDirectory(parent.getPresentableUrl());
|
||||
}
|
||||
}
|
||||
@@ -150,8 +150,7 @@ public final class FindInProjectUtil {
|
||||
model.setProjectScope(model.getDirectoryName() == null && model.getModuleName() == null && !model.isCustomScope());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static VirtualFile getDirectory(@NotNull FindModel findModel) {
|
||||
public static @Nullable VirtualFile getDirectory(@NotNull FindModel findModel) {
|
||||
String directoryName = findModel.getDirectoryName();
|
||||
if (findModel.isProjectScope() || StringUtil.isEmptyOrSpaces(directoryName)) {
|
||||
return null;
|
||||
@@ -185,34 +184,30 @@ public final class FindInProjectUtil {
|
||||
}
|
||||
|
||||
/* filter can have form "*.js, !*_min.js", latter means except matched by *_min.js */
|
||||
@NotNull
|
||||
public static Condition<CharSequence> createFileMaskCondition(@Nullable String filter) throws PatternSyntaxException {
|
||||
public static @NotNull Condition<CharSequence> createFileMaskCondition(@Nullable String filter) throws PatternSyntaxException {
|
||||
if (StringUtil.isEmpty(filter)) {
|
||||
return Conditions.alwaysTrue();
|
||||
}
|
||||
|
||||
String pattern = "";
|
||||
String negativePattern = "";
|
||||
StringBuilder pattern = new StringBuilder();
|
||||
StringBuilder negativePattern = new StringBuilder();
|
||||
List<String> masks = StringUtil.split(filter, ",");
|
||||
|
||||
for(String mask:masks) {
|
||||
for (String mask : masks) {
|
||||
mask = mask.trim();
|
||||
if (StringUtil.startsWith(mask, "!")) {
|
||||
negativePattern += (negativePattern.isEmpty() ? "" : "|") + "(" + PatternUtil.convertToRegex(mask.substring(1)) + ")";
|
||||
if (mask.startsWith("!")) {
|
||||
negativePattern.append((negativePattern.isEmpty()) ? "" : "|").append("(").append(PatternUtil.convertToRegex(mask.substring(1))).append(")");
|
||||
}
|
||||
else {
|
||||
pattern += (pattern.isEmpty() ? "" : "|") + "(" + PatternUtil.convertToRegex(mask) + ")";
|
||||
pattern.append((pattern.isEmpty()) ? "" : "|").append("(").append(PatternUtil.convertToRegex(mask)).append(")");
|
||||
}
|
||||
}
|
||||
|
||||
if (pattern.isEmpty()) pattern = PatternUtil.convertToRegex("*");
|
||||
String finalPattern = pattern;
|
||||
String finalNegativePattern = negativePattern;
|
||||
if (pattern.isEmpty()) pattern.append(PatternUtil.convertToRegex("*"));
|
||||
|
||||
return new Condition<>() {
|
||||
final Pattern regExp = Pattern.compile(finalPattern, Pattern.CASE_INSENSITIVE);
|
||||
final Pattern negativeRegExp =
|
||||
StringUtil.isEmpty(finalNegativePattern) ? null : Pattern.compile(finalNegativePattern, Pattern.CASE_INSENSITIVE);
|
||||
final Pattern regExp = Pattern.compile(pattern.toString(), Pattern.CASE_INSENSITIVE);
|
||||
final Pattern negativeRegExp = negativePattern.isEmpty() ? null : Pattern.compile(negativePattern.toString(), Pattern.CASE_INSENSITIVE);
|
||||
|
||||
@Override
|
||||
public boolean value(CharSequence input) {
|
||||
@@ -323,8 +318,7 @@ public final class FindInProjectUtil {
|
||||
return true;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static @Nls String getTitleForScope(@NotNull FindModel findModel) {
|
||||
public static @NotNull @Nls String getTitleForScope(@NotNull FindModel findModel) {
|
||||
String scopeName;
|
||||
if (findModel.isProjectScope()) {
|
||||
scopeName = FindBundle.message("find.scope.project.title");
|
||||
@@ -347,13 +341,11 @@ public final class FindInProjectUtil {
|
||||
return result;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static UsageViewPresentation setupViewPresentation(@NotNull FindModel findModel) {
|
||||
public static @NotNull UsageViewPresentation setupViewPresentation(@NotNull FindModel findModel) {
|
||||
return setupViewPresentation(FindSettings.getInstance().isShowResultsInSeparateView(), findModel);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static UsageViewPresentation setupViewPresentation(boolean toOpenInNewTab, @NotNull FindModel findModel) {
|
||||
public static @NotNull UsageViewPresentation setupViewPresentation(boolean toOpenInNewTab, @NotNull FindModel findModel) {
|
||||
UsageViewPresentation presentation = new UsageViewPresentation();
|
||||
setupViewPresentation(presentation, toOpenInNewTab, findModel);
|
||||
return presentation;
|
||||
@@ -409,17 +401,28 @@ public final class FindInProjectUtil {
|
||||
presentation.setReplaceMode(findModel.isReplaceState());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static FindUsagesProcessPresentation setupProcessPresentation(@NotNull Project project,
|
||||
@NotNull UsageViewPresentation presentation) {
|
||||
return setupProcessPresentation(project, !FindSettings.getInstance().isSkipResultsWithOneUsage(), presentation);
|
||||
/** @deprecated please use {@link #setupProcessPresentation(UsageViewPresentation)} instead */
|
||||
@Deprecated(forRemoval = true)
|
||||
@SuppressWarnings("unused")
|
||||
public static @NotNull FindUsagesProcessPresentation setupProcessPresentation(@NotNull Project project, @NotNull UsageViewPresentation presentation) {
|
||||
return setupProcessPresentation(presentation);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static FindUsagesProcessPresentation setupProcessPresentation(@NotNull Project project,
|
||||
boolean showPanelIfOnlyOneUsage,
|
||||
@NotNull UsageViewPresentation presentation) {
|
||||
FindUsagesProcessPresentation processPresentation = new FindUsagesProcessPresentation(presentation);
|
||||
/** @deprecated please use {@link #setupProcessPresentation(boolean, UsageViewPresentation)} instead */
|
||||
@Deprecated(forRemoval = true)
|
||||
@SuppressWarnings("unused")
|
||||
public static @NotNull FindUsagesProcessPresentation setupProcessPresentation(@NotNull Project project,
|
||||
boolean showPanelIfOnlyOneUsage,
|
||||
@NotNull UsageViewPresentation presentation) {
|
||||
return setupProcessPresentation(showPanelIfOnlyOneUsage, presentation);
|
||||
}
|
||||
|
||||
public static @NotNull FindUsagesProcessPresentation setupProcessPresentation(@NotNull UsageViewPresentation presentation) {
|
||||
return setupProcessPresentation(!FindSettings.getInstance().isSkipResultsWithOneUsage(), presentation);
|
||||
}
|
||||
|
||||
public static @NotNull FindUsagesProcessPresentation setupProcessPresentation(boolean showPanelIfOnlyOneUsage, @NotNull UsageViewPresentation presentation) {
|
||||
var processPresentation = new FindUsagesProcessPresentation(presentation);
|
||||
processPresentation.setShowNotFoundMessage(true);
|
||||
processPresentation.setShowPanelIfOnlyOneUsage(showPanelIfOnlyOneUsage);
|
||||
return processPresentation;
|
||||
@@ -446,15 +449,14 @@ public final class FindInProjectUtil {
|
||||
return result != null ? result : Collections.emptyList();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String extractStringToFind(@NotNull String regexp, @NotNull Project project) {
|
||||
public static @NotNull String extractStringToFind(@NotNull String regexp, @NotNull Project project) {
|
||||
return ReadAction.compute(() -> {
|
||||
List<PsiElement> topLevelRegExpChars = getTopLevelRegExpChars("a", project);
|
||||
if (topLevelRegExpChars.size() != 1) return " ";
|
||||
|
||||
// leave only top level regExpChars
|
||||
|
||||
Class regExpCharPsiClass = topLevelRegExpChars.get(0).getClass();
|
||||
Class<?> regExpCharPsiClass = topLevelRegExpChars.get(0).getClass();
|
||||
return getTopLevelRegExpChars(regexp, project)
|
||||
.stream()
|
||||
.map(psi -> {
|
||||
@@ -468,8 +470,7 @@ public final class FindInProjectUtil {
|
||||
});
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String buildStringToFindForIndicesFromRegExp(@NotNull String stringToFind, @NotNull Project project) {
|
||||
public static @NotNull String buildStringToFindForIndicesFromRegExp(@NotNull String stringToFind, @NotNull Project project) {
|
||||
return StringUtil.trim(StringUtil.join(extractStringToFind(stringToFind, project), " "));
|
||||
}
|
||||
|
||||
@@ -482,8 +483,8 @@ public final class FindInProjectUtil {
|
||||
}
|
||||
|
||||
public static class StringUsageTarget implements ConfigurableUsageTarget, ItemPresentation, DataProvider {
|
||||
@NotNull protected final Project myProject;
|
||||
@NotNull protected final FindModel myFindModel;
|
||||
protected final @NotNull Project myProject;
|
||||
protected final @NotNull FindModel myFindModel;
|
||||
|
||||
public StringUsageTarget(@NotNull Project project, @NotNull FindModel findModel) {
|
||||
myProject = project;
|
||||
@@ -491,8 +492,7 @@ public final class FindInProjectUtil {
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String getPresentableText() {
|
||||
public @NotNull String getPresentableText() {
|
||||
UsageViewPresentation presentation = setupViewPresentation(false, myFindModel);
|
||||
return presentation.getToolwindowTitle();
|
||||
}
|
||||
@@ -598,8 +598,7 @@ public final class FindInProjectUtil {
|
||||
outSourceRoots.addAll(otherSourceRoots);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
static SearchScope getScopeFromModel(@NotNull Project project, @NotNull FindModel findModel) {
|
||||
static @NotNull SearchScope getScopeFromModel(@NotNull Project project, @NotNull FindModel findModel) {
|
||||
SearchScope customScope = findModel.isCustomScope() ? findModel.getCustomScope() : null;
|
||||
VirtualFile directory = getDirectory(findModel);
|
||||
Module module = findModel.getModuleName() == null ? null : ModuleManager.getInstance(project).findModuleByName(findModel.getModuleName());
|
||||
@@ -613,10 +612,9 @@ public final class FindInProjectUtil {
|
||||
GlobalSearchScope.allScope(project);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static GlobalSearchScope forDirectory(@NotNull Project project,
|
||||
boolean withSubdirectories,
|
||||
@NotNull VirtualFile directory) {
|
||||
private static @NotNull GlobalSearchScope forDirectory(@NotNull Project project,
|
||||
boolean withSubdirectories,
|
||||
@NotNull VirtualFile directory) {
|
||||
Set<VirtualFile> result = new LinkedHashSet<>();
|
||||
result.add(directory);
|
||||
addSourceDirectoriesFromLibraries(project, directory, result);
|
||||
@@ -657,4 +655,4 @@ public final class FindInProjectUtil {
|
||||
};
|
||||
return FindBundle.message(messageKey);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1181,8 +1181,7 @@ public class FindPopupPanel extends JBPanel<FindPopupPanel> implements FindUI, D
|
||||
() -> GlobalSearchScopeUtil.toGlobalSearchScope(FindInProjectUtil.getScopeFromModel(project, myHelper.myPreviousModel), project)
|
||||
).wrapProgress(indicator).executeSynchronously();
|
||||
|
||||
FindUsagesProcessPresentation processPresentation =
|
||||
FindInProjectUtil.setupProcessPresentation(project, myUsageViewPresentation);
|
||||
FindUsagesProcessPresentation processPresentation = FindInProjectUtil.setupProcessPresentation(myUsageViewPresentation);
|
||||
ThreadLocal<String> lastUsageFileRef = new ThreadLocal<>();
|
||||
ThreadLocal<Reference<FindPopupItem>> recentItemRef = new ThreadLocal<>();
|
||||
|
||||
@@ -2126,4 +2125,4 @@ public class FindPopupPanel extends JBPanel<FindPopupPanel> implements FindUI, D
|
||||
return accessibleContext;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,7 +97,7 @@ class TextSearchContributor(val event: AnActionEvent) : WeightedSearchEverywhere
|
||||
consumer: Processor<in FoundItemDescriptor<SearchEverywhereItem>>) {
|
||||
FindModel.initStringToFind(model, pattern)
|
||||
|
||||
val presentation = FindInProjectUtil.setupProcessPresentation(project, UsageViewPresentation())
|
||||
val presentation = FindInProjectUtil.setupProcessPresentation(UsageViewPresentation())
|
||||
|
||||
val scope = GlobalSearchScope.projectScope(project) // TODO use scope from model ?
|
||||
val recentItemRef = ThreadLocal<Reference<SearchEverywhereItem>>()
|
||||
@@ -291,4 +291,4 @@ class TextSearchContributor(val event: AnActionEvent) : WeightedSearchEverywhere
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -155,7 +155,7 @@ public final class ReplaceInProjectManager {
|
||||
final FindModel findModelCopy = findModel.clone();
|
||||
|
||||
final UsageViewPresentation presentation = FindInProjectUtil.setupViewPresentation(findModelCopy);
|
||||
final FindUsagesProcessPresentation processPresentation = FindInProjectUtil.setupProcessPresentation(myProject, true, presentation);
|
||||
final FindUsagesProcessPresentation processPresentation = FindInProjectUtil.setupProcessPresentation(true, presentation);
|
||||
processPresentation.setShowFindOptionsPrompt(findModel.isPromptOnReplace());
|
||||
|
||||
UsageSearcherFactory factory = new UsageSearcherFactory(findModelCopy, processPresentation);
|
||||
|
||||
@@ -73,14 +73,14 @@ val Project.isExternalStorageEnabled: Boolean
|
||||
return false
|
||||
}
|
||||
|
||||
val manager = this.getService(ExternalStorageConfigurationManager::class.java) ?: return false
|
||||
val manager = ExternalStorageConfigurationManager.getInstance(this) ?: return false
|
||||
if (manager.isEnabled) return true
|
||||
val testMode = ApplicationManager.getApplication()?.isUnitTestMode ?: false
|
||||
return testMode && enableExternalStorageByDefaultInTests
|
||||
}
|
||||
|
||||
/**
|
||||
* By default external storage is enabled in tests. Wrap code which loads the project into this call to always use explicit option value.
|
||||
* By default, external storage is enabled in tests. Wrap code which loads the project into this call to always use explicit option value.
|
||||
*/
|
||||
@TestOnly
|
||||
fun doNotEnableExternalStorageByDefaultInTests(action: () -> Unit) {
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.openapi.roots.libraries;
|
||||
|
||||
import com.intellij.openapi.module.Module;
|
||||
@@ -19,8 +18,7 @@ import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public final class LibraryUtil {
|
||||
private LibraryUtil() {
|
||||
}
|
||||
private LibraryUtil() { }
|
||||
|
||||
public static boolean isClassAvailableInLibrary(@NotNull Library library, @NotNull String fqn) {
|
||||
return isClassAvailableInLibrary(library.getFiles(OrderRootType.CLASSES), fqn);
|
||||
@@ -37,8 +35,7 @@ public final class LibraryUtil {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static Library findLibraryByClass(@NotNull String fqn, @Nullable Project project) {
|
||||
public static @Nullable Library findLibraryByClass(@NotNull String fqn, @Nullable Project project) {
|
||||
if (project != null) {
|
||||
final LibraryTable projectTable = LibraryTablesRegistrar.getInstance().getLibraryTable(project);
|
||||
Library library = findInTable(projectTable, fqn);
|
||||
@@ -61,8 +58,7 @@ public final class LibraryUtil {
|
||||
return child != null && findInFile(child, tokenizer);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static Library findInTable(@NotNull LibraryTable table, @NotNull String fqn) {
|
||||
private static @Nullable Library findInTable(@NotNull LibraryTable table, @NotNull String fqn) {
|
||||
for (Library library : table.getLibraries()) {
|
||||
if (isClassAvailableInLibrary(library, fqn)) {
|
||||
return library;
|
||||
@@ -71,8 +67,7 @@ public final class LibraryUtil {
|
||||
return null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static Library createLibrary(@NotNull LibraryTable libraryTable, @NonNls @NotNull String baseName) {
|
||||
public static @NotNull Library createLibrary(@NotNull LibraryTable libraryTable, @NonNls @NotNull String baseName) {
|
||||
String name = baseName;
|
||||
int count = 2;
|
||||
while (libraryTable.getLibraryByName(name) != null) {
|
||||
@@ -116,8 +111,7 @@ public final class LibraryUtil {
|
||||
return VfsUtilCore.toVirtualFileArray(roots);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static Library findLibrary(@NotNull Module module, @NotNull final String name) {
|
||||
public static @Nullable Library findLibrary(@NotNull Module module, final @NotNull String name) {
|
||||
final Ref<Library> result = Ref.create(null);
|
||||
OrderEnumerator.orderEntries(module).forEachLibrary(library -> {
|
||||
if (name.equals(library.getName())) {
|
||||
@@ -129,8 +123,7 @@ public final class LibraryUtil {
|
||||
return result.get();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static OrderEntry findLibraryEntry(@NotNull VirtualFile file, @NotNull Project project) {
|
||||
public static @Nullable OrderEntry findLibraryEntry(@NotNull VirtualFile file, @NotNull Project project) {
|
||||
List<OrderEntry> entries = ProjectRootManager.getInstance(project).getFileIndex().getOrderEntriesForFile(file);
|
||||
for (OrderEntry entry : entries) {
|
||||
if (entry instanceof LibraryOrderEntry || entry instanceof JdkOrderEntry) {
|
||||
@@ -140,12 +133,9 @@ public final class LibraryUtil {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use {@link Library#getPresentableName()} instead
|
||||
*/
|
||||
/** @deprecated use {@link Library#getPresentableName()} instead */
|
||||
@Deprecated(forRemoval = true)
|
||||
@NotNull
|
||||
public static @Nls(capitalization = Nls.Capitalization.Title) String getPresentableName(@NotNull Library library) {
|
||||
public static @NotNull @Nls(capitalization = Nls.Capitalization.Title) String getPresentableName(@NotNull Library library) {
|
||||
return library.getPresentableName();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package org.jetbrains.idea.maven.dom.refactorings.introduce;
|
||||
|
||||
import com.intellij.find.FindManager;
|
||||
@@ -194,7 +194,7 @@ public class IntroducePropertyAction extends BaseRefactoringAction {
|
||||
FindModel findModel = createFindModel(findManager, selectedString, replaceWith);
|
||||
|
||||
final UsageViewPresentation presentation = FindInProjectUtil.setupViewPresentation(true, findModel);
|
||||
final FindUsagesProcessPresentation processPresentation = FindInProjectUtil.setupProcessPresentation(project, true, presentation);
|
||||
final FindUsagesProcessPresentation processPresentation = FindInProjectUtil.setupProcessPresentation(true, presentation);
|
||||
|
||||
findManager.getFindInProjectModel().copyFrom(findModel);
|
||||
final FindModel findModelCopy = findModel.clone();
|
||||
|
||||
Reference in New Issue
Block a user