boolean (@NotNull PsiVariable psiVariable) { if (!(psiVariable instanceof PsiParameter psiParameter)) { return false; } PsiElement declarationScope = psiParameter.getDeclarationScope(); if (!(declarationScope instanceof PsiForStatement) && !(declarationScope instanceof PsiForeachStatement)) { return false; } PsiTypeElement typeElement = psiParameter.getTypeElement(); return typeElement != null && !typeElement.isInferredType() && isNotFinal(psiParameter); }