示例#1
0
        /// <summary>
        /// Returns a look-up of workspace edits suggested by the compiler for the given location and context.
        /// The key of the look-up is a suitable title for the corresponding edits that can be presented to the user.
        /// Returns null if any of the given arguments is null or if suitable edits cannot be determined.
        /// </summary>
        public static ILookup <string, WorkspaceEdit>?CodeActions(this FileContentManager file, CompilationUnit compilation, Range?range, CodeActionContext?context)
        {
            if (range?.Start is null || range.End is null || !file.ContainsRange(range))
            {
                return(null);
            }
            var diagnostics = context?.Diagnostics ?? Array.Empty <Diagnostic>();

            return(file.UnknownIdSuggestions(compilation, range.Start.Line, diagnostics)
                   .Concat(file.AmbiguousIdSuggestions(compilation, diagnostics))
                   .Concat(file.DeprecatedSyntaxSuggestions(diagnostics))
                   .Concat(file.UpdateReassignStatementSuggestions(diagnostics))
                   .Concat(file.IndexRangeSuggestions(compilation, range))
                   .Concat(file.UnreachableCodeSuggestions(diagnostics))
                   .Concat(file.DocCommentSuggestions(range))
                   .ToLookup(s => s.Item1, s => s.Item2));
        }