void (@NotNull PsiForeachPatternStatement statement) { super.visitForeachPatternStatement(statement); boolean showAsInfo = false; if (options.maxLevel <= 0) { return; } PsiStatement foreachBody = statement.getBody(); if (foreachBody == null) { return; } PsiPattern pattern = statement.getIterationPattern(); if (!(pattern instanceof PsiDeconstructionPattern deconstructionPattern)) { return; } Deque<DeconstructionContext> queueToProcess = new ArrayDeque<>(); queueToProcess.add(new DeconstructionContext(1, deconstructionPattern, statement)); while (!queueToProcess.isEmpty()) { DeconstructionContext currentContext = queueToProcess.poll(); int level = currentContext.level; if (level >= options.maxLevel + 1) { if (!options.isOnTheFly) { return; } showAsInfo = true; } PsiDeconstructionPattern currentDeconstruction = currentContext.pattern; PsiDeconstructionList list = currentDeconstruction.getDeconstructionList(); for (PsiPattern component : list.getDeconstructionComponents()) { if (component instanceof PsiDeconstructionPattern newDeconstruction) { queueToProcess.add(new DeconstructionContext(level + 1, newDeconstruction, currentContext.foreachPatternStatement)); continue; } if (component instanceof PsiTypeTestPattern typeTestPattern) { PsiTypeElement typeElement = typeTestPattern.getCheckType(); PsiPatternVariable variable = typeTestPattern.getPatternVariable(); if (typeElement == null || variable == null) { continue; } PsiType type = typeElement.getType(); PsiSubstitutor substitutor = PsiSubstitutor.EMPTY; if (type instanceof PsiClassType referenceType) { substitutor = referenceType.resolveGenerics().getSubstitutor(); } PsiClass parameterClass = PsiUtil.resolveClassInClassTypeOnly(type); if (parameterClass == null) { continue; } ShowInfoFolder showInfoFolder = new ShowInfoFolder(); showInfoFolder.showInfo = showAsInfo; ComponentContext context = new ComponentContext(level, variable, parameterClass, substitutor, currentContext.foreachPatternStatement, options, showInfoFolder); processComponentContext(context, this::highlight); } } } }