TextRange (@NotNull PsiImportList list) { PsiImportStatementBase[] statements = list.getAllImportStatements(); if (statements.length == 0) return null; final PsiElement importKeyword = statements[0].getFirstChild(); if (importKeyword == null) return null; int startOffset = importKeyword.getTextRange().getEndOffset() + 1; int endOffset = statements[statements.length - 1].getTextRange().getEndOffset(); return hasErrorElementsNearby(list.getContainingFile(), startOffset, endOffset) ? null : new TextRange(startOffset, endOffset); }