void () { @Language("XML") String xml = "<div>&amp;abc</div>"; XmlFile file = (XmlFile)PsiFileFactory.getInstance(getProject()).createFileFromText("foo.xml", XmlFileType.INSTANCE, xml); XmlTag root = file.getDocument().getRootTag(); final XmlText text = root.getValue().getTextElements()[0]; assertEquals("&abc", text.getValue()); assertEquals(0, text.physicalToDisplay(0)); assertEquals(1, text.physicalToDisplay(5)); assertEquals(2, text.physicalToDisplay(6)); assertEquals(3, text.physicalToDisplay(7)); assertEquals(4, text.physicalToDisplay(8)); }