void () { final XmlTag rootTag = XmlElementFactory.getInstance(getProject()).createTagFromText("<html><x>xxx</x>\n<y>yyy</y></html>"); final XmlTag y = rootTag.findFirstSubTag("y"); final PsiFile file = y.getContainingFile(); String text = y.getValue().getText(); TextRange textRange = y.getValue().getTextRange(); assertEquals(text, textRange.substring(file.getText())); WriteCommandAction.writeCommandAction(getProject(), file).run(() -> CodeStyleManager.getInstance(getProject()).adjustLineIndent(file, y.getTextOffset())); text = y.getValue().getText(); textRange = y.getValue().getTextRange(); assertEquals(text, textRange.substring(file.getText())); }