Add completions for #disable-diagnostics and #restore-diagnostics#18919
Open
Add completions for #disable-diagnostics and #restore-diagnostics#18919
#disable-diagnostics and #restore-diagnostics#18919Conversation
Contributor
|
Test this change out locally with the following install scripts (Action run 21522770437) VSCode
Azure CLI
|
There was a problem hiding this comment.
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.
anthony-c-martin
approved these changes
Jan 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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