void () { PsiClass aClass = myJavaFacade.findClass("AClass", GlobalSearchScope.allScope(getProject())); assertNotNull(aClass); final SmartPsiElementPointer<PsiIdentifier> pointer = createPointer(aClass.getNameIdentifier()); final PsiComment javadoc = JavaPsiFacade.getElementFactory(aClass.getProject()).createCommentFromText("/** javadoc */", aClass); ApplicationManager.getApplication().runWriteAction(() -> { aClass.getParent().addBefore(javadoc, aClass); }); final PsiIdentifier elt = pointer.getElement(); assertNotNull(elt); assertSame(elt, aClass.getNameIdentifier()); }