Ejemplo n.º 1
0
        public void Publish(DocumentUri document)
        {
            PublishDiagnosticsParams diagnosticsParams = new PublishDiagnosticsParams();

            diagnosticsParams.Uri = document;

            var documentErrors = diagnosticCategories[document];
            var allErrors      = documentErrors.Values.SelectMany(x => x);

            diagnosticsParams.Diagnostics = new Container <Diagnostic>(allErrors);
            server.PublishDiagnostics(diagnosticsParams);
        }
Ejemplo n.º 2
0
        public void Update(Uri file, string content)
        {
            this.content = content;
            this.items   = ParseItems(server, content);

            var diagnostics = new List <Diagnostic>();

            var sections        = GetCurrentSections();
            var matchedSections = Data.GetSections()
                                  .Join(sections, x => x, x => x, (a, b) => a, StringComparer.OrdinalIgnoreCase);
            var extraSections = sections.Except(matchedSections, StringComparer.OrdinalIgnoreCase);

            if (extraSections.Any())
            {
                foreach (var section in extraSections.Select(x => items.First(z => z.Value == x)))
                {
                    diagnostics.Add(new Diagnostic()
                    {
                        Range    = section.Range,
                        Severity = DiagnosticSeverity.Warning,
                        Message  = $"Unknown section '{section.Value}'"
                    });
                }
            }

            foreach (var section in sections.Select(x => items.First(z => z.Value == x)))
            {
                var names        = GetCurrentItemsForSection(section.Value);
                var matchedNames = Data.GetNamesForSection(section.Value)
                                   .Join(names, x => x, x => x.Value, (a, b) => b, StringComparer.OrdinalIgnoreCase);
                var extraNames = names.Except(matchedNames);
                foreach (var name in extraNames)
                {
                    diagnostics.Add(new Diagnostic()
                    {
                        Range    = name.Range,
                        Severity = DiagnosticSeverity.Warning,
                        Message  = $"Unknown name '{name.Value}'"
                    });
                }
            }

            server.PublishDiagnostics(new PublishDiagnosticsParams()
            {
                Uri         = file,
                Diagnostics = diagnostics
            });
        }
Ejemplo n.º 3
0
        /// <summary>
        ///     Publish the specified diagnostics.
        /// </summary>
        /// <param name="documentUri">
        ///     The URI of the document that the diagnostics apply to.
        /// </param>
        /// <param name="diagnostics">
        ///     A sequence of <see cref="Diagnostic"/>s to publish.
        /// </param>
        public void Publish(Uri documentUri, IEnumerable <Diagnostic> diagnostics)
        {
            if (documentUri == null)
            {
                throw new ArgumentNullException(nameof(documentUri));
            }

            if (diagnostics == null)
            {
                diagnostics = Enumerable.Empty <Diagnostic>();
            }

            _languageServer.PublishDiagnostics(new PublishDiagnosticsParams
            {
                Uri         = documentUri,
                Diagnostics = diagnostics.ToArray()
            });
        }
Ejemplo n.º 4
0
 public void PublishDiagnostics(DafnyDocument document, CancellationToken cancellationToken)
 {
     _languageServer.PublishDiagnostics(ToPublishDiagnostics(document, cancellationToken));
 }