提交 20347f68 编写于 作者: C CyrusNajmabadi

Don't filter for goto-def and goto-impl.

上级 0b79656b
......@@ -125,7 +125,8 @@ private IStreamingFindUsagesPresenter GetStreamingPresenter()
{
// Let the presented know we're starging a search. It will give us back
// the context object that the FAR service will push results into.
var context = presenter.StartSearch(EditorFeaturesResources.Find_References);
var context = presenter.StartSearch(
EditorFeaturesResources.Find_References, alwaysShowDeclarations: false);
await findUsagesService.FindReferencesAsync(document, caretPosition, context).ConfigureAwait(false);
// Note: we don't need to put this in a finally. The only time we might not hit
......
......@@ -71,7 +71,8 @@ internal static class GoToDefinitionHelpers
var presenter = GetFindUsagesPresenter(streamingPresenters);
return presenter.TryNavigateToOrPresentItemsAsync(
EditorFeaturesResources.Go_to_Definition,
definitions.ToImmutableAndFree()).WaitAndGetResult(cancellationToken);
definitions.ToImmutableAndFree(),
alwaysShowDeclarations: true).WaitAndGetResult(cancellationToken);
}
private static IStreamingFindUsagesPresenter GetFindUsagesPresenter(
......
......@@ -125,7 +125,8 @@ private void ExecuteCommand(Document document, int caretPosition)
var definitionItems = goToImplContext.GetDefinitions();
streamingPresenter.TryNavigateToOrPresentItemsAsync(
EditorFeaturesResources.Go_To_Implementation, definitionItems).Wait(cancellationToken);
EditorFeaturesResources.Go_To_Implementation, definitionItems,
alwaysShowDeclarations: true).Wait(cancellationToken);
}
private IStreamingFindUsagesPresenter GetStreamingPresenter()
......
......@@ -21,7 +21,7 @@ internal interface IStreamingFindUsagesPresenter
/// search completes <see cref="FindUsagesContext.OnCompletedAsync"/> should be called.
/// etc. etc.
/// </summary>
FindUsagesContext StartSearch(string title);
FindUsagesContext StartSearch(string title, bool alwaysShowDeclarations);
}
internal static class IStreamingFindUsagesPresenterExtensions
......@@ -31,8 +31,8 @@ internal static class IStreamingFindUsagesPresenterExtensions
/// items to the user.
/// </summary>
public static async Task<bool> TryNavigateToOrPresentItemsAsync(
this IStreamingFindUsagesPresenter presenter,
string title, ImmutableArray<DefinitionItem> items)
this IStreamingFindUsagesPresenter presenter, string title,
ImmutableArray<DefinitionItem> items, bool alwaysShowDeclarations)
{
// Ignore any definitions that we can't navigate to.
var definitions = items.WhereAsArray(d => d.CanNavigateTo());
......@@ -66,7 +66,7 @@ internal static class IStreamingFindUsagesPresenterExtensions
// We have multiple definitions, or we have definitions with multiple locations.
// Present this to the user so they can decide where they want to go to.
var context = presenter.StartSearch(title);
var context = presenter.StartSearch(title, alwaysShowDeclarations);
foreach (var definition in nonExternalItems)
{
await context.OnDefinitionFoundAsync(definition).ConfigureAwait(false);
......
......@@ -34,6 +34,7 @@ private class TableDataSourceFindUsagesContext :
public readonly StreamingFindUsagesPresenter Presenter;
private readonly IFindAllReferencesWindow _findReferencesWindow;
private readonly IWpfTableControl2 _tableControl;
private readonly bool _alwaysIncludeDeclarations;
private readonly object _gate = new object();
......@@ -67,8 +68,8 @@ private class TableDataSourceFindUsagesContext :
/// </summary>
private bool _currentlyGroupingByDefinition;
private ImmutableList<Entry> _entriesWhenGroupingByDefinition = ImmutableList<Entry>.Empty;
private ImmutableList<Entry> _entriesWhenNotGroupingByDefinition = ImmutableList<Entry>.Empty;
private ImmutableList<Entry> _entriesWithDeclarations = ImmutableList<Entry>.Empty;
private ImmutableList<Entry> _entriesWithoutDeclarations = ImmutableList<Entry>.Empty;
private TableEntriesSnapshot _lastSnapshot;
public int CurrentVersionNumber { get; private set; }
......@@ -77,11 +78,13 @@ private class TableDataSourceFindUsagesContext :
public TableDataSourceFindUsagesContext(
StreamingFindUsagesPresenter presenter,
IFindAllReferencesWindow findReferencesWindow)
IFindAllReferencesWindow findReferencesWindow,
bool alwaysIncludeDeclarations)
{
presenter.AssertIsForeground();
Presenter = presenter;
_alwaysIncludeDeclarations = alwaysIncludeDeclarations;
_findReferencesWindow = findReferencesWindow;
_tableControl = (IWpfTableControl2)findReferencesWindow.TableControl;
_tableControl.GroupingsChanged += OnTableControlGroupingsChanged;
......@@ -227,8 +230,8 @@ private async Task CreateNoResultsFoundEntryIfNecessaryAsync()
await OnEntryFoundAsync(NoResultsDefinitionItem,
bucket => SimpleMessageEntry.CreateAsync(
bucket, ServicesVisualStudioNextResources.Search_found_no_results),
showEntryWhenGroupingByDefinition: true,
showEntryWhenNotGroupingByDefinition: true).ConfigureAwait(false);
addToEntriesWithDeclarations: true,
addToEntriesWithoutDeclarations: true).ConfigureAwait(false);
}
}
......@@ -241,17 +244,17 @@ private async Task CreateNoResultsFoundEntryIfNecessaryAsync()
private async Task CreateMissingReferenceEntriesIfNecessaryAsync()
{
await CreateMissingReferenceEntriesIfNecessaryAsync(whenGroupingByDefinition: true).ConfigureAwait(false);
await CreateMissingReferenceEntriesIfNecessaryAsync(whenGroupingByDefinition: false).ConfigureAwait(false);
await CreateMissingReferenceEntriesIfNecessaryAsync(withDeclarations: true).ConfigureAwait(false);
await CreateMissingReferenceEntriesIfNecessaryAsync(withDeclarations: false).ConfigureAwait(false);
}
private async Task CreateMissingReferenceEntriesIfNecessaryAsync(
bool whenGroupingByDefinition)
bool withDeclarations)
{
// Go through and add dummy entries for any definitions that
// that we didn't find any references for.
var definitions = GetDefinitionsToCreateMissingReferenceItemsFor(whenGroupingByDefinition);
var definitions = GetDefinitionsToCreateMissingReferenceItemsFor(withDeclarations);
foreach (var definition in definitions)
{
// Create a fake reference to this definition that says
......@@ -259,8 +262,8 @@ private async Task CreateMissingReferenceEntriesIfNecessaryAsync()
await OnEntryFoundAsync(definition,
bucket => SimpleMessageEntry.CreateAsync(
bucket, GetMessage(bucket.DefinitionItem)),
showEntryWhenGroupingByDefinition: whenGroupingByDefinition,
showEntryWhenNotGroupingByDefinition: !whenGroupingByDefinition).ConfigureAwait(false);
addToEntriesWithDeclarations: withDeclarations,
addToEntriesWithoutDeclarations: !withDeclarations).ConfigureAwait(false);
}
}
......@@ -277,13 +280,13 @@ private static string GetMessage(DefinitionItem definition)
}
private ImmutableArray<DefinitionItem> GetDefinitionsToCreateMissingReferenceItemsFor(
bool whenGroupingByDefinition)
bool withDeclarations)
{
lock (_gate)
{
var entries = whenGroupingByDefinition
? _entriesWhenGroupingByDefinition
: _entriesWhenNotGroupingByDefinition;
var entries = withDeclarations
? _entriesWithDeclarations
: _entriesWithoutDeclarations;
// Find any definitions that we didn't have any references to. But only show
// them if they want to be displayed without any references. This will
......@@ -334,9 +337,7 @@ private bool HasDeclarationEntries(DefinitionItem definition)
{
lock (_gate)
{
// We only store declaration entries in the entries list we use when
// we're not grouping by definition.
return _entriesWhenNotGroupingByDefinition.Any(e => e.DefinitionBucket.DefinitionItem == definition);
return _entriesWithDeclarations.Any(e => e.DefinitionBucket.DefinitionItem == definition);
}
}
......@@ -375,7 +376,7 @@ private async Task AddDeclarationEntriesAsync(DefinitionItem definition)
{
// We only include declaration entries in the entries we show when
// not grouping by definition.
_entriesWhenNotGroupingByDefinition = _entriesWhenNotGroupingByDefinition.AddRange(declarations);
_entriesWithDeclarations = _entriesWithDeclarations.AddRange(declarations);
CurrentVersionNumber++;
}
}
......@@ -393,17 +394,17 @@ public override Task OnReferenceFoundAsync(SourceReferenceItem reference)
reference.Definition,
bucket => CreateDocumentLocationEntryAsync(
bucket, reference.SourceSpan, isDefinitionLocation: false),
showEntryWhenGroupingByDefinition: true,
showEntryWhenNotGroupingByDefinition: true);
addToEntriesWithDeclarations: true,
addToEntriesWithoutDeclarations: true);
}
private async Task OnEntryFoundAsync(
DefinitionItem definition,
Func<RoslynDefinitionBucket, Task<Entry>> createEntryAsync,
bool showEntryWhenGroupingByDefinition,
bool showEntryWhenNotGroupingByDefinition)
bool addToEntriesWithDeclarations,
bool addToEntriesWithoutDeclarations)
{
Debug.Assert(showEntryWhenGroupingByDefinition || showEntryWhenNotGroupingByDefinition);
Debug.Assert(addToEntriesWithDeclarations || addToEntriesWithoutDeclarations);
CancellationToken.ThrowIfCancellationRequested();
// First find the bucket corresponding to our definition.
......@@ -421,14 +422,14 @@ public override Task OnReferenceFoundAsync(SourceReferenceItem reference)
lock (_gate)
{
// Once we can make the new entry, add it to the appropriate list.
if (showEntryWhenGroupingByDefinition)
if (addToEntriesWithDeclarations)
{
_entriesWhenGroupingByDefinition = _entriesWhenGroupingByDefinition.Add(entry);
_entriesWithDeclarations = _entriesWithDeclarations.Add(entry);
}
if (showEntryWhenNotGroupingByDefinition)
if (addToEntriesWithoutDeclarations)
{
_entriesWhenNotGroupingByDefinition = _entriesWhenNotGroupingByDefinition.Add(entry);
_entriesWithoutDeclarations = _entriesWithoutDeclarations.Add(entry);
}
CurrentVersionNumber++;
......@@ -704,9 +705,9 @@ public ITableEntriesSnapshot GetCurrentSnapshot()
// our version.
if (_lastSnapshot?.VersionNumber != CurrentVersionNumber)
{
var entries = _currentlyGroupingByDefinition
? _entriesWhenGroupingByDefinition
: _entriesWhenNotGroupingByDefinition;
var entries = _currentlyGroupingByDefinition && !_alwaysIncludeDeclarations
? _entriesWithoutDeclarations
: _entriesWithDeclarations;
_lastSnapshot = new TableEntriesSnapshot(entries, CurrentVersionNumber);
}
......
......@@ -60,7 +60,7 @@ internal partial class StreamingFindUsagesPresenter :
_vsFindAllReferencesService = (IFindAllReferencesService)_serviceProvider.GetService(typeof(SVsFindAllReferences));
}
public FindUsagesContext StartSearch(string title)
public FindUsagesContext StartSearch(string title, bool alwaysShowDeclarations)
{
this.AssertIsForeground();
......@@ -68,7 +68,8 @@ public FindUsagesContext StartSearch(string title)
var window = _vsFindAllReferencesService.StartSearch(title);
// Make the data source that will feed data into this window.
var dataSource = new TableDataSourceFindUsagesContext(this, window);
var dataSource = new TableDataSourceFindUsagesContext(
this, window, alwaysShowDeclarations);
// And return the data source so that the FindRefs engine can report results
// which the data source can then create the appropriate presentation items for
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册