Skip to content
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

Release 2.21.1 #824

Closed
wants to merge 5 commits into from
Closed
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
16 changes: 15 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,23 @@

##### Bug Fixes

- None.

## 2.21.1 (2024-09-28)

##### Breaking

- None.

##### Enhancements

- None.

##### Bug Fixes

- Enums with the `@main` attribute are now retained.
- Unused public/exported imports are excluded from the results even if unused in the declaring file as the exported symbols may be referenced in other files, and thus removing the import would result in a build failure.
- Fixed issue in Swift 6 where declarations that override external type members are incorrectly identified as unused.
- Unused public/exported imports are excluded from the results even if unused in the declaring file as the exported symbols may be referenced in other files, and thus removing the import would result in a build failure.

## 2.21.0 (2024-06-15)

Expand Down
2 changes: 1 addition & 1 deletion Sources/Frontend/Version.swift
Original file line number Diff line number Diff line change
@@ -1 +1 @@
let PeripheryVersion = "3.0.0.beta4"
let PeripheryVersion = "2.21.1"
39 changes: 39 additions & 0 deletions Sources/PeripheryKit/Syntax/ImportSyntaxVisitor.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import Foundation
import SwiftSyntax

struct ImportStatement {
let module: String
let isTestable: Bool
let isExported: Bool
let location: SourceLocation
}

final class ImportSyntaxVisitor: PeripherySyntaxVisitor {
var importStatements: [ImportStatement] = []

private let sourceLocationBuilder: SourceLocationBuilder

init(sourceLocationBuilder: SourceLocationBuilder) {
self.sourceLocationBuilder = sourceLocationBuilder
}

func visit(_ node: ImportDeclSyntax) {
let parts = node.path.map { $0.name.text }
let module = parts.first ?? ""
let attributes = node.attributes.compactMap {
if case let .attribute(attr) = $0 {
attr.attributeName.trimmedDescription
} else {
nil
}
}
let location = sourceLocationBuilder.location(at: node.positionAfterSkippingLeadingTrivia)
let statement = ImportStatement(
module: module,
isTestable: attributes.contains("testable"),
isExported: attributes.contains("_exported") || node.modifiers.contains { $0.name.text == "public" },
location: location
)
importStatements.append(statement)
}
}
5 changes: 2 additions & 3 deletions Sources/SourceGraph/Mutators/ExternalOverrideRetainer.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import Configuration
import Foundation
import Shared

Expand All @@ -10,9 +9,9 @@ final class ExternalOverrideRetainer: SourceGraphMutator {
private let graph: SourceGraph
private let isSwift6FixEnabled: Bool

required init(graph: SourceGraph, configuration _: Configuration, swiftVersion: SwiftVersion) {
required init(graph: SourceGraph, configuration _: Configuration) {
self.graph = graph
isSwift6FixEnabled = swiftVersion.version.isVersion(greaterThanOrEqualTo: "6.0")
isSwift6FixEnabled = SwiftVersion.current.version.isVersion(greaterThanOrEqualTo: "6.0")
}

func mutate() {
Expand Down
Loading