public IEnumerable <ITagSpan <IClassificationTag> > GetTags(NormalizedSnapshotSpanCollection spans) { if (!_options.SemanticColoringEnabled || spans.Count == 0) { return(Enumerable.Empty <ITagSpan <IClassificationTag> >()); } var thingy = _thingy; if (thingy == null || thingy.Snapshot != spans[0].Snapshot) { try { thingy = ThreadHelper.JoinableTaskFactory.Run(async() => await Thingy.GetAsync(_buffer, spans[0].Snapshot)); _thingy = thingy; } catch { return(Enumerable.Empty <ITagSpan <IClassificationTag> >()); } } if (thingy == null) { return(Enumerable.Empty <ITagSpan <IClassificationTag> >()); } return(thingy.GetClassifiedSpans(spans).Select(GetTagSpan).Where(s => s != null)); }
public IEnumerable <ITagSpan <IClassificationTag> > GetTags(NormalizedSnapshotSpanCollection spans) { if (!_options.SemanticColoringEnabled || spans.Count == 0) { return(Enumerable.Empty <ITagSpan <IClassificationTag> >()); } var thingy = _thingy; if (thingy == null || thingy.Snapshot != spans[0].Snapshot) { try { var task = Thingy.Get(_buffer, spans[0].Snapshot); task.Wait(); thingy = task.Result; _thingy = thingy; } catch { return(Enumerable.Empty <ITagSpan <IClassificationTag> >()); } } if (thingy == null) { return(Enumerable.Empty <ITagSpan <IClassificationTag> >()); } return(thingy.GetClassifiedSpans(spans).Select(GetTagSpan).Where(s => s != null)); }
private void OnOptionsChanged(object sender, PropertyChangedEventArgs e) { if (!_options.SemanticColoringEnabled) { _thingy = null; } TagsChanged?.Invoke(this, new SnapshotSpanEventArgs(new SnapshotSpan(_buffer.CurrentSnapshot, 0, _buffer.CurrentSnapshot.Length))); }