Skip to content

Releases: swiftlang/swift-syntax

603.0.0-prerelease-2025-09-15

15 Sep 23:24
6673b05
Compare
Choose a tag to compare
Pre-release
Merge pull request #3146 from rintaro/parse-attr-lparen-space-rdar147…

602.0.0

15 Sep 23:19
4799286
Compare
Choose a tag to compare

New APIs

  • SwiftLexicalLookup - A new Swift unqualified lookup library

    • Description: The library provides a new Swift unqualified lookup implementation detached from the compiler and accessible to outside clients. The query is stateless and can be directly run on swift-syntax syntax tree, with any syntax node functioning as an entry point. It produces an enum-based data structure as a result that partitions collected names based on the lexical scope of introduction.
    • Pull Request: #2952
    • Notes: The library follows the behavior of the compiler implementation with some minor differences, such as a different way of handling dollar identifiers $x and generic parameters inside extensions. Furthermore, in the future, once the compiler adopts SwiftLexicalLookup and it becomes the canonical implementation, results produced by the query will be guaranteed to be correct.
  • DiagnosticMessage has a new optional property, category, that provides a category name and documentation URL for a diagnostic.

    • Description: Tools often have many different diagnostics. Diagnostic categories allow tools to group several diagnostics together with documentation that can help users understand what the diagnostics mean and how to address them. This API allows diagnostics to provide this category information. The diagnostic renderer will provide the category at the end of the diagnostic message in the form [#CategoryName], and can print categories as "footnotes" with its categoryFootnotes method.
    • Pull Request: #2981
    • 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.
  • DiagnosticsFormatter has a new method, formattedMessage, that formats a diagnostic message without any corresponding syntax node.

    • 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.
    • Pull Request: #3059
    • Migration steps: None required.
  • FixIt.Change has a new case replaceText that performs a textual replacement of a range of text with another string.

    • Description: The other FixIt.Change cases provide structured
      modifications to syntax trees, such as replacing specific notes. Some
      clients provide Fix-Its that don't fit well into this structured model. The
      replaceText case makes it possible for such clients to express Fix-Its.
    • Pull request: #3030
    • Migration stems: None required.

API Behavior Changes

Deprecations

API-Incompatible Changes

  • ExpandEditorPlaceholdersToTrailingClosures has changed to ExpandEditorPlaceholdersToLiteralClosures

    • Description: Whether function-typed placeholders are expanded to trailing closures is now configurable using a format argument to this rewriter. Additionally clients that support nested placeholders may request that the entire expanded closure be wrapped in an outer placeholder, e.g. <#{ <#foo#> in <#Bar#> }#>.
    • Pull Request: #2897
    • Migration steps: Replace uses of ExpandEditorPlaceholdersToTrailingClosures with ExpandEditorPlaceholdersToLiteralClosures. The initializer does not need to change: .init(indentationWidth:) on the new type provides the same behavior as the old type.
    • Notes: This improves code completion in a SourceKitLSP session where the trailing closure form may be undesirable. The nested placeholders offer more flexibility to end users, in editors that support it.
  • SyntaxArena and ParsingSyntaxArena has changed to SPI

    • Description: SyntaxArena and the subclasses were only meant to be used when dealing with RawSyntax which is also SPI.
    • Pull Request: #2930
    • Migration steps: Do not use SyntaxArena or ParsingSyntaxArena directly.
    • Notes: Although the type itself was public, most initializers were already SPI and there was no way to retrive them from existing types via public API.
  • SyntaxChildrenIndex is no longer ExpressibleByNilLiteral

    • Description: nil used to represent the end index. However, due to a change in the internal structure, the end index must now be retrieved from the collection.
    • Pull Request: #2925
    • Migration steps: Use SyntaxChildren.endIndex instead.
    • Notes: ExpressibleByNilLiteral was a mistake. In general, Collection.Index should only be created and managed by the collection itself. For example, Collection.index(after:) exists, but Index.advanced(by:) does not.
  • Some cases in AttributeSyntax.Arguments choices and related types has been removed

    • Description: Some attributes that used to have special attribute list syntax are now parsed as a regular AttributeSyntax with .argumentList(LabeledExprListSyntax).
    • Pull Request: #3028
    • Migration steps: Use AttributeSyntax.Arguments.argumentList(LabeledExprListSyntax) instead.
    • Notes: Removed cases from AttributeSyntax.Arguments: token(TokenSyntax), string(StringLiteralExprSyntax), conventionArguments(ConventionAttributeArgumentsSyntax), conventionWitnessMethodArguments(ConventionWitnessMethodAttributeArgumentsSyntax), opaqueReturnTypeOfAttributeArguments(OpaqueReturnTypeOfAttributeArgumentsSyntax), exposeAttributeArguments(ExposeAttributeArgumentsSyntax), underscorePrivateAttributeArguments(UnderscorePrivateAttributeArgumentsSyntax), and unavailableFromAsyncArguments(UnavailableFromAsyncAttributeArgumentsSyntax). Removed Syntax kinds: ConventionAttributeArgumentsSyntax, ConventionWitnessMethodAttributeArgumentsSyntax, OpaqueReturnTypeOfAttributeArgumentsSyntax, ExposeAttributeArgumentsSyntax, UnderscorePrivateAttributeArgumentsSyntax, and UnavailableFromAsyncAttributeArgumentsSyntax.
  • ExpandEditorPlaceholdersToLiteralClosures & CallToTrailingClosures now take a Syntax parameter

    • Description: These refactorings now take an arbitrary Syntax and return a Syntax?. If a non-function-like syntax node is passed, nil is returned. The previous FunctionCallExprSyntax overloads are deprecated.
    • Pull Request: #3092
    • Migration steps: Insert a Syntax(...) initializer call for the argument, and cast the result with .as(...) if necessary.
    • Notes: This allows the refactorings to correctly handle macro expansion expressions and declarations.

603.0.0-prerelease-2025-08-11

11 Aug 18:28
07bf225
Compare
Choose a tag to compare
Pre-release
Merge pull request #3136 from rintaro/parser-attr-recover

[SwiftParser] Improve attribute parsing and recovering

602.0.0-prerelease-2025-08-11

11 Aug 17:34
21b3b45
Compare
Choose a tag to compare
Pre-release
Merge pull request #3126 from hamishknight/enable-inlinearray-sugar-6.2

[6.2] Enable InlineArray type sugar

603.0.0-prerelease-2025-06-26

26 Jun 01:26
c40a978
Compare
Choose a tag to compare
Pre-release
Merge pull request #3110 from swiftlang/jepa

Enable some nice-to-have code formatting rules

602.0.0-prerelease-2025-06-26

26 Jun 01:24
fd6373f
Compare
Choose a tag to compare
Pre-release
Merge pull request #3108 from hamishknight/3104-6.2

[6.2] Fix a crash if we had a dollar identifier as the second parameter label in a closure not followed by a colon

602.0.0-prerelease-2025-05-29

29 May 03:50
0dff260
Compare
Choose a tag to compare
Pre-release
Merge pull request #3086 from bnbarham/cherry-add-sendable-metatype

[6.2] Add a `SendableMetatype` conformance to `Macro`

602.0.0-prerelease-2025-04-16

16 Apr 17:48
340f840
Compare
Choose a tag to compare
Pre-release
Merge pull request #3049 from ahoppen/6.2/default-release-version

Change default release version in GitHub action to `602.0.0`

602.0.0-prerelease-2025-04-10

10 Apr 15:38
340f840
Compare
Choose a tag to compare
Pre-release
Merge pull request #3049 from ahoppen/6.2/default-release-version

Change default release version in GitHub action to `602.0.0`

601.0.1

02 Apr 20:39
Compare
Choose a tag to compare

Fixes a missing dependency from SwiftSyntax to SwiftSyntax601 which prevented its use in #if canImport.