void () { @Language("JAVA") String text = "public class X{ int xxx; } //comment"; PsiFile psiFile = myFixture.addFileToProject("X.java", text); Usage usage = createUsage(psiFile, psiFile.getText().indexOf("xxx")); PsiDocumentManager documentManager = PsiDocumentManager.getInstance(getProject()); Document document = documentManager.getDocument(psiFile); WriteCommandAction.runWriteCommandAction(getProject(), () -> document.insertString(0, "/* sdfsdfsd */")); documentManager.commitAllDocuments(); int navigationOffset = ((UsageInfo2UsageAdapter)usage).getUsageInfo().getNavigationOffset(); assertEquals(psiFile.getText().indexOf("xxx"), navigationOffset); }