TextRange (@NotNull PsiElement element) { PsiElement toRemove = getElementToRemove(element); if (toRemove instanceof PsiExpressionStatement) { PsiElement lastChild = toRemove.getLastChild(); while (lastChild instanceof PsiComment || lastChild instanceof PsiWhiteSpace) { lastChild = lastChild.getPrevSibling(); } if (lastChild != null) { return TextRange.create(toRemove.getTextRange().getStartOffset(), lastChild.getTextRange().getEndOffset()); } } return toRemove.getTextRange(); }