-
Notifications
You must be signed in to change notification settings - Fork 203
Bind directive attribute event
parameter HTML event completions
#11804
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
base: release/dev17.14
Are you sure you want to change the base?
Bind directive attribute event
parameter HTML event completions
#11804
Conversation
…ive attribute parameter
...zor.Workspaces.Test/Completion/DirectiveAttributeEventParameterCompletionItemProviderTest.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you very much for your contribution @Peter-Juhasz!
...alysis.Razor.Workspaces/Completion/DirectiveAttributeEventParameterCompletionItemProvider.cs
Outdated
Show resolved
Hide resolved
...zor/src/Microsoft.AspNetCore.Razor.LanguageServer/Extensions/IServiceCollectionExtensions.cs
Show resolved
Hide resolved
...zor.Workspaces.Test/Completion/DirectiveAttributeEventParameterCompletionItemProviderTest.cs
Outdated
Show resolved
Hide resolved
...zor.Workspaces.Test/Completion/DirectiveAttributeEventParameterCompletionItemProviderTest.cs
Outdated
Show resolved
Hide resolved
…tests, code style
@Peter-Juhasz: Please rebase this to |
This is quite challenging because I'm running into conflict where I have absolutely no idea what I should choose. :D And my VS is crashing between each change. :D Probably because I don't have the bits in my public preview that you have in main already. We discussed this with @davidwengier that after I move on from the VS preview release commit, I bump into breaking changes and can't test my changes locally anymore. @DustinCampbell What is your recommendation on the right process overall here and how shall we proceed? |
Currently you basically have a few options:
I wouldn't recommend trying to figure out the rebase yourself. It will get tedious fast |
|
||
public ImmutableArray<RazorCompletionItem> GetCompletionItems(RazorCompletionContext context) | ||
{ | ||
var owner = context.Owner?.FirstAncestorOrSelf<MarkupTagHelperDirectiveAttributeSyntax>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we avoid this tree walk? The owner here could be an arbitrarily nested node, and this call can happen on every keystroke.
I suspect there is a relatively small set of nodes that the owner could be, with a well defined number of ".Parent.Parent" calls needed to get to where we want to be.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be clear, I mean doing something like:
if (context.Owner is MarkupTextLiteralSyntaxNode { Parent.Parent: MarkupTagHelperDirectiveAttributeSyntaxNode owner })
(Typing on my phone, and only guessing at type names)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch! I just sent a fix already.
🌴 FYI: I will be traveling in the rest of this week, and while I can read/reply comments, I won't be close to my desktop workstation to be able to make any meaningful changes. Will be back on Monday next week. Feel free to make any changes if needed to proceed with this PR until then.
I would appreciate if you could help me with that. And when I get back I will reach out to you to discuss how can this work with the least friction on both ends. |
I suggested option 2 for the other PR, and am happy to do the work to merge and resolve conflicts on both, when the time comes. You've found yourself in an odd timing for VS releases, and I don't see why you should have to pay the price when it's out of your control. Though technically its out of our control too 😁 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
In an ideal world we'd get these from a Html LSP but in reality they're never going to understand @bind:event
and seems like even if they did, they wouldn't produce any better list anyway.
Actually, I guess I might ask for at least one test in https://github.com/dotnet/razor/blob/main/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostDocumentCompletionEndpointTest.cs, just to be sure its all good. Shouldn't require anything except the literal test method, but will at least validate the MEF composition is correct. |
Summary of the changes
Created a basic completion provider for completing HTML event names for
@bind:event
directive attribute parameter, primarily to cover the most common use case: setting it tooninput
oronchange
.What is not included:
Alternatives for schema data: