internal TaskProviderItem( IServiceProvider serviceProvider, string message, SourceSpan rawSpan, VSTASKPRIORITY priority, VSTASKCATEGORY category, bool squiggle, LocationTracker spanTranslator ) { _serviceProvider = serviceProvider; _message = message; _rawSpan = rawSpan; _spanTranslator = spanTranslator; _rawSpan = rawSpan; _priority = priority; _category = category; _squiggle = squiggle; }
public TaskProviderItemFactory(LocationTracker spanTranslator) { _spanTranslator = spanTranslator; }
public TaskProviderItemFactory(LocationTracker spanTranslator, int fromVersion) { _spanTranslator = spanTranslator; _fromVersion = fromVersion; }
public object CreateDiffView(AnalysisProtocol.ChangeInfo[] changes, LocationTracker tracker, ITextBuffer originalBuffer) { // Create a copy of the left hand buffer (we're going to remove all of the // content we don't care about from it). var leftBuffer = _bufferFactory.CreateTextBuffer(originalBuffer.ContentType); using (var edit = leftBuffer.CreateEdit()) { edit.Insert(0, originalBuffer.CurrentSnapshot.GetText()); edit.Apply(); } // create a buffer for the right hand side, copy the original buffer // into it, and then apply the changes. var rightBuffer = _bufferFactory.CreateTextBuffer(originalBuffer.ContentType); using (var edit = rightBuffer.CreateEdit()) { edit.Insert(0, originalBuffer.CurrentSnapshot.GetText()); edit.Apply(); } var startingVersion = rightBuffer.CurrentSnapshot; VsProjectAnalyzer.ApplyChanges(changes, rightBuffer, tracker); var textChanges = startingVersion.Version.Changes; int minPos = startingVersion.Length, maxPos = 0; foreach (var change in textChanges) { minPos = Math.Min(change.OldPosition, minPos); maxPos = Math.Max(change.OldPosition, maxPos); } if (minPos == startingVersion.Length && maxPos == 0) { // no changes? that's weird... return(null); } MinimizeBuffers(leftBuffer, rightBuffer, startingVersion, minPos, maxPos); // create the difference buffer and view... var diffBuffer = _diffBufferFactory.CreateDifferenceBuffer(leftBuffer, rightBuffer); var diffView = _diffFactory.CreateDifferenceView(diffBuffer, _previewRoleSet); diffView.ViewMode = DifferenceViewMode.Inline; diffView.InlineView.ZoomLevel *= .75; diffView.InlineView.VisualElement.Focusable = false; diffView.InlineHost.GetTextViewMargin("deltadifferenceViewerOverview").VisualElement.Visibility = System.Windows.Visibility.Collapsed; // Reduce the size of the buffer once it's ready diffView.DifferenceBuffer.SnapshotDifferenceChanged += (sender, args) => { diffView.InlineView.DisplayTextLineContainingBufferPosition( new SnapshotPoint(diffView.DifferenceBuffer.CurrentInlineBufferSnapshot, 0), 0.0, ViewRelativePosition.Top, double.MaxValue, double.MaxValue ); var width = Math.Max(diffView.InlineView.MaxTextRightCoordinate * (diffView.InlineView.ZoomLevel / 100), 400); // Width of the widest line. var height = diffView.InlineView.LineHeight * (diffView.InlineView.ZoomLevel / 100) * // Height of each line. diffView.DifferenceBuffer.CurrentInlineBufferSnapshot.LineCount; diffView.VisualElement.Width = width; diffView.VisualElement.Height = height; }; return(diffView.VisualElement); }
private async void OnNewAnalysis(AnalysisEntry entry) { if (!_provider._colorNames) { bool raise = false; lock (_spanCacheLock) { if (_spanCache != null) { _spanCache = null; raise = true; } } if (raise) { OnNewClassifications(_buffer.CurrentSnapshot); } return; } var classifications = await entry.Analyzer.GetAnalysisClassificationsAsync( entry, _buffer, _provider._colorNamesWithAnalysis ); if (classifications != null) { Debug.WriteLine("Received {0} classifications", classifications.Data.classifications.Length); // sort the spans by starting position so we can use binary search when handing them out Array.Sort( classifications.Data.classifications, (x, y) => x.start - y.start ); lock (_spanCacheLock) { _spanCache = classifications.Data.classifications; _spanTranslator = classifications.GetTracker(classifications.Data.version); } if (_spanTranslator != null) { OnNewClassifications(_buffer.CurrentSnapshot); } } }