void (@NotNull PsiDeclarationStatement declaration, @NotNull PsiStatement scope, @NotNull Set<PsiVariable> nonFinalVariables, @NotNull Set<? super PsiVariable> declaredVariables) { Set<PsiVariable> usedVariables = VariableAccessUtils.collectUsedVariables(declaration); boolean hasNonFinalVariables = haveCommonElements(usedVariables, nonFinalVariables); for (PsiElement element : declaration.getDeclaredElements()) { if (!(element instanceof PsiVariable variable)) continue; declaredVariables.add(variable); if (hasNonFinalVariables || !HighlightControlFlowUtil.isEffectivelyFinal(variable, scope, null)) { nonFinalVariables.add(variable); } } }