@NotNull
  private PsiClass createInnerFromAnonymous(String name, PsiAnonymousClass anonymousClass, PsiElementFactory factory) {
    PsiClass aClass = factory.createClass(name);
    PsiJavaCodeReferenceElement baseClassRef = anonymousClass.getBaseClassReference();
    final PsiReferenceParameterList parameterList = baseClassRef.getParameterList();
    if (parameterList != null) {
      final PsiTypeElement[] parameterElements = parameterList.getTypeParameterElements();
      if (parameterElements.length == 1 && parameterElements[0].getType() instanceof PsiDiamondType) {
        baseClassRef = (PsiJavaCodeReferenceElement)PsiDiamondTypeUtil.replaceDiamondWithExplicitTypes(parameterList);
      }
    }
    PsiClass baseClass = (PsiClass)baseClassRef.resolve();
    if (baseClass == null || !CommonClassNames.JAVA_LANG_OBJECT.equals(baseClass.getQualifiedName())) {
      PsiReferenceList refList = baseClass != null && baseClass.isInterface() ?
                                 aClass.getImplementsList() :
                                 aClass.getExtendsList();
      if (refList != null) refList.add(baseClassRef);
    }
    PsiElement lbrace = myAnonOrLocalClass.getLBrace();
    PsiElement rbrace = myAnonOrLocalClass.getRBrace();
    if (lbrace != null) {
      aClass.addRange(lbrace.getNextSibling(), rbrace != null ? rbrace.getPrevSibling() : myAnonOrLocalClass.getLastChild());
    }
    return aClass;
  }
@NotNull
  private PsiClass createInnerFromAnonymous(String name, PsiAnonymousClass anonymousClass, PsiElementFactory factory)