Skip to content

Commit

Permalink
fix mismerge
Browse files Browse the repository at this point in the history
  • Loading branch information
olegtk committed Feb 27, 2018
1 parent 6b1b25d commit bb0d4b1
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 104 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,12 @@ internal class FindReferencesCommandHandler : VSCommanding.ICommandHandler<FindR

[ImportingConstructor]
internal FindReferencesCommandHandler(
[ImportMany] IEnumerable<IDefinitionsAndReferencesPresenter> synchronousPresenters,
[ImportMany] IEnumerable<Lazy<IStreamingFindUsagesPresenter>> streamingPresenters,
IAsynchronousOperationListenerProvider listenerProvider)
{
Contract.ThrowIfNull(streamingPresenters);
Contract.ThrowIfNull(listenerProvider);

_synchronousPresenters = synchronousPresenters;
_streamingPresenters = streamingPresenters;
_asyncListener = listenerProvider.GetListener(FeatureAttribute.FindReferences);
}
Expand Down Expand Up @@ -96,17 +94,6 @@ private bool TryExecuteCommand(int caretPosition, Document document, CommandExec
return true;
}

// Otherwise, either the language doesn't support streaming results,
// or the host has no way to present results in a streaming manner.
// Fall back to the old non-streaming approach to finding and presenting
// results.
var synchronousService = document.GetLanguageService<IFindReferencesService>();
if (synchronousService != null)
{
FindReferences(document, synchronousService, caretPosition, context);
return true;
}

return false;
}

Expand Down Expand Up @@ -159,26 +146,5 @@ private async void StreamingFindReferences(
{
}
}

internal void FindReferences(
Document document, IFindReferencesService service, int caretPosition, CommandExecutionContext context)
{
using (var waitScope = context.OperationContext.AddScope(allowCancellation: true, EditorFeaturesResources.Finding_references))
using (Logger.LogBlock(
FunctionId.CommandHandler_FindAllReference,
KeyValueLogMessage.Create(LogType.UserAction, m => m["type"] = "legacy"),
context.OperationContext.UserCancellationToken))
{
if (!service.TryFindReferences(document, caretPosition, new WaitContextAdapter(waitScope)))
{
// The service failed, so just present an empty list of references
foreach (var presenter in _synchronousPresenters)
{
presenter.DisplayResult(DefinitionsAndReferences.Empty);
return;
}
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public GoToImplementationCommandHandler(

public string DisplayName => EditorFeaturesResources.Go_To_Implementation;

private (Document, IGoToImplementationService, IFindUsagesService) GetDocumentAndServices(ITextSnapshot snapshot)
private (Document, IFindUsagesService) GetDocumentAndService(ITextSnapshot snapshot)
{
var document = snapshot.GetOpenDocumentInCurrentContextWithChanges();
return (document, document?.GetLanguageService<IFindUsagesService>());
Expand All @@ -46,8 +46,8 @@ public VSCommanding.CommandState GetCommandState(GoToImplementationCommandArgs a
{
// Because this is expensive to compute, we just always say yes as long as the language allows it.

var (document, implService, findUsagesService) = GetDocumentAndServices(args.SubjectBuffer.CurrentSnapshot);
return implService != null || findUsagesService != null
var (document, findUsagesService) = GetDocumentAndService(args.SubjectBuffer.CurrentSnapshot);
return findUsagesService != null
? VSCommanding.CommandState.Available
: VSCommanding.CommandState.Unavailable;
}
Expand All @@ -60,7 +60,7 @@ public bool ExecuteCommand(GoToImplementationCommandArgs args, CommandExecutionC
var caret = args.TextView.GetCaretPoint(args.SubjectBuffer);
if (caret.HasValue)
{
ExecuteCommand(document, caret.Value, implService, findUsagesService, context);
ExecuteCommand(document, caret.Value, findUsagesService, context);
return true;
}
}
Expand All @@ -70,7 +70,6 @@ public bool ExecuteCommand(GoToImplementationCommandArgs args, CommandExecutionC

private void ExecuteCommand(
Document document, int caretPosition,
IGoToImplementationService synchronousService,
IFindUsagesService streamingService,
CommandExecutionContext context)
{
Expand All @@ -85,18 +84,11 @@ private void ExecuteCommand(
using (context.OperationContext.AddScope(allowCancellation: true, EditorFeaturesResources.Locating_implementations))
{
var userCancellationToken = context.OperationContext.UserCancellationToken;
if (canUseStreamingWindow)
{
StreamingGoToImplementation(
document, caretPosition,
streamingService, streamingPresenter,
userCancellationToken, out messageToShow);
}
else
{
synchronousService.TryGoToImplementation(
document, caretPosition, userCancellationToken, out messageToShow);
}

StreamingGoToImplementation(
document, caretPosition,
streamingService, streamingPresenter,
userCancellationToken, out messageToShow);
}

if (messageToShow != null)
Expand Down
49 changes: 0 additions & 49 deletions src/EditorFeatures/Core/Shared/Utilities/WaitContextAdapter.cs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Editor.Commands;
using Microsoft.CodeAnalysis.Editor.FindReferences;
using Microsoft.CodeAnalysis.Editor.Host;
using Microsoft.CodeAnalysis.Editor.UnitTests.Utilities;
using Microsoft.CodeAnalysis.Editor.UnitTests.Workspaces;
using Microsoft.CodeAnalysis.FindUsages;
using Microsoft.CodeAnalysis.Shared.TestHooks;
using Microsoft.VisualStudio.Text;
using Microsoft.VisualStudio.Text.Editor.Commanding.Commands;
using Roslyn.Test.Utilities;
using Roslyn.Utilities;
using Xunit;
Expand Down Expand Up @@ -63,15 +63,14 @@ public async Task TestFindReferencesAsynchronousCall()
var listenerProvider = new AsynchronousOperationListenerProvider();

var handler = new FindReferencesCommandHandler(
TestWaitIndicator.Default,
SpecializedCollections.SingletonEnumerable(new Lazy<IStreamingFindUsagesPresenter>(() => presenter)),
listenerProvider);

var textView = workspace.Documents[0].GetTextView();
textView.Caret.MoveTo(new SnapshotPoint(textView.TextSnapshot, 7));
handler.ExecuteCommand(new FindReferencesCommandArgs(
textView,
textView.TextBuffer), () => { });
textView.TextBuffer), TestCommandExecutionContext.Create());

var waiter = listenerProvider.GetWaiter(FeatureAttribute.FindReferences);
await waiter.CreateWaitTask();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class C

Dim context = New FindReferencesTests.TestContext()
Dim commandHandler = New FindReferencesCommandHandler(
{}, {New Lazy(Of IStreamingFindUsagesPresenter)(Function() New MockStreamingFindReferencesPresenter(context))},
{New Lazy(Of IStreamingFindUsagesPresenter)(Function() New MockStreamingFindReferencesPresenter(context))},
listenerProvider)

Dim document = workspace.CurrentSolution.GetDocument(testDocument.Id)
Expand Down

0 comments on commit bb0d4b1

Please sign in to comment.