Skip to content

[SwiftRefactor] PackageManifest: Make a couple of properties external… #3139

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
24 changes: 0 additions & 24 deletions Sources/SwiftRefactor/PackageManifest/AddPackageTarget.swift
Original file line number Diff line number Diff line change
Expand Up @@ -295,18 +295,6 @@ public struct AddPackageTarget: ManifestEditRefactoringProvider {
}
}

fileprivate extension PackageTarget.Dependency {
/// Retrieve the name of the dependency
var name: String {
switch self {
case .target(let name),
.byName(let name),
.product(let name, package: _):
return name
}
}
}

/// The array of auxiliary files that can be added by a package editing
/// operation.
private typealias AuxiliaryFiles = [(String, SourceFileSyntax)]
Expand Down Expand Up @@ -346,18 +334,6 @@ fileprivate extension PackageDependency {
}
}

fileprivate extension PackageTarget {
var sanitizedName: String {
name
.mangledToC99ExtendedIdentifier()
.localizedFirstWordCapitalized()
}
}

fileprivate extension String {
func localizedFirstWordCapitalized() -> String { prefix(1).uppercased() + dropFirst() }
}

extension SourceFileSyntax {
private class ContainsLiteralVisitor: SyntaxVisitor {
let string: String
Expand Down
20 changes: 20 additions & 0 deletions Sources/SwiftRefactor/PackageManifest/PackageTarget.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ import SwiftSyntax
public struct PackageTarget {
public let name: String

public var sanitizedName: String {
name
.mangledToC99ExtendedIdentifier()
.localizedFirstWordCapitalized()
}

/// The type of target.
public let type: TargetKind

Expand Down Expand Up @@ -51,6 +57,16 @@ public struct PackageTarget {
case byName(name: String)
case target(name: String)
case product(name: String, package: String?)

/// Retrieve the name of the dependency
public var name: String {
switch self {
case .byName(let name),
.target(let name),
.product(let name, package: _):
return name
}
}
}

public init(
Expand Down Expand Up @@ -141,3 +157,7 @@ extension PackageTarget.PluginUsage: ManifestSyntaxRepresentable {
}
}
}

fileprivate extension String {
func localizedFirstWordCapitalized() -> String { prefix(1).uppercased() + dropFirst() }
}
Loading