示例#1
0
        private static VSCodeAction GenerateVSCodeAction(
            CodeActionParams request,
            SourceText documentText,
            IUnifiedSuggestedAction suggestedAction,
            LSP.CodeActionKind codeActionKind,
            UnifiedSuggestedActionSetPriority setPriority,
            LSP.Range?applicableRange,
            int currentSetNumber,
            ref int currentHighestSetNumber,
            string currentTitle = "")
        {
            if (!string.IsNullOrEmpty(currentTitle))
            {
                // Adding a delimiter for nested code actions, e.g. 'Suppress or Configure issues|Suppress IDEXXXX|in Source'
                currentTitle += '|';
            }

            var codeAction = suggestedAction.OriginalCodeAction;

            currentTitle += codeAction.Title;

            // Nested code actions' unique identifiers consist of: parent code action unique identifier + '|' + title of code action
            var nestedActions = GenerateNestedVSCodeActions(request, documentText, suggestedAction, codeActionKind, ref currentHighestSetNumber, currentTitle);

            return(new VSCodeAction
            {
                Title = codeAction.Title,
                Kind = codeActionKind,
                Diagnostics = request.Context.Diagnostics,
                Children = nestedActions,
                Priority = UnifiedSuggestedActionSetPriorityToPriorityLevel(setPriority),
                Group = $"Roslyn{currentSetNumber}",
                ApplicableRange = applicableRange,
                Data = new CodeActionResolveData(currentTitle, request.Range, request.TextDocument)
            });
示例#2
0
 public UnifiedSuggestedActionSet(
     string?categoryName,
     IEnumerable <IUnifiedSuggestedAction> actions,
     object?title,
     UnifiedSuggestedActionSetPriority priority,
     TextSpan?applicableToSpan)
 {
     CategoryName     = categoryName;
     Actions          = actions;
     Title            = title;
     Priority         = priority;
     ApplicableToSpan = applicableToSpan;
 }
示例#3
0
 public UnifiedSuggestedActionSet(
     Solution originalSolution,
     string?categoryName,
     ImmutableArray <IUnifiedSuggestedAction> actions,
     object?title,
     UnifiedSuggestedActionSetPriority priority,
     TextSpan?applicableToSpan)
 {
     OriginalSolution = originalSolution;
     CategoryName     = categoryName;
     Actions          = actions;
     Title            = title;
     Priority         = priority;
     ApplicableToSpan = applicableToSpan;
 }
 static SuggestedActionSetPriority ConvertToSuggestedActionSetPriority(UnifiedSuggestedActionSetPriority unifiedSuggestedActionSetPriority)
 => unifiedSuggestedActionSetPriority switch
 {