void (@NotNull final PsiParameter psiParameter, @NotNull final ProblemsHolder holder) { final PsiTypeElement typeElement = psiParameter.getTypeElement(); final String typeElementText = null != typeElement ? typeElement.getText() : null; boolean isVal = isPossibleVal(typeElementText) && isVal(resolveQualifiedName(typeElement)); boolean isVar = isPossibleVar(typeElementText) && isVar(resolveQualifiedName(typeElement)); if (isVar || isVal) { PsiElement scope = psiParameter.getDeclarationScope(); boolean isForeachStatement = scope instanceof PsiForeachStatement; boolean isForStatement = scope instanceof PsiForStatement; if (isVal && !isForeachStatement) { holder.registerProblem(psiParameter, LombokBundle.message("inspection.message.val.works.only.on.local.variables"), ProblemHighlightType.ERROR); } else if (isVar && !(isForeachStatement || isForStatement)) { holder.registerProblem(psiParameter, LombokBundle.message("inspection.message.var.works.only.on.local.variables.on.for.foreach.loops"), ProblemHighlightType.ERROR); } } }