void () { final PsiClass aClass = myJavaFacade.findClass("pack.MyInterface1", GlobalSearchScope.allScope(myProject)); assertNotNull(aClass); final PsiFile containingFile = aClass.getContainingFile(); final CompositeElement element = ((PsiFileImpl)containingFile).calcTreeElement(); aClass.putCopyableUserData(TEST_KEY, "TEST"); final PsiJavaFile fileCopy = (PsiJavaFile)containingFile.copy(); final PsiClass[] classesCopy = fileCopy.getClasses(); assertEquals(1, classesCopy.length); assertNotNull(element); assertEquals("TEST", classesCopy[0].getCopyableUserData(TEST_KEY)); }