PsiStatement (@Nullable PsiElement psiElement, @Nullable Set<? super PsiElement> skippedEmptyStatements) { if (psiElement == null || !(psiElement.getParent() instanceof PsiCodeBlock)) { return null; } PsiStatement prevStatement = PsiTreeUtil.getPrevSiblingOfType(psiElement, PsiStatement.class); List<PsiStatement> skipped = new ArrayList<>(); while (prevStatement instanceof PsiEmptyStatement) { skipped.add(prevStatement); prevStatement = PsiTreeUtil.getPrevSiblingOfType(prevStatement, PsiStatement.class); } if (prevStatement != null && skippedEmptyStatements != null) { skippedEmptyStatements.addAll(skipped); } return prevStatement; }