[SwiftExtract] Add a pluggable diagnostics sink for skipped declarations - #900
Open
kateinoigakukun wants to merge 1 commit into
Open
Conversation
Today the analyzer logs a warning and silently drops any declaration it cannot fully model, and consumers have no programmatic way to observe that. That is acceptable for jextract's opt-out model, but a consumer with an opt-in model (e.g. JavaScriptKit's BridgeJS, where every @js declaration was explicitly marked for export) must fail the build with a source-located error instead of quietly not exporting the API. Introduce SwiftExtractDiagnosticsSink, an optional observer supplied to SwiftAnalyzer/analyze(). Every skipped declaration is reported as a SwiftExtractDiagnostic carrying the affected syntax node, its source file path, the neutral message, and the underlying translation error, so consumers can render precise caret diagnostics or aggregate errors per run. The default (no sink) behavior and log output are unchanged. Also ship CollectingDiagnosticsSink, a trivial recording sink.
kateinoigakukun
force-pushed
the
pr-30763c45bc612048883b0803c0173589d0860643
branch
from
August 21, 2026 13:38
36b1fa3 to
58740dc
Compare
kateinoigakukun
marked this pull request as ready for review
August 21, 2026 13:39
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.
Today the analyzer logs a warning and silently drops any declaration it cannot fully model, and consumers have no programmatic way to observe that. That is acceptable for jextract's opt-out model, but a consumer with an opt-in model (e.g. JavaScriptKit's BridgeJS, where every
@JSdeclaration was explicitly marked for export) must fail the build with a source-located error instead of quietly not exporting the API.Introduce SwiftExtractDiagnosticsSink, an optional observer supplied to
SwiftAnalyzer/analyze(). Every skipped declaration is reported as aSwiftExtractDiagnosticcarrying the affected syntax node, its source file path, the neutral message, and the underlying translation error, so consumers can render precise caret diagnostics or aggregate errors per run. The default (no sink) behavior and log output are unchanged.