コード例 #1
0
            /// <summary>
            /// Arrange refactorings into groups.
            /// </summary>
            /// <remarks>
            /// Refactorings are returned in priority order determined based on <see cref="ExtensionOrderAttribute"/>.
            /// Priority for all <see cref="SuggestedActionSet"/>s containing refactorings is set to <see cref="SuggestedActionSetPriority.Low"/>
            /// and should show up after fixes but before suppression fixes in the light bulb menu.
            /// </remarks>
            private SuggestedActionSet OrganizeRefactorings(
                Workspace workspace, CodeRefactoring refactoring,
                SuggestedActionSetPriority priority, Span applicableSpan)
            {
                var refactoringSuggestedActions = ArrayBuilder <SuggestedAction> .GetInstance();

                foreach (var action in refactoring.Actions)
                {
                    if (action.NestedCodeActions.Length > 0)
                    {
                        var nestedActions = action.NestedCodeActions.SelectAsArray(
                            na => new CodeRefactoringSuggestedAction(
                                _owner, workspace, _subjectBuffer, refactoring.Provider, na));

                        var set = new SuggestedActionSet(categoryName: null,
                                                         actions: nestedActions, priority: SuggestedActionSetPriority.Medium, applicableToSpan: applicableSpan);

                        refactoringSuggestedActions.Add(new SuggestedActionWithNestedActions(
                                                            _owner, workspace, _subjectBuffer,
                                                            refactoring.Provider, action, set));
                    }
                    else
                    {
                        refactoringSuggestedActions.Add(new CodeRefactoringSuggestedAction(
                                                            _owner, workspace, _subjectBuffer, refactoring.Provider, action));
                    }
                }

                return(new SuggestedActionSet(
                           PredefinedSuggestedActionCategoryNames.Refactoring,
                           refactoringSuggestedActions.ToImmutableAndFree(),
                           priority: priority,
                           applicableToSpan: applicableSpan));
            }
コード例 #2
0
        /// <summary>
        /// Creates a new instance of the <see cref="SuggestedActionSet"/> for given list
        /// of suggested actions with a header and optionally an applicable span of text.
        /// </summary>
        /// <param name="categoryName">
        /// The name of the <see cref="ISuggestedActionCategory"/> to which all of these actions belong.
        /// </param>
        /// <param name="actions">A list of suggested actions.</param>
        /// <param name="title">The title for this list of suggested actions.</param>
        /// <param name="priority">The <see cref="SuggestedActionSetPriority"/> value of this list of suggested actions</param>
        /// <param name="applicableToSpan">The applicability span for this list of suggested actions.</param>
        public SuggestedActionSet(
            string categoryName,
            IEnumerable <ISuggestedAction> actions,
            object title = null,
            SuggestedActionSetPriority priority = SuggestedActionSetPriority.None,
            Span?applicableToSpan = null)
        {
            if (actions == null)
            {
                throw new ArgumentNullException(nameof(actions));
            }

            this.CategoryName     = categoryName ?? PredefinedSuggestedActionCategoryNames.Any;
            this.Actions          = actions.ToArray();
            this.Priority         = priority;
            this.ApplicableToSpan = applicableToSpan;
            this.Title            = title;
        }
コード例 #3
0
            /// <summary>
            /// Arrange refactorings into groups.
            /// </summary>
            /// <remarks>
            /// Refactorings are returned in priority order determined based on <see cref="ExtensionOrderAttribute"/>.
            /// Priority for all <see cref="SuggestedActionSet"/>s containing refactorings is set to <see cref="SuggestedActionSetPriority.Low"/>
            /// and should show up after fixes but before suppression fixes in the light bulb menu.
            /// </remarks>
            private SuggestedActionSet OrganizeRefactorings(
                Workspace workspace, CodeRefactoring refactoring,
                SuggestedActionSetPriority priority, Span applicableSpan)
            {
                var refactoringSuggestedActions = ArrayBuilder <SuggestedAction> .GetInstance();

                foreach (var action in refactoring.Actions)
                {
                    refactoringSuggestedActions.Add(new CodeRefactoringSuggestedAction(
                                                        _owner, workspace, _subjectBuffer, refactoring.Provider, action));
                }

                return(new SuggestedActionSet(
                           PredefinedSuggestedActionCategoryNames.Refactoring,
                           refactoringSuggestedActions.ToImmutableAndFree(),
                           priority: priority,
                           applicableToSpan: applicableSpan));
            }
コード例 #4
0
 public SuggestedActionSet(IEnumerable <ISuggestedAction> actions, object title,
                           SuggestedActionSetPriority priority = SuggestedActionSetPriority.None,
                           Span?applicableToSpan = null) : this(null, actions, title, priority, applicableToSpan)
 {
 }
コード例 #5
0
 public SuggestedActionSet(IEnumerable <ISuggestedAction> actions,
                           SuggestedActionSetPriority priority = SuggestedActionSetPriority.None,
                           Span?applicableToSpan = null) : this(actions, title : null, priority : priority, applicableToSpan : applicableToSpan)
 {
 }