예제 #1
0
            protected AbstractTableDataSourceFindUsagesContext(
                StreamingFindUsagesPresenter presenter,
                IFindAllReferencesWindow findReferencesWindow)
            {
                presenter.AssertIsForeground();

                Presenter                      = presenter;
                _findReferencesWindow          = findReferencesWindow;
                TableControl                   = (IWpfTableControl2)findReferencesWindow.TableControl;
                TableControl.GroupingsChanged += OnTableControlGroupingsChanged;

                // If the window is closed, cancel any work we're doing.
                _findReferencesWindow.Closed += OnFindReferencesWindowClosed;

                DetermineCurrentGroupingByDefinitionState();

                Debug.Assert(_findReferencesWindow.Manager.Sources.Count == 0);

                // 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);
            }
예제 #2
0
 public AbstractItemEntry(
     RoslynDefinitionBucket definitionBucket,
     StreamingFindUsagesPresenter presenter
     ) : base(definitionBucket)
 {
     Presenter = presenter;
 }
예제 #3
0
            public TableDataSourceFindUsagesContext(
                StreamingFindUsagesPresenter presenter,
                IFindAllReferencesWindow findReferencesWindow,
                bool alwaysIncludeDeclarations)
            {
                presenter.AssertIsForeground();

                Presenter = presenter;
                _alwaysIncludeDeclarations = alwaysIncludeDeclarations;
                _findReferencesWindow      = findReferencesWindow;
                _tableControl = (IWpfTableControl2)findReferencesWindow.TableControl;
                _tableControl.GroupingsChanged += OnTableControlGroupingsChanged;

                // If the window is closed, cancel any work we're doing.
                _findReferencesWindow.Closed += OnFindReferencesWindowClosed;

                DetermineCurrentGroupingByDefinitionState();

                // 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);
            }
예제 #4
0
            protected AbstractTableDataSourceFindUsagesContext(
                StreamingFindUsagesPresenter presenter,
                IFindAllReferencesWindow findReferencesWindow,
                ImmutableArray <ITableColumnDefinition> customColumns,
                bool includeContainingTypeAndMemberColumns,
                bool includeKindColumn)
            {
                presenter.AssertIsForeground();

                Presenter                      = presenter;
                _findReferencesWindow          = findReferencesWindow;
                TableControl                   = (IWpfTableControl2)findReferencesWindow.TableControl;
                TableControl.GroupingsChanged += OnTableControlGroupingsChanged;

                // If the window is closed, cancel any work we're doing.
                _findReferencesWindow.Closed += OnFindReferencesWindowClosed;

                DetermineCurrentGroupingByDefinitionState();

                Debug.Assert(_findReferencesWindow.Manager.Sources.Count == 0);

                // Add ourselves as the source of results for the window.
                // Additionally, add applicable custom columns to display custom reference information
                _findReferencesWindow.Manager.AddSource(
                    this,
                    SelectCustomColumnsToInclude(customColumns, includeContainingTypeAndMemberColumns, includeKindColumn));

                // 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);
            }
            public TableDataSourceFindUsagesContext(
                StreamingFindUsagesPresenter 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);
            }
            public TableDataSourceFindUsagesContext(
                 StreamingFindUsagesPresenter presenter,
                 IFindAllReferencesWindow findReferencesWindow,
                 bool alwaysIncludeDeclarations)
            {
                presenter.AssertIsForeground();

                Presenter = presenter;
                _alwaysIncludeDeclarations = alwaysIncludeDeclarations;
                _findReferencesWindow = findReferencesWindow;
                _tableControl = (IWpfTableControl2)findReferencesWindow.TableControl;
                _tableControl.GroupingsChanged += OnTableControlGroupingsChanged;

                // If the window is closed, cancel any work we're doing.
                _findReferencesWindow.Closed += OnFindReferencesWindowClosed;

                DetermineCurrentGroupingByDefinitionState();

                // 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);
            }
            public TableDataSourceFindUsagesContext(
                 StreamingFindUsagesPresenter 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);
            }
 public WithoutReferencesFindUsagesContext(
     StreamingFindUsagesPresenter presenter,
     IFindAllReferencesWindow findReferencesWindow,
     ImmutableArray <AbstractFindUsagesCustomColumnDefinition> customColumns)
     : base(presenter, findReferencesWindow, customColumns)
 {
 }
예제 #9
0
 public WithoutReferencesFindUsagesContext(
     StreamingFindUsagesPresenter presenter,
     IFindAllReferencesWindow findReferencesWindow,
     ImmutableArray <ITableColumnDefinition> customColumns,
     bool includeContainingTypeAndMemberColumns,
     bool includeKindColumn)
     : base(presenter, findReferencesWindow, customColumns, includeContainingTypeAndMemberColumns, includeKindColumn)
 {
 }
예제 #10
0
 public RoslynDefinitionBucket(
     StreamingFindUsagesPresenter presenter,
     AbstractTableDataSourceFindUsagesContext context,
     DefinitionItem definitionItem)
     : base(name: definitionItem.DisplayParts.JoinText() + " " + definitionItem.GetHashCode(),
            sourceTypeIdentifier: context.SourceTypeIdentifier,
            identifier: context.Identifier)
 {
     _presenter     = presenter;
     DefinitionItem = definitionItem;
 }
 public WithReferencesFindUsagesContext(
     StreamingFindUsagesPresenter presenter,
     IFindAllReferencesWindow findReferencesWindow,
     ImmutableArray <ITableColumnDefinition> customColumns,
     IGlobalOptionService globalOptions,
     bool includeContainingTypeAndMemberColumns,
     bool includeKindColumn,
     IThreadingContext threadingContext)
     : base(presenter, findReferencesWindow, customColumns, globalOptions, includeContainingTypeAndMemberColumns, includeKindColumn, threadingContext)
 {
 }
 public RoslynDefinitionBucket(
     StreamingFindUsagesPresenter presenter,
     TableDataSourceFindUsagesContext context,
     DefinitionItem definitionItem)
     : base(name: definitionItem.DisplayParts.JoinText() + " " + definitionItem.GetHashCode(),
            sourceTypeIdentifier: context.SourceTypeIdentifier,
            identifier: context.Identifier)
 {
     _presenter = presenter;
     _context = context;
     DefinitionItem = definitionItem;
 }
예제 #13
0
            public static RoslynDefinitionBucket Create(
                StreamingFindUsagesPresenter presenter,
                AbstractTableDataSourceFindUsagesContext context,
                DefinitionItem definitionItem)
            {
                var isPrimary = definitionItem.Properties.ContainsKey(DefinitionItem.Primary);

                // Sort the primary item above everything else.
                var name = $"{(isPrimary ? 0 : 1)} {definitionItem.DisplayParts.JoinText()} {definitionItem.GetHashCode()}";

                return(new RoslynDefinitionBucket(
                           name, expandedByDefault: true, presenter, context, definitionItem));
            }
예제 #14
0
 public RoslynDefinitionBucket(
     string name,
     bool expandedByDefault,
     StreamingFindUsagesPresenter presenter,
     AbstractTableDataSourceFindUsagesContext context,
     DefinitionItem definitionItem)
     : base(name,
            sourceTypeIdentifier: context.SourceTypeIdentifier,
            identifier: context.Identifier,
            expandedByDefault: expandedByDefault)
 {
     _presenter     = presenter;
     DefinitionItem = definitionItem;
 }
            protected AbstractTableDataSourceFindUsagesContext(
                StreamingFindUsagesPresenter presenter,
                IFindAllReferencesWindow findReferencesWindow,
                ImmutableArray <ITableColumnDefinition> customColumns,
                bool includeContainingTypeAndMemberColumns,
                bool includeKindColumn)
            {
                presenter.AssertIsForeground();

                Presenter                      = presenter;
                _findReferencesWindow          = findReferencesWindow;
                TableControl                   = (IWpfTableControl2)findReferencesWindow.TableControl;
                TableControl.GroupingsChanged += OnTableControlGroupingsChanged;

                // If the window is closed, cancel any work we're doing.
                _findReferencesWindow.Closed += OnFindReferencesWindowClosed;

                DetermineCurrentGroupingByDefinitionState();

                Debug.Assert(_findReferencesWindow.Manager.Sources.Count == 0);

                // Add ourselves as the source of results for the window.
                // Additionally, add applicable custom columns to display custom reference information
                _findReferencesWindow.Manager.AddSource(
                    this,
                    SelectCustomColumnsToInclude(customColumns, includeContainingTypeAndMemberColumns, includeKindColumn));

                // 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);

                // https://devdiv.visualstudio.com/web/wi.aspx?pcguid=011b8bdf-6d56-4f87-be0d-0092136884d9&id=359162
                // VS actually responds to each SetProgess call by queuing a UI task to do the
                // progress bar update.  This can made FindReferences feel extremely slow when
                // thousands of SetProgress calls are made.
                //
                // To ensure a reasonable experience, we instead add the progress into a queue and
                // only update the UI a few times a second so as to not overload it.
                _progressQueue = new AsyncBatchingWorkQueue <(int current, int maximum)>(
                    TimeSpan.FromMilliseconds(250),
                    this.UpdateTableProgressAsync,
                    this.CancellationToken);
            }
예제 #16
0
            protected AbstractTableDataSourceFindUsagesContext(
                StreamingFindUsagesPresenter presenter,
                IFindAllReferencesWindow findReferencesWindow,
                ImmutableArray <AbstractCustomColumnDefinition> customColumns,
                bool includeContainingTypeAndMemberColumns,
                bool includeKindColumn)
            {
                presenter.AssertIsForeground();

                Presenter                      = presenter;
                _findReferencesWindow          = findReferencesWindow;
                TableControl                   = (IWpfTableControl2)findReferencesWindow.TableControl;
                TableControl.GroupingsChanged += OnTableControlGroupingsChanged;

                // If the window is closed, cancel any work we're doing.
                _findReferencesWindow.Closed += OnFindReferencesWindowClosed;

                DetermineCurrentGroupingByDefinitionState();

                Debug.Assert(_findReferencesWindow.Manager.Sources.Count == 0);

                // Add ourselves as the source of results for the window.
                // Additionally, add applicable custom columns to display custom reference information
                _findReferencesWindow.Manager.AddSource(
                    this,
                    SelectCustomColumnsToInclude(customColumns, includeContainingTypeAndMemberColumns, includeKindColumn).ToReadOnlyCollection());

                // 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);

                // Initialize custom column states at start of the FAR query.
                _customColumnTitleToStatesMap = GetInitialCustomColumnStates(findReferencesWindow.TableControl.ColumnStates, customColumns);

                // Now update the custom columns' state/visibility in the FAR window.
                // Note that the visibility of the custom column(s) can change only at two possible places:
                //  1. FAR query start, i.e. below invocation to SetColumnStates and/or
                //  2. First reference result which has a non-default custom column value
                //     (UpdateCustomColumnVisibility method below).
                // Also note that the TableControl.SetColumnStates is not dependent on order of the input column states.
                TableControl.SetColumnStates(_customColumnTitleToStatesMap.Values);
            }
예제 #17
0
            private static IList <System.Windows.Documents.Inline> GetHighlightedInlines(
                StreamingFindUsagesPresenter 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(
                StreamingFindUsagesPresenter 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;
            }
 public WithoutReferencesFindUsagesContext(
     StreamingFindUsagesPresenter presenter,
     IFindAllReferencesWindow findReferencesWindow)
     : base(presenter, findReferencesWindow)
 {
 }