Commit c87ceed
authored
Add snippet support for component completion with EditorRequired attributes (#12325)
- [x] Understand the current completion system and how TagHelper element
completion works
- [x] Modify RazorCompletionItem.CreateTagHelperElement to support
snippet mode
- [x] Update GetElementCompletions in TagHelperCompletionProvider to
detect EditorRequired attributes
- [x] Build snippet text with placeholders for EditorRequired properties
- [x] Add comprehensive tests for the new snippet functionality
- [x] Validate the changes work correctly
- [x] Address PR feedback:
- Changed to add a separate completion item for snippets (with "..."
suffix) instead of modifying the existing item
- Always add quotes in snippets (removed autoInsertAttributeQuotes
parameter)
- Use pooled StringBuilder instead of regular StringBuilder
- Added test in CohostDocumentCompletionEndpointTest.cs
- Simplified Cohost test to use VerifyCompletionListAsync helper
- Optimized component tag helper lookup to use first Component kind tag
helper only
- [x] Merged main into branch (test files moved to VS Code project)
- [x] Fixed test failure - snippet items don't need resolve, they
already have complete insertText
- [x] Updated snippet display text to "{displayText} (and req'd
attributes...)" for better clarity
- [x] Simplified test to use VerifyCompletionListAsync helper with
verifySnippetItem callback
- [x] Optimized to avoid .Any() and .ToImmutableArray() allocation by
changing method to accept IEnumerable
- [x] Added localized resource string for component completion label
- [x] Updated tests to use SR resource for consistent labeling
- [x] Extracted snippet completion logic to
AddCompletionItemWithRequiredAttributesSnippet method
- [x] Inverted if statement for early exit and pass descriptionInfo from
calling method
- [x] Merged latest main and resolved conflicts - both
ComponentWithEditorRequiredAttributes and new Blazor data attribute
tests now coexist
- [x] Added comment to SR.resx explaining "req'd" abbreviation for
localization
<!-- START COPILOT CODING AGENT SUFFIX -->
<details>
<summary>Original prompt</summary>
>
> ----
>
> *This section details on the original issue you should resolve*
>
> <issue_title>Component completion snippet</issue_title>
> <issue_description>Noticed today watching someone use the Razor
editor: For components that have one or more properties that are
`[EditorRequired]`, we could do completion as a snippet, that includes
the attributes for each required property (similar to how drag and drop
will create attributes for them) and either puts the caret in the first
one, or even puts placeholders in each and lets the user tab between
them.</issue_description>
>
> ## Comments on the Issue (you are @copilot in this section)
>
> <comments>
> </comments>
>
</details>
Fixes #6980
<!-- START COPILOT CODING AGENT TIPS -->
---
💬 Share your feedback on Copilot coding agent for the chance to win a
$200 gift card! Click
[here](https://survey3.medallia.com/?EAHeSx-AP01bZqG0Ld9QLQ) to start
the survey.File tree
19 files changed
+347
-3
lines changed- .github/workflows
- src/Razor
- src/Microsoft.CodeAnalysis.Razor.Workspaces
- Completion
- Resources
- xlf
- test
- Microsoft.AspNetCore.Razor.LanguageServer.Test/Completion
19 files changed
+347
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
43 | 48 | | |
44 | 49 | | |
45 | 50 | | |
| |||
Lines changed: 2 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
87 | 87 | | |
88 | 88 | | |
89 | 89 | | |
| 90 | + | |
90 | 91 | | |
91 | | - | |
| 92 | + | |
92 | 93 | | |
93 | 94 | | |
94 | 95 | | |
| |||
Lines changed: 85 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
231 | 231 | | |
232 | 232 | | |
233 | 233 | | |
| 234 | + | |
234 | 235 | | |
235 | 236 | | |
236 | 237 | | |
237 | 238 | | |
238 | | - | |
| 239 | + | |
| 240 | + | |
239 | 241 | | |
240 | 242 | | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
241 | 252 | | |
242 | 253 | | |
243 | 254 | | |
| |||
307 | 318 | | |
308 | 319 | | |
309 | 320 | | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
310 | 394 | | |
311 | 395 | | |
312 | 396 | | |
| |||
Lines changed: 4 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
223 | 223 | | |
224 | 224 | | |
225 | 225 | | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
226 | 230 | | |
Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
0 commit comments