Skip to content

Commit

Permalink
Drop support for Swift 5.7 (#623)
Browse files Browse the repository at this point in the history
  • Loading branch information
ileitch authored Jun 25, 2023
1 parent 8647b02 commit 20ac46c
Show file tree
Hide file tree
Showing 8 changed files with 8 additions and 104 deletions.
11 changes: 2 additions & 9 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,10 @@ jobs:
strategy:
fail-fast: false
matrix:
xcode: ["14.3", "14.2", "14.1"]
xcode: ["14.3"]
include:
- xcode: "14.3"
macos: macOS-13
- xcode: "14.2"
macos: macOS-12
- xcode: "14.1"
macos: macOS-12
runs-on: ${{ matrix.macos }}
name: macOS
steps:
Expand Down Expand Up @@ -57,14 +53,11 @@ jobs:
strategy:
fail-fast: false
matrix:
swift: ["5.8", "5.7"]
swift: ["5.8"]
include:
- swift: "5.8"
container: "swift:5.8"
cache-version: 1
- swift: "5.7"
container: "swift:5.7"
cache-version: 1
runs-on: ubuntu-20.04
container: ${{ matrix.container }}
name: Linux
Expand Down
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

##### Breaking

- None.
- Swift 5.7 is no longer supported.

##### Enhancements

Expand Down
4 changes: 2 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version:5.5
// swift-tools-version:5.8
import PackageDescription

var dependencies: [Package.Dependency] = [
Expand All @@ -7,7 +7,7 @@ var dependencies: [Package.Dependency] = [
.package(url: "https://github.com/tadija/AEXML", from: "4.0.0"),
.package(url: "https://github.com/apple/swift-argument-parser", from: "1.0.0"),
.package(url: "https://github.com/ileitch/swift-indexstore", from: "9.0.0"),
.package(url: "https://github.com/peripheryapp/swift-syntax", .exact("1.0.2")),
.package(url: "https://github.com/peripheryapp/swift-syntax", exact: "1.0.2"),
.package(url: "https://github.com/ileitch/swift-filename-matcher", from: "0.0.0"),
]

Expand Down
13 changes: 2 additions & 11 deletions Sources/PeripheryKit/Indexer/SwiftIndexer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ public final class SwiftIndexer: Indexer {
private let configuration: Configuration
private let indexStorePaths: [FilePath]

private lazy var letShorthandWorkaroundEnabled: Bool = {
SwiftVersion.current.version.isVersion(lessThan: "5.8")
}()

public required init(
sourceFiles: [FilePath: Set<String>],
graph: SourceGraph,
Expand Down Expand Up @@ -88,8 +84,7 @@ public final class SwiftIndexer: Indexer {
units: units,
graph: graph,
logger: logger,
configuration: configuration,
letShorthandWorkaroundEnabled: letShorthandWorkaroundEnabled
configuration: configuration
)
}

Expand Down Expand Up @@ -129,23 +124,20 @@ public final class SwiftIndexer: Indexer {
private let graph: SourceGraph
private let logger: ContextualLogger
private let configuration: Configuration
private let letShorthandWorkaroundEnabled: Bool

required init(
file: SourceFile,
units: [(IndexStore, IndexStoreUnit)],
graph: SourceGraph,
logger: ContextualLogger,
configuration: Configuration,
letShorthandWorkaroundEnabled: Bool
configuration: Configuration

) {
self.file = file
self.units = units
self.graph = graph
self.logger = logger
self.configuration = configuration
self.letShorthandWorkaroundEnabled = letShorthandWorkaroundEnabled
}

struct RawRelation {
Expand Down Expand Up @@ -248,7 +240,6 @@ public final class SwiftIndexer: Indexer {
func phaseTwo() throws {
let multiplexingSyntaxVisitor = try MultiplexingSyntaxVisitor(file: file)
let declarationSyntaxVisitor = multiplexingSyntaxVisitor.add(DeclarationSyntaxVisitor.self)
declarationSyntaxVisitor.letShorthandWorkaroundEnabled = letShorthandWorkaroundEnabled
let importSyntaxVisitor = multiplexingSyntaxVisitor.add(ImportSyntaxVisitor.self)

multiplexingSyntaxVisitor.visit()
Expand Down
27 changes: 0 additions & 27 deletions Sources/PeripheryKit/SourceGraph/Mutators/MainActorRetainer.swift

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ public final class SourceGraphMutatorRunner {
StringInterpolationAppendInterpolationRetainer.self,
PropertyWrapperRetainer.self,
ResultBuilderRetainer.self,
MainActorRetainer.self,
CapitalSelfFunctionCallRetainer.self,

PlainExtensionEliminator.self,
Expand Down
2 changes: 1 addition & 1 deletion Sources/PeripheryKit/SwiftVersion.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Shared
public struct SwiftVersion {
public static let current = SwiftVersion()

static let minimumVersion = "5.6"
static let minimumVersion = "5.8"

public let version: VersionString
public let fullVersion: String
Expand Down
52 changes: 0 additions & 52 deletions Sources/PeripheryKit/Syntax/DeclarationSyntaxVisitor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,10 @@ final class DeclarationSyntaxVisitor: PeripherySyntaxVisitor {
hasGenericFunctionReturnedMetatypeParameters: Bool
)

var letShorthandWorkaroundEnabled: Bool = false

private let sourceLocationBuilder: SourceLocationBuilder
private let typeSyntaxInspector: TypeSyntaxInspector
private(set) var results: [Result] = []
private var letShorthandIdentifiers: Set<String> = []
private var didVisitCapitalSelfFunctionCall: Bool = false
private var declarationBodyStackDepth = 0

var resultsByLocation: [SourceLocation: Result] {
results.reduce(into: [SourceLocation: Result]()) { (dict, result) in
Expand Down Expand Up @@ -121,13 +117,7 @@ final class DeclarationSyntaxVisitor: PeripherySyntaxVisitor {
)
}

func visit(_: FunctionDeclSyntax) {
declarationBodyStackDepth += 1
}

func visitPost(_ node: FunctionDeclSyntax) {
declarationBodyStackDepth -= 1

parse(
modifiers: node.modifiers,
attributes: node.attributes,
Expand All @@ -140,13 +130,7 @@ final class DeclarationSyntaxVisitor: PeripherySyntaxVisitor {
)
}

func visit(_: InitializerDeclSyntax) {
declarationBodyStackDepth += 1
}

func visitPost(_ node: InitializerDeclSyntax) {
declarationBodyStackDepth -= 1

parse(
modifiers: node.modifiers,
attributes: node.attributes,
Expand All @@ -158,13 +142,7 @@ final class DeclarationSyntaxVisitor: PeripherySyntaxVisitor {
)
}

func visit(_: DeinitializerDeclSyntax) {
declarationBodyStackDepth += 1
}

func visitPost(_ node: DeinitializerDeclSyntax) {
declarationBodyStackDepth -= 1

parse(
modifiers: node.modifiers,
attributes: node.attributes,
Expand All @@ -173,13 +151,7 @@ final class DeclarationSyntaxVisitor: PeripherySyntaxVisitor {
)
}

func visit(_: SubscriptDeclSyntax) {
declarationBodyStackDepth += 1
}

func visitPost(_ node: SubscriptDeclSyntax) {
declarationBodyStackDepth -= 1

parse(
modifiers: node.modifiers,
attributes: node.attributes,
Expand All @@ -192,13 +164,7 @@ final class DeclarationSyntaxVisitor: PeripherySyntaxVisitor {
)
}

func visit(_: VariableDeclSyntax) {
declarationBodyStackDepth += 1
}

func visitPost(_ node: VariableDeclSyntax) {
declarationBodyStackDepth -= 1

for binding in node.bindings {
if binding.pattern.is(IdentifierPatternSyntax.self) {
let closureSignature = binding.initializer?.value.as(ClosureExprSyntax.self)?.signature
Expand Down Expand Up @@ -299,17 +265,6 @@ final class DeclarationSyntaxVisitor: PeripherySyntaxVisitor {
)
}

func visit(_ node: OptionalBindingConditionSyntax) {
guard letShorthandWorkaroundEnabled else { return }

guard node.initializer == nil,
let identifier = node.pattern.as(IdentifierPatternSyntax.self)?.identifier,
let parentStmt = node.parent?.parent?.parent,
(parentStmt.is(IfExprSyntax.self) || parentStmt.is(GuardStmtSyntax.self))
else { return }
letShorthandIdentifiers.insert(identifier.text)
}

func visit(_ node: FunctionCallExprSyntax) {
if let identifierExpr = node.calledExpression.as(IdentifierExprSyntax.self),
identifierExpr.identifier.tokenKind == .keyword(.Self) {
Expand Down Expand Up @@ -343,13 +298,6 @@ final class DeclarationSyntaxVisitor: PeripherySyntaxVisitor {
let location = sourceLocationBuilder.location(at: position)
var letShorthandIdentifiers = Set<String>()

// Only associate let shorthand identifiers in nested code blocks with the top-most
// code block.
if declarationBodyStackDepth == 0 {
letShorthandIdentifiers = self.letShorthandIdentifiers
self.letShorthandIdentifiers.removeAll()
}

var didVisitCapitalSelfFunctionCall = false
if consumeCapitalSelfFunctionCalls {
didVisitCapitalSelfFunctionCall = self.didVisitCapitalSelfFunctionCall
Expand Down

0 comments on commit 20ac46c

Please sign in to comment.