public void CreateSquiggleSpan(SimpleTagger <ErrorTag> tagger) { if (_rawSpan.Start >= _rawSpan.End || _spanTranslator == null) { return; } // TODO: Map between versions rather than using the current snapshot var snapshot = _spanTranslator.TextBuffer.CurrentSnapshot; var target = _rawSpan.ToSnapshotSpan(snapshot); //SnapshotSpan target = _spanTranslator.TranslateForward( // new Span(_rawSpan.Start.Index, _rawSpan.Length) //); if (target.Length <= 0) { return; } var tagSpan = snapshot.CreateTrackingSpan( target.Start, target.Length, SpanTrackingMode.EdgeInclusive ); tagger.CreateTagSpan(tagSpan, new ErrorTag(ErrorType, _message)); }
private ITextBuffer CreateNewBuffer() { Presenter.AssertIsForeground(); // is it okay to create buffer from threads other than UI thread? var contentTypeService = Document.Project.LanguageServices.GetService <IContentTypeLanguageService>(); var contentType = contentTypeService.GetDefaultContentType(); var textBuffer = Presenter.TextBufferFactoryService.CreateTextBuffer( _sourceText.ToString(), contentType); // Create an appropriate highlight span on that buffer for the reference. var key = _isDefinitionLocation ? PredefinedPreviewTaggerKeys.DefinitionHighlightingSpansKey : PredefinedPreviewTaggerKeys.ReferenceHighlightingSpansKey; textBuffer.Properties.RemoveProperty(key); textBuffer.Properties.AddProperty(key, new NormalizedSnapshotSpanCollection( SourceSpan.ToSnapshotSpan(textBuffer.CurrentSnapshot))); return(textBuffer); }