IJPL-176959 explicitly use deprecated Query.asIterable to raise awareness

GitOrigin-RevId: a80ca48786d03b446f0407a8daeebad93a319154
This commit is contained in:
Daniil Ovchinnikov
2025-02-05 18:52:54 +00:00
committed by intellij-monorepo-bot
parent 02fd2e64c7
commit 96a2ab2603
32 changed files with 61 additions and 103 deletions
@@ -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.dom.impl;
import com.intellij.codeInsight.completion.CompletionConfidenceEP;
@@ -78,7 +78,7 @@ public final class LanguageResolvingUtil {
}
else {
GlobalSearchScope allScope = projectProductionScope.union(librariesScope);
allLanguages = ClassInheritorsSearch.search(languageClass, allScope, true);
allLanguages = ClassInheritorsSearch.search(languageClass, allScope, true).asIterable();
libraryDefinitions = collectLibraryLanguages(context, allScope);
}
@@ -1,4 +1,4 @@
// Copyright 2000-2023 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.inspections;
import com.intellij.codeInspection.LocalQuickFix;
@@ -149,7 +149,7 @@ final class ComponentNotRegisteredInspection extends DevKitJvmInspection.ForClas
}
final Query<PsiReference> search = ReferencesSearch.search(actionClass, actionClass.getUseScope());
for (PsiReference reference : search) {
for (PsiReference reference : search.asIterable()) {
if (!(reference instanceof PsiJavaCodeReferenceElement)) continue;
final PsiNewExpression newExpression = PsiTreeUtil.getParentOfType(reference.getElement(), PsiNewExpression.class);
@@ -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.inspections;
import com.intellij.codeInspection.ProblemsHolder;
@@ -142,7 +142,7 @@ final class MissingAccessibleContextInspection extends DevKitUastInspectionBase
ContainerUtil.addIfNotNull(workList, uVar.getUastInitializer());
PsiElement bodyPsi = body.getSourcePsi();
if (bodyPsi != null) {
for (PsiReference ref : ReferencesSearch.search(psiVar, new LocalSearchScope(bodyPsi))) {
for (PsiReference ref : ReferencesSearch.search(psiVar, new LocalSearchScope(bodyPsi)).asIterable()) {
UExpression lValue = UastContextKt.toUElement(ref.getElement(), UExpression.class);
if (lValue != null) {
UBinaryExpression parent = ObjectUtils.tryCast(lValue.getUastParent(), UBinaryExpression.class);
@@ -1,31 +1,14 @@
// 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.inspections
import com.intellij.codeInspection.ProblemsHolder
import com.intellij.codeInspection.registerUProblem
import com.intellij.openapi.project.Project
import com.intellij.psi.JavaPsiFacade
import com.intellij.psi.PsiClass
import com.intellij.psi.PsiClassType
import com.intellij.psi.PsiElement
import com.intellij.psi.PsiElementVisitor
import com.intellij.psi.*
import com.intellij.psi.search.searches.ClassInheritorsSearch
import com.intellij.uast.UastHintedVisitorAdapter
import org.jetbrains.idea.devkit.DevKitBundle
import org.jetbrains.uast.UCallExpression
import org.jetbrains.uast.UClass
import org.jetbrains.uast.UClassLiteralExpression
import org.jetbrains.uast.UElement
import org.jetbrains.uast.UExpression
import org.jetbrains.uast.UField
import org.jetbrains.uast.UMethod
import org.jetbrains.uast.UObjectLiteralExpression
import org.jetbrains.uast.UParameter
import org.jetbrains.uast.UQualifiedReferenceExpression
import org.jetbrains.uast.USimpleNameReferenceExpression
import org.jetbrains.uast.UVariable
import org.jetbrains.uast.resolveToUElement
import org.jetbrains.uast.toUElement
import org.jetbrains.uast.*
import org.jetbrains.uast.util.isConstructorCall
import org.jetbrains.uast.util.isNewArrayWithInitializer
import org.jetbrains.uast.visitor.AbstractUastNonRecursiveVisitor
@@ -120,6 +103,7 @@ internal class UastHintedVisitorAdapterHintsInspection : DevKitUastInspectionBas
private fun PsiClass.collectUElementInterfaces(uElementClass: PsiClass): Iterable<PsiClass> {
return ClassInheritorsSearch.search(this, this.useScope, true, true, false)
.asIterable()
.filter { it.isInterface }
.filter { it.isInheritor(uElementClass, true) } + this
}
@@ -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.devkit.workspaceModel.metaModel.impl.extensions
import com.intellij.devkit.workspaceModel.metaModel.impl.*
@@ -47,7 +47,7 @@ internal fun ClassDescriptor.inheritors(
}
private fun PsiClass.inheritors(scope: SearchScope): List<PsiClass> {
val inheritors = ClassInheritorsSearch.search(this, scope, true, true, false).filterNot { it.isAnonymous }
val inheritors = ClassInheritorsSearch.search(this, scope, true, true, false).asIterable().filterNot { it.isAnonymous }
return inheritors.sortedBy { it.qualifiedName } //Sorting is needed for consistency in case of regeneration
}
@@ -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.groovy.intentions.style;
import com.intellij.modcommand.ActionContext;
@@ -39,7 +39,7 @@ public final class ImportOnDemandIntention extends GrPsiUpdateIntention {
if (!(containingFile instanceof GroovyFile)) return;
((GroovyFile)containingFile).addImport(importStatement);
for (PsiReference reference : ReferencesSearch.search(resolved, new LocalSearchScope(containingFile))) {
for (PsiReference reference : ReferencesSearch.search(resolved, new LocalSearchScope(containingFile)).asIterable()) {
final PsiElement refElement = reference.getElement();
final PsiElement parent = refElement.getParent();
if (parent instanceof GrQualifiedReference<?>) {
@@ -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.groovy.intentions.style;
import com.intellij.openapi.editor.Editor;
@@ -108,7 +108,7 @@ public final class ImportStaticIntention extends Intention {
private static boolean shortenUsages(PsiElement resolved, PsiFile containingFile) {
boolean isAnythingShortened = false;
for (PsiReference reference : ReferencesSearch.search(resolved, new LocalSearchScope(containingFile))) {
for (PsiReference reference : ReferencesSearch.search(resolved, new LocalSearchScope(containingFile)).asIterable()) {
final PsiElement refElement = reference.getElement();
if (refElement instanceof GrQualifiedReference<?>) {
boolean shortened = GrReferenceAdjuster.shortenReference((GrQualifiedReference<?>)refElement);
@@ -1,18 +1,4 @@
/*
* Copyright 2000-2016 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-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package org.jetbrains.plugins.groovy.refactoring.changeSignature;
import com.intellij.psi.*;
@@ -221,7 +207,7 @@ class GrChageSignatureUsageSearcher {
private static void addParameterUsages(PsiParameter parameter, ArrayList<UsageInfo> results, ParameterInfo info) {
for (PsiReference psiReference : ReferencesSearch.search(parameter)) {
for (PsiReference psiReference : ReferencesSearch.search(parameter).asIterable()) {
PsiElement parmRef = psiReference.getElement();
UsageInfo usageInfo = new ChangeSignatureParameterUsageInfo(parmRef, parameter.getName(), info.getName());
results.add(usageInfo);
@@ -63,7 +63,7 @@ public class ExtractClosureFromClosureProcessor extends ExtractClosureProcessorB
final GrVariable var = (GrVariable)myHelper.getToSearchFor();
if (var != null) {
final List<UsageInfo> result = new ArrayList<>();
for (PsiReference ref : ReferencesSearch.search(var)) {
for (PsiReference ref : ReferencesSearch.search(var).asIterable()) {
final PsiElement element = ref.getElement();
if (element.getLanguage() != GroovyLanguage.INSTANCE) {
result.add(new OtherLanguageUsageInfo(ref));
@@ -115,7 +115,7 @@ public class ExtractClosureFromMethodProcessor extends ExtractClosureProcessorBa
final PsiMethod toSearchFor = (PsiMethod)myHelper.getToSearchFor();
for (PsiReference ref1 : MethodReferencesSearch.search(toSearchFor, GlobalSearchScope.projectScope(myProject), true)) {
for (PsiReference ref1 : MethodReferencesSearch.search(toSearchFor, GlobalSearchScope.projectScope(myProject), true).asIterable()) {
PsiElement ref = ref1.getElement();
if (ref.getLanguage() != GroovyLanguage.INSTANCE) {
result.add(new OtherLanguageUsageInfo(ref1));
@@ -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.groovy.refactoring.introduce.parameter;
import com.intellij.openapi.diagnostic.Logger;
@@ -46,7 +46,7 @@ public class FieldConflictsResolver {
if (!(oldVariable instanceof PsiField)) return;
myReferenceExpressions = new ArrayList<>();
for (PsiReference reference : ReferencesSearch.search(myField, new LocalSearchScope(myScope), false)) {
for (PsiReference reference : ReferencesSearch.search(myField, new LocalSearchScope(myScope), false).asIterable()) {
final PsiElement element = reference.getElement();
if (element instanceof GrReferenceExpression referenceExpression) {
if (referenceExpression.getQualifier() == null) {
@@ -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.groovy.refactoring.introduce.parameter;
import com.intellij.java.refactoring.JavaRefactoringBundle;
@@ -289,7 +289,7 @@ public final class GroovyIntroduceParameterUtil {
}
private static boolean shouldRemove(GrParameter parameter, int start, int end) {
for (PsiReference reference : ReferencesSearch.search(parameter)) {
for (PsiReference reference : ReferencesSearch.search(parameter).asIterable()) {
final PsiElement element = reference.getElement();
final int offset = element.getTextRange().getStartOffset();
@@ -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.groovy.refactoring.introduce.parameter.java2groovy;
@@ -42,7 +42,7 @@ public class FieldConflictsResolver {
return;
}
myReferenceExpressions = new ArrayList<>();
for (PsiReference reference : ReferencesSearch.search(myField, new LocalSearchScope(myScope), false)) {
for (PsiReference reference : ReferencesSearch.search(myField, new LocalSearchScope(myScope), false).asIterable()) {
final PsiElement element = reference.getElement();
if (element instanceof GrReferenceExpression referenceExpression) {
if (referenceExpression.getQualifierExpression() == null) {
@@ -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.groovy.refactoring.introduce.parameter.java2groovy;
@@ -250,7 +250,7 @@ public class OldReferencesResolver {
if (myExpr instanceof GrClosableBlock) {
int count = 0;
for (PsiReference reference : ReferencesSearch.search(parameter, new LocalSearchScope(myParameterInitializer))) {
for (PsiReference reference : ReferencesSearch.search(parameter, new LocalSearchScope(myParameterInitializer)).asIterable()) {
count++;
if (count > 1) break;
}
@@ -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.groovy.refactoring.memberPullUp;
import com.intellij.java.refactoring.JavaRefactoringBundle;
@@ -228,7 +228,7 @@ public final class GrPullUpConflictsUtil {
if (member instanceof PsiMethod method) {
final PsiModifierList modifierList = method.getModifierList();
if (!modifierList.hasModifierProperty(PsiModifier.PRIVATE)) {
for (PsiClass subClass : ClassInheritorsSearch.search(superClass)) {
for (PsiClass subClass : ClassInheritorsSearch.search(superClass).asIterable()) {
if (method.getContainingClass() != subClass) {
MethodSignature signature = ((PsiMethod) member).getSignature(TypeConversionUtil.getSuperClassSubstitutor(superClass, subClass, PsiSubstitutor.EMPTY));
final PsiMethod wouldBeOverriden = MethodSignatureUtil.findMethodBySignature(subClass, signature, false);
@@ -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-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package org.jetbrains.plugins.groovy.refactoring.memberPullUp;
import com.intellij.codeInsight.AnnotationUtil;
@@ -195,7 +195,7 @@ public class GrPullUpHelper implements PullUpHelper<MemberInfo> {
}
private static boolean willBeUsedInSubclass(PsiElement member, Set<? extends PsiMember> movedMembers, PsiClass superclass, PsiClass subclass) {
for (PsiReference ref : ReferencesSearch.search(member, new LocalSearchScope(subclass), false)) {
for (PsiReference ref : ReferencesSearch.search(member, new LocalSearchScope(subclass), false).asIterable()) {
PsiElement element = ref.getElement();
if (!RefactoringHierarchyUtil.willBeInTargetClass(element, movedMembers, superclass, false)) {
return true;
@@ -320,7 +320,7 @@ public class GrPullUpHelper implements PullUpHelper<MemberInfo> {
PsiType type = substitutedType != null ? substitutedType : TypeConversionUtil.erasure(factory.createType(parameter));
PsiElement scopeElement = member instanceof GrField ? member.getParent() : member;
for (PsiReference reference : ReferencesSearch.search(parameter, new LocalSearchScope(scopeElement))) {
for (PsiReference reference : ReferencesSearch.search(parameter, new LocalSearchScope(scopeElement)).asIterable()) {
final PsiElement element = reference.getElement();
final PsiElement parent = element.getParent();
if (parent instanceof PsiTypeElement) {
@@ -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-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package org.jetbrains.plugins.groovy.slicer
import com.intellij.psi.PsiElement
@@ -95,7 +81,7 @@ class GroovySliceUsage : SliceUsage {
public override fun processUsagesFlownFromThe(element: PsiElement, processor: Processor<in SliceUsage>) {
when (element) {
is GrVariable -> {
ReferencesSearch.search(element, params.scope.toSearchScope()).forEach {
ReferencesSearch.search(element, params.scope.toSearchScope()).asIterable().forEach {
val refElement = it.element
if (refElement.language != GroovyLanguage) return refElement.passToProcessor(processor)
@@ -113,7 +99,7 @@ class GroovySliceUsage : SliceUsage {
}
else if (parent is GrReturnStatement) {
val method = PsiTreeUtil.getParentOfType(parent, GrMethod::class.java) ?: return
MethodReferencesSearch.search(method, params.scope.toSearchScope(), true).forEach {
MethodReferencesSearch.search(method, params.scope.toSearchScope(), true).asIterable().forEach {
val callElement = it.element.parent
if (callElement.language != GroovyLanguage) return callElement.passToProcessor(processor)
@@ -664,7 +664,7 @@ private class JUnitMalformedSignatureVisitor(
}
private fun implementationsTestInstanceAnnotated(containingClass: PsiClass): Boolean =
ClassInheritorsSearch.search(containingClass, containingClass.resolveScope, true).any { TestUtils.testInstancePerClass(it) }
ClassInheritorsSearch.search(containingClass, containingClass.resolveScope, true).asIterable().any { TestUtils.testInstancePerClass(it) }
private fun getComponentType(returnType: PsiType?, method: PsiMethod): PsiType? {
val collectionItemType = JavaGenericsUtil.getCollectionItemType(returnType, method.resolveScope)
@@ -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.execution.junit.references
import com.intellij.codeInsight.lookup.AutoCompletionPolicy
@@ -84,6 +84,7 @@ abstract class BaseJunitAnnotationReference(
}
if (clazzMethods.isEmpty() && (psiClazz.isInterface || PsiUtil.isAbstractClass(psiClazz))) {
return ClassInheritorsSearch.search(psiClazz, psiClazz.resolveScope, false)
.asIterable()
.mapNotNull { aClazz ->
val methods = aClazz.findMethodsByName(finalMethodName, false)
filteredMethod(methods, literalClazz, literalMethod)
@@ -77,7 +77,7 @@ public class RemoveMiddlemanProcessor extends FixableUsagesRefactoringProcessor
private void processUsagesForMethod(final boolean deleteMethodHierarchy, PsiMethod method, int[] paramPermutation, String getterName, PsiMethod delegatedMethod,
List<? super FixableUsageInfo> usages) {
for (PsiReference reference : ReferencesSearch.search(method)) {
for (PsiReference reference : ReferencesSearch.search(method).asIterable()) {
final PsiElement referenceElement = reference.getElement();
final PsiMethodCallExpression call = (PsiMethodCallExpression)referenceElement.getParent();
final String access;
@@ -1,4 +1,4 @@
// Copyright 2000-2023 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.typeCook.deductive.builder;
import com.intellij.ide.highlighter.JavaFileType;
@@ -638,7 +638,7 @@ public class SystemBuilder {
final PsiSearchHelper helper = PsiSearchHelper.getInstance(myManager.getProject());
SearchScope scope = getScope(helper, method);
for (PsiReference ref : ReferencesSearch.search(method, scope, true)) {
for (PsiReference ref : ReferencesSearch.search(method, scope, true).asIterable()) {
final PsiElement elt = ref.getElement();
final PsiCallExpression call = PsiTreeUtil.getParentOfType(elt, PsiCallExpression.class);
@@ -950,7 +950,7 @@ public class SystemBuilder {
if (!(element instanceof PsiExpression)) {
for (PsiReference ref : ReferencesSearch.search(element, getScope(helper, element), true)) {
for (PsiReference ref : ReferencesSearch.search(element, getScope(helper, element), true).asIterable()) {
addUsage(system, ref.getElement());
}
}
@@ -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.typeCook.deductive.resolver;
import com.intellij.openapi.diagnostic.Logger;
@@ -50,7 +50,7 @@ public class BindingFactory {
descendants.add(aClass);
}
else {
for (PsiClass bInheritor : ClassInheritorsSearch.search(bClass, false)) {
for (PsiClass bInheritor : ClassInheritorsSearch.search(bClass, false).asIterable()) {
getGreatestLowerClasses(bInheritor, aClass, descendants);
}
}
@@ -111,13 +111,13 @@ public class WrapReturnValueProcessor extends FixableUsagesRefactoringProcessor
@Override
public void findUsages(@NotNull List<? super FixableUsageInfo> usages) {
findUsagesForMethod(myMethod, usages);
for (PsiMethod overridingMethod : OverridingMethodsSearch.search(myMethod)) {
for (PsiMethod overridingMethod : OverridingMethodsSearch.search(myMethod).asIterable()) {
findUsagesForMethod(overridingMethod, usages);
}
}
private void findUsagesForMethod(PsiMethod psiMethod, List<? super FixableUsageInfo> usages) {
for (PsiReference reference : ReferencesSearch.search(psiMethod, psiMethod.getUseScope())) {
for (PsiReference reference : ReferencesSearch.search(psiMethod, psiMethod.getUseScope()).asIterable()) {
final PsiElement referenceElement = reference.getElement();
final PsiElement parent = referenceElement.getParent();
if (parent instanceof PsiCallExpression) {
@@ -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.theoryinpractice.testng.model;
import com.intellij.codeInsight.AnnotationUtil;
@@ -146,7 +146,7 @@ public abstract class TestNGTestObject {
if (testAnnotation == null) {
return;
}
for (PsiMember psiMember : AnnotatedMembersSearch.search(testAnnotation, searchScope)) {
for (PsiMember psiMember : AnnotatedMembersSearch.search(testAnnotation, searchScope).asIterable()) {
final PsiClass containingClass = psiMember.getContainingClass();
if (containingClass == null) continue;
if (skipUnrelated && ArrayUtil.find(classes, containingClass) < 0) continue;
@@ -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.theoryinpractice.testng.util;
import com.intellij.codeInsight.AnnotationUtil;
@@ -357,7 +357,7 @@ public final class TestNGUtil {
final PsiManager manager = PsiManager.getInstance(filter.getProject());
final GlobalSearchScope projectScope = GlobalSearchScope.projectScope(manager.getProject());
final GlobalSearchScope scope = projectScope.intersectWith(filter.getScope());
for (final PsiClass psiClass : AllClassesSearch.search(scope, manager.getProject())) {
for (final PsiClass psiClass : AllClassesSearch.search(scope, manager.getProject()).asIterable()) {
if (filter.isAccepted(psiClass)) {
if (indicator != null) {
indicator.setText2(TestngBundle.message("testng.util.found.test.class", ReadAction.compute(psiClass::getQualifiedName)));
@@ -43,7 +43,7 @@ public class DeleteUnusedParameterFix extends DeleteUnusedElementBase<XsltParame
final XsltTemplate template = XsltCodeInsightUtil.getTemplate(obj.getTag(), false);
if (template == null || template.getMatchExpression() == null) {
final SearchScope searchScope = obj.getResolveScope();
for (PsiReference reference : ReferencesSearch.search(obj, searchScope, false)) {
for (PsiReference reference : ReferencesSearch.search(obj, searchScope, false).asIterable()) {
final XmlTag t = PsiTreeUtil.getContextOfType(reference.getElement(), XmlTag.class, true);
if (t != null && XsltSupport.XSLT_NS.equals(t.getNamespace())) {
assert "with-param".equals(t.getLocalName());
@@ -162,7 +162,7 @@ public class XsltExtractTemplateAction extends XsltRefactoringActionBase {
final XsltVariable variable = XsltElementFactory.getInstance().wrapElement(tag, XsltVariable.class);
final LocalSearchScope searchScope = new LocalSearchScope(parentScope);
final Query<PsiReference> query = ReferencesSearch.search(variable, searchScope);
for (PsiReference reference : query) {
for (PsiReference reference : query.asIterable()) {
final XmlElement context = PsiTreeUtil.getContextOfType(reference.getElement(), XmlElement.class, true);
if (context == null || context.getTextRange().getStartOffset() > endOffset) {
return false;
@@ -73,6 +73,7 @@ class PyFinalInspection : PyInspection() {
if (cls != null) {
PySuperMethodsSearch
.search(node, myTypeEvalContext)
.asIterable()
.asSequence()
.filterIsInstance<PyFunction>()
.firstOrNull { isFinal(it) }
@@ -42,7 +42,7 @@ public final class PyMethodOverridingInspection extends PyInspection {
return;
}
for (PsiElement psiElement : PySuperMethodsSearch.search(function, myTypeEvalContext)) {
for (PsiElement psiElement : PySuperMethodsSearch.search(function, myTypeEvalContext).asIterable()) {
if (psiElement instanceof PyFunction baseMethod) {
if (!PyUtil.isSignatureCompatibleTo(function, baseMethod, myTypeEvalContext)) {
final PyClass baseClass = baseMethod.getContainingClass();
@@ -136,11 +136,11 @@ class PyInlineFunctionHandler : InlineActionHandler() {
private fun overridesMethod(function: PyFunction, project: Project): Boolean {
return function.containingClass != null
&& PySuperMethodsSearch.search(function, TypeEvalContext.codeAnalysis(project, function.containingFile)).any()
&& PySuperMethodsSearch.search(function, TypeEvalContext.codeAnalysis(project, function.containingFile)).asIterable().any()
}
private fun isOverridden(function: PyFunction): Boolean {
return function.containingClass != null && PyOverridingMethodsSearch.search(function, true).any()
return function.containingClass != null && PyOverridingMethodsSearch.search(function, true).asIterable().any()
}
private fun hasStarArgs(function: PyFunction): Boolean {
@@ -101,9 +101,9 @@ class PyInlineFunctionProcessor(project: Project,
}
// TODO: replace with PyRefactoringUtil#findUsages after PY-26881 and PY-36493 are fixed
var references = ReferencesSearch.search(myFunction, myRefactoringScope).findAll().asSequence()
var references = ReferencesSearch.search(myFunction, myRefactoringScope).asIterable().asSequence()
PyiUtil.getPythonStub(myFunction)?.let { stub ->
references += ReferencesSearch.search(stub, myRefactoringScope).asSequence()
references += ReferencesSearch.search(stub, myRefactoringScope).asIterable().asSequence()
}
return references
.distinct()
@@ -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.jetbrains.python.hierarchy.treestructures;
import com.intellij.ide.hierarchy.HierarchyNodeDescriptor;
@@ -30,7 +30,7 @@ public class PySubTypesHierarchyTreeStructure extends HierarchyTreeStructure {
final PsiElement element = descriptor.getPsiElement();
if (element instanceof PyClass cls) {
Query<PyClass> subClasses = PyClassInheritorsSearch.search(cls, false);
for (PyClass subClass : subClasses) {
for (PyClass subClass : subClasses.asIterable()) {
res.add(new PyHierarchyNodeDescriptor(descriptor, subClass, false));
}