void () { XmlFile xmlFile = (XmlFile)PsiFileFactory.getInstance(getProject()) .createFileFromText(XMLLanguage.INSTANCE, "<a><child-element/><child-element/></a>"); VirtualFile file = xmlFile.getViewProvider().getVirtualFile(); getDomManager().registerFileDescription(new MockDomFileDescription<>(MyElement.class, "a", file), getTestRootDisposable()); MyElement element = getDomManager().getFileElement(xmlFile, MyElement.class).getRootElement().getChildElements().get(1); MyElement copy = element.createStableCopy(); ApplicationManager.getApplication().runWriteAction(() -> ((FileManagerImpl)PsiManagerEx.getInstanceEx(getProject()).getFileManager()).forceReload(file)); assertFalse(element.isValid()); assertTrue(copy.isValid()); }