Skip to content

Commit 447a849

Browse files
authored
Merge pull request #3063 from swiftlang/automerge/merge-main-2025-04-21_18-31
Merge `main` into `release/6.2`
2 parents 9d52204 + b146d3f commit 447a849

File tree

4 files changed

+59
-0
lines changed

4 files changed

+59
-0
lines changed

.github/workflows/automerge.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: Create PR to merge main into release branch
2+
# In the first period after branching the release branch, we typically want to include many changes from `main` in the release branch. This workflow automatically creates a PR every Monday to merge main into the release branch.
3+
# Later in the release cycle we should stop this practice to avoid landing risky changes by disabling this workflow. To do so, disable the workflow as described in https://docs.github.com/en/actions/managing-workflow-runs-and-deployments/managing-workflow-runs/disabling-and-enabling-a-workflow
4+
on:
5+
schedule:
6+
- cron: '0 9 * * MON'
7+
workflow_dispatch:
8+
jobs:
9+
create_merge_pr:
10+
name: Create PR to merge main into release branch
11+
uses: swiftlang/github-workflows/.github/workflows/create_automerge_pr.yml@main
12+
with:
13+
base_branch: release/6.2
14+
permissions:
15+
contents: write
16+
pull-requests: write
17+
if: (github.event_name == 'schedule' && github.repository == 'swiftlang/swift-syntax') || (github.event_name != 'schedule') # Ensure that we don't run this on a schedule in a fork

Release Notes/602.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@
1212
- Pull Request: https://github.com/swiftlang/swift-syntax/pull/2981
1313
- Migration steps: None required. The new `category` property has optional type, and there is a default implementation that returns `nil`. Types that conform to `DiagnosticMessage` can choose to implement this property and provide a category when appropriate.
1414

15+
- `DiagnosticsFormatter` has a new method, `formattedMessage`, that formats a diagnostic message without any corresponding syntax node.
16+
- Description: 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. This API allows them to do so while maintaining consistent presentation.
17+
- Pull Request: https://github.com/swiftlang/swift-syntax/pull/3059
18+
- Migration steps: None required.
19+
1520
- `FixIt.Change` has a new case `replaceText` that performs a textual replacement of a range of text with another string.
1621
- Description: The other `FixIt.Change` cases provide structured
1722
modifications to syntax trees, such as replacing specific notes. Some

Sources/SwiftDiagnostics/DiagnosticsFormatter.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,12 @@ public struct DiagnosticsFormatter {
360360
)
361361
}
362362

363+
/// Produce a string that formats the given diagnostic message with any
364+
/// source-location information.
365+
public func formattedMessage(_ message: some DiagnosticMessage) -> String {
366+
diagnosticDecorator.decorateDiagnosticMessage(message)
367+
}
368+
363369
/// Produce a string containing "footnotes" for each of the diagnostic
364370
/// category provided that has associated documentation. Each category
365371
/// is printed in Markdown link format, e.g.,
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2014 - 2025 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See https://swift.org/LICENSE.txt for license information
9+
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
import SwiftDiagnostics
14+
import XCTest
15+
16+
final class DiagnosticFormatterTests: XCTestCase {
17+
func testFormattedMessage() {
18+
let message = SimpleDiagnosticMessage(
19+
message: "something went wrong",
20+
diagnosticID: MessageID(domain: "swift-syntax", id: "testing"),
21+
severity: .error,
22+
category: DiagnosticCategory(
23+
name: "Testing",
24+
documentationURL: "http://example.com"
25+
)
26+
)
27+
28+
let formattedText = DiagnosticsFormatter().formattedMessage(message)
29+
XCTAssertEqual(formattedText, "error: something went wrong [#Testing]")
30+
}
31+
}

0 commit comments

Comments
 (0)