Object (@NotNull Object element) { if (element instanceof PsiElement psi) { return ReadAction.compute(() -> { if (!psi.isValid()) return psi; return SmartPointerManager.getInstance(psi.getProject()).createSmartPsiElementPointer(psi); }); } return super.createAnchor(element); }