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

Add a code action to promote a using directive #11241

Merged
merged 3 commits into from
Nov 28, 2024

Conversation

davidwengier
Copy link
Contributor

Fixes #6155

Me: I really like the cohosting code action tests, it must be really easy to add a new code action now!
Me: Oh really? Well, try it and find out, I dare you!!
Me: <this PR>

(Also me: That wasn't as much fun as I expected. I have thoughts.)

@davidwengier davidwengier requested a review from a team November 22, 2024 00:50
@davidwengier davidwengier requested a review from a team as a code owner November 22, 2024 00:51
@davidwengier davidwengier removed the request for review from a team November 22, 2024 00:51
Copy link
Contributor

@ryzngard ryzngard left a comment

Choose a reason for hiding this comment

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

Great job! Nothing blocking. Some opinionated things and potential for less work in the provider.

return SpecializedTasks.EmptyImmutableArray<RazorVSInternalCodeAction>();
}

var owner = syntaxTree.Root.FindNode(TextSpan.FromBounds(context.StartAbsoluteIndex, context.EndAbsoluteIndex));
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: We know context.HasSelection is false so you only need StartAbsoluteIndex

Copy link
Contributor Author

Choose a reason for hiding this comment

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

True, but there is no "TextSpan.FromPoint" where I can just pass in one argument, so I think I'll leave this, just in case we add selection support later and it hides a bug.

[Fact]
public async Task PromoteUsingDirective_ExistingImports_WhitespaceLineAtEnd()
{
await VerifyCodeActionAsync(
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it worth adding a test that showcases moving from Imports/_ViewImports to one a folder up?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is really annoying to do with our current test infra :(

I'll have a go, but will time box it. I wouldn't mind cleaning up some of the code actions infra a bit more, as we add more, so can always come back to it.

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'm giving up 🎉

Should be easier once the source generator is hooked up.

@davidwengier davidwengier merged commit 5f32f26 into dotnet:main Nov 28, 2024
12 checks passed
@davidwengier davidwengier deleted the PromoteUsingDirective branch November 28, 2024 03:37
@dotnet-policy-service dotnet-policy-service bot added this to the Next milestone Nov 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Blazor add missing using to _Imports automatically
2 participants