Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trigger IRefactorNotify on Workspace.TryApplyChange #47579

Closed
wants to merge 13 commits into from

Conversation

ryzngard
Copy link
Contributor

@ryzngard ryzngard commented Sep 10, 2020

Change so that we annotate symbols that are being renamed in the Renamer and similar scenarios such that when they are applied with Workspace.TryApplyChanges we notify of the symbol change.

This allows our public Rename API to have the correct behavior for callers automatically if hosted in a workspace environment where IRefactorNotify is important.

Fixes #47048

@ryzngard ryzngard marked this pull request as ready for review September 17, 2020 19:32
@ryzngard ryzngard requested review from a team as code owners September 17, 2020 19:32
Copy link
Member

@jasonmalinowski jasonmalinowski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall structure looks good. A few specific concerns:

  1. I'm worried this might be transitioning notifications from the UI thread to a background thread, and this has a deadlock risk.
  2. Can we also use this to clean up the features that have to clear rename tracking too? Or is that something you want to do later? That might clean up some of the RenameTrackingAction hackery.
  3. I also hope this doesn't break things now that we're triggering the "OnBefore" notifications after the actual rename instead before. Any worries about that causing issues?

Comment on lines +1266 to +1277
var solutionPair = await TestActionAsync(
workspace,
@"public interface ITest { }",
action,
ImmutableArray<TextSpan>.Empty,
ImmutableArray<TextSpan>.Empty,
ImmutableArray<TextSpan>.Empty,
ImmutableArray<TextSpan>.Empty,
testParameters);

var oldSolution = solutionPair.Item1;
var newSolution = solutionPair.Item2;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it worth breaking all of this into a helper?

@@ -19,10 +19,6 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.Diagnostics.Naming
Return (New VisualBasicNamingStyleDiagnosticAnalyzer(), New NamingStyleCodeFixProvider())
End Function

Protected Overrides Function GetComposition() As TestComposition
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[this is a comment to the file itself.]

Did we want some of the tests that exist on the C# side of things here as well?

Comment on lines -234 to -240
/// <summary>
/// Called after the rename is applied to the specified documents in the workspace. Return
/// <see langword="true"/> if this operation succeeded, or <see langword="false"/> if it failed.
/// </summary>
bool TryOnAfterGlobalSymbolRenamed(Workspace workspace, IEnumerable<DocumentId> changedDocumentIDs, string replacementText);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We've confirmed this isn't used by F# or TypeScript or anything? I don't quite know how they could, but it's my job to ask.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not yet :)

documentName: "IInterface.vb",
newDocumentName: "IInterface2.vb");
name: "IInterface2.vb"),
RenameHelpers.MakeSymbolPairs("IInterface", "IInterface2"));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't forget you can write `New Dictionary(Of String) From{ { "IInterface", "IInterface2" } }" and use collection initializers. On the C# side you might even be able to use target-typed new and omit all sorts of stuff.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've had comments in the past that it's less readable, so I've been doing this style 🤷‍♀️

@ryzngard ryzngard marked this pull request as draft November 10, 2020 22:40
@ryzngard
Copy link
Contributor Author

Moving to draft PR while I update this to latest. Still targeting 16.9

Base automatically changed from master to main March 3, 2021 23:52
@ryzngard
Copy link
Contributor Author

Updated to #55033

@ryzngard ryzngard closed this Jul 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

RenameDocument does not fire IVSRefactorNotify or dismiss rename tracking
3 participants