public TableDataSourceFindReferencesContext(
                StreamingFindReferencesPresenter presenter,
                IFindAllReferencesWindow findReferencesWindow)
            {
                presenter.AssertIsForeground();

                Presenter             = presenter;
                _findReferencesWindow = findReferencesWindow;

                // If the window is closed, cancel any work we're doing.
                _findReferencesWindow.Closed += (s, e) => CancelSearch();

                // Remove any existing sources in the window.
                foreach (var source in findReferencesWindow.Manager.Sources.ToArray())
                {
                    findReferencesWindow.Manager.RemoveSource(source);
                }

                // And add ourselves as the source of results for the window.
                findReferencesWindow.Manager.AddSource(this);

                // After adding us as the source, the manager should immediately call into us to
                // tell us what the data sink is.
                Debug.Assert(_tableDataSink != null);
            }
            private static IList <System.Windows.Documents.Inline> GetHighlightedInlines(
                StreamingFindReferencesPresenter presenter,
                TaggedTextAndHighlightSpan taggedTextAndHighlight,
                bool isDefinition)
            {
                var propertyId = isDefinition
                    ? DefinitionHighlightTag.TagId
                    : ReferenceHighlightTag.TagId;

                var properties = presenter._formatMapService
                                 .GetEditorFormatMap("text")
                                 .GetProperties(propertyId);
                var highlightBrush = properties["Background"] as Brush;

                var lineParts = taggedTextAndHighlight.TaggedText;
                var inlines   = lineParts.ToInlines(
                    presenter._typeMap,
                    runCallback: (run, taggedText, position) =>
                {
                    if (highlightBrush != null)
                    {
                        if (position == taggedTextAndHighlight.HighlightSpan.Start)
                        {
                            run.SetValue(
                                System.Windows.Documents.TextElement.BackgroundProperty,
                                highlightBrush);
                        }
                    }
                });

                return(inlines);
            }
            public TableDataSourceFindReferencesContext(
                 StreamingFindReferencesPresenter presenter,
                 IFindAllReferencesWindow findReferencesWindow)
            {
                presenter.AssertIsForeground();

                Presenter = presenter;
                _findReferencesWindow = findReferencesWindow;

                // If the window is closed, cancel any work we're doing.
                _findReferencesWindow.Closed += (s, e) => CancelSearch();

                // Remove any existing sources in the window.  
                foreach (var source in findReferencesWindow.Manager.Sources.ToArray())
                {
                    findReferencesWindow.Manager.RemoveSource(source);
                }

                // And add ourselves as the source of results for the window.
                findReferencesWindow.Manager.AddSource(this);

                // After adding us as the source, the manager should immediately call into us to
                // tell us what the data sink is.
                Debug.Assert(_tableDataSink != null);
            }
Beispiel #4
0
 public RoslynDefinitionBucket(
     StreamingFindReferencesPresenter presenter,
     TableDataSourceFindReferencesContext context,
     DefinitionItem definitionItem)
     : base(name: definitionItem.DisplayParts.JoinText() + " " + definitionItem.GetHashCode(),
            sourceTypeIdentifier: context.SourceTypeIdentifier,
            identifier: context.Identifier)
 {
     _presenter     = presenter;
     _context       = context;
     DefinitionItem = definitionItem;
 }
 public RoslynDefinitionBucket(
     StreamingFindReferencesPresenter presenter,
     TableDataSourceFindReferencesContext context,
     DefinitionItem definitionItem)
     : base(name: definitionItem.DisplayParts.JoinText() + " " + definitionItem.GetHashCode(),
            sourceTypeIdentifier: context.SourceTypeIdentifier,
            identifier: context.Identifier)
 {
     _presenter = presenter;
     _context = context;
     DefinitionItem = definitionItem;
 }
            private static IList <System.Windows.Documents.Inline> GetHighlightedInlines(
                StreamingFindReferencesPresenter presenter,
                SourceText sourceText,
                ClassifiedSpansAndHighlightSpan classifiedSpansAndHighlight,
                bool isDefinition)
            {
                var propertyId = isDefinition
                    ? DefinitionHighlightTag.TagId
                    : ReferenceHighlightTag.TagId;

                var properties = presenter._formatMapService
                                 .GetEditorFormatMap("text")
                                 .GetProperties(propertyId);
                var highlightBrush = properties["Background"] as Brush;

                var classifiedSpans = classifiedSpansAndHighlight.ClassifiedSpans;
                var classifiedTexts = classifiedSpans.SelectAsArray(
                    cs => new ClassifiedText(cs.ClassificationType, sourceText.ToString(cs.TextSpan)));

                var inlines = classifiedTexts.ToInlines(
                    presenter._typeMap,
                    runCallback: (run, classifiedText, position) =>
                {
                    if (highlightBrush != null)
                    {
                        if (position == classifiedSpansAndHighlight.HighlightSpan.Start)
                        {
                            run.SetValue(
                                System.Windows.Documents.TextElement.BackgroundProperty,
                                highlightBrush);
                        }
                    }
                });

                return(inlines);
            }
            private static IList<System.Windows.Documents.Inline> GetHighlightedInlines(
                StreamingFindReferencesPresenter presenter,
                TaggedTextAndHighlightSpan taggedTextAndHighlight,
                bool isDefinition)
            {
                var propertyId = isDefinition
                    ? DefinitionHighlightTag.TagId
                    : ReferenceHighlightTag.TagId;

                var properties = presenter._formatMapService
                                          .GetEditorFormatMap("text")
                                          .GetProperties(propertyId);
                var highlightBrush = properties["Background"] as Brush;

                var lineParts = taggedTextAndHighlight.TaggedText;
                var inlines = lineParts.ToInlines(
                    presenter._typeMap,
                    runCallback: (run, taggedText, position) =>
                    {
                        if (highlightBrush != null)
                        {
                            if (position == taggedTextAndHighlight.HighlightSpan.Start)
                            {
                                run.SetValue(
                                    System.Windows.Documents.TextElement.BackgroundProperty,
                                    highlightBrush);
                            }
                        }
                    });

                return inlines;
            }
            private static IList<System.Windows.Documents.Inline> GetHighlightedInlines(
                StreamingFindReferencesPresenter presenter,
                SourceText sourceText,
                ClassifiedSpansAndHighlightSpan classifiedSpansAndHighlight,
                bool isDefinition)
            {
                var propertyId = isDefinition
                    ? DefinitionHighlightTag.TagId
                    : ReferenceHighlightTag.TagId;

                var properties = presenter._formatMapService
                                          .GetEditorFormatMap("text")
                                          .GetProperties(propertyId);
                var highlightBrush = properties["Background"] as Brush;

                var classifiedSpans = classifiedSpansAndHighlight.ClassifiedSpans;
                var classifiedTexts = classifiedSpans.SelectAsArray(
                    cs => new ClassifiedText(cs.ClassificationType, sourceText.ToString(cs.TextSpan)));

                var inlines = classifiedTexts.ToInlines(
                    presenter._typeMap,
                    runCallback: (run, classifiedText, position) =>
                    {
                        if (highlightBrush != null)
                        {
                            if (position == classifiedSpansAndHighlight.HighlightSpan.Start)
                            {
                                run.SetValue(
                                    System.Windows.Documents.TextElement.BackgroundProperty,
                                    highlightBrush);
                            }
                        }
                    });

                return inlines;
            }