TextRange (PsiStatement[] statements) { PsiElement start = statements[0]; while (true) { PsiElement prev = PsiTreeUtil.skipWhitespacesBackward(start); if (prev instanceof PsiComment) { start = prev; } else { break; } } int startOffset = start.getTextRangeInParent().getStartOffset(); int endOffset = statements[statements.length - 1].getTextRangeInParent().getEndOffset(); return TextRange.create(startOffset, endOffset); }