private bool UpdateExistingMethod([CanBeNull] IMethodDeclaration methodDeclaration, IPsiServices psiServices)
        {
            if (methodDeclaration?.Body == null)
            {
                return(false);
            }

            var classLikeDeclaration = methodDeclaration.GetContainingTypeDeclaration() as IClassLikeDeclaration;

            if (classLikeDeclaration == null)
            {
                return(false);
            }

            using (var cookie = new PsiTransactionCookie(psiServices, DefaultAction.Rollback, "UpdateExistingMethod"))
                using (WriteLockCookie.Create())
                {
                    methodDeclaration.SetName(myEventFunction.Name);

                    // TODO: We should also update return type and parameters
                    // This doesn't work - it doesn't shorten the references and we end up "global::System.Void". Don't know
                    // why and don't have time to look into right now.
                    // At least the method signature inspections will help fix up if necessary
                    // When this comes back, remember to try to match the existing parameters - they might be correct but
                    // renamed. We don't want to set the names back and break code
//                methodDeclaration.SetTypeUsage(newDeclaration.TypeUsage);
//                methodDeclaration.SetParams(newDeclaration.Params);

                    cookie.Commit();
                }

            return(true);
        }
        public override bool IsAvailable(IUserDataHolder cache)
        {
            myMethodDeclaration = myProvider.GetSelectedElement<IMethodDeclaration>(true, true);
              if (myMethodDeclaration == null)
            return false;

              // only on non-generic methods
              var method = myMethodDeclaration.DeclaredElement;
              if (method == null || method.TypeParameters.Any())
            return false;

              if (!method.IsStatic)
              {
            // only on non-generic types
            myClassDeclaration = myMethodDeclaration.GetContainingTypeDeclaration() as IClassDeclaration;
            if (myClassDeclaration == null || myClassDeclaration.TypeParameters.Any())
              return false;

            // with default constructor
            if (!myClassDeclaration.IsStatic &&
              (!myClassDeclaration.ConstructorDeclarations.IsEmpty() && !myClassDeclaration.ConstructorDeclarations.Any(c => c.ParameterDeclarations.IsEmpty())))
              return false;
              }

              return !method.Parameters.Any();
        }