- Link to PR: Add a new API DiagnosticsFormatter.formattedMessage(_:) for messages without source location info by DougGregor · Pull Request #3059 · swiftlang/swift-syntax · GitHub
- Summary: Some tools want to use the diagnostics formatter to produce diagnostics that don't relate to source code, or for which the source code isn't available. Add an that API allows them to do so while maintaining consistent presentation.
- API Changes: The API is this:
extension DiagnosticsFormatter { /// Produce a string that formats the given diagnostic message with any /// source-location information. public func formattedMessage(_ message: some DiagnosticMessage) -> String }
- Migration: New API, no migration needed.
For reference, the compiler's adoption of this API is at [Diagnostics] Use the swift-syntax formatting for invalid source locations, too by DougGregor · Pull Request #80874 · swiftlang/swift · GitHub.
Doug