Skip to content

Commit de2d770

Browse files
authored
Merge branch 'main' into adamcarter93/separate-backtick-tokens
2 parents e903d9a + 83ee689 commit de2d770

File tree

201 files changed

+6795
-2161
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

201 files changed

+6795
-2161
lines changed

.bazelrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
common --enable_bzlmod
2+
common --incompatible_disallow_empty_glob
23
common --incompatible_use_host_features
34
common --lockfile_mode=off
45

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
* **Explanation**: <!-- A description of the issue being fixed or enhancement being made. This can be brief, but it should be clear. -->
2+
* **Scope**: <!-- An assessment of the impact/importance of the change. For example, is the change a source-breaking language change, etc. -->
3+
* **Issue**: <!-- The GitHub Issue link if the change fixes/implements an issue/enhancement -->
4+
* **Original PR**: <!-- Pull Request link from main branch -->
5+
* **Risk**: <!-- What is the (specific) risk to the release for taking this change? -->
6+
* **Testing**: <!-- What specific testing has been done or needs to be done to further validate any impact of this change? -->
7+
* **Reviewer**: <!-- One or more code owners for the impacted components should review the change. Technical review can be delegated by a code owner or otherwise requested as deemed appropriate or useful. -->

BUILD.bazel

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ swift_syntax_library(
3636
":SwiftSyntax",
3737
":SwiftSyntaxMacroExpansion",
3838
":SwiftSyntaxMacros",
39+
":_SwiftSyntaxCShims",
3940
],
4041
)
4142

@@ -82,6 +83,14 @@ swift_syntax_test(
8283
],
8384
)
8485

86+
swift_syntax_library(
87+
name = "SwiftLibraryPluginProvider",
88+
deps = [
89+
":SwiftCompilerPluginMessageHandling",
90+
":SwiftSyntaxMacros",
91+
],
92+
)
93+
8594
swift_syntax_library(
8695
name = "SwiftOperators",
8796
deps = [
@@ -161,7 +170,7 @@ swift_syntax_library(
161170
":SwiftSyntax509",
162171
":SwiftSyntax510",
163172
":SwiftSyntax600",
164-
":_AtomicBool",
173+
":_SwiftSyntaxCShims",
165174
],
166175
)
167176

@@ -281,15 +290,6 @@ swift_syntax_test(
281290
],
282291
)
283292

284-
cc_library(
285-
name = "_AtomicBool",
286-
srcs = glob(["Sources/_AtomicBool/src/*.c"]),
287-
hdrs = glob(["Sources/_AtomicBool/include/*.h"]),
288-
includes = ["Sources/_AtomicBool/include"],
289-
tags = ["swift_module=_AtomicBool"],
290-
visibility = ["//visibility:private"],
291-
)
292-
293293
cc_library(
294294
name = "_InstructionCounter",
295295
srcs = glob(["Sources/_InstructionCounter/src/*.c"]),
@@ -299,6 +299,14 @@ cc_library(
299299
visibility = ["//visibility:private"],
300300
)
301301

302+
cc_library(
303+
name = "_SwiftSyntaxCShims",
304+
hdrs = glob(["Sources/_SwiftSyntaxCShims/include/*.h"]),
305+
includes = ["Sources/_SwiftSyntaxCShims/include"],
306+
tags = ["swift_module=_SwiftSyntaxCShims"],
307+
visibility = ["//visibility:private"],
308+
)
309+
302310
swift_syntax_library(
303311
name = "_SwiftSyntaxTestSupport",
304312
testonly = True,

CONTRIBUTING.md

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ If you want to modify the generated files, open the [CodeGeneration](CodeGenerat
4949
Alternatively, you can generate the files from the command line by running the following command from the swift-syntax directory
5050
5151
```bash
52-
swift run --package-path CodeGeneration
52+
./swift-syntax-dev-utils generate-source-code
5353
```
5454
5555
## Running Pre-PR Checks Script
@@ -71,6 +71,42 @@ We prefer to not squash commits when merging a PR because, especially for larger
7171
- During review, the commits can be reviewed individually, making each review chunk smaller
7272
- In case this PR introduced a bug that is identified later, it is possible to check if it resulted from the refactoring or the actual change, thereby making it easier find the lines that introduce the issue.
7373

74+
## Opening a PR
75+
76+
To submit a PR you don't need permissions on this repo, instead you can fork the repo and create a PR through your forked version.
77+
78+
For more information and instructions, read the GitHub docs on [forking a repo](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/fork-a-repo).
79+
80+
Once you've pushed your branch, you should see an option on this repository's page to create a PR from a branch in your fork.
81+
82+
## Opening a PR for Release Branch
83+
84+
In order for a pull request to be considered for inclusion in a release branch (e.g. `release/6.0`) after it has been cut, it must meet the following requirements:
85+
86+
1. The title of the PR should start with the tag `[{swift version number}]`. For example, `[6.0]` for the Swift 6.0 release branch.
87+
88+
1. The PR description must include the following information:
89+
90+
```md
91+
* **Explanation**: A description of the issue being fixed or enhancement being made. This can be brief, but it should be clear.
92+
* **Scope**: An assessment of the impact/importance of the change. For example, is the change a source-breaking language change, etc.
93+
* **Issue**: The GitHub Issue link if the change fixes/implements an issue/enhancement.
94+
* **Original PR**: Pull Request link from the `main` branch.
95+
* **Risk**: What is the (specific) risk to the release for taking this change?
96+
* **Testing**: What specific testing has been done or needs to be done to further validate any impact of this change?
97+
* **Reviewer**: One or more code owners for the impacted components should review the change. Technical review can be delegated by a code owner or otherwise requested as deemed appropriate or useful.
98+
```
99+
100+
> [!TIP]
101+
> The PR description can be generated using the [release_branch.md](https://github.com/apple/swift-syntax/blob/main/.github/PULL_REQUEST_TEMPLATE/release_branch.md) [pull request template](https://docs.github.com/en/communities/using-templates-to-encourage-useful-issues-and-pull-requests/about-issue-and-pull-request-templates). To use this template when creating a PR, you need to add the query parameter:
102+
> ```
103+
> ?expand=1&template=release_branch.md
104+
> ```
105+
> to the PR URL, as described in the [GitHub documentation on using query parameters to create a pull request](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/using-query-parameters-to-create-a-pull-request).
106+
> This is necessary because GitHub does not currently provide a UI to choose a PR template.
107+
108+
All changes going into a release branch must go through pull requests that are approved and merged by the corresponding release manager.
109+
74110
## Review and CI Testing
75111

76112
After you opened your PR, a maintainer will review it and test your changes in CI (*Continuous Integration*) by adding a `@swift-ci Please test` comment on the pull request. Once your PR is approved and CI has passed, the maintainer will merge your pull request.

CodeGeneration/README.md

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,8 @@ This directory contains file to generate source code that is part of the SwiftSy
44

55
Some source code inside SwiftSyntax is generated using [SwiftSyntaxBuilder](../Sources/SwiftSyntaxBuilder), a Swift library whose purpose is to generate Swift code using Swift itself. This kind of code generation is performed by the Swift package defined in this directory.
66

7-
To re-generate the files after changing `CodeGeneration` run the `generate-swift-syntax`
8-
target of `CodeGeneration` and pass `path/to/swift-syntax/Sources` as the argument.
7+
To re-generate the files after changing `CodeGeneration` run the following command on the command line.
98

10-
On the command line, this would be
119
```bash
12-
swift run --package-path CodeGeneration generate-swift-syntax Sources
10+
path/to/swift-syntax/swift-syntax-dev-utils generate-source-code
1311
```
14-
15-
Or if you open the `CodeGeneration` package in Xcode, you can add the
16-
`generate-swift syntax ../Sources` arguments using Product -> Scheme -> Edit Scheme…
17-

CodeGeneration/Sources/SyntaxSupport/DeclNodes.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,7 @@ public let DECL_NODES: [Node] = [
472472
.keyword(.transferring),
473473
.keyword(.unowned),
474474
.keyword(.weak),
475+
.keyword(.sending),
475476
])
476477
),
477478
Child(

CodeGeneration/Sources/SyntaxSupport/ExperimentalFeatures.swift

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ public enum ExperimentalFeature: String, CaseIterable {
1818
case doExpressions
1919
case nonescapableTypes
2020
case transferringArgsAndResults
21-
case borrowingSwitch
21+
case trailingComma
22+
case sendingArgsAndResults
2223

2324
/// The name of the feature, which is used in the doc comment.
2425
public var featureName: String {
@@ -33,8 +34,10 @@ public enum ExperimentalFeature: String, CaseIterable {
3334
return "NonEscableTypes"
3435
case .transferringArgsAndResults:
3536
return "TransferringArgsAndResults"
36-
case .borrowingSwitch:
37-
return "borrowing pattern matching"
37+
case .trailingComma:
38+
return "trailing comma"
39+
case .sendingArgsAndResults:
40+
return "SendingArgsAndResults"
3841
}
3942
}
4043

CodeGeneration/Sources/SyntaxSupport/KeywordSpec.swift

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ public struct KeywordSpec {
1919
/// The experimental feature the keyword is part of, or `nil` if this isn't
2020
/// for an experimental feature.
2121
public let experimentalFeature: ExperimentalFeature?
22-
public let experimentalFeature2: ExperimentalFeature?
2322

2423
/// Indicates if the token kind is switched from being an identifier to a keyword in the lexer.
2524
public let isLexerClassified: Bool
@@ -69,26 +68,6 @@ public struct KeywordSpec {
6968
) {
7069
self.name = name
7170
self.experimentalFeature = experimentalFeature
72-
self.experimentalFeature2 = nil
73-
self.isLexerClassified = isLexerClassified
74-
}
75-
76-
/// Initializes a new `KeywordSpec` instance.
77-
///
78-
/// - Parameters:
79-
/// - name: A name of the keyword.
80-
/// - experimentalFeature: The experimental feature the keyword is part of, or `nil` if this isn't for an experimental feature.
81-
/// - or: A second experimental feature the keyword is also part of, or `nil` if this isn't for an experimental feature.
82-
/// - isLexerClassified: Indicates if the token kind is switched from being an identifier to a keyword in the lexer.
83-
init(
84-
_ name: String,
85-
experimentalFeature: ExperimentalFeature,
86-
or experimentalFeature2: ExperimentalFeature,
87-
isLexerClassified: Bool = false
88-
) {
89-
self.name = name
90-
self.experimentalFeature = experimentalFeature
91-
self.experimentalFeature2 = experimentalFeature2
9271
self.isLexerClassified = isLexerClassified
9372
}
9473
}
@@ -284,6 +263,7 @@ public enum Keyword: CaseIterable {
284263
case safe
285264
case scoped
286265
case `self`
266+
case sending
287267
case `Self`
288268
case Sendable
289269
case set
@@ -340,7 +320,7 @@ public enum Keyword: CaseIterable {
340320
case ._borrow:
341321
return KeywordSpec("_borrow")
342322
case ._borrowing:
343-
return KeywordSpec("_borrowing", experimentalFeature: .referenceBindings, or: .borrowingSwitch)
323+
return KeywordSpec("_borrowing")
344324
case ._BridgeObject:
345325
return KeywordSpec("_BridgeObject")
346326
case ._cdecl:
@@ -722,6 +702,11 @@ public enum Keyword: CaseIterable {
722702
"transferring",
723703
experimentalFeature: .transferringArgsAndResults
724704
)
705+
case .sending:
706+
return KeywordSpec(
707+
"sending",
708+
experimentalFeature: .sendingArgsAndResults
709+
)
725710
case .transpose:
726711
return KeywordSpec("transpose")
727712
case .true:

CodeGeneration/Sources/SyntaxSupport/PatternNodes.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ public let PATTERN_NODES: [Node] = [
201201
kind: .token(choices: [
202202
.keyword(.let), .keyword(.var), .keyword(.inout),
203203
.keyword(._mutating), .keyword(._borrowing), .keyword(._consuming),
204+
.keyword(.borrowing),
204205
])
205206
),
206207
Child(

CodeGeneration/Sources/SyntaxSupport/String+Extensions.swift

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

13-
public extension StringProtocol {
14-
var withFirstCharacterLowercased: String {
13+
extension StringProtocol {
14+
public var withFirstCharacterLowercased: String {
1515
guard first?.isLetter ?? false else {
1616
return String(first!) + dropFirst().withFirstCharacterLowercased
1717
}
1818
return prefix(1).lowercased() + dropFirst()
1919
}
20-
var withFirstCharacterUppercased: String {
20+
public var withFirstCharacterUppercased: String {
2121
guard first?.isLetter ?? false else {
2222
return String(first!) + dropFirst().withFirstCharacterUppercased
2323
}
2424
return prefix(1).uppercased() + dropFirst()
2525
}
26-
var backtickedIfNeeded: String {
26+
public var backtickedIfNeeded: String {
2727
if Keyword.allCases.map(\.spec).contains(where: {
2828
$0.name == self && ($0.isLexerClassified || $0.name == "Type" || $0.name == "Protocol")
2929
}) {

0 commit comments

Comments
 (0)