-
Notifications
You must be signed in to change notification settings - Fork 809
Multiline diagnostic pragmas #18622
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?
Multiline diagnostic pragmas #18622
Conversation
|
Test this change out locally with the following install scripts (Action run 19978233671) VSCode
Azure CLI
|
Dotnet Test Results 102 files - 51 102 suites - 51 38m 41s ⏱️ - 23m 55s Results for commit ad0e86f. ± Comparison against base commit 8d3ffa5. This pull request removes 1958 and adds 665 tests. Note that renamed tests count towards both.♻️ This comment has been updated with latest results. |
|
NB for reviewers: I did not add much in terms of language server support for these new pragmas. The completions proposed for all diagnostic pragmas is the same, meaning that completions for |
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 introduces multiline diagnostic suppression directives (#disable-diagnostics and #restore-diagnostics) while refactoring the existing #disable-next-line directive to use a unified pragma system. The changes enable developers to disable specific diagnostics for entire files or for code spans between disable/restore pairs.
Key changes:
- Unified all diagnostic pragmas under a single
DiagnosticsPragmaSyntaxTriviaclass with aDiagnosticsPragmaTypeenum - Implemented span-based caching in
DisabledDiagnosticsCacheto track disabled diagnostic regions - Updated lexer to recognize all three pragma types using dynamic keyword matching
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Bicep.Core/Syntax/DisableNextLineDiagnosticsSyntaxTrivia.cs | Removed - replaced by unified DiagnosticsPragmaSyntaxTrivia |
| src/Bicep.Core/Syntax/DiagnosticsPragmaSyntaxTrivia.cs | New unified class for all diagnostic pragmas with enum for pragma types |
| src/Bicep.Core/Syntax/SyntaxTriviaType.cs | Renamed enum value from DisableNextLineDiagnosticsDirective to DiagnosticsPragma |
| src/Bicep.Core/Syntax/SyntaxFacts.cs | Updated IsDirective check to use new pragma type |
| src/Bicep.Core/LanguageConstants.cs | Added new keyword constants for disable-diagnostics and restore-diagnostics |
| src/Bicep.Core/Parsing/Lexer.cs | Updated to dynamically detect pragma types and scan accordingly |
| src/Bicep.Core/Diagnostics/DisabledDiagnosticsCache.cs | Completely rewritten to support span-based caching for all pragma types |
| src/Bicep.Core/Semantics/SemanticModel.cs | Simplified diagnostic filtering to use new IsDisabledAtPosition method |
| src/Bicep.Core/PrettyPrintV2/SyntaxLayouts.cs | Updated to format all pragma types dynamically |
| src/Bicep.Core/PrettyPrint/DocumentBuildVisitor.cs | Updated trivia type check for pragma handling |
| src/Bicep.Core/Highlighting/SemanticTokenVisitor.cs | Updated to handle unified pragma type |
| src/Bicep.LangServer/Completions/BicepCompletionContext.cs | Updated type checks for pragma completion context |
| src/Bicep.Core.UnitTests/Parsing/LexerTests.cs | Updated test assertions for new pragma type |
| src/Bicep.Core.IntegrationTests/DirectiveTests.cs | New comprehensive integration tests for all pragma types |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Description
This PR adds two new pragmas/directives,
#disable-diagnosticsand#restore-diagnostics. The former can be used to disable diagnostics by code for an entire file, or, when paired with#restore-diagnostics, for code that falls between the directives.As with
#disable-next-line, these pragmas will not suppress error-level diagnostics. Passing a code that has not been disabled to#restore-diagnosticsis a no-op, as is passing a non-existent diagnostic code (to match the behavior of#disable-next-line).Example Usage
Disable a specific diagnostic for a whole file
Disable specific diagnostics for a span
Microsoft Reviewers: Open in CodeFlow