boolean (@NotNull PsiCodeBlock block, PsiCodeBlock parentBlock, List<PsiExpression> expressions) { for (PsiStatement statement : block.getStatements()) { if (statement instanceof PsiDeclarationStatement declaration) { if (expressions.size() > 1) return false; for (PsiElement element : declaration.getDeclaredElements()) { PsiResolveHelper resolveHelper = PsiResolveHelper.getInstance(block.getProject()); if (element instanceof PsiVariable variable) { String name = variable.getName(); if (name != null && resolveHelper.resolveReferencedVariable(name, parentBlock) != null) { return false; } } if (element instanceof PsiClass psiClass) { String name = psiClass.getName(); if (name != null && resolveHelper.resolveReferencedClass(name, parentBlock) != null) { return false; } } } } } return true; }