Skip to content

Commit 2a77692

Browse files
committed
Removed TODOs in testRecovery102/103/104
1 parent 06720d7 commit 2a77692

File tree

171 files changed

+13527
-11931
lines changed

Some content is hidden

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

171 files changed

+13527
-11931
lines changed

BUILD.bazel

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ load("//utils/bazel:swift_syntax_library.bzl", "swift_syntax_library")
33
package(default_visibility = ["//visibility:public"])
44

55
swift_syntax_library(
6-
name = "IDEUtils",
6+
name = "SwiftIDEUtils",
77
deps = [
88
":SwiftSyntax",
99
],
@@ -95,14 +95,6 @@ swift_syntax_library(
9595
],
9696
)
9797

98-
swift_syntax_library(
99-
name = "SwiftSyntaxParser",
100-
deps = [
101-
":SwiftParser",
102-
":SwiftSyntax",
103-
],
104-
)
105-
10698
swift_syntax_library(
10799
name = "SwiftRefactor",
108100
deps = [

CONTRIBUTING.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Alternatively you can also build it from the command line using `build-script.py
1414
- (enclosing directory)
1515
- swift-argument-parser
1616
- swift-syntax
17+
```
1718
2. Execute the following command
1819
```bash
1920
swift-syntax/build-script.py build --toolchain /Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-<recent date>.xctoolchain/usr
@@ -43,11 +44,7 @@ If you can’t find it in your Schemes, you need to manually add it using Produc
4344
4445
### XCTests
4546
46-
The `SwiftSyntaxParser` module (the legacy parser) of this repository depends on the C++ parser library (`_InternalSwiftSyntaxParser.dylib`) to parse source code.
47-
The syntax node definitions of that parser library need to match those used by your SwiftSyntax checkout.
48-
Most of the time, the parser library included in the latest Swift Development Snapshot will fulfill this requirement.
49-
50-
To run the tests in Xcode, select the latest Swift Development Snapshot in Xcode -> Toolchains, select the SwiftSyntax-Package scheme and hit Product -> Test.
47+
To run the tests in Xcode, select the SwiftSyntax-Package scheme and hit Product -> Test.
5148
5249
You can also run the tests from the command line using
5350
```bash
@@ -66,15 +63,15 @@ Tip: Running SwiftSyntax’s self-parse tests takes the majority of testing time
6663
2. Select the Arguments tab in the Run section
6764
3. Add a `SKIP_LONG_TESTS` environment variable with value `1`
6865

69-
### `lit`-based tests
66+
### `lit`-based Tests
7067

71-
A few tests of the `SwiftSyntaxParser` module (the legacy parser), which test the interaction between SwiftSyntax and the C++ parser library (`_InternalSwiftSyntaxParser.dylib`) are based LLVM’s `lit` and `FileCheck` tools.
68+
A few tests are based LLVM’s `lit` and `FileCheck` tools.
7269
To run these, build `FileCheck`, e.g. by building the Swift compiler and run the tests using the following command:
7370
```bash
7471
./build-script.py test --toolchain /Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-<recent date>.xctoolchain/usr --skip-lit-tests --filecheck-exec /path/to/build/Release+Asserts/llvm-macosx-x86_64/bin/FileCheck
7572
```
7673

77-
## Generating source code
74+
## Generating Source Code
7875

7976
If you want to modify the code-generated files, perform the following steps:
8077

@@ -90,3 +87,7 @@ If you want to modify the code-generated files, perform the following steps:
9087
swift-syntax/build-script.py generate-source-code --toolchain /Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-<recent date>.xctoolchain/usr
9188
```
9289
3. The new source-generated file will be written into your `Sources` directory.
90+
91+
## Swift Version
92+
93+
We require that SwiftSyntax builds with the latest released compiler and the previous major version (e.g. with Swift 5.8 and Swift 5.7).

CodeGeneration/Package.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ let package = Package(
1111
.executable(name: "generate-swiftsyntax", targets: ["generate-swiftsyntax"])
1212
],
1313
dependencies: [
14-
.package(url: "https://github.com/apple/swift-syntax.git", revision: "39b3336c3f3bfcd4ddbcbf6a111d8814ffe542f3"),
15-
.package(url: "https://github.com/apple/swift-argument-parser.git", .upToNextMinor(from: "1.2.2")),
14+
.package(url: "https://github.com/apple/swift-syntax.git", revision: "c7087adb193b26f02b59d21cd06d17ec202d1bf5"),
15+
.package(url: "https://github.com/apple/swift-argument-parser.git", from: "1.2.2"),
1616
],
1717
targets: [
1818
.executableTarget(

CodeGeneration/Sources/SyntaxSupport/AttributeNodes.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ public let ATTRIBUTE_NODES: [Node] = [
388388
children: [
389389
Child(
390390
name: "Parameter",
391-
kind: .token(choices: [.token(tokenKind: "IdentifierToken"), .token(tokenKind: "IntegerLiteralToken"), .token(tokenKind: "KeywordToken")])
391+
kind: .token(choices: [.token(tokenKind: "IdentifierToken"), .token(tokenKind: "IntegerLiteralToken"), .keyword(text: "self")])
392392
),
393393
Child(
394394
name: "TrailingComma",
@@ -518,7 +518,7 @@ public let ATTRIBUTE_NODES: [Node] = [
518518
kind: .nodeChoices(choices: [
519519
Child(
520520
name: "Token",
521-
kind: .token(choices: [.token(tokenKind: "IdentifierToken"), .token(tokenKind: "KeywordToken")])
521+
kind: .token(choices: [.token(tokenKind: "IdentifierToken"), .keyword(text: "private"), .keyword(text: "fileprivate"), .keyword(text: "internal"), .keyword(text: "public"), .keyword(text: "open")])
522522
), // Keywords can be: public, internal, private, fileprivate, open
523523
Child(
524524
name: "String",

CodeGeneration/Sources/SyntaxSupport/CommonNodes.swift

Lines changed: 71 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ public let COMMON_NODES: [Node] = [
1616
name: "CodeBlockItemList",
1717
nameForDiagnostics: nil,
1818
kind: "SyntaxCollection",
19-
element: "CodeBlockItem",
20-
elementsSeparatedByNewline: true
19+
element: "CodeBlockItem"
2120
),
2221

2322
// code-block-item = (decl | stmt | expr) ';'?
@@ -144,6 +143,7 @@ public let COMMON_NODES: [Node] = [
144143
Node(
145144
name: "MissingDecl",
146145
nameForDiagnostics: "declaration",
146+
description: "In case the source code is missing a declaration, this node stands in place of the missing declaration.",
147147
kind: "Decl",
148148
traits: [
149149
"Attributed"
@@ -152,44 +152,108 @@ public let COMMON_NODES: [Node] = [
152152
Child(
153153
name: "Attributes",
154154
kind: .collection(kind: "AttributeList", collectionElementName: "Attribute"),
155+
description: "If there were standalone attributes without a declaration to attach them to, the `MissingDeclSyntax` will contain these.",
155156
isOptional: true
156157
),
157158
Child(
158159
name: "Modifiers",
159160
kind: .collection(kind: "ModifierList", collectionElementName: "Modifier"),
161+
description: "If there were standalone modifiers without a declaration to attach them to, the `MissingDeclSyntax` will contain these.",
160162
isOptional: true
161163
),
164+
Child(
165+
name: "Placeholder",
166+
kind: .token(choices: [.token(tokenKind: "IdentifierToken")], requiresLeadingSpace: false, requiresTrailingSpace: false),
167+
description: """
168+
A placeholder, i.e. `<#decl#>` that can be inserted into the source code to represent the missing declaration.
169+
This token should always have `presence = .missing`.
170+
"""
171+
),
162172
]
163173
),
164174

165175
Node(
166176
name: "MissingExpr",
167177
nameForDiagnostics: "expression",
168-
kind: "Expr"
178+
description: "In case the source code is missing a expression, this node stands in place of the missing expression.",
179+
kind: "Expr",
180+
children: [
181+
Child(
182+
name: "Placeholder",
183+
kind: .token(choices: [.token(tokenKind: "IdentifierToken")], requiresLeadingSpace: false, requiresTrailingSpace: false),
184+
description: """
185+
A placeholder, i.e. `<#expression#>` that can be inserted into the source code to represent the missing expression.
186+
This token should always have `presence = .missing`.
187+
"""
188+
)
189+
]
169190
),
170191

171192
Node(
172193
name: "MissingPattern",
173194
nameForDiagnostics: "pattern",
174-
kind: "Pattern"
195+
description: "In case the source code is missing a pattern, this node stands in place of the missing pattern.",
196+
kind: "Pattern",
197+
children: [
198+
Child(
199+
name: "Placeholder",
200+
kind: .token(choices: [.token(tokenKind: "IdentifierToken")], requiresLeadingSpace: false, requiresTrailingSpace: false),
201+
description: """
202+
A placeholder, i.e. `<#pattern#>` that can be inserted into the source code to represent the missing pattern.
203+
This token should always have `presence = .missing`.
204+
"""
205+
)
206+
]
175207
),
176208

177209
Node(
178210
name: "MissingStmt",
179211
nameForDiagnostics: "statement",
180-
kind: "Stmt"
212+
description: "In case the source code is missing a statement, this node stands in place of the missing statement.",
213+
kind: "Stmt",
214+
children: [
215+
Child(
216+
name: "Placeholder",
217+
kind: .token(choices: [.token(tokenKind: "IdentifierToken")], requiresLeadingSpace: false, requiresTrailingSpace: false),
218+
description: """
219+
A placeholder, i.e. `<#statement#>` that can be inserted into the source code to represent the missing pattern.
220+
This token should always have `presence = .missing`.
221+
"""
222+
)
223+
]
181224
),
182225

183226
Node(
184227
name: "Missing",
185228
nameForDiagnostics: nil,
186-
kind: "Syntax"
229+
description: "In case the source code is missing a syntax node, this node stands in place of the missing node.",
230+
kind: "Syntax",
231+
children: [
232+
Child(
233+
name: "Placeholder",
234+
kind: .token(choices: [.token(tokenKind: "IdentifierToken")], requiresLeadingSpace: false, requiresTrailingSpace: false),
235+
description: """
236+
A placeholder, i.e. `<#syntax#>` that can be inserted into the source code to represent the missing pattern.
237+
This token should always have `presence = .missing`
238+
"""
239+
)
240+
]
187241
),
188242

189243
Node(
190244
name: "MissingType",
191245
nameForDiagnostics: "type",
192-
kind: "Type"
246+
description: "In case the source code is missing a type, this node stands in place of the missing type.",
247+
kind: "Type",
248+
children: [
249+
Child(
250+
name: "Placeholder",
251+
kind: .token(choices: [.token(tokenKind: "IdentifierToken")], requiresLeadingSpace: false, requiresTrailingSpace: false),
252+
description: """
253+
A placeholder, i.e. `<#type#>` that can be inserted into the source code to represent the missing type. This token should always have `presence = .missing`.
254+
"""
255+
)
256+
]
193257
),
194258

195259
Node(

CodeGeneration/Sources/SyntaxSupport/DeclNodes.swift

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,7 @@ public let DECL_NODES: [Node] = [
111111
name: "AccessorList",
112112
nameForDiagnostics: nil,
113113
kind: "SyntaxCollection",
114-
element: "AccessorDecl",
115-
elementsSeparatedByNewline: true
114+
element: "AccessorDecl"
116115
),
117116

118117
// (value)
@@ -1029,14 +1028,6 @@ public let DECL_NODES: [Node] = [
10291028
"WithTrailingComma"
10301029
],
10311030
children: [
1032-
/// Indicates whether the 'without' operator was applied to the type to
1033-
/// indicate the suppression of implicit conformance to this type.
1034-
/// This child stores the token representing the 'without' operator.
1035-
Child(
1036-
name: "HasWithout",
1037-
kind: .token(choices: [.token(tokenKind: "PrefixOperatorToken")]),
1038-
isOptional: true
1039-
),
10401031
Child(
10411032
name: "TypeName",
10421033
kind: .node(kind: "Type")
@@ -1296,8 +1287,7 @@ public let DECL_NODES: [Node] = [
12961287
name: "MemberDeclList",
12971288
nameForDiagnostics: nil,
12981289
kind: "SyntaxCollection",
1299-
element: "MemberDeclListItem",
1300-
elementsSeparatedByNewline: true
1290+
element: "MemberDeclListItem"
13011291
),
13021292

13031293
// declaration-modifier -> access-level-modifier

CodeGeneration/Sources/SyntaxSupport/ExprNodes.swift

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -781,7 +781,7 @@ public let EXPR_NODES: [Node] = [
781781
children: [
782782
Child(
783783
name: "Identifier",
784-
kind: .token(choices: [.token(tokenKind: "IdentifierToken"), .token(tokenKind: "KeywordToken"), .token(tokenKind: "DollarIdentifierToken"), .token(tokenKind: "BinaryOperatorToken")])
784+
kind: .token(choices: [.token(tokenKind: "IdentifierToken"), .keyword(text: "self"), .keyword(text: "Self"), .keyword(text: "init"), .token(tokenKind: "DollarIdentifierToken"), .token(tokenKind: "BinaryOperatorToken")])
785785
),
786786
Child(
787787
name: "DeclNameArguments",
@@ -1005,7 +1005,7 @@ public let EXPR_NODES: [Node] = [
10051005
children: [
10061006
Child(
10071007
name: "Identifier",
1008-
kind: .token(choices: [.token(tokenKind: "IdentifierToken"), .token(tokenKind: "KeywordToken"), .token(tokenKind: "DollarIdentifierToken"), .token(tokenKind: "BinaryOperatorToken"), .token(tokenKind: "IntegerLiteralToken")])
1008+
kind: .token(choices: [.token(tokenKind: "IdentifierToken"), .keyword(text: "self"), .keyword(text: "Self"), .keyword(text: "init"), .token(tokenKind: "DollarIdentifierToken"), .token(tokenKind: "BinaryOperatorToken"), .token(tokenKind: "IntegerLiteralToken")])
10091009
),
10101010
Child(
10111011
name: "DeclNameArguments",
@@ -1481,8 +1481,7 @@ public let EXPR_NODES: [Node] = [
14811481
kind: "SyntaxCollection",
14821482
element: "Syntax",
14831483
elementName: "SwitchCase",
1484-
elementChoices: ["SwitchCase", "IfConfigDecl"],
1485-
elementsSeparatedByNewline: true
1484+
elementChoices: ["SwitchCase", "IfConfigDecl"]
14861485
),
14871486

14881487
// switch-case -> unknown-attr? switch-case-label stmt-list

CodeGeneration/Sources/SyntaxSupport/Node.swift

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ public class Node {
3030
public let collectionElementName: String?
3131
public let collectionElementChoices: [String]?
3232
public let omitWhenEmpty: Bool
33-
public let elementsSeparatedByNewline: Bool
3433
public let collectionElement: String
3534

3635
/// Returns `true` if this node declares one of the base syntax kinds.
@@ -98,8 +97,7 @@ public class Node {
9897
element: String = "",
9998
elementName: String? = nil,
10099
elementChoices: [String]? = nil,
101-
omitWhenEmpty: Bool = false,
102-
elementsSeparatedByNewline: Bool = false
100+
omitWhenEmpty: Bool = false
103101
) {
104102
self.syntaxKind = name
105103
self.swiftSyntaxKind = lowercaseFirstWord(name: name)
@@ -159,7 +157,6 @@ public class Node {
159157
// from its supertype, use that.
160158
self.collectionElementName = elementName ?? self.collectionElement
161159
self.collectionElementChoices = elementChoices ?? []
162-
self.elementsSeparatedByNewline = elementsSeparatedByNewline
163160

164161
// For SyntaxCollections make sure that the elementName is set.
165162
precondition(!isSyntaxCollection || elementName != nil || element != "")

CodeGeneration/Sources/SyntaxSupport/PatternNodes.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public let PATTERN_NODES: [Node] = [
3131
children: [
3232
Child(
3333
name: "Identifier",
34-
kind: .token(choices: [.token(tokenKind: "IdentifierToken"), .token(tokenKind: "KeywordToken")])
34+
kind: .token(choices: [.token(tokenKind: "IdentifierToken"), .keyword(text: "self"), .keyword(text: "init")])
3535
)
3636
]
3737
),

CodeGeneration/Sources/SyntaxSupport/Traits.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@ public let TRAITS: [Trait] = [
4848
traitName: "EffectSpecifiers",
4949
children: [
5050
Child(name: "UnexpectedBeforeAsyncSpecifier", kind: .node(kind: "UnexpectedNodes"), isOptional: true),
51-
Child(name: "AsyncSpecifier", kind: .token(choices: [.token(tokenKind: "KeywordToken")]), isOptional: true),
51+
Child(name: "AsyncSpecifier", kind: .token(choices: [.keyword(text: "async"), .keyword(text: "reasync")]), isOptional: true),
5252
Child(name: "UnexpectedBetweenAsyncSpecifierAndThrowsSpecifier", kind: .node(kind: "UnexpectedNodes"), isOptional: true),
53-
Child(name: "ThrowsSpecifier", kind: .token(choices: [.token(tokenKind: "KeywordToken")]), isOptional: true),
53+
Child(name: "ThrowsSpecifier", kind: .token(choices: [.keyword(text: "throws"), .keyword(text: "rethrows")]), isOptional: true),
5454
Child(name: "UnexpectedAfterThrowsSpecifier", kind: .node(kind: "UnexpectedNodes"), isOptional: true),
5555
]
5656
),

0 commit comments

Comments
 (0)