Find() public static method

public static Find ( ITextBuffer buffer ) : IEnumerable
buffer ITextBuffer
return IEnumerable
示例#1
0
        private void FindDiagnostics()
        {
            try
            {
                spansAndDiagnostics.Clear();

                int minPosition = buffer.CurrentSnapshot.Length;
                int maxPosition = 0;

                foreach (var diagnostic in DiagnosticsFinder.Find(buffer))
                {
                    if (diagnostic.StartLine != 0)
                    {
                        diagnostic.StartLine--;
                    }

                    var textLine      = buffer.CurrentSnapshot.GetLineFromLineNumber(diagnostic.StartLine);
                    var startPosition = textLine.Start.Position;
                    var endPosition   = textLine.End.Position;

                    minPosition = Math.Min(minPosition, startPosition);
                    maxPosition = Math.Max(maxPosition, endPosition);

                    SnapshotSpan span = new SnapshotSpan(buffer.CurrentSnapshot,
                                                         Span.FromBounds(startPosition, endPosition));
                    spansAndDiagnostics.Add(Tuple.Create(span, diagnostic));
                }

                if (spansAndDiagnostics.Any())
                {
                    RaiseTagsChanged(minPosition, maxPosition);
                }
                else
                {
                    if (TagsChanged != null && !lastTotalDiagnosticsSpan.IsEmpty)
                    {
                        TagsChanged(this, new SnapshotSpanEventArgs(lastTotalDiagnosticsSpan));
                    }
                }
            }
            catch (Exception e)
            {
                dte.StatusBar.Text = "Naggy Error: " + e.Message;
            }
        }