private void invokeImpl(final PsiClass targetClass) {
    PsiNewExpression newExpression = getNewExpression();
    if (!targetClass.isPhysical()) {
      newExpression = PsiTreeUtil.findSameElementInCopy(newExpression, targetClass.getContainingFile());
    }
    PsiJavaCodeReferenceElement ref = newExpression.getClassOrAnonymousClassReference();
    assert ref != null;
    String refName = ref.getReferenceName();
    LOG.assertTrue(refName != null);
    PsiElementFactory elementFactory = JavaPsiFacade.getElementFactory(newExpression.getProject());
    PsiClass created = getKind().create(elementFactory, refName);
    created = (PsiClass)targetClass.add(created);

    final PsiModifierList modifierList = created.getModifierList();
    LOG.assertTrue(modifierList != null);
    if (PsiTreeUtil.isAncestor(targetClass, newExpression, true)) {
      if (targetClass.isInterface() || PsiUtil.isLocalOrAnonymousClass(targetClass)) {
        modifierList.setModifierProperty(PsiModifier.PACKAGE_LOCAL, true);
      } else {
        modifierList.setModifierProperty(PsiModifier.PRIVATE, true);
      }
    }

    if (!created.hasModifierProperty(PsiModifier.STATIC) &&
        newExpression.getQualifier() == null &&
        (!PsiTreeUtil.isAncestor(targetClass, newExpression, true) || PsiUtil.getEnclosingStaticElement(newExpression, targetClass) != null || isInThisOrSuperCall(newExpression))) {
      modifierList.setModifierProperty(PsiModifier.STATIC, true);
    }

    setupGenericParameters(created, ref);
    setupClassFromNewExpression(created, newExpression);
  }
private void invokeImpl(final PsiClass targetClass)