Skip to content

[SwiftExtract] Add a pluggable diagnostics sink for skipped declarations - #900

Open
kateinoigakukun wants to merge 1 commit into
swiftlang:mainfrom
kateinoigakukun:pr-30763c45bc612048883b0803c0173589d0860643
Open

[SwiftExtract] Add a pluggable diagnostics sink for skipped declarations#900
kateinoigakukun wants to merge 1 commit into
swiftlang:mainfrom
kateinoigakukun:pr-30763c45bc612048883b0803c0173589d0860643

Conversation

@kateinoigakukun

@kateinoigakukun kateinoigakukun commented Aug 21, 2026

Copy link
Copy Markdown
Member

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.

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
kateinoigakukun force-pushed the pr-30763c45bc612048883b0803c0173589d0860643 branch from 36b1fa3 to 58740dc Compare August 21, 2026 13:38
@kateinoigakukun
kateinoigakukun marked this pull request as ready for review August 21, 2026 13:39
@kateinoigakukun
kateinoigakukun requested a review from ktoso as a code owner August 21, 2026 13:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant