Skip to content

Commit 43ba656

Browse files
committed
Add Sendable conformances to the SwiftSyntax module
1 parent 48a0f06 commit 43ba656

39 files changed

+215
-94
lines changed

CodeGeneration/Sources/generate-swift-syntax/templates/swiftsyntax/KeywordFile.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ let lookupTable = ArrayExprSyntax(leftSquare: .leftSquareToken(trailingTrivia: .
2424
let keywordFile = SourceFileSyntax(leadingTrivia: copyrightHeader) {
2525
try! EnumDeclSyntax(
2626
"""
27-
public enum Keyword: UInt8, Hashable
27+
public enum Keyword: UInt8, Hashable, Sendable
2828
"""
2929
) {
3030
for keyword in Keyword.allCases {

CodeGeneration/Sources/generate-swift-syntax/templates/swiftsyntax/SyntaxEnumFile.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ let syntaxEnumFile = SourceFileSyntax(leadingTrivia: copyrightHeader) {
1919
try! EnumDeclSyntax(
2020
"""
2121
/// Enum to exhaustively switch over all different syntax nodes.
22-
public enum SyntaxEnum
22+
public enum SyntaxEnum: Sendable
2323
"""
2424
) {
2525
DeclSyntax("case token(TokenSyntax)")

CodeGeneration/Sources/generate-swift-syntax/templates/swiftsyntax/SyntaxKindFile.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ let syntaxKindFile = SourceFileSyntax(leadingTrivia: copyrightHeader) {
1919
try! EnumDeclSyntax(
2020
"""
2121
/// Enumerates the known kinds of Syntax represented in the Syntax tree.
22-
public enum SyntaxKind
22+
public enum SyntaxKind: Sendable
2323
"""
2424
) {
2525
DeclSyntax("case token")

CodeGeneration/Sources/generate-swift-syntax/templates/swiftsyntax/TokenKindFile.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ let tokenKindFile = SourceFileSyntax(leadingTrivia: copyrightHeader) {
1919
try! EnumDeclSyntax(
2020
"""
2121
/// Enumerates the kinds of tokens in the Swift language.
22-
public enum TokenKind: Hashable
22+
public enum TokenKind: Hashable, Sendable
2323
"""
2424
) {
2525
for tokenSpec in Token.allCases.map(\.spec) {

CodeGeneration/Sources/generate-swift-syntax/templates/swiftsyntax/TriviaPiecesFile.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ let triviaPiecesFile = SourceFileSyntax(leadingTrivia: copyrightHeader) {
2626
///
2727
/// In general, you should deal with the actual Trivia collection instead
2828
/// of individual pieces whenever possible.
29-
public enum TriviaPiece
29+
public enum TriviaPiece: Sendable
3030
"""
3131
) {
3232
for trivia in TRIVIAS {
@@ -176,7 +176,7 @@ let triviaPiecesFile = SourceFileSyntax(leadingTrivia: copyrightHeader) {
176176
/// In contrast to ``TriviaPiece``, a ``RawTriviaPiece`` does not own the source
177177
/// text of the trivia.
178178
@_spi(RawSyntax)
179-
public enum RawTriviaPiece: Equatable
179+
public enum RawTriviaPiece: Equatable, Sendable
180180
"""
181181
) {
182182
for trivia in TRIVIAS {

Sources/SwiftParser/CollectionNodes+Parsable.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ fileprivate extension SyntaxCollection {
4545
} else {
4646
// First unwrap: We know that children.last exists because children is not empty
4747
// Second unwrap: This is a collection and collections never have optional children. Thus the last child can’t be nil.
48-
let lastWithRemainder = parser.parseRemainder(into: layoutView.children.last!!)
48+
let lastWithRemainder = parser.parseRemainder(into: layoutView.children[layoutView.children.count - 1]!)
4949
let raw = layoutView.replacingChild(at: layoutView.children.count - 1, with: lastWithRemainder, arena: parser.arena)
5050
return Syntax(raw: raw, rawNodeArena: parser.arena).cast(Self.self)
5151
}

Sources/SwiftSyntax/AbsolutePosition.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
/// An absolute position in a source file as text - the absolute utf8Offset from
1414
/// the start of the file.
15-
public struct AbsolutePosition: Comparable, Hashable {
15+
public struct AbsolutePosition: Comparable, Hashable, Sendable {
1616
public let utf8Offset: Int
1717

1818
static let startOfFile = AbsolutePosition(utf8Offset: 0)

Sources/SwiftSyntax/AbsoluteRawSyntax.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13-
struct AbsoluteRawSyntax {
13+
struct AbsoluteRawSyntax: Sendable {
1414
let raw: RawSyntax
1515
let info: AbsoluteSyntaxInfo
1616

Sources/SwiftSyntax/AbsoluteSyntaxInfo.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13-
struct AbsoluteSyntaxPosition {
13+
struct AbsoluteSyntaxPosition: Sendable {
1414
/// The UTF-8 offset of the syntax node in the source file
1515
let offset: UInt32
1616
let indexInParent: UInt32
@@ -32,7 +32,7 @@ struct AbsoluteSyntaxPosition {
3232

3333
/// `AbsoluteSyntaxInfo` represents the information that relates a `RawSyntax`
3434
/// to a source file tree, like its absolute source offset.
35-
struct AbsoluteSyntaxInfo {
35+
struct AbsoluteSyntaxInfo: Sendable {
3636
let position: AbsoluteSyntaxPosition
3737
let nodeId: SyntaxIdentifier
3838

Sources/SwiftSyntax/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ add_swift_syntax_library(SwiftSyntax
2323
SwiftSyntaxCompatibility.swift
2424
Syntax.swift
2525
SyntaxArena.swift
26+
SyntaxArenaAllocatedBuffer.swift
2627
SyntaxChildren.swift
2728
SyntaxCollection.swift
2829
SyntaxHashable.swift

0 commit comments

Comments
 (0)