示例#1
0
        /// <summary>
        /// If the provided fix all context is non-null and the context's code action Id matches the given code action's Id then,
        /// returns the set of fix all occurrences actions associated with the code action.
        /// </summary>
        internal static SuggestedActionSet GetFixAllSuggestedActionSet(
            CodeAction action,
            int actionCount,
            FixAllProvider fixAllProvider,
            FixAllContext fixAllCodeActionContext,
            IEnumerable <FixAllScope> supportedScopes,
            Diagnostic firstDiagnostic,
            Workspace workspace,
            ITextBuffer subjectBuffer,
            ICodeActionEditHandlerService editHandler,
            IWaitIndicator waitIndicator,
            IAsynchronousOperationListener operationListener)
        {
            if (fixAllCodeActionContext == null)
            {
                return(null);
            }

            if (actionCount > 1 && action.EquivalenceKey == null)
            {
                return(null);
            }

            var fixAllSuggestedActions = ImmutableArray.CreateBuilder <FixAllSuggestedAction>();

            foreach (var scope in supportedScopes)
            {
                var fixAllContext         = fixAllCodeActionContext.GetContextForScopeAndActionId(scope, action.EquivalenceKey);
                var fixAllAction          = new FixAllCodeAction(fixAllContext, fixAllProvider, showPreviewChangesDialog: true);
                var fixAllSuggestedAction = new FixAllSuggestedAction(
                    workspace, subjectBuffer, editHandler, waitIndicator, fixAllAction,
                    fixAllProvider, firstDiagnostic, operationListener);
                fixAllSuggestedActions.Add(fixAllSuggestedAction);
            }

            return(new SuggestedActionSet(fixAllSuggestedActions.ToImmutable(), title: EditorFeaturesResources.FixAllOccurrencesIn));
        }