PsiClass (@NotNull PsiClass aClass) { Object marker = new Object(); PsiTreeUtil.mark(aClass, marker); PsiElement copy = aClass.getContainingFile().copy(); PsiElement copyClass = PsiTreeUtil.releaseMark(copy, marker); LOG.assertTrue(copyClass != null); return (PsiClass)copyClass; }