protected IEnumerable <BulbMenuItem> GetEventFunctionActions(ICSharpDeclaration declaration)
        {
            var result = new List <BulbMenuItem>();

            if (declaration is IMethodDeclaration methodDeclaration)
            {
                var declaredElement = methodDeclaration.DeclaredElement;
                var textControl     = Solution.GetComponent <ITextControlManager>().LastFocusedTextControl.Value;

                if (textControl != null && declaredElement != null)
                {
                    var isCoroutine = IsCoroutine(methodDeclaration, UnityApi);
                    if (isCoroutine.HasValue)
                    {
                        IBulbAction bulbAction;
                        if (isCoroutine.Value)
                        {
                            bulbAction = new ConvertFromCoroutineBulbAction(methodDeclaration);
                        }
                        else
                        {
                            bulbAction = new ConvertToCoroutineBulbAction(methodDeclaration);
                        }

                        result.Add(new BulbMenuItem(
                                       new IntentionAction.MyExecutableProxi(bulbAction, Solution, textControl),
                                       bulbAction.Text, BulbThemedIcons.ContextAction.Id,
                                       BulbMenuAnchors.FirstClassContextItems));
                    }

                    if (UnityApi.IsEventFunction(declaredElement))
                    {
                        var documentationNavigationAction = new DocumentationNavigationAction(
                            Solution.GetComponent <ShowUnityHelp>(), declaredElement, UnityApi);
                        result.Add(new BulbMenuItem(
                                       new IntentionAction.MyExecutableProxi(documentationNavigationAction, Solution,
                                                                             textControl), documentationNavigationAction.Text, CommonThemedIcons.Question.Id,
                                       BulbMenuAnchors.FirstClassContextItems));
                    }
                }
            }

            return(result);
        }
        // TODO: Move this somewhere better
        public IEnumerable <BulbMenuItem> GetBulbMenuItems(ISolution solution, ITextControl textControl)
        {
            var unityApi = solution.GetComponent <UnityApi>();

            if (Declaration is IClassLikeDeclaration classDeclaration)
            {
                var fix = new GenerateUnityEventFunctionsFix(classDeclaration);
                return(new[]
                {
                    new BulbMenuItem(new IntentionAction.MyExecutableProxi(fix, solution, textControl),
                                     "Generate Unity event functions", PsiFeaturesUnsortedThemedIcons.FuncZoneGenerate.Id,
                                     BulbMenuAnchors.FirstClassContextItems)
                });
            }

            if (Declaration is IMethodDeclaration methodDeclaration)
            {
                var isCoroutine = IsCoroutine(methodDeclaration, unityApi);
                if (isCoroutine.HasValue)
                {
                    IBulbAction bulbAction;
                    if (isCoroutine.Value)
                    {
                        bulbAction = new ConvertFromCoroutineBulbAction(methodDeclaration);
                    }
                    else
                    {
                        bulbAction = new ConvertToCoroutineBulbAction(methodDeclaration);
                    }
                    return(new[]
                    {
                        new BulbMenuItem(new IntentionAction.MyExecutableProxi(bulbAction, solution, textControl),
                                         bulbAction.Text, BulbThemedIcons.ContextAction.Id, BulbMenuAnchors.FirstClassContextItems)
                    });
                }
            }

            return(EmptyList <BulbMenuItem> .Enumerable);
        }
        public IEnumerable <BulbMenuItem> CreateBulbItemsForUnityDeclaration(IDeclaration declaration)
        {
            var unityApi    = Solution.GetComponent <UnityApi>();
            var textControl = TextControlManager.LastFocusedTextControl.Value;

            if (textControl != null)
            {
                var result = new List <BulbMenuItem>();
                if (declaration is IClassLikeDeclaration classDeclaration)
                {
                    var fix = new GenerateUnityEventFunctionsFix(classDeclaration);
                    result.Add(
                        new BulbMenuItem(new IntentionAction.MyExecutableProxi(fix, Solution, textControl),
                                         "Generate Unity event functions", PsiFeaturesUnsortedThemedIcons.FuncZoneGenerate.Id,
                                         BulbMenuAnchors.FirstClassContextItems)
                        );
                }

                if (declaration is IMethodDeclaration methodDeclaration)
                {
                    var declaredElement = methodDeclaration.DeclaredElement;

                    if (declaredElement != null)
                    {
                        var isCoroutine = IsCoroutine(methodDeclaration, unityApi);
                        if (isCoroutine.HasValue)
                        {
                            IBulbAction bulbAction;
                            if (isCoroutine.Value)
                            {
                                bulbAction = new ConvertFromCoroutineBulbAction(methodDeclaration);
                            }
                            else
                            {
                                bulbAction = new ConvertToCoroutineBulbAction(methodDeclaration);
                            }

                            result.Add(new BulbMenuItem(
                                           new IntentionAction.MyExecutableProxi(bulbAction, Solution, textControl),
                                           bulbAction.Text, BulbThemedIcons.ContextAction.Id,
                                           BulbMenuAnchors.FirstClassContextItems));
                        }

                        if (unityApi.IsEventFunction(declaredElement))
                        {
                            var documentationNavigationAction = new DocumentationNavigationAction(
                                Solution.GetComponent <ShowUnityHelp>(), declaredElement, unityApi);
                            result.Add(new BulbMenuItem(
                                           new IntentionAction.MyExecutableProxi(documentationNavigationAction, Solution,
                                                                                 textControl), documentationNavigationAction.Text, BulbThemedIcons.ContextAction.Id,
                                           BulbMenuAnchors.FirstClassContextItems));
                        }
                    }
                }

                result.AddRange(CreateAdditionalMenuItem(declaration, unityApi, textControl));
                return(result);
            }

            return(EmptyList <BulbMenuItem> .Enumerable);
        }