TextRange (@NotNull PsiFile source, @NotNull TextRange rangeToReformat, @NotNull CodeStyleSettings settings) { if (!isApplicableTo(source)) { return rangeToReformat; } final TextRange oldWhitespaceRange = findTrailingWhitespacesRange(source); if (rangeToReformat.intersects(oldWhitespaceRange)) { final TextRange newWhitespaceRange = replaceOrDeleteTrailingWhitespaces(source, oldWhitespaceRange); return rangeToReformat.grown(oldWhitespaceRange.getLength() - newWhitespaceRange.getLength()); } return rangeToReformat; }