Skip to content

Commit

Permalink
Remove legacy signature help interaction code. (#76495)
Browse files Browse the repository at this point in the history
  • Loading branch information
CyrusNajmabadi authored Dec 19, 2024
2 parents 4234893 + 549eca4 commit c49efbd
Show file tree
Hide file tree
Showing 11 changed files with 58 additions and 545 deletions.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,11 @@
namespace Microsoft.CodeAnalysis.Editor.CommandHandlers
{
/// <summary>
/// There are two forms of intellisense that may be active at the same time. Completion and
/// SigHelp. Completion precedes SigHelp in the command handler because it wants to make sure
/// it's operating on a buffer *after* Completion has changed it. i.e. if "WriteL(" is typed,
/// sig help wants to allow completion to complete that to "WriteLine(" before it tried to
/// proffer sig help. If we were to reverse things, then we'd get a bogus situation where sig
/// help would see "WriteL(" would have nothing to offer and would return.
///
/// However, despite wanting sighelp to receive typechar first and then defer it to completion,
/// we want completion to receive other events first (like escape, and navigation keys). We
/// consider completion to have higher priority for those commands. In order to accomplish that,
/// we introduced <see cref="SignatureHelpAfterCompletionCommandHandler"/>
/// This command handler then delegates escape, up and down to those command handlers.
/// It is called before <see cref="PredefinedCompletionNames.CompletionCommandHandler"/>.
/// There are two forms of intellisense that may be active at the same time. Completion and SigHelp. Completion
/// precedes SigHelp in the command handler because it wants to make sure it's operating on a buffer *after*
/// Completion has changed it. i.e. if "WriteL(" is typed, sig help wants to allow completion to complete that to
/// "WriteLine(" before it tried to proffer sig help. If we were to reverse things, then we'd get a bogus situation
/// where sig help would see "WriteL(" would have nothing to offer and would return.
/// </summary>
[Export]
[Export(typeof(ICommandHandler))]
Expand Down
27 changes: 3 additions & 24 deletions src/EditorFeatures/Core/IntelliSense/AbstractController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
using Microsoft.VisualStudio.Text.Editor;
using Roslyn.Utilities;
using Microsoft.CodeAnalysis.Editor.Shared.Extensions;
using System.Threading.Tasks;

namespace Microsoft.CodeAnalysis.Editor.Implementation.IntelliSense;

Expand Down Expand Up @@ -77,11 +78,11 @@ private void OnTextViewClosed(object sender, EventArgs e)
this.TextView.TextBuffer.PostChanged -= this.OnTextViewBufferPostChanged;
}

public TModel WaitForController()
public Task WaitForModelComputation_ForTestingPurposesOnlyAsync()
{
this.ThreadingContext.ThrowIfNotOnUIThread();
VerifySessionIsActive();
return sessionOpt.WaitForController();
return sessionOpt.WaitForModelComputation_ForTestingPurposesOnlyAsync();
}

void IController<TModel>.OnModelUpdated(TModel result, bool updateController)
Expand Down Expand Up @@ -136,26 +137,4 @@ public void StopModelComputation()
sessionOpt = null;
localSession.Stop();
}

public bool TryHandleEscapeKey()
{
this.ThreadingContext.ThrowIfNotOnUIThread();

// Escape simply dismissed a session if it's up. Otherwise let the next thing in the
// chain handle us.
if (!IsSessionActive)
{
return false;
}

// If we haven't even computed a model yet, then also send this command to anyone
// listening. It's unlikely that the command was intended for us (as we wouldn't
// have even shown ui yet.
var handledCommand = sessionOpt.InitialUnfilteredModel != null;

// In the presence of an escape, we always stop what we're doing.
this.StopModelComputation();

return handledCommand;
}
}
4 changes: 3 additions & 1 deletion src/EditorFeatures/Core/IntelliSense/ISession.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

#nullable disable

using System.Threading.Tasks;

namespace Microsoft.CodeAnalysis.Editor.Implementation.IntelliSense;

internal interface ISession<TModel>
Expand All @@ -12,5 +14,5 @@ internal interface ISession<TModel>

void Stop();

TModel WaitForController();
Task WaitForModelComputation_ForTestingPurposesOnlyAsync();
}
21 changes: 4 additions & 17 deletions src/EditorFeatures/Core/IntelliSense/ModelComputation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

namespace Microsoft.CodeAnalysis.Editor.Implementation.IntelliSense;

internal class ModelComputation<TModel> where TModel : class
internal sealed class ModelComputation<TModel> where TModel : class
{
#region Fields that can be accessed from either thread

Expand Down Expand Up @@ -81,23 +81,10 @@ public Task<TModel> ModelTask
}
}

public TModel WaitForController()
{
ThreadingContext.ThrowIfNotOnUIThread();

var model = ModelTask.WaitAndGetResult(CancellationToken.None);
if (!_notifyControllerTask.IsCompleted)
{
OnModelUpdated(model, updateController: true);

// Reset lastTask so controller.OnModelUpdated is only called once
_lastTask = Task.FromResult(model);
}

return model;
}
public Task WaitForModelComputation_ForTestingPurposesOnlyAsync()
=> ModelTask;

public virtual void Stop()
public void Stop()
{
ThreadingContext.ThrowIfNotOnUIThread();

Expand Down
5 changes: 3 additions & 2 deletions src/EditorFeatures/Core/IntelliSense/Session.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#nullable disable

using System;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Editor.Shared.Extensions;
using Roslyn.Utilities;

Expand Down Expand Up @@ -52,9 +53,9 @@ public virtual void Stop()
this.PresenterSession.Dismiss();
}

public TModel WaitForController()
public Task WaitForModelComputation_ForTestingPurposesOnlyAsync()
{
Computation.ThreadingContext.ThrowIfNotOnUIThread();
return Computation.WaitForController();
return Computation.WaitForModelComputation_ForTestingPurposesOnlyAsync();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ class C
state.SendEscape()
End If

state.SendUpKey()
state.CurrentSignatureHelpPresenterSession.SelectPreviousItem()
Await state.AssertSelectedSignatureHelpItem("void C.M(int i, int j, int k)")

state.SendTypeChars("1")
Expand Down Expand Up @@ -545,7 +545,7 @@ class C
state.SendEscape()
End If

state.SendDownKey()
state.CurrentSignatureHelpPresenterSession.SelectNextItem()
Await state.AssertSelectedSignatureHelpItem("void C.M(int i, string x)")

state.SendTypeChars("1")
Expand Down Expand Up @@ -580,7 +580,7 @@ class C
state.SendTypeChars("1, """" ")
Await state.AssertSelectedSignatureHelpItem("void C.M(int i, string x)")

state.SendUpKey()
state.CurrentSignatureHelpPresenterSession.SelectPreviousItem()
Await state.AssertSelectedSignatureHelpItem("void C.M(int i, int j)")

state.SendTypeChars(",")
Expand Down
Loading

0 comments on commit c49efbd

Please sign in to comment.