Exemplo n.º 1
0
        /// <summary>
        /// Returns workspace edits for correcting the casing or capitalization of unknown identifiers.
        /// </summary>
        private static IEnumerable <(string, WorkspaceEdit)> UnknownIdCaseSuggestions(
            this FileContentManager file, CompilationUnit compilation, IReadOnlyCollection <Diagnostic> diagnostics)
        {
            (string, WorkspaceEdit) SuggestedIdEdit(string suggestedId, Lsp.Range range)
            {
                var edit = new TextEdit {
                    Range = range, NewText = suggestedId
                };

                return($"Replace with \"{suggestedId}\".", file.GetWorkspaceEdit(edit));
            }

            var idSuggestions =
                from diagnostic in diagnostics
                where DiagnosticTools.ErrorType(ErrorCode.UnknownIdentifier)(diagnostic)
                from id in file.IdCaseSuggestions(diagnostic.Range.Start.ToQSharp(), compilation)
                select SuggestedIdEdit(id, diagnostic.Range);

            var typeSuggestions =
                from diagnostic in diagnostics
                where DiagnosticTools.ErrorType(ErrorCode.UnknownType)(diagnostic)
                from type in file.TypeCaseSuggestions(diagnostic.Range.Start.ToQSharp(), compilation)
                select SuggestedIdEdit(type, diagnostic.Range);

            return(idSuggestions.Concat(typeSuggestions));
        }