PsiClass (@NotNull PsiClass aClass, @NotNull PsiClass targetClass) { if (aClass.getLanguage() != JavaLanguage.INSTANCE) { return null; } ChangeContextUtil.encodeContextInfo(aClass, true); PsiClass newClass = (PsiClass)targetClass.addBefore(aClass, targetClass.getRBrace()); if (targetClass.isInterface()) { PsiUtil.setModifierProperty(newClass, PsiModifier.PACKAGE_LOCAL, true); } else if (!newClass.isEnum()) { PsiUtil.setModifierProperty(newClass, PsiModifier.STATIC, true); } return (PsiClass)ChangeContextUtil.decodeContextInfo(newClass, null, null); }