Releases: swiftlang/swift-syntax
601.0.0
New APIs
-
SameTypeRequirementSyntaxhas a newRightTypenested type.- Description: The Swift parser can now parse values as types in certain situations, so the new type reflects the possibility of the argument being either an
ExprSyntaxor aTypeSyntax. - Pull Request: #2859
- Description: The Swift parser can now parse values as types in certain situations, so the new type reflects the possibility of the argument being either an
-
SameTypeRequirementSyntaxhas a newLeftTypenested type.- Description: The Swift parser can now parse values as types in certain situations, so the new type reflects the possibility of the argument being either an
ExprSyntaxor aTypeSyntax. - Pull Request: #2859
- Description: The Swift parser can now parse values as types in certain situations, so the new type reflects the possibility of the argument being either an
-
GenericArgumentSynaxhas a newArgumentnested type.- Description: The Swift parser can now parse values as types in certain situations, so the new type reflects the possibility of the argument being either an
ExprSyntaxor aTypeSyntax. - Pull Request: #2859
- Description: The Swift parser can now parse values as types in certain situations, so the new type reflects the possibility of the argument being either an
-
GenericParameterSyntaxnow has a newspecifierproperty.- Description: With the introduction of value generics, generic parameters can now be optionally preceded by either a
letor aneach. Thespecifierproperty captures the token representing which one was parsed. - Pull Request: #2785
- Description: With the introduction of value generics, generic parameters can now be optionally preceded by either a
-
IntegerLiteralExprSyntaxandFloatLiteralExprSyntaxnow have a computedrepresentedLiteralValueproperty. -
SyntaxProtocolnow has a methodancestorOrSelf.- Description: Returns the node or the first ancestor that satisfies
condition. - Pull Request: #2696
- Description: Returns the node or the first ancestor that satisfies
-
Errorprotocol now has anasDiagnostics(at:)method.- Description: This method translates an error into one or more diagnostics, recognizing
DiagnosticsErrorandDiagnosticMessageinstances or providing its ownDiagnosticas needed. - Pull Request: #1816
- Description: This method translates an error into one or more diagnostics, recognizing
-
Added a new library
SwiftIfConfig.- Description: This new library provides facilities for evaluating
#ifconditions and determining which regions of a syntax tree are active according to a given build configuration. - Pull Request: #1816
- Description: This new library provides facilities for evaluating
-
SwiftBasicFormatadds a methodindented(by:)to all syntax node types.- Description: This method indents a node’s contents using a provided piece of
Trivia, optionally including the first line. - Pull Request: #2843
- Description: This method indents a node’s contents using a provided piece of
-
Parser.ExperimentalFeatureshas a newinit?(name: String)initializer.- Description: This initializer returns the
Parser.ExperimentalFeaturesvalue that matches the experimental parser feature with the given name. The name must be spelled the same way as it is when passed to the compiler using the-enable-experimental-featureflag. - Pull Request: #2895
- Description: This initializer returns the
API Behavior Changes
SyntaxProtocol.trimmeddetaches the node- Description: Getting a trimmed version of a node detaches it from its parent. Having the trimmed node be attached to a parent was not intuitive because eg. printing the parent node would have the trimmed trivia missing, most likely forming invalid Swift code.
- Pull Request: #2689
Deprecations
-
GenericParameterSyntaxdeprecatedeachKeywordin favor ofspecifier- Description:
specifieris now used to grab either theeachkeyword for a generic parameter or theletkeyword. - Pull request: #2785
- Description:
-
IncrementalEditdeprecated in favor ofSourceEdit -
ClosureCaptureSyntax.init(leadingTrivia:specifier:name:equal:expression:trailingComma:trailingTrivia:)deprecated in favor of a newClosureCaptureSyntax.init(leadingTrivia:_:specifier:_:name:_:initializer:_:trailingComma:_:trailingTrivia:)initializer.- Description:
ClosureCaptureSyntaxnow has aninitializerproperty instead ofequalandexpression. Additionally, thenameproperty is no longer optional. - Pull request: #2763
- Description:
-
IndenterinSwiftSyntaxBuilderhas been deprecated in favor of the newindented(by:)inSwiftBasicFormat.- Description: Indenting is really more of a formatting operation than a syntax-building operation. Additionally, the
indented(by:)method is more intuitive to use than aSyntaxRewriter. Aside fromBasicFormat, there are no other publicSyntaxRewriterclasses in the package. - Pull Request: #2843
- Description: Indenting is really more of a formatting operation than a syntax-building operation. Additionally, the
API-Incompatible Changes
-
SameTypeRequirementSyntax.rightTypehas changed types fromTypeSyntaxtoSameTypeRequirementSyntax.RightType- Description: The Swift parser can now parse values as types in certain situations, so the new type reflects the possibility of the argument being either an
ExprSyntaxor aTypeSyntax. - Pull Request: #2859
- Description: The Swift parser can now parse values as types in certain situations, so the new type reflects the possibility of the argument being either an
-
SameTypeRequirementSyntax.leftTypehas changed types fromTypeSyntaxtoSameTypeRequirementSyntax.LeftType- Description: The Swift parser can now parse values as types in certain situations, so the new type reflects the possibility of the argument being either an
ExprSyntaxor aTypeSyntax. - Pull Request: #2859
- Description: The Swift parser can now parse values as types in certain situations, so the new type reflects the possibility of the argument being either an
-
GenericArgumentSyntax.argumenthas changed types fromTypeSyntaxtoGenericArgumentSyntax.Argument- Description: The Swift parser can now parse values as types in certain situations, so the new type reflects the possibility of the argument being either an
ExprSyntaxor aTypeSyntax. - Pull Request: #2859
- Description: The Swift parser can now parse values as types in certain situations, so the new type reflects the possibility of the argument being either an
-
Moved
RadixandIntegerLiteralExprSyntax.radixfromSwiftRefactortoSwiftSyntax. -
FixIt.Changegained a new casereplaceChild(data:). -
ClosureCaptureSyntax.nameis no longer optional.- Description: Due to the new
ClosureCaptureSyntaxnode structure,nameproperty is non-optional. - Pull request: #2763
- Description: Due to the new
600.0.1
Compared to 600.0.0 this release fixes a compilation issue when building swift-syntax in C++ interop mode (#2861).
It also contains the following changes from 600.0.0.
New APIs
-
FixIt now has a new computed property named
edits- Description: the
editsrepresent the non-overlapping textualeditsthat need to be performed when the Fix-It is applied. - Issue: swiftlang/sourcekit-lsp#909
- Pull Request: #2314
- Description: the
-
SourceEdit- Description:
SourceEdithas been moved from SwiftRefactor to SwiftSyntax - Issue: swiftlang/sourcekit-lsp#909
- Pull Request: #2314
- Description:
-
assertMacroExpansionnow have new parameters namedapplyFixItsandfixedSource -
DeclSyntaxEnum,StmtSyntaxEnum,ExprSyntaxEnum,TypeSyntaxEnum, andPatternSyntaxEnum- Description: Enum to exhaustively switch over all different syntax nodes of each base type.
- Pull Request: #2351
-
WithOptionalCodeBlock- Description: A trait for syntax nodes that have an optional code block, such as
FunctionDeclSyntaxandInitializerDeclSyntax. - Pull Request: #2359
- Description: A trait for syntax nodes that have an optional code block, such as
-
CodeBlockSyntax- Description:
CodeBlockSyntaxis nowSyntaxParseable, so it can be used with string interpolations. - Pull Request: #2361
- Description:
-
ThrowsClause- Description: The
throwsSpecifierfor the effects nodes (AccessorEffectSpecifiers,FunctionEffectSpecifiers,TypeEffectSpecifiers,EffectSpecifiers) has been replaced withthrowsClause, which captures both the throws specifier and the (optional) thrown error type, as introduced by SE-0413. - Pull Request: #2379
- Description: The
-
String.isValidSwiftIdentifier(for:)- Description:
SwiftParseradds an extension onStringto check if it can be used as an identifier in a given context. - Pull Request: #2434
- Description:
-
MacroDeclSyntax.expand- the
expand(argumentList:definition:replacements:)method gains a new parameter 'genericReplacements:' that is defaulted to an empty array. - The method's signature is now
expand(argumentList:definition:replacements:genericReplacements:) - Pull Request: #2450
- the
-
SyntaxProtocol.asMacroLexicalContext()andallMacroLexicalContexts(enclosingSyntax:)- Description: Produce the lexical context for a given syntax node (if it has one), or the entire stack of lexical contexts enclosing a syntax node, for use in macro expansion.
- Pull request: #1554
-
TriviaPiece.isComment- Description:
TriviaPiecenow has a computed propertyisCommentthat returnstrueif the trivia piece is a comment. - Pull Request: #2469
- Description:
-
New
assertMacroExpansionAPI with option to specify macro specifications withmacroSpecsargument -
BasicFormat.inferIndentation(of:)- Description: Uses heuristics to infer the indentation width used in a syntax tree.
- Pull Request: #2514
-
IncrementalEditstores replacement text- Description:
IncrementalEditused to store the range that was replaced and the length of the replacement but not the replacement bytes by itself.IncrementalEditnow has areplacementproperty that contains the replacement bytes. - Pull Request: #2527
- Description:
-
Type specifiers
- Description:
AttributedTypeSyntaxcan now contain multiple specifiers and these types are used to model the list of specifiers. Additionally, type specifiers can now contain arguments, likeborrow(data). To facilitate this, the following new types were introduces:LifetimeSpecifierArgumentListSyntax,LifetimeSpecifierArgumentSyntax,LifetimeSpecifierArgumentsSyntax,LifetimeTypeSpecifierSyntax,SimpleTypeSpecifierSyntax,TypeSpecifierListSyntax - Pull request: #2433
- Description:
-
DeclGroupSyntax.introducer- Description: The
DeclGroupSyntaxtrait has an extraintroducerproperty, ie. the keyword that introduces the declaration. - Issue: https://github.com/swiftlang/sourcekit-lsp/issues/2535
- Pull Request: #2539
- Description: The
-
ExprSyntax.interpretedAsVersionTuple- Description: With the change to parse
#if canImport(MyModule, _version: 1.2.3)as a function call instead of a dedicated syntax node,1.2.3natively gets parsed as a member access3to the1.2float literal. This property allows the reinterpretation of such an expression as a version tuple. - Pull request: #2025
- Description: With the change to parse
-
SyntaxProtocol.node(at:)- Description: Given a
SyntaxIdentifier, returns theSyntaxnode with that identifier - Pull request: #2594
- Description: Given a
-
SyntaxIdentifier.IndexInTree- Description: Uniquely identifies a syntax node within a tree. This is similar to
SyntaxIdentifierbut does not store the root ID of the tree. It can thus be transferred across trees that are structurally equivalent, for example two copies of the same tree that live in different processes. The only public functions on this type aretoOpaqueandinit(fromOpaque:), which allow serialization of theIndexInTree. - Pull request: #2594
- Description: Uniquely identifies a syntax node within a tree. This is similar to
-
SyntaxIdentifierconformance toComparable:- Description: A
SyntaxIdentifiercompares less than anotherSyntaxIdentifierif the node at that identifier occurs first during a depth-first traversal of the tree. - Pull request: #2594
- Description: A
-
SyntaxIdentifier.indexInTreeandSyntaxIdentifier.fromIndexInTree- Description:
SyntaxIdentifier.indexInTreeallows the retrieval of aSyntaxIdentifierthat identifies the syntax node independent of the syntax tree.SyntaxIdentifier.fromIndexInTreeallows the creation for aSyntaxIdentifierfrom a tree-agnosticSyntaxIdentifier.IndexInTreeand the tree's root node. - Pull request: #2594
- Description:
-
SwiftSyntaxMacrosGenericTestSupport- Description: A version of the
SwiftSyntaxMacrosTestSupportmodule that doesn't depend onFoundationorXCTestand can thus be used to write macro tests usingswift-testing. Since swift-syntax can't depend on swift-testing (which would incur a circular dependency since swift-testing depends on swift-syntax), users need to manually specify a failure handler like the following, that fails the swift-testing test:Issue.record("\($0.message)", fileID: $0.location.fileID, filePath: $0.location.filePath, line: $0.location.line, column: $0.location.column) - Pull request: #2647
- Description: A version of the
-
TokenSyntax.identifier- Description: Adds an
identifierproperty toTokenSyntaxwhich returns a canonicalized representation of an identifier that strips away backticks. - Pull request: #2576
- Description: Adds an
Deprecations
-
Child Choice Node Casts
- Description:
is,as, andcastmethods for types not contained in the choice node are marked as deprecated. The deprecated methods will emit a warning, indicating that the cast will always fail. - Issue: #2092
- Pull Request: #2184
- Migration steps: Remove the
is,asorcastmethods because they will always fail.
- Description:
-
IncrementalParseTransition:- Description: The initializer
IncrementalParseTransition.init(previousTree:edits:lookaheadRanges:reusedNodeCallback:)is marked as deprecated. UseIncrementalParseTransition.init(previousIncrementalParseResult:edits:reusedNodeCallback:)instead. - Issue: #2267
- Pull request: #2272
- Migration steps: Call
IncrementalParseTransition.init(previousIncrementalParseResult:edits:reusedNodeCallback:)instead.
- Description: The initializer
-
MacroExpansion{Error|Warning|FixIt}Messagemoved to theSwiftSyntaxMacrosmodule- Description: Move the
MacroExpansion{Error|Warning|FixIt}Messagetypes from theSwiftSyntaxMacroExpansionmodule toSwiftSyntaxMacros. Deprecated typealiases inSwiftSyntaxMacroExpansionforward toSwiftSyntaxMacros. - Pull request: #2338
- Notes: The expansion diagnostic messages were defined in
SwiftSyntaxMacroExpansion, which is intended as an implementation detail of the plugin server and should not need to be imported by macros.
- Description: Move the
-
EditorPlaceholderDeclSyntaxandEditorPlaceholderExprSyntax:- Description:
EditorPlaceholderDeclSyntaxandEditorPlaceholderExprSyntaxare now deprecated and placeholders are inst...
- Description:
600.0.0
New APIs
-
FixIt now has a new computed property named
edits- Description: the
editsrepresent the non-overlapping textualeditsthat need to be performed when the Fix-It is applied. - Issue: swiftlang/sourcekit-lsp#909
- Pull Request: #2314
- Description: the
-
SourceEdit- Description:
SourceEdithas been moved from SwiftRefactor to SwiftSyntax - Issue: swiftlang/sourcekit-lsp#909
- Pull Request: #2314
- Description:
-
assertMacroExpansionnow have new parameters namedapplyFixItsandfixedSource -
DeclSyntaxEnum,StmtSyntaxEnum,ExprSyntaxEnum,TypeSyntaxEnum, andPatternSyntaxEnum- Description: Enum to exhaustively switch over all different syntax nodes of each base type.
- Pull Request: #2351
-
WithOptionalCodeBlock- Description: A trait for syntax nodes that have an optional code block, such as
FunctionDeclSyntaxandInitializerDeclSyntax. - Pull Request: #2359
- Description: A trait for syntax nodes that have an optional code block, such as
-
CodeBlockSyntax- Description:
CodeBlockSyntaxis nowSyntaxParseable, so it can be used with string interpolations. - Pull Request: #2361
- Description:
-
ThrowsClause- Description: The
throwsSpecifierfor the effects nodes (AccessorEffectSpecifiers,FunctionEffectSpecifiers,TypeEffectSpecifiers,EffectSpecifiers) has been replaced withthrowsClause, which captures both the throws specifier and the (optional) thrown error type, as introduced by SE-0413. - Pull Request: #2379
- Description: The
-
String.isValidSwiftIdentifier(for:)- Description:
SwiftParseradds an extension onStringto check if it can be used as an identifier in a given context. - Pull Request: #2434
- Description:
-
MacroDeclSyntax.expand- the
expand(argumentList:definition:replacements:)method gains a new parameter 'genericReplacements:' that is defaulted to an empty array. - The method's signature is now
expand(argumentList:definition:replacements:genericReplacements:) - Pull Request: #2450
- the
-
SyntaxProtocol.asMacroLexicalContext()andallMacroLexicalContexts(enclosingSyntax:)- Description: Produce the lexical context for a given syntax node (if it has one), or the entire stack of lexical contexts enclosing a syntax node, for use in macro expansion.
- Pull request: #1554
-
TriviaPiece.isComment- Description:
TriviaPiecenow has a computed propertyisCommentthat returnstrueif the trivia piece is a comment. - Pull Request: #2469
- Description:
-
New
assertMacroExpansionAPI with option to specify macro specifications withmacroSpecsargument -
BasicFormat.inferIndentation(of:)- Description: Uses heuristics to infer the indentation width used in a syntax tree.
- Pull Request: #2514
-
IncrementalEditstores replacement text- Description:
IncrementalEditused to store the range that was replaced and the length of the replacement but not the replacement bytes by itself.IncrementalEditnow has areplacementproperty that contains the replacement bytes. - Pull Request: #2527
- Description:
-
Type specifiers
- Description:
AttributedTypeSyntaxcan now contain multiple specifiers and these types are used to model the list of specifiers. Additionally, type specifiers can now contain arguments, likeborrow(data). To facilitate this, the following new types were introduces:LifetimeSpecifierArgumentListSyntax,LifetimeSpecifierArgumentSyntax,LifetimeSpecifierArgumentsSyntax,LifetimeTypeSpecifierSyntax,SimpleTypeSpecifierSyntax,TypeSpecifierListSyntax - Pull request: #2433
- Description:
-
DeclGroupSyntax.introducer- Description: The
DeclGroupSyntaxtrait has an extraintroducerproperty, ie. the keyword that introduces the declaration. - Issue: https://github.com/swiftlang/sourcekit-lsp/issues/2535
- Pull Request: #2539
- Description: The
-
ExprSyntax.interpretedAsVersionTuple- Description: With the change to parse
#if canImport(MyModule, _version: 1.2.3)as a function call instead of a dedicated syntax node,1.2.3natively gets parsed as a member access3to the1.2float literal. This property allows the reinterpretation of such an expression as a version tuple. - Pull request: #2025
- Description: With the change to parse
-
SyntaxProtocol.node(at:)- Description: Given a
SyntaxIdentifier, returns theSyntaxnode with that identifier - Pull request: #2594
- Description: Given a
-
SyntaxIdentifier.IndexInTree- Description: Uniquely identifies a syntax node within a tree. This is similar to
SyntaxIdentifierbut does not store the root ID of the tree. It can thus be transferred across trees that are structurally equivalent, for example two copies of the same tree that live in different processes. The only public functions on this type aretoOpaqueandinit(fromOpaque:), which allow serialization of theIndexInTree. - Pull request: #2594
- Description: Uniquely identifies a syntax node within a tree. This is similar to
-
SyntaxIdentifierconformance toComparable:- Description: A
SyntaxIdentifiercompares less than anotherSyntaxIdentifierif the node at that identifier occurs first during a depth-first traversal of the tree. - Pull request: #2594
- Description: A
-
SyntaxIdentifier.indexInTreeandSyntaxIdentifier.fromIndexInTree- Description:
SyntaxIdentifier.indexInTreeallows the retrieval of aSyntaxIdentifierthat identifies the syntax node independent of the syntax tree.SyntaxIdentifier.fromIndexInTreeallows the creation for aSyntaxIdentifierfrom a tree-agnosticSyntaxIdentifier.IndexInTreeand the tree's root node. - Pull request: #2594
- Description:
-
SwiftSyntaxMacrosGenericTestSupport- Description: A version of the
SwiftSyntaxMacrosTestSupportmodule that doesn't depend onFoundationorXCTestand can thus be used to write macro tests usingswift-testing. Since swift-syntax can't depend on swift-testing (which would incur a circular dependency since swift-testing depends on swift-syntax), users need to manually specify a failure handler like the following, that fails the swift-testing test:Issue.record("\($0.message)", fileID: $0.location.fileID, filePath: $0.location.filePath, line: $0.location.line, column: $0.location.column) - Pull request: #2647
- Description: A version of the
-
TokenSyntax.identifier- Description: Adds an
identifierproperty toTokenSyntaxwhich returns a canonicalized representation of an identifier that strips away backticks. - Pull request: #2576
- Description: Adds an
Deprecations
-
Child Choice Node Casts
- Description:
is,as, andcastmethods for types not contained in the choice node are marked as deprecated. The deprecated methods will emit a warning, indicating that the cast will always fail. - Issue: #2092
- Pull Request: #2184
- Migration steps: Remove the
is,asorcastmethods because they will always fail.
- Description:
-
IncrementalParseTransition:- Description: The initializer
IncrementalParseTransition.init(previousTree:edits:lookaheadRanges:reusedNodeCallback:)is marked as deprecated. UseIncrementalParseTransition.init(previousIncrementalParseResult:edits:reusedNodeCallback:)instead. - Issue: #2267
- Pull request: #2272
- Migration steps: Call
IncrementalParseTransition.init(previousIncrementalParseResult:edits:reusedNodeCallback:)instead.
- Description: The initializer
-
MacroExpansion{Error|Warning|FixIt}Messagemoved to theSwiftSyntaxMacrosmodule- Description: Move the
MacroExpansion{Error|Warning|FixIt}Messagetypes from theSwiftSyntaxMacroExpansionmodule toSwiftSyntaxMacros. Deprecated typealiases inSwiftSyntaxMacroExpansionforward toSwiftSyntaxMacros. - Pull request: #2338
- Notes: The expansion diagnostic messages were defined in
SwiftSyntaxMacroExpansion, which is intended as an implementation detail of the plugin server and should not need to be imported by macros.
- Description: Move the
-
EditorPlaceholderDeclSyntaxandEditorPlaceholderExprSyntax:- Description:
EditorPlaceholderDeclSyntaxandEditorPlaceholderExprSyntaxare now deprecated and placeholders are instead parsed as identifiers within aMissingDeclSyntaxorDeclReferenceExprSyntax. - Pull request: #2237
- Description:
-
AttributedTypeSyntax.specifierhas renamed tospecifiersand changed to be a collection- Description: Types can h...
600.0.0-prerelease-2024-09-04
Merge pull request #2801 from SimplyDanny/increase-compiler-version [6.0] Increase tools version
600.0.0-prerelease-2024-08-14
Merge pull request #2801 from SimplyDanny/increase-compiler-version [6.0] Increase tools version
510.0.3
Compared to 510.0.2 improves swift-syntax’s ability to build using Bazel.
It also contains the following changes from 510.0.0.
New APIs
-
SyntaxStringInterpolation.appendInterpolation(_: (some SyntaxProtocol)?)- Description: Allows optional syntax nodes to be used inside string interpolation of syntax nodes. If the node is
nil, nothing will get added to the string interpolation. - Pull Request: #2085
- Description: Allows optional syntax nodes to be used inside string interpolation of syntax nodes. If the node is
-
SyntaxCollection.index(at:)- Description: Returns the index of the n-th element in a
SyntaxCollection. This computation is in O(n) andSyntaxCollectionis not subscriptable by an integer. - Pull Request: #2014
- Description: Returns the index of the n-th element in a
-
Convenience initializer
ClosureCaptureSyntax.init() -
Convenience initializer
EnumCaseParameterSyntax.init() -
DiagnosticSeverityandPluginMessage.Diagnostic.Severitynow have new case namedremark- Description: Remarks are used by the Swift compiler and other tools to describe some aspect of translation that doesn't reflect correctness, but may be useful for the user. Remarks have been added to the diagnostic severity enums to align with the Swift compiler.
- Pull Request: #2143
Deprecations
-
Leaf Node Casts
-
Same-Type Casts
-
Base Node Casts
-
WildcardPatternSyntax.typeAnnotation- Description:
typeAnnotationonWildcardPatternSyntaxwas a mistake. UsetypeAnnotationproperties on the outer constructs instead. E.g.PatternBindingListSyntax.typeAnnotation - Pull Request: #2393
- Description:
API-Incompatible Changes
-
NoteMessage.fixItIDrenamed tonoteID -
DiagnosticSpec.highlightreplaced byhighlights- Description: The use of a single string
highlightprevented users from asserting that a macro highlighted exactly the expected set of syntax nodes. Use ofDiagnosticSpec.init(...highlight:...)is deprecated and forwards toDiagnosticSpec.init(...highlights:...). Migrating fromhighlighttohighlightsis straightforward; any uses ofDiagnosticSpec.initwhich do not specify ahighlightdo not need to change, otherwise:- If the diagnostic highlights a single node, the
highlightstring should be replaced with a single element array containing the same string without any trailing trivia, e.g.,highlight: "let "->highlights: ["let"]. - If the diagnostic highlights multiple nodes, the
highlightstring should be replaced with an array containing an element for each highlighted node, e.g.,highlight: "struct {}"->highlights: ["struct", "{}"].
- If the diagnostic highlights a single node, the
- Pull Request: #2213
- Description: The use of a single string
600.0.0-prerelease-2024-07-24
Merge pull request #2751 from ahoppen/6.0/fix-build-warnings [6.0] Fix build warnings
600.0.0-prerelease-2024-06-12
Merge pull request #2672 from ahoppen/6.0/atomic-on-heap [6.0] Heap allocate our atomics
510.0.2
Compared to 510.0.1 this release fixes compilation warnings about retroactive conformances when building swift-syntax with a Swift 6 compiler.
It also contains the following changes from 510.0.0.
New APIs
-
SyntaxStringInterpolation.appendInterpolation(_: (some SyntaxProtocol)?)- Description: Allows optional syntax nodes to be used inside string interpolation of syntax nodes. If the node is
nil, nothing will get added to the string interpolation. - Pull Request: #2085
- Description: Allows optional syntax nodes to be used inside string interpolation of syntax nodes. If the node is
-
SyntaxCollection.index(at:)- Description: Returns the index of the n-th element in a
SyntaxCollection. This computation is in O(n) andSyntaxCollectionis not subscriptable by an integer. - Pull Request: #2014
- Description: Returns the index of the n-th element in a
-
Convenience initializer
ClosureCaptureSyntax.init() -
Convenience initializer
EnumCaseParameterSyntax.init() -
DiagnosticSeverityandPluginMessage.Diagnostic.Severitynow have new case namedremark- Description: Remarks are used by the Swift compiler and other tools to describe some aspect of translation that doesn't reflect correctness, but may be useful for the user. Remarks have been added to the diagnostic severity enums to align with the Swift compiler.
- Pull Request: #2143
Deprecations
-
Leaf Node Casts
-
Same-Type Casts
-
Base Node Casts
-
WildcardPatternSyntax.typeAnnotation- Description:
typeAnnotationonWildcardPatternSyntaxwas a mistake. UsetypeAnnotationproperties on the outer constructs instead. E.g.PatternBindingListSyntax.typeAnnotation - Pull Request: #2393
- Description:
API-Incompatible Changes
-
NoteMessage.fixItIDrenamed tonoteID -
DiagnosticSpec.highlightreplaced byhighlights- Description: The use of a single string
highlightprevented users from asserting that a macro highlighted exactly the expected set of syntax nodes. Use ofDiagnosticSpec.init(...highlight:...)is deprecated and forwards toDiagnosticSpec.init(...highlights:...). Migrating fromhighlighttohighlightsis straightforward; any uses ofDiagnosticSpec.initwhich do not specify ahighlightdo not need to change, otherwise:- If the diagnostic highlights a single node, the
highlightstring should be replaced with a single element array containing the same string without any trailing trivia, e.g.,highlight: "let "->highlights: ["let"]. - If the diagnostic highlights multiple nodes, the
highlightstring should be replaced with an array containing an element for each highlighted node, e.g.,highlight: "struct {}"->highlights: ["struct", "{}"].
- If the diagnostic highlights a single node, the
- Pull Request: #2213
- Description: The use of a single string
510.0.1
Compared to 510.0.0 this fixes a possible misaligned memory access.
It also contains the following changes from 510.0.0.
New APIs
-
SyntaxStringInterpolation.appendInterpolation(_: (some SyntaxProtocol)?)- Description: Allows optional syntax nodes to be used inside string interpolation of syntax nodes. If the node is
nil, nothing will get added to the string interpolation. - Pull Request: #2085
- Description: Allows optional syntax nodes to be used inside string interpolation of syntax nodes. If the node is
-
SyntaxCollection.index(at:)- Description: Returns the index of the n-th element in a
SyntaxCollection. This computation is in O(n) andSyntaxCollectionis not subscriptable by an integer. - Pull Request: #2014
- Description: Returns the index of the n-th element in a
-
Convenience initializer
ClosureCaptureSyntax.init() -
Convenience initializer
EnumCaseParameterSyntax.init() -
DiagnosticSeverityandPluginMessage.Diagnostic.Severitynow have new case namedremark- Description: Remarks are used by the Swift compiler and other tools to describe some aspect of translation that doesn't reflect correctness, but may be useful for the user. Remarks have been added to the diagnostic severity enums to align with the Swift compiler.
- Pull Request: #2143
Deprecations
-
Leaf Node Casts
-
Same-Type Casts
-
Base Node Casts
-
WildcardPatternSyntax.typeAnnotation- Description:
typeAnnotationonWildcardPatternSyntaxwas a mistake. UsetypeAnnotationproperties on the outer constructs instead. E.g.PatternBindingListSyntax.typeAnnotation - Pull Request: #2393
- Description:
API-Incompatible Changes
-
NoteMessage.fixItIDrenamed tonoteID -
DiagnosticSpec.highlightreplaced byhighlights- Description: The use of a single string
highlightprevented users from asserting that a macro highlighted exactly the expected set of syntax nodes. Use ofDiagnosticSpec.init(...highlight:...)is deprecated and forwards toDiagnosticSpec.init(...highlights:...). Migrating fromhighlighttohighlightsis straightforward; any uses ofDiagnosticSpec.initwhich do not specify ahighlightdo not need to change, otherwise:- If the diagnostic highlights a single node, the
highlightstring should be replaced with a single element array containing the same string without any trailing trivia, e.g.,highlight: "let "->highlights: ["let"]. - If the diagnostic highlights multiple nodes, the
highlightstring should be replaced with an array containing an element for each highlighted node, e.g.,highlight: "struct {}"->highlights: ["struct", "{}"].
- If the diagnostic highlights a single node, the
- Pull Request: #2213
- Description: The use of a single string