Skip to content

Commit 451ecc4

Browse files
author
Harlan
committed
Merge pull request #242 from harlanhaskins/se-0046-consistent-func-labels
[SE-0046] Implemented consistent function labels
2 parents 1dad145 + 7784824 commit 451ecc4

File tree

83 files changed

+183
-183
lines changed

Some content is hidden

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

83 files changed

+183
-183
lines changed

Sources/Build/Buildable.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ protocol Buildable {
1818

1919
extension CModule {
2020
///Returns the build directory path of a CModule
21-
func buildDirectory(prefix: String) -> String {
21+
func buildDirectory(_ prefix: String) -> String {
2222
return Path.join(prefix, "\(c99name).build")
2323
}
2424
}
@@ -28,7 +28,7 @@ extension Module: Buildable {
2828
return self is TestModule
2929
}
3030

31-
func XccFlags(prefix: String) -> [String] {
31+
func XccFlags(_ prefix: String) -> [String] {
3232
return recursiveDependencies.flatMap { module -> [String] in
3333
if let module = module as? ClangModule {
3434
///For ClangModule we check if there is a user provided module map

Sources/Build/Command.compile(ClangModule).swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ private extension ClangModule {
2222
return args
2323
}
2424

25-
func includeFlagsWithExternalModules(externalModules: Set<Module>) -> [String] {
25+
func includeFlagsWithExternalModules(_ externalModules: Set<Module>) -> [String] {
2626
var args: [String] = []
2727
for case let dep as ClangModule in dependencies {
2828
let includeFlag: String
@@ -45,7 +45,7 @@ private extension ClangModule {
4545
return args
4646
}
4747

48-
func optimizationFlags(conf: Configuration) -> [String] {
48+
func optimizationFlags(_ conf: Configuration) -> [String] {
4949
switch conf {
5050
case .Debug:
5151
return ["-g", "-O0"]
@@ -56,7 +56,7 @@ private extension ClangModule {
5656
}
5757

5858
private extension Sources {
59-
func compilePathsForBuildDir(wd: String) -> [(filename: String, source: String, object: String, deps: String)] {
59+
func compilePathsForBuildDir(_ wd: String) -> [(filename: String, source: String, object: String, deps: String)] {
6060
return relativePaths.map { source in
6161
let path = Path.join(root, source)
6262
let object = Path.join(wd, "\(source).o")

Sources/Build/Command.compile(SwiftModule).swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ extension Command {
1616

1717
let otherArgs = otherArgs + module.XccFlags(prefix)
1818

19-
func cmd(tool: ToolProtocol) -> Command {
19+
func cmd(_ tool: ToolProtocol) -> Command {
2020
return Command(node: module.targetName, tool: tool)
2121
}
2222

Sources/Build/Command.link().swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import Utility
1717

1818

1919
extension Command {
20-
static func link(product: Product, configuration conf: Configuration, prefix: String, otherArgs: [String], SWIFT_EXEC: String) throws -> Command {
20+
static func link(_ product: Product, configuration conf: Configuration, prefix: String, otherArgs: [String], SWIFT_EXEC: String) throws -> Command {
2121

2222
let objects: [String]
2323
switch conf {

Sources/Build/Command.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ struct Command {
1212
let node: String
1313
let tool: ToolProtocol
1414

15-
static func createDirectory(path: String) -> Command {
15+
static func createDirectory(_ path: String) -> Command {
1616
return Command(node: path, tool: MkdirTool(path: path))
1717
}
1818
}

Sources/Build/YAML.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ extension Bool: YAMLRepresentable {
2828

2929
extension Array where Element: YAMLRepresentable {
3030
var YAML: String {
31-
func quote(input: String) -> String {
31+
func quote(_ input: String) -> String {
3232
for c in input.characters {
3333
if c == "@" || c == " " || c == "-" || c == "&" {
3434
return "\"\(input)\""

Sources/Build/describe().swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import Utility
1818
/**
1919
- Returns: path to generated YAML for consumption by the llbuild based swift-build-tool
2020
*/
21-
public func describe(prefix: String, _ conf: Configuration, _ modules: [Module], _ externalModules: Set<Module>, _ products: [Product], Xcc: [String], Xld: [String], Xswiftc: [String], toolchain: Toolchain) throws -> String {
21+
public func describe(_ prefix: String, _ conf: Configuration, _ modules: [Module], _ externalModules: Set<Module>, _ products: [Product], Xcc: [String], Xld: [String], Xswiftc: [String], toolchain: Toolchain) throws -> String {
2222

2323
guard modules.count > 0 else {
2424
throw Error.NoModules
@@ -78,7 +78,7 @@ public func describe(prefix: String, _ conf: Configuration, _ modules: [Module],
7878
}
7979
}
8080

81-
private func write(path path: String, write: ((String) -> Void) -> Void) throws -> String {
81+
private func write(path: String, write: ((String) -> Void) -> Void) throws -> String {
8282
var storedError: ErrorProtocol?
8383

8484
try fopen(path, mode: .Write) { fp in
@@ -105,7 +105,7 @@ private struct Targets {
105105
var test = Target(node: "test", cmds: [])
106106
var main = Target(node: "default", cmds: [])
107107

108-
mutating func append(command: Command, for buildable: Buildable) {
108+
mutating func append(_ command: Command, for buildable: Buildable) {
109109
if buildable.isTest {
110110
test.cmds.append(command)
111111
} else {

Sources/Build/misc.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ extension ClangModule {
9999
}
100100

101101
///warn user if in case module name and c99name are different and there a `name.h` umbrella header
102-
private func diagnoseInvalidUmbrellaHeader(path: String) {
102+
private func diagnoseInvalidUmbrellaHeader(_ path: String) {
103103
let umbrellaHeader = Path.join(path, "\(c99name).h")
104104
let invalidUmbrellaHeader = Path.join(path, "\(name).h")
105105
if c99name != name && invalidUmbrellaHeader.isFile {

Sources/Get/Fetchable.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,5 @@ protocol Fetchable {
2626
//FIXME protocols cannot impose new property constraints,
2727
// so Package has a version { get } already, we cannot add
2828
// a set, so instead we have to have this protocol func
29-
func setVersion(newValue: Version) throws
29+
func setVersion(_ newValue: Version) throws
3030
}

Sources/Get/Fetcher.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ import struct PackageDescription.Version
1717
protocol Fetcher {
1818
associatedtype T: Fetchable
1919

20-
func find(url url: String) throws -> Fetchable?
21-
func fetch(url url: String) throws -> Fetchable
22-
func finalize(fetchable: Fetchable) throws -> T
20+
func find(url: String) throws -> Fetchable?
21+
func fetch(url: String) throws -> Fetchable
22+
func finalize(_ fetchable: Fetchable) throws -> T
2323

24-
func recursivelyFetch(urls: [(String, Range<Version>)]) throws -> [T]
24+
func recursivelyFetch(_ urls: [(String, Range<Version>)]) throws -> [T]
2525
}
2626

2727
extension Fetcher {
@@ -30,15 +30,15 @@ extension Fetcher {
3030

3131
This is our standard implementation that we override when testing.
3232
*/
33-
func recursivelyFetch(urls: [(String, Range<Version>)]) throws -> [T] {
33+
func recursivelyFetch(_ urls: [(String, Range<Version>)]) throws -> [T] {
3434

3535
var graph = [String: (Fetchable, Range<Version>)]()
3636

37-
func recurse(urls: [(String, Range<Version>)]) throws -> [String] {
37+
func recurse(_ urls: [(String, Range<Version>)]) throws -> [String] {
3838

3939
return try urls.flatMap { url, specifiedVersionRange -> [String] in
4040

41-
func adjust(pkg: Fetchable, _ versionRange: Range<Version>) throws {
41+
func adjust(_ pkg: Fetchable, _ versionRange: Range<Version>) throws {
4242
guard let v = pkg.constrain(to: versionRange) else {
4343
throw Error.InvalidDependencyGraphMissingTag(package: url, requestedTag: "\(versionRange)", existingTags: "\(pkg.availableVersions)")
4444
}

Sources/Get/Git.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import enum POSIX.Error
1515
import Utility
1616

1717
extension Git {
18-
class func clone(url: String, to dstdir: String) throws -> Repo {
18+
class func clone(_ url: String, to dstdir: String) throws -> Repo {
1919
// canonicalize URL
2020
var url = url
2121
if URL.scheme(url) == nil {

Sources/Get/Package.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import Utility
1515
extension Package {
1616
// FIXME we *always* have a manifest, don't reparse it
1717

18-
static func make(repo repo: Git.Repo, manifestParser: (path: String, url: String) throws -> Manifest) throws -> Package? {
18+
static func make(repo: Git.Repo, manifestParser: (path: String, url: String) throws -> Manifest) throws -> Package? {
1919
guard let origin = repo.origin else { throw Error.NoOrigin(repo.path) }
2020
let manifest = try manifestParser(path: repo.path, url: origin)
2121
let pkg = Package(manifest: manifest, url: origin)
@@ -45,7 +45,7 @@ extension Package: Fetchable {
4545
return [version]
4646
}
4747

48-
func setVersion(newValue: Version) throws {
48+
func setVersion(_ newValue: Version) throws {
4949
throw Get.Error.InvalidDependencyGraph(url)
5050
}
5151
}

Sources/Get/PackagesDirectory.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class PackagesDirectory {
3030
extension PackagesDirectory: Fetcher {
3131
typealias T = Package
3232

33-
func find(url url: String) throws -> Fetchable? {
33+
func find(url: String) throws -> Fetchable? {
3434
for prefix in walk(self.prefix, recursively: false) {
3535
guard let repo = Git.Repo(path: prefix) else { continue } //TODO warn user
3636
guard repo.origin == url else { continue }
@@ -39,7 +39,7 @@ extension PackagesDirectory: Fetcher {
3939
return nil
4040
}
4141

42-
func fetch(url url: String) throws -> Fetchable {
42+
func fetch(url: String) throws -> Fetchable {
4343
let dstdir = Path.join(prefix, Package.nameForURL(url))
4444
if let repo = Git.Repo(path: dstdir) where repo.origin == url {
4545
//TODO need to canonicalize the URL need URL struct
@@ -52,7 +52,7 @@ extension PackagesDirectory: Fetcher {
5252
return try RawClone(path: dstdir, manifestParser: manifestParser)
5353
}
5454

55-
func finalize(fetchable: Fetchable) throws -> Package {
55+
func finalize(_ fetchable: Fetchable) throws -> Package {
5656
switch fetchable {
5757
case let clone as RawClone:
5858
let prefix = Path.join(self.prefix, clone.finalName)

Sources/Get/RawClone.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class RawClone: Fetchable {
6060
}
6161

6262
/// contract, you cannot call this before you have attempted to `constrain` this clone
63-
func setVersion(ver: Version) throws {
63+
func setVersion(_ ver: Version) throws {
6464
let packageVersionsArePrefixed = repo.versionsArePrefixed
6565
let v = (packageVersionsArePrefixed ? "v" : "") + ver.description
6666
try Git.runPopen([Git.tool, "-C", path, "reset", "--hard", v])

Sources/Get/Version.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ extension Version {
2424
return self.min..<self.max
2525
}
2626

27-
static func vprefix(string: String.CharacterView) -> Version? {
27+
static func vprefix(_ string: String.CharacterView) -> Version? {
2828
if string.first == "v" {
2929
return Version(string.dropFirst())
3030
} else {

Sources/Get/get().swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import Utility
1717
- Throws: Error.InvalidDependencyGraph
1818
- Returns: The modules that this manifest requires building
1919
*/
20-
public func get(manifest: Manifest, manifestParser: (path: String, url: String) throws -> Manifest) throws -> (rootPackage: Package, externalPackages:[Package]) {
20+
public func get(_ manifest: Manifest, manifestParser: (path: String, url: String) throws -> Manifest) throws -> (rootPackage: Package, externalPackages:[Package]) {
2121
let dir = Path.join(manifest.path.parentDirectory, "Packages")
2222
let box = PackagesDirectory(prefix: dir, manifestParser: manifestParser)
2323

Sources/ManifestParser/TOML.swift

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ private struct Parser {
467467
}
468468

469469
/// Find the new table to insert into given the top-level table and a list of specifiers.
470-
private mutating func findInsertPoint(topLevelTable: TOMLItemTable, _ specifiers: [String], isAppend: Bool, startToken: Lexer.Token) -> TOMLItemTable {
470+
private mutating func findInsertPoint(_ topLevelTable: TOMLItemTable, _ specifiers: [String], isAppend: Bool, startToken: Lexer.Token) -> TOMLItemTable {
471471
// FIXME: Handle TOML requirements (sole definition).
472472
var into = topLevelTable
473473
for (i,specifier) in specifiers.enumerated() {
@@ -517,7 +517,7 @@ private struct Parser {
517517
/// item), including the terminating brackets.
518518
///
519519
/// - Parameter isAppend: Whether the specifier should end with double brackets.
520-
private mutating func parseTableSpecifier(isAppend: Bool) -> [String]? {
520+
private mutating func parseTableSpecifier(_ isAppend: Bool) -> [String]? {
521521
let startToken = lookahead
522522

523523
// Parse all of the specifiers.
@@ -573,7 +573,7 @@ private struct Parser {
573573
// MARK: Parser Implementation
574574

575575
/// Report an error at the given token.
576-
private mutating func error(message: String, at: Lexer.Token) {
576+
private mutating func error(_ message: String, at: Lexer.Token) {
577577
errors.append(message)
578578
}
579579

@@ -588,7 +588,7 @@ private struct Parser {
588588
}
589589

590590
/// Consume a token if it matches a particular block.
591-
private mutating func consumeIf(match: (Lexer.Token) -> Bool) -> Bool {
591+
private mutating func consumeIf(_ match: (Lexer.Token) -> Bool) -> Bool {
592592
if match(lookahead) {
593593
eat()
594594
return true
@@ -610,7 +610,7 @@ private struct Parser {
610610
}
611611

612612
/// Parse the contents of a table, stopping at the next table marker.
613-
private mutating func parseTableContents(table: TOMLItemTable) {
613+
private mutating func parseTableContents(_ table: TOMLItemTable) {
614614
// Parse assignments until we reach the EOF or a new table record.
615615
while lookahead != .EOF && lookahead != .LSquare {
616616
// If we have a bare newline, ignore it.
@@ -624,7 +624,7 @@ private struct Parser {
624624
}
625625

626626
/// Parse an individual table assignment.
627-
private mutating func parseAssignment(table: TOMLItemTable) {
627+
private mutating func parseAssignment(_ table: TOMLItemTable) {
628628
// Parse the LHS.
629629
let key: String
630630
switch eat() {
@@ -727,7 +727,7 @@ private struct Parser {
727727
return .Array(contents: array)
728728
}
729729

730-
private func parseNumberItem(spelling: String) -> TOMLItem? {
730+
private func parseNumberItem(_ spelling: String) -> TOMLItem? {
731731

732732
let normalized = String(spelling.characters.filter { $0 != "_" })
733733

@@ -749,7 +749,7 @@ public struct TOMLParsingError : ErrorProtocol {
749749

750750
/// Public interface to parsing TOML.
751751
public extension TOMLItem {
752-
static func parse(data: Swift.String) throws -> TOMLItem {
752+
static func parse(_ data: Swift.String) throws -> TOMLItem {
753753
// Parse the string.
754754
var parser = Parser(data)
755755
let result = parser.parse()
@@ -768,7 +768,7 @@ public extension TOMLItem {
768768
/// Internal function for testing the lexer.
769769
///
770770
/// returns: A list of the lexed tokens' string representations.
771-
internal func lexTOML(data: String) -> [String] {
771+
internal func lexTOML(_ data: String) -> [String] {
772772
let lexer = Lexer(data)
773773
return lexer.map { String($0) }
774774
}

Sources/ManifestParser/fromTOML().swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import Utility
1212
import PackageDescription
1313

1414
extension PackageDescription.Package {
15-
public static func fromTOML(item: TOMLItem, baseURL: String? = nil) -> PackageDescription.Package {
15+
public static func fromTOML(_ item: TOMLItem, baseURL: String? = nil) -> PackageDescription.Package {
1616
// This is a private API, currently, so we do not currently try and
1717
// validate the input.
1818
guard case .Table(let topLevelTable) = item else { fatalError("unexpected item") }
@@ -61,7 +61,7 @@ extension PackageDescription.Package {
6161
}
6262

6363
extension PackageDescription.Package.Dependency {
64-
public static func fromTOML(item: TOMLItem, baseURL: String?) -> PackageDescription.Package.Dependency {
64+
public static func fromTOML(_ item: TOMLItem, baseURL: String?) -> PackageDescription.Package.Dependency {
6565
guard case .Array(let array) = item where array.items.count == 3 else {
6666
fatalError("Unexpected TOMLItem")
6767
}
@@ -86,7 +86,7 @@ extension PackageDescription.Package.Dependency {
8686
}
8787

8888
extension PackageDescription.Target {
89-
private static func fromTOML(item: TOMLItem) -> PackageDescription.Target {
89+
private static func fromTOML(_ item: TOMLItem) -> PackageDescription.Target {
9090
// This is a private API, currently, so we do not currently try and
9191
// validate the input.
9292
guard case .Table(let table) = item else { fatalError("unexpected item") }
@@ -106,7 +106,7 @@ extension PackageDescription.Target {
106106
}
107107

108108
extension PackageDescription.Target.Dependency {
109-
private static func fromTOML(item: TOMLItem) -> PackageDescription.Target.Dependency {
109+
private static func fromTOML(_ item: TOMLItem) -> PackageDescription.Target.Dependency {
110110
guard case .String(let name) = item else { fatalError("unexpected item") }
111111
return .Target(name: name)
112112
}
@@ -142,7 +142,7 @@ extension PackageDescription.Product {
142142
self.init(name: name, type: type, modules: modules)
143143
}
144144

145-
public static func fromTOML(item: TOMLItem) -> [PackageDescription.Product] {
145+
public static func fromTOML(_ item: TOMLItem) -> [PackageDescription.Product] {
146146
guard case .Table(let root) = item else { fatalError("unexpected item") }
147147
guard let productsItem = root.items["products"] else { return [] }
148148
guard case .Array(let array) = productsItem else { fatalError("products wrong type") }

Sources/Multitool/Error.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ extension Error: CustomStringConvertible {
5555
}
5656
}
5757

58-
@noreturn public func handleError(msg: Any, usage: ((String) -> Void) -> Void) {
58+
@noreturn public func handleError(_ msg: Any, usage: ((String) -> Void) -> Void) {
5959
switch msg {
6060
case CommandLineError.InvalidUsage(let hint, let mode):
6161
print(error: "invalid usage: \(hint)")
@@ -77,14 +77,14 @@ extension Error: CustomStringConvertible {
7777
exit(1)
7878
}
7979

80-
private func red(input: Any) -> String {
80+
private func red(_ input: Any) -> String {
8181
let input = "\(input)"
8282
let ESC = "\u{001B}"
8383
let CSI = "\(ESC)["
8484
return CSI + "31m" + input + CSI + "0m"
8585
}
8686

87-
private func print(error error: Any) {
87+
private func print(error: Any) {
8888
if !isatty(fileno(libc.stderr)) {
8989
let cmd = Process.arguments.first?.basename ?? "SwiftPM"
9090
print("\(cmd): error:", error, to: &stderr)

0 commit comments

Comments
 (0)