Skip to content

Commit 947e6f3

Browse files
committed
Update the interpolation failure message
When a user is getting the interpolation `os_log` failure message but actually supports parsing invalid source code, offer them an alternative parses the source code without checking for errors.
1 parent ccab07f commit 947e6f3

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

Sources/SwiftSyntaxBuilder/SyntaxParsable+ExpressibleByStringInterpolation.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,14 @@ extension SyntaxParseable {
4848
{
4949
let diagnostics = ParseDiagnosticsGenerator.diagnostics(for: self)
5050
let formattedDiagnostics = DiagnosticsFormatter().annotatedSource(tree: self, diags: diagnostics)
51-
Logger(subsystem: "SwiftSyntax", category: "ParseError").fault(
51+
Logger(subsystem: "org.swift.swift-syntax", category: "ParseError").fault(
5252
"""
5353
Parsing a `\(Self.self)` node from string interpolation produced the following parsing errors.
5454
Set a breakpoint in `SyntaxParseable.logStringInterpolationParsingError()` to debug the failure.
55+
56+
To explicitly support parsing of invalid source code, import SwiftParser and invoke the parser as follows
57+
var parser = Parser(source)
58+
\(Self.self).parse(from: &parser)
5559
\(formattedDiagnostics, privacy: .private)
5660
"""
5761
)
@@ -61,7 +65,7 @@ extension SyntaxParseable {
6165

6266
/// Initialize the syntax node from a string interpolation.
6367
///
64-
/// - Important: This asssumes that the string interpolation produces a valid
68+
/// - Important: This assumes that the string interpolation produces a valid
6569
/// syntax tree. If the syntax tree is not valid, a fault will
6670
/// be logged using OSLog on Darwin platforms.
6771
public init(stringInterpolation: SyntaxStringInterpolation) {

0 commit comments

Comments
 (0)