void () { PsiJavaFile file = (PsiJavaFile)PsiFileFactory.getInstance(getProject()) .createFileFromText("a.java", JavaLanguage.INSTANCE, "class Foo {}", false, false); Document document = FileDocumentManager.getInstance().getDocument(file.getViewProvider().getVirtualFile()); assertNotNull(document); file.getClasses()[0].getModifierList().setModifierProperty(PsiModifier.PUBLIC, true); assertEquals("public class Foo {}", document.getText()); assertFalse(PsiDocumentManager.getInstance(getProject()).isUncommited(document)); }