boolean (PsiClass psiClass, ProblemSink builder) { if (checkWrongType(psiClass)) { builder.addErrorMessage("inspection.message.utility.class.only.supported.on.class"); return false; } PsiElement context = psiClass.getContext(); if (context == null) { return false; } if (!(context instanceof PsiFile)) { PsiElement contextUp = context; while (true) { if (contextUp instanceof PsiClass psiClassUp) { if (psiClassUp.getContext() instanceof PsiFile) { return true; } boolean isStatic = isStatic(psiClassUp.getModifierList()); if (isStatic || checkWrongType(psiClassUp)) { contextUp = contextUp.getContext(); } else { builder.addErrorMessage("inspection.message.utility.class.automatically.makes.class.static"); return false; } } else { builder.addErrorMessage("inspection.message.utility.class.cannot.be.placed"); return false; } } } return true; }