void HandleActivatedDiagnostic(EditCodeVM vm, CompilerDiagnosticVM diag) { if (string.IsNullOrEmpty(diag.FullPath)) { return; } var doc = vm.Documents.FirstOrDefault(a => a.Name == diag.FullPath); Debug.Assert(doc != null); if (doc == null) { return; } vm.SelectedDocument = doc; if (diag.LineLocationSpan != null) { UIUtilities.Focus(doc.TextView.VisualElement, () => { // The caret isn't always moved unless we wait a little Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() => { if (doc == vm.SelectedDocument) { doc.TextView.MoveCaretTo(diag.LineLocationSpan.Value.StartLinePosition.Line, diag.LineLocationSpan.Value.StartLinePosition.Character); doc.TextView.Caret.EnsureVisible(); doc.TextView.Selection.Clear(); } })); }); } }
void GoToDiagnostic(int offset) { var item = SelectedCompilerDiagnosticVM ?? Diagnostics.FirstOrDefault(); if (item == null) { return; } int index = Diagnostics.IndexOf(item); Debug.Assert(index >= 0); if (index < 0) { return; } index = (index + offset) % Diagnostics.Count; if (index < 0) { index += Diagnostics.Count; } var diag = Diagnostics[index]; SelectedCompilerDiagnosticVM = diag; MoveTo(diag); }
void SetDiagnostics(IEnumerable <CompilerDiagnostic> diags) { Diagnostics.Clear(); Diagnostics.AddRange(diags.OrderBy(a => a, CompilerDiagnosticComparer.Instance). Where(a => a.Severity != CompilerDiagnosticSeverity.Hidden). Select(a => new CompilerDiagnosticVM(a, GetImageReference(a.Severity) ?? default(ImageReference)))); SelectedCompilerDiagnosticVM = Diagnostics.FirstOrDefault(); }
void CopyToClipboard(CompilerDiagnosticVM[] diags) { if (diags.Length == 0) return; var sb = new StringBuilder(); foreach (var d in diags) { d.WriteTo(sb); sb.AppendLine(); } if (sb.Length > 0) { try { Clipboard.SetText(sb.ToString()); } catch (ExternalException) { } } }