Ejemplo n.º 1
0
        public IEnumerable <IntentionAction> CreateBulbItems()
        {
            var node = myDataProvider.GetSelectedTreeNode <ITreeNode>();

            Assertion.Assert(node != null, "node != null");
            var classDeclaration = node.GetContainingNode <IClassLikeDeclaration>();

            var fix    = new GenerateUnityEventFunctionsFix(classDeclaration);
            var action = new IntentionAction(fix, PsiFeaturesUnsortedThemedIcons.FuncZoneGenerate.Id,
                                             BulbMenuAnchors.PermanentItem);

            return(new[] { action });
        }
Ejemplo n.º 2
0
        public IEnumerable<BulbMenuItem> GetBulbMenuItems(ISolution solution, ITextControl textControl)
        {
            var declaration = myElement as IClassLikeDeclaration;
            if (declaration != null)
            {
                var foo = new GenerateUnityEventFunctionsFix(declaration);
                return new[]
                {
                    new BulbMenuItem(new IntentionAction.MyExecutableProxi(foo, solution, textControl), "Generate Unity event functions", PsiFeaturesUnsortedThemedIcons.FuncZoneGenerate.Id, BulbMenuAnchors.FirstClassContextItems)
                };
            }

            return EmptyList<BulbMenuItem>.Enumerable;
        }
        public IEnumerable <IntentionAction> CreateBulbItems()
        {
            var node = myDataProvider.GetSelectedTreeNode <ITreeNode>();

            Assertion.Assert(node != null, "node != null");
            var classDeclaration = node.GetContainingNode <IClassLikeDeclaration>();

            var fix = new GenerateUnityEventFunctionsFix(classDeclaration, node);

            //RIDER-30526
            var action = new IntentionAction(fix, PsiFeaturesUnsortedThemedIcons.FuncZoneGenerate.Id,
                                             new SubmenuAnchor(BulbMenuAnchors.PermanentBackgroundItems, SubmenuBehavior.Executable));

            return(new[] { action });
        }
Ejemplo n.º 4
0
        public IEnumerable <BulbMenuItem> GetBulbMenuItems(ISolution solution, ITextControl textControl)
        {
            var declaration = myElement as IClassLikeDeclaration;

            if (declaration != null)
            {
                var foo = new GenerateUnityEventFunctionsFix(declaration);
                return(new[]
                {
                    new BulbMenuItem(new IntentionAction.MyExecutableProxi(foo, solution, textControl), "Generate Unity event functions", PsiFeaturesUnsortedThemedIcons.FuncZoneGenerate.Id, BulbMenuAnchors.FirstClassContextItems)
                });
            }

            return(EmptyList <BulbMenuItem> .Enumerable);
        }
Ejemplo n.º 5
0
        protected override IEnumerable <BulbMenuItem> GetActions(ICSharpDeclaration declaration)
        {
            var result      = new List <BulbMenuItem>();
            var textControl = Solution.GetComponent <ITextControlManager>().LastFocusedTextControl.Value;

            if (declaration is IClassLikeDeclaration classLikeDeclaration &&
                textControl != null && myUnityApi.IsUnityType(classLikeDeclaration.DeclaredElement))
            {
                var fix = new GenerateUnityEventFunctionsFix(classLikeDeclaration);
                result.Add(
                    new BulbMenuItem(new IntentionAction.MyExecutableProxi(fix, Solution, textControl),
                                     "Generate Unity event functions", PsiFeaturesUnsortedThemedIcons.FuncZoneGenerate.Id,
                                     BulbMenuAnchors.FirstClassContextItems)
                    );
            }

            return(result);
        }
Ejemplo n.º 6
0
        public IEnumerable <BulbMenuItem> GetBulbMenuItems(ISolution solution, ITextControl textControl)
        {
            var classDeclaration = myElement as IClassLikeDeclaration;

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

            var methodDeclaration = myElement as IMethodDeclaration;

            if (methodDeclaration != null)
            {
                var isCoroutine = IsCoroutine(methodDeclaration, myUnityApi);
                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);
        }