-
Notifications
You must be signed in to change notification settings - Fork 814
Add completions for #disable-diagnostics and #restore-diagnostics
#18919
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: main
Are you sure you want to change the base?
Conversation
|
Test this change out locally with the following install scripts (Action run 21522770437) VSCode
Azure CLI
|
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.
Pull request overview
This PR adds IntelliSense completions for #disable-diagnostics and #restore-diagnostics pragmas in Bicep files. Previously, only #disable-next-line had completion support. The implementation provides reactive completions based on existing diagnostics in the file.
Changes:
- Added keyword completions for
#disable-diagnosticsand#restore-diagnosticsafter typing# - Added diagnostic code completions for
#disable-diagnostics(suggesting suppressible diagnostics that occur after the cursor) - Added diagnostic code completions for
#restore-diagnostics(suggesting codes currently disabled at the cursor, excluding codes from preceding#disable-next-linedirectives)
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Bicep.LangServer/Completions/BicepCompletionProvider.cs | Refactored directive completion method to support all three pragma types; added completion methods for disable and restore diagnostic codes |
| src/Bicep.LangServer/Completions/BicepCompletionContextKind.cs | Renamed enum value to be more generic (DirectiveStart) and added two new context kinds for the new directive code completions |
| src/Bicep.LangServer/Completions/BicepCompletionContext.cs | Updated context detection logic to identify all three pragma types using switch expressions |
| src/Bicep.Core/Diagnostics/DisabledDiagnosticsCache.cs | Added helper method to retrieve all diagnostic codes disabled at a given position |
| src/Bicep.LangServer.IntegrationTests/CompletionTests.cs | Added comprehensive tests for the new completion functionality covering various scenarios |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This PR adds keyword completions for
disable-diagnosticsandrestore-diagnosticsfollowing a#sign. It also adds completions for the trailing error codes for these pragmas using the following rules:#disable-diagnostics |, the completion provider returns the codes for all suppressible diagnostics that are raised after the cursor#restore-diagnostics |, the provider returns all codes that are suppressed at the cursor#restore-diagnosticsdo not include code from the preceding line's#disable-next-linedirective (if any)The diagnostic code completions are reactive rather than proactive, so we may need to revisit the first rule in the future if users are more often adding directives to files before adding any code that may raise those diagnostics.
Microsoft Reviewers: Open in CodeFlow