From feb324866d9f819c8b23b3cdaf9dbf2b319cd8e1 Mon Sep 17 00:00:00 2001 From: Daniil Ovchinnikov Date: Thu, 6 Feb 2025 14:23:24 +0100 Subject: [PATCH] IJPL-176959 explicitly use deprecated `Query.asIterable` to raise awareness GitOrigin-RevId: 5a2122d583775c3a30670058b6b292fa99b639dc --- .../debugger/settings/NodeRendererSettings.java | 3 ++- .../ComparatorCombinatorsInspection.java | 3 ++- .../streamMigration/JoiningMigration.java | 4 ++-- .../JavaVariableInplaceIntroducer.java | 4 ++-- .../safeDelete/JavaSafeDeleteProcessor.java | 4 ++-- .../codeInsight/daemon/impl/JavaTelescope.java | 5 +++-- .../daemon/impl/quickfix/MethodReturnTypeFix.java | 4 ++-- .../find/findUsages/JavaFindUsagesHandler.java | 2 +- .../psi/impl/search/PsiTodoSearchHelperImpl.java | 11 +++++++---- .../src/references/IconsReferencesQueryExecutor.java | 4 ++-- .../plugins/javaFX/sceneBuilder/SceneBuilderImpl.java | 4 ++-- .../refactoring/changeSignature/KotlinChangeInfo.kt | 11 +++-------- 12 files changed, 30 insertions(+), 29 deletions(-) diff --git a/java/debugger/impl/src/com/intellij/debugger/settings/NodeRendererSettings.java b/java/debugger/impl/src/com/intellij/debugger/settings/NodeRendererSettings.java index 643476ddbb78..a9674636435d 100644 --- a/java/debugger/impl/src/com/intellij/debugger/settings/NodeRendererSettings.java +++ b/java/debugger/impl/src/com/intellij/debugger/settings/NodeRendererSettings.java @@ -1,4 +1,4 @@ -// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.intellij.debugger.settings; import com.intellij.codeInsight.AnnotationUtil; @@ -619,6 +619,7 @@ public class NodeRendererSettings implements PersistentStateComponent { PsiClass annotationClass = JavaPsiFacade.getInstance(project).findClass(annotationFqn, GlobalSearchScope.allScope(project)); if (annotationClass == null) continue; AnnotatedElementsSearch.searchElements(annotationClass, GlobalSearchScope.allScope(project), types) + .asIterable() .forEach((PsiModifierListOwner owner) -> { R element = consumer.apply(owner, AnnotationUtil.findAnnotation(owner, annotationFqn)); if (element != null) { diff --git a/java/java-impl-inspections/src/com/intellij/codeInspection/ComparatorCombinatorsInspection.java b/java/java-impl-inspections/src/com/intellij/codeInspection/ComparatorCombinatorsInspection.java index ec0c6608b73a..9d71ee940f1e 100644 --- a/java/java-impl-inspections/src/com/intellij/codeInspection/ComparatorCombinatorsInspection.java +++ b/java/java-impl-inspections/src/com/intellij/codeInspection/ComparatorCombinatorsInspection.java @@ -1,4 +1,4 @@ -// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.intellij.codeInspection; import com.intellij.codeInsight.intention.impl.RemoveRedundantParameterTypesFix; @@ -409,6 +409,7 @@ public final class ComparatorCombinatorsInspection extends AbstractBaseJavaLocal @NotNull PsiVariable exprVariable) { PsiExpression copy = (PsiExpression)expression.copy(); ReferencesSearch.search(exprVariable, new LocalSearchScope(copy)) + .asIterable() .forEach(reference ->{ PsiReferenceExpression ref = tryCast(reference.getElement(), PsiReferenceExpression.class); if(ref == null) return; diff --git a/java/java-impl-inspections/src/com/intellij/codeInspection/streamMigration/JoiningMigration.java b/java/java-impl-inspections/src/com/intellij/codeInspection/streamMigration/JoiningMigration.java index 8d3fc99ab748..baaa0825dc9a 100644 --- a/java/java-impl-inspections/src/com/intellij/codeInspection/streamMigration/JoiningMigration.java +++ b/java/java-impl-inspections/src/com/intellij/codeInspection/streamMigration/JoiningMigration.java @@ -1,4 +1,4 @@ -// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.intellij.codeInspection.streamMigration; @@ -1192,7 +1192,7 @@ public class JoiningMigration extends BaseStreamApiMigration { @NotNull PsiExpression replacement) { List copies = ContainerUtil.map(joinParts, expression -> (PsiExpression)expression.copy()); for (PsiElement joinPart : copies) { - ReferencesSearch.search(localVariable, new LocalSearchScope(joinPart)).forEach(reference -> { + ReferencesSearch.search(localVariable, new LocalSearchScope(joinPart)).asIterable().forEach(reference -> { reference.getElement().replace(replacement); }); } diff --git a/java/java-impl-refactorings/src/com/intellij/refactoring/introduceVariable/JavaVariableInplaceIntroducer.java b/java/java-impl-refactorings/src/com/intellij/refactoring/introduceVariable/JavaVariableInplaceIntroducer.java index 49834c9e31ad..72dc89503493 100644 --- a/java/java-impl-refactorings/src/com/intellij/refactoring/introduceVariable/JavaVariableInplaceIntroducer.java +++ b/java/java-impl-refactorings/src/com/intellij/refactoring/introduceVariable/JavaVariableInplaceIntroducer.java @@ -1,4 +1,4 @@ -// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.intellij.refactoring.introduceVariable; import com.intellij.codeInsight.intention.impl.TypeExpression; @@ -398,7 +398,7 @@ public class JavaVariableInplaceIntroducer extends AbstractJavaInplaceIntroducer if (isReplaceAllOccurrences()) { List occurrences = new ArrayList<>(); - ReferencesSearch.search(variable).forEach(reference -> { + ReferencesSearch.search(variable).asIterable().forEach(reference -> { occurrences.add(createMarker(reference.getElement())); }); setOccurrenceMarkers(occurrences); diff --git a/java/java-impl-refactorings/src/com/intellij/refactoring/safeDelete/JavaSafeDeleteProcessor.java b/java/java-impl-refactorings/src/com/intellij/refactoring/safeDelete/JavaSafeDeleteProcessor.java index 79b23ace8cc8..15a6d82ffdeb 100644 --- a/java/java-impl-refactorings/src/com/intellij/refactoring/safeDelete/JavaSafeDeleteProcessor.java +++ b/java/java-impl-refactorings/src/com/intellij/refactoring/safeDelete/JavaSafeDeleteProcessor.java @@ -983,7 +983,7 @@ public class JavaSafeDeleteProcessor extends SafeDeleteProcessorDelegateBase { assert header != null; int index = ArrayUtil.indexOf(header.getRecordComponents(), component); if (index < 0) return isInsideDeleted; - ReferencesSearch.search(constructor).forEach(ref -> { + ReferencesSearch.search(constructor).asIterable().forEach(ref -> { PsiElement element = ref.getElement(); if (!isInsideDeleted.test(element)) { JavaSafeDeleteDelegate safeDeleteDelegate = JavaSafeDeleteDelegate.EP.forLanguage(element.getLanguage()); @@ -993,7 +993,7 @@ public class JavaSafeDeleteProcessor extends SafeDeleteProcessorDelegateBase { } }); } - ReferencesSearch.search(component).forEach(ref -> { + ReferencesSearch.search(component).asIterable().forEach(ref -> { PsiElement element = ref.getElement(); if (!isInsideDeleted.test(element)) { boolean javadoc = element instanceof PsiDocParamRef; diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/JavaTelescope.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/JavaTelescope.java index 86f8ec672065..93325bb5ada3 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/JavaTelescope.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/JavaTelescope.java @@ -1,4 +1,4 @@ -// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.intellij.codeInsight.daemon.impl; import com.intellij.concurrency.JobLauncher; @@ -121,6 +121,7 @@ final class JavaTelescope { AtomicInteger count = new AtomicInteger(); ClassInheritorsSearch.INSTANCE.createQuery(new ClassInheritorsSearch.SearchParameters(aClass, aClass.getUseScope(), true, true, true)) + .asIterable() .forEach((Consumer)__ -> count.incrementAndGet()); return count.get(); @@ -128,7 +129,7 @@ final class JavaTelescope { static int collectOverridingMethods(@NotNull PsiMethod method) { AtomicInteger count = new AtomicInteger(); - OverridingMethodsSearch.search(method).forEach((Consumer)__ -> count.incrementAndGet()); + OverridingMethodsSearch.search(method).asIterable().forEach((Consumer)__ -> count.incrementAndGet()); return count.get(); } diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/MethodReturnTypeFix.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/MethodReturnTypeFix.java index a1b51f90fb89..9b031bc95448 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/MethodReturnTypeFix.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/MethodReturnTypeFix.java @@ -1,4 +1,4 @@ -// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.intellij.codeInsight.daemon.impl.quickfix; import com.intellij.codeInsight.FileModificationService; @@ -378,7 +378,7 @@ public class MethodReturnTypeFix extends LocalQuickFixAndIntentionActionOnPsiEle PsiMethod[] hierarchyMethods = methods; if (!ProgressManager.getInstance().runProcessWithProgressSynchronously(() -> { for (PsiMethod psiMethod : hierarchyMethods) { - OverridingMethodsSearch.search(psiMethod).forEach(m -> { + OverridingMethodsSearch.search(psiMethod).asIterable().forEach(m -> { affectedMethods.add(m); }); } diff --git a/java/java-impl/src/com/intellij/find/findUsages/JavaFindUsagesHandler.java b/java/java-impl/src/com/intellij/find/findUsages/JavaFindUsagesHandler.java index 78122d4cb55e..6d95de310fff 100644 --- a/java/java-impl/src/com/intellij/find/findUsages/JavaFindUsagesHandler.java +++ b/java/java-impl/src/com/intellij/find/findUsages/JavaFindUsagesHandler.java @@ -90,7 +90,7 @@ public class JavaFindUsagesHandler extends FindUsagesHandler { } } - FunctionalExpressionSearch.search(method).forEach(element -> { + FunctionalExpressionSearch.search(method).asIterable().forEach(element -> { if (element instanceof PsiLambdaExpression) { PsiParameter[] parameters = ReadAction.compute(() -> ((PsiLambdaExpression)element).getParameterList().getParameters()); if (idx < parameters.length) { diff --git a/platform/editor-ui-ex/src/com/intellij/psi/impl/search/PsiTodoSearchHelperImpl.java b/platform/editor-ui-ex/src/com/intellij/psi/impl/search/PsiTodoSearchHelperImpl.java index 9f4f87910d10..5207fe6dc4d5 100644 --- a/platform/editor-ui-ex/src/com/intellij/psi/impl/search/PsiTodoSearchHelperImpl.java +++ b/platform/editor-ui-ex/src/com/intellij/psi/impl/search/PsiTodoSearchHelperImpl.java @@ -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-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.intellij.psi.impl.search; import com.intellij.ide.todo.TodoConfiguration; @@ -6,7 +6,10 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.PsiFile; import com.intellij.psi.impl.cache.TodoCacheManager; -import com.intellij.psi.search.*; +import com.intellij.psi.search.IndexPatternProvider; +import com.intellij.psi.search.PsiTodoSearchHelper; +import com.intellij.psi.search.TodoItem; +import com.intellij.psi.search.TodoPattern; import com.intellij.psi.search.searches.IndexPatternSearch; import com.intellij.psi.util.PsiUtilCore; import com.intellij.util.CommonProcessors; @@ -48,7 +51,7 @@ public class PsiTodoSearchHelperImpl implements PsiTodoSearchHelper { TodoItemCreator todoItemCreator = new TodoItemCreator(); boolean multiLine = TodoConfiguration.getInstance().isMultiLine(); for (IndexPatternProvider provider : IndexPatternProvider.EP_NAME.getExtensionList()) { - IndexPatternSearch.search(file, provider, startOffset, endOffset, multiLine).forEach(occurrence -> { + IndexPatternSearch.search(file, provider, startOffset, endOffset, multiLine).asIterable().forEach(occurrence -> { if (occurrence.getTextRange().intersects(startOffset, endOffset)) { occurrences.add(todoItemCreator.createTodo(occurrence)); } @@ -69,7 +72,7 @@ public class PsiTodoSearchHelperImpl implements PsiTodoSearchHelper { for (IndexPatternProvider provider : IndexPatternProvider.EP_NAME.getExtensionList()) { LightIndexPatternSearch.SEARCH.createQuery( new IndexPatternSearch.SearchParameters(file, provider, TodoConfiguration.getInstance().isMultiLine()) - ).forEach(occurrence -> { + ).asIterable().forEach(occurrence -> { if (occurrence.getTextRange().intersects(startOffset, endOffset)) { occurrences.add(todoItemCreator.createTodo(occurrence)); } diff --git a/plugins/devkit/devkit-core/src/references/IconsReferencesQueryExecutor.java b/plugins/devkit/devkit-core/src/references/IconsReferencesQueryExecutor.java index 5332c3386f7e..07c10749341b 100644 --- a/plugins/devkit/devkit-core/src/references/IconsReferencesQueryExecutor.java +++ b/plugins/devkit/devkit-core/src/references/IconsReferencesQueryExecutor.java @@ -1,4 +1,4 @@ -// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package org.jetbrains.idea.devkit.references; import com.intellij.codeInsight.daemon.EmptyResolveMessageProvider; @@ -209,7 +209,7 @@ final class IconsReferencesQueryExecutor implements QueryExecutor allIconsSearch = AllClassesSearch.search(productionScope.intersectWith(GlobalSearchScope.notScope(notIconsPackageScope)), project, s -> StringUtil.endsWith(s, ICONS_CLASSNAME_SUFFIX) && !s.equals(ICONS_CLASSNAME_SUFFIX)); - allIconsSearch.forEach(psiClass -> { + allIconsSearch.asIterable().forEach(psiClass -> { if (ALL_ICONS_FQN.equals(psiClass.getQualifiedName()) || psiClass.isInterface() || psiClass.getContainingClass() != null || diff --git a/plugins/javaFX/sceneBuilder/src/org/jetbrains/plugins/javaFX/sceneBuilder/SceneBuilderImpl.java b/plugins/javaFX/sceneBuilder/src/org/jetbrains/plugins/javaFX/sceneBuilder/SceneBuilderImpl.java index a60f2e049e1e..29bca7577803 100644 --- a/plugins/javaFX/sceneBuilder/src/org/jetbrains/plugins/javaFX/sceneBuilder/SceneBuilderImpl.java +++ b/plugins/javaFX/sceneBuilder/src/org/jetbrains/plugins/javaFX/sceneBuilder/SceneBuilderImpl.java @@ -1,4 +1,4 @@ -// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package org.jetbrains.plugins.javaFX.sceneBuilder;// Copyright 2000-2019 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. import com.intellij.openapi.application.ReadAction; @@ -159,7 +159,7 @@ public class SceneBuilderImpl implements SceneBuilder { final LanguageLevel ideLanguageLevel = ideJdkVersion != null ? ideJdkVersion.getMaxLanguageLevel() : null; final Query query = ClassInheritorsSearch.search(nodeClass, scope, true, true, false); final Set result = new HashSet<>(); - query.forEach(psiClass -> { + query.asIterable().forEach(psiClass -> { if (psiClass.hasModifierProperty(PsiModifier.PUBLIC) && !psiClass.hasModifierProperty(PsiModifier.ABSTRACT) && !isBuiltInComponent(psiClass) && diff --git a/plugins/kotlin/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/KotlinChangeInfo.kt b/plugins/kotlin/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/KotlinChangeInfo.kt index ca84c6d40c2a..059a9c2c2433 100644 --- a/plugins/kotlin/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/KotlinChangeInfo.kt +++ b/plugins/kotlin/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/KotlinChangeInfo.kt @@ -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 that can be found in the LICENSE file. +// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package org.jetbrains.kotlin.idea.refactoring.changeSignature @@ -15,12 +15,7 @@ import com.intellij.util.VisibilityUtil import org.jetbrains.kotlin.asJava.getRepresentativeLightMethod import org.jetbrains.kotlin.asJava.toLightMethods import org.jetbrains.kotlin.asJava.unwrapped -import org.jetbrains.kotlin.descriptors.CallableDescriptor -import org.jetbrains.kotlin.descriptors.DescriptorVisibilities -import org.jetbrains.kotlin.descriptors.DescriptorVisibility -import org.jetbrains.kotlin.descriptors.FunctionDescriptor -import org.jetbrains.kotlin.descriptors.Visibilities -import org.jetbrains.kotlin.descriptors.Visibility +import org.jetbrains.kotlin.descriptors.* import org.jetbrains.kotlin.idea.KotlinLanguage import org.jetbrains.kotlin.idea.base.facet.platform.platform import org.jetbrains.kotlin.idea.base.psi.unquoteKotlinIdentifier @@ -260,7 +255,7 @@ open class KotlinChangeInfo( for (caller in value) { add(caller) - OverridingMethodsSearch.search(caller.getRepresentativeLightMethod() ?: continue).forEach(::add) + OverridingMethodsSearch.search(caller.getRepresentativeLightMethod() ?: continue).asIterable().forEach(::add) } propagationTargetUsageInfos = result.toList()