Skip to content

Commit

Permalink
Swift 4 updates
Browse files Browse the repository at this point in the history
  • Loading branch information
tomlokhorst committed Sep 3, 2017
1 parent d8d82c4 commit 75b58cc
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"repositoryURL": "https://github.com/tomlokhorst/XcodeEdit",
"state": {
"branch": "release/2.0",
"revision": "2a6ab33948312a4342269099b548fb19af4ad16d",
"revision": "f9ce2c414f69bd3d309938b75dd0c4af7a815dbe",
"version": null
}
}
Expand Down
10 changes: 5 additions & 5 deletions Sources/RswiftCore/ResourceTypes/StringParam.swift
Original file line number Diff line number Diff line change
Expand Up @@ -187,16 +187,16 @@ private func createFormatParts(_ formatString: String) -> [FormatPart] {
// Extract the list of chars (conversion specifiers) and their optional positional specifier
let chars = formatTypesRegEx.matches(in: formatString, options: [], range: range).map { match -> (String, Int?) in
let range: NSRange
if match.rangeAt(3).location != NSNotFound {
if match.range(at: 3).location != NSNotFound {
// [dioux] are in range #3 because in #2 there may be length modifiers (like in "lld")
range = match.rangeAt(3)
range = match.range(at: 3)
} else {
// otherwise, no length modifier, the conversion specifier is in #2
range = match.rangeAt(2)
range = match.range(at: 2)
}
let char = nsString.substring(with: range)

let posRange = match.rangeAt(1)
let posRange = match.range(at: 1)
if posRange.location == NSNotFound {
// No positional specifier
return (char, nil)
Expand Down Expand Up @@ -261,7 +261,7 @@ extension NSRegularExpression {
return nil
}

let range = match.rangeAt(1)
let range = match.range(at: 1)
return nsInput.substring(with: range)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@ struct ImportPrinter: SwiftCodeConverible {
.flatMap(getUsedTypes)
.map { $0.type.module }

swiftCode = modules
let modulesSet = modules
.union(extractedModules)
.subtracting(excludedModules)

swiftCode = Array(modulesSet)
.filter { $0.isCustom }
.sorted { $0.description < $1.description }
.map { "import \($0)" }
Expand Down
4 changes: 2 additions & 2 deletions Sources/RswiftCore/Util/UtilExtensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ extension String {
var lowercaseFirstCharacter: String {
if self.characters.count <= 1 { return self.lowercased() }
let index = characters.index(startIndex, offsetBy: 1)
return substring(to: index).lowercased() + substring(from: index)
return self[..<index].lowercased() + self[index...]
}

var uppercaseFirstCharacter: String {
if self.characters.count <= 1 { return self.uppercased() }
let index = characters.index(startIndex, offsetBy: 1)
return substring(to: index).uppercased() + substring(from: index)
return self[..<index].uppercased() + self[index...]
}

func indent(with indentation: String) -> String {
Expand Down

0 comments on commit 75b58cc

Please sign in to comment.