/// <summary> /// Called when a UVSS document is generated by the parser service. /// </summary> private void OnDocumentGenerated(UvssTextParserResult result) { lock (errors) { errors.Clear(); if (result.Document != null) { var diagnostics = result.Document.GetDiagnostics().Where(x => x.Severity == DiagnosticSeverity.Error).ToList(); var diagnosticErrors = diagnostics.Select(x => { var errorSpan = new SnapshotSpan(result.Snapshot, x.Location.Start, x.Location.Length); return(new Error(textDocument.FilePath, errorSpan, x)); }); errors.AddRange(diagnosticErrors); } errorsDirty = true; } }
/// <summary> /// Visits the specified UVSS document and returns a list of classification spans that /// intersect with the specified span. /// </summary> /// <param name="document">The document to visit.</param> /// <param name="span">The span for which to retrieve classification spans.</param> /// <returns>The classification spans that intersect with the specified span.</returns> public IList <ClassificationSpan> VisitDocument(UvssTextParserResult result, SnapshotSpan span) { if (result.Document == null) { return(null); } span = span.TranslateTo(result.Snapshot, SpanTrackingMode.EdgeExclusive); var results = new List <ClassificationSpan>(); var visitor = new UvssClassifierVisitor(registry, (start, width, type, kind) => { var nodeSpan = new SnapshotSpan(span.Snapshot, start, width); if (nodeSpan.IntersectsWith(span)) { results.Add(new ClassificationSpan(nodeSpan, type)); } }); visitor.Visit(result.Document); return(results); }