Skip to content

Revert "[5.9 🍒] Add support for various new 5.9 features." #628

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ extension DeclModifierListSyntax {
var accessLevelModifier: DeclModifierSyntax? {
for modifier in self {
switch modifier.name.tokenKind {
case .keyword(.public), .keyword(.private), .keyword(.fileprivate), .keyword(.internal),
.keyword(.package):
case .keyword(.public), .keyword(.private), .keyword(.fileprivate), .keyword(.internal):
return modifier
default:
continue
Expand Down
44 changes: 0 additions & 44 deletions Sources/SwiftFormat/PrettyPrint/TokenStreamCreator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2293,7 +2293,6 @@ fileprivate final class TokenStreamCreator: SyntaxVisitor {

override func visit(_ node: GenericParameterSyntax) -> SyntaxVisitorContinueKind {
before(node.firstToken(viewMode: .sourceAccurate), tokens: .open)
after(node.eachKeyword, tokens: .break)
after(node.colon, tokens: .break)
if let trailingComma = node.trailingComma {
after(trailingComma, tokens: .close, .break(.same))
Expand All @@ -2313,28 +2312,6 @@ fileprivate final class TokenStreamCreator: SyntaxVisitor {
return .visitChildren
}

override func visit(_ node: PackElementExprSyntax) -> SyntaxVisitorContinueKind {
// `each` cannot be separated from the following token, or it is parsed as an identifier itself.
after(node.eachKeyword, tokens: .space)
return .visitChildren
}

override func visit(_ node: PackElementTypeSyntax) -> SyntaxVisitorContinueKind {
// `each` cannot be separated from the following token, or it is parsed as an identifier itself.
after(node.eachKeyword, tokens: .space)
return .visitChildren
}

override func visit(_ node: PackExpansionExprSyntax) -> SyntaxVisitorContinueKind {
after(node.repeatKeyword, tokens: .break)
return .visitChildren
}

override func visit(_ node: PackExpansionTypeSyntax) -> SyntaxVisitorContinueKind {
after(node.repeatKeyword, tokens: .break)
return .visitChildren
}

override func visit(_ node: ExpressionPatternSyntax) -> SyntaxVisitorContinueKind {
return .visitChildren
}
Expand Down Expand Up @@ -2504,27 +2481,6 @@ fileprivate final class TokenStreamCreator: SyntaxVisitor {
return .visitChildren
}

override func visit(_ node: ConsumeExprSyntax) -> SyntaxVisitorContinueKind {
// The `consume` keyword cannot be separated from the following token or it will be parsed as
// an identifier.
after(node.consumeKeyword, tokens: .space)
return .visitChildren
}

override func visit(_ node: CopyExprSyntax) -> SyntaxVisitorContinueKind {
// The `copy` keyword cannot be separated from the following token or it will be parsed as an
// identifier.
after(node.copyKeyword, tokens: .space)
return .visitChildren
}

override func visit(_ node: DiscardStmtSyntax) -> SyntaxVisitorContinueKind {
// The `discard` keyword cannot be separated from the following token or it will be parsed as
// an identifier.
after(node.discardKeyword, tokens: .space)
return .visitChildren
}

override func visit(_ node: InheritanceClauseSyntax) -> SyntaxVisitorContinueKind {
// Normally, the open-break is placed before the open token. In this case, it's intentionally
// ordered differently so that the inheritance list can start on the current line and only
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,8 @@ public final class AlwaysUseLiteralForEmptyCollectionInit : SyntaxFormatRule {
}

private func getLiteralType(_ arrayLiteral: ArrayExprSyntax) -> TypeSyntax? {
guard arrayLiteral.elements.count == 1 else {
guard let elementExpr = arrayLiteral.elements.firstAndOnly,
elementExpr.is(ArrayElementSyntax.self) else {
return nil
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ public final class NoAccessLevelOnExtensionDeclaration: SyntaxFormatRule {
var result = node

switch keyword {
// Public, private, fileprivate, or package keywords need to be moved to members
case .public, .private, .fileprivate, .package:
// Public, private, or fileprivate keywords need to be moved to members
case .public, .private, .fileprivate:
// The effective access level of the members of a `private` extension is `fileprivate`, so
// we have to update the keyword to ensure that the result is correct.
var accessKeywordToAdd = accessKeyword
Expand Down
14 changes: 0 additions & 14 deletions Tests/SwiftFormatTests/PrettyPrint/ConsumeExprTests.swift

This file was deleted.

14 changes: 0 additions & 14 deletions Tests/SwiftFormatTests/PrettyPrint/CopyExprSyntax.swift

This file was deleted.

13 changes: 0 additions & 13 deletions Tests/SwiftFormatTests/PrettyPrint/DiscardStmtTests.swift

This file was deleted.

46 changes: 0 additions & 46 deletions Tests/SwiftFormatTests/PrettyPrint/ParameterPackTests.swift

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -128,31 +128,6 @@ final class NoAccessLevelOnExtensionDeclarationTests: LintOrFormatRuleTestCase {
)
}

func testPackageAccessLevel() {
assertFormatting(
NoAccessLevelOnExtensionDeclaration.self,
input: """
1️⃣package extension Foo {
2️⃣func f() {}
}
""",
expected: """
extension Foo {
package func f() {}
}
""",
findings: [
FindingSpec(
"1️⃣",
message: "move this 'package' access modifier to precede each member inside this extension",
notes: [
NoteSpec("2️⃣", message: "add 'package' access modifier to this declaration"),
]
),
]
)
}

func testPrivateIsEffectivelyFileprivate() {
assertFormatting(
NoAccessLevelOnExtensionDeclaration.self,
Expand Down