void () { LazyRangeMarkerFactoryImpl factory = (LazyRangeMarkerFactoryImpl)LazyRangeMarkerFactory.getInstance(getProject()); // need to be physical file, because LightVirtualFile retains Document hard VirtualFile virtualFile = VfsTestUtil.createFile(getSourceRoot(), "x.txt", " "); PsiFile psiFile = Objects.requireNonNull(getPsiManager().findFile(virtualFile)); RangeMarker marker = factory.createRangeMarker(virtualFile, 2); assertEquals(" ", psiFile.getText()); document = FileDocumentManager.getInstance().getDocument(virtualFile); assertEquals(" ", document.getText()); assertTrue(marker.toString(), marker.isValid()); assertEquals(TextRange.create(2,2), marker.getTextRange()); gcDocument(); HeavyPlatformTestCase.setBinaryContent(virtualFile, "".getBytes(StandardCharsets.UTF_8)); // shrink contents to invalidate markers Document d2 = FileDocumentManager.getInstance().getDocument(virtualFile); assertEquals("", d2.getText()); assertFalse(marker.isValid()); }