diff --git a/platform/lang-impl/src/com/intellij/find/findUsages/FindUsagesManager.java b/platform/lang-impl/src/com/intellij/find/findUsages/FindUsagesManager.java index 43b4b8d3ce36..d0ab4bf6182b 100644 --- a/platform/lang-impl/src/com/intellij/find/findUsages/FindUsagesManager.java +++ b/platform/lang-impl/src/com/intellij/find/findUsages/FindUsagesManager.java @@ -330,24 +330,16 @@ public class FindUsagesManager { final PsiFile scopeFile) { final FindUsagesOptions optionsClone = options.clone(); return processor -> { - Project project = ApplicationManager.getApplication().runReadAction(new Computable() { - @Override - public Project compute() { - return scopeFile != null ? scopeFile.getProject() : primaryElements[0].getProject(); - } - }); + Project project = ApplicationManager.getApplication().runReadAction( + (Computable)() -> scopeFile != null ? scopeFile.getProject() : primaryElements[0].getProject()); dropResolveCacheRegularly(ProgressManager.getInstance().getProgressIndicator(), project); if (scopeFile != null) { optionsClone.searchScope = new LocalSearchScope(scopeFile); } final Processor usageInfoProcessor = new CommonProcessors.UniqueProcessor<>(usageInfo -> { - Usage usage = ApplicationManager.getApplication().runReadAction(new Computable() { - @Override - public Usage compute() { - return UsageInfoToUsageConverter.convert(primaryElements, usageInfo); - } - }); + Usage usage = ApplicationManager.getApplication().runReadAction( + (Computable)() -> UsageInfoToUsageConverter.convert(primaryElements, usageInfo)); return processor.process(usage); }); final Iterable elements = ContainerUtil.concat(primaryElements, secondaryElements); @@ -379,12 +371,9 @@ public class FindUsagesManager { PsiSearchHelper.SERVICE.getInstance(project) .processRequests(optionsClone.fastTrack, ref -> { - UsageInfo info = ApplicationManager.getApplication().runReadAction(new Computable() { - @Override - public UsageInfo compute() { - if (!ref.getElement().isValid()) return null; - return new UsageInfo(ref); - } + UsageInfo info = ApplicationManager.getApplication().runReadAction((Computable)() -> { + if (!ref.getElement().isValid()) return null; + return new UsageInfo(ref); }); return info == null || usageInfoProcessor.process(info); }); diff --git a/platform/lang-impl/src/com/intellij/find/impl/FindInProjectTask.java b/platform/lang-impl/src/com/intellij/find/impl/FindInProjectTask.java index bdfb02642296..3d80ea0d5828 100644 --- a/platform/lang-impl/src/com/intellij/find/impl/FindInProjectTask.java +++ b/platform/lang-impl/src/com/intellij/find/impl/FindInProjectTask.java @@ -102,12 +102,8 @@ class FindInProjectTask { myPsiManager = PsiManager.getInstance(project); final String moduleName = findModel.getModuleName(); - myModule = moduleName == null ? null : ApplicationManager.getApplication().runReadAction(new Computable() { - @Override - public Module compute() { - return ModuleManager.getInstance(project).findModuleByName(moduleName); - } - }); + myModule = moduleName == null ? null : ApplicationManager.getApplication().runReadAction( + (Computable)() -> ModuleManager.getInstance(project).findModuleByName(moduleName)); myProjectFileIndex = ProjectRootManager.getInstance(project).getFileIndex(); myFileIndex = myModule == null ? myProjectFileIndex : ModuleRootManager.getInstance(myModule).getFileIndex(); @@ -127,16 +123,11 @@ class FindInProjectTask { myStringToFindInIndices = stringToFind; } - public void findUsages(@NotNull final Processor consumer, @NotNull final FindUsagesProcessPresentation processPresentation) { + public void findUsages(@NotNull Processor consumer, @NotNull FindUsagesProcessPresentation processPresentation) { try { myProgress.setIndeterminate(true); myProgress.setText("Scanning indexed files..."); - final Set filesForFastWordSearch = ApplicationManager.getApplication().runReadAction(new Computable>() { - @Override - public Set compute() { - return getFilesForFastWordSearch(); - } - }); + Set filesForFastWordSearch = ApplicationManager.getApplication().runReadAction((Computable>)this::getFilesForFastWordSearch); myProgress.setIndeterminate(false); if (LOG.isDebugEnabled()) { LOG.debug("Searching for " + myFindModel.getStringToFind() + " in " + filesForFastWordSearch.size() + " indexed files"); @@ -146,8 +137,8 @@ class FindInProjectTask { myProgress.setIndeterminate(true); myProgress.setText("Scanning non-indexed files..."); - boolean skipIndexed = canRelyOnIndices(); - final Collection otherFiles = collectFilesInScope(filesForFastWordSearch, skipIndexed); + boolean canRelyOnIndices = canRelyOnIndices(); + final Collection otherFiles = collectFilesInScope(filesForFastWordSearch, canRelyOnIndices); myProgress.setIndeterminate(false); if (LOG.isDebugEnabled()) { @@ -156,8 +147,9 @@ class FindInProjectTask { long start = System.currentTimeMillis(); searchInFiles(otherFiles, processPresentation, consumer); - if (skipIndexed && otherFiles.size() > 1000) { - logStats(otherFiles, start); + if (canRelyOnIndices && otherFiles.size() > 1000) { + long time = System.currentTimeMillis() - start; + logStats(otherFiles, time); } } catch (ProcessCanceledException e) { @@ -176,8 +168,7 @@ class FindInProjectTask { } } - private static void logStats(Collection otherFiles, long start) { - long time = System.currentTimeMillis() - start; + private static void logStats(@NotNull Collection otherFiles, long time) { final Multiset stats = HashMultiset.create(); for (VirtualFile file : otherFiles) { @@ -251,7 +242,6 @@ class FindInProjectTask { } return true; }; - //virtualFiles.forEach(processor::process); JobLauncher.getInstance().invokeConcurrentlyUnderProgress(new ArrayList<>(virtualFiles), myProgress, false, processor); } @@ -259,8 +249,7 @@ class FindInProjectTask { @NotNull private Collection collectFilesInScope(@NotNull final Set alreadySearched, final boolean skipIndexed) { SearchScope customScope = myFindModel.isCustomScope() ? myFindModel.getCustomScope() : null; - final GlobalSearchScope globalCustomScope = customScope == null ? null : GlobalSearchScopeUtil.toGlobalSearchScope(customScope, - myProject); + final GlobalSearchScope globalCustomScope = customScope == null ? null : GlobalSearchScopeUtil.toGlobalSearchScope(customScope, myProject); final ProjectFileIndex fileIndex = ProjectFileIndex.SERVICE.getInstance(myProject); final boolean hasTrigrams = hasTrigrams(myStringToFindInIndices); @@ -340,12 +329,9 @@ class FindInProjectTask { else { boolean success = myFileIndex.iterateContent(iterator); if (success && globalCustomScope != null && globalCustomScope.isSearchInLibraries()) { - final VirtualFile[] librarySources = ApplicationManager.getApplication().runReadAction(new Computable() { - @Override - public VirtualFile[] compute() { - OrderEnumerator enumerator = myModule == null ? OrderEnumerator.orderEntries(myProject) : OrderEnumerator.orderEntries(myModule); - return enumerator.withoutModuleSourceEntries().withoutDepModules().getSourceRoots(); - } + final VirtualFile[] librarySources = ApplicationManager.getApplication().runReadAction((Computable)() -> { + OrderEnumerator enumerator = myModule == null ? OrderEnumerator.orderEntries(myProject) : OrderEnumerator.orderEntries(myModule); + return enumerator.withoutModuleSourceEntries().withoutDepModules().getSourceRoots(); }); iterateAll(librarySources, globalCustomScope, iterator); } @@ -355,13 +341,8 @@ class FindInProjectTask { private static boolean iterateAll(@NotNull VirtualFile[] files, @NotNull final GlobalSearchScope searchScope, @NotNull final ContentIterator iterator) { final FileTypeManager fileTypeManager = FileTypeManager.getInstance(); - final VirtualFileFilter contentFilter = new VirtualFileFilter() { - @Override - public boolean accept(@NotNull final VirtualFile file) { - return file.isDirectory() || - !fileTypeManager.isFileIgnored(file) && !file.getFileType().isBinary() && searchScope.contains(file); - } - }; + final VirtualFileFilter contentFilter = file -> file.isDirectory() || + !fileTypeManager.isFileIgnored(file) && !file.getFileType().isBinary() && searchScope.contains(file); for (VirtualFile file : files) { if (!VfsUtilCore.iterateChildrenRecursively(file, contentFilter, iterator)) return false; } diff --git a/platform/usageView/src/com/intellij/usages/FindUsagesProcessPresentation.java b/platform/usageView/src/com/intellij/usages/FindUsagesProcessPresentation.java index d6b45e237e6d..d73c901764c0 100644 --- a/platform/usageView/src/com/intellij/usages/FindUsagesProcessPresentation.java +++ b/platform/usageView/src/com/intellij/usages/FindUsagesProcessPresentation.java @@ -56,7 +56,7 @@ public class FindUsagesProcessPresentation { @NotNull public List getNotFoundActions() { - return myNotFoundActions == null ? Collections.emptyList() : myNotFoundActions; + return myNotFoundActions == null ? Collections.emptyList() : myNotFoundActions; } public boolean isShowNotFoundMessage() { @@ -98,7 +98,7 @@ public class FindUsagesProcessPresentation { @NotNull public Collection getLargeFiles() { - return myLargeFiles == null ? Collections.emptyList() : myLargeFiles; + return myLargeFiles == null ? Collections.emptyList() : myLargeFiles; } public boolean isShowFindOptionsPrompt() {