-
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Swift format for consistent whitespace (#15)
* Add swift-format.json * Add format script * Automatically formatted source code
- Loading branch information
Showing
57 changed files
with
2,938 additions
and
2,631 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"indentation" : { | ||
"tabs" : 1 | ||
}, | ||
"tabWidth" : 4, | ||
"version" : 1 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 19 additions & 17 deletions
36
Sources/LanguageServerProtocol/Additions/NSRegularExpression+Matching.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,31 @@ | ||
import Foundation | ||
|
||
extension NSRegularExpression { | ||
func matches(inFullString string: String, options: NSRegularExpression.MatchingOptions = []) -> [NSTextCheckingResult] { | ||
let range = NSMakeRange(0, string.utf16.count) | ||
func matches(inFullString string: String, options: NSRegularExpression.MatchingOptions = []) | ||
-> [NSTextCheckingResult] | ||
{ | ||
let range = NSMakeRange(0, string.utf16.count) | ||
|
||
return matches(in: string, options: options, range: range) | ||
} | ||
return matches(in: string, options: options, range: range) | ||
} | ||
} | ||
|
||
extension NSTextCheckingResult { | ||
func range(at index: Int, in string: String) -> Range<String.Index>? { | ||
let nsRange = range(at: index) | ||
func range(at index: Int, in string: String) -> Range<String.Index>? { | ||
let nsRange = range(at: index) | ||
|
||
return Range(nsRange, in: string) | ||
} | ||
return Range(nsRange, in: string) | ||
} | ||
|
||
func stringValue(at index: Int, in string: String) -> Substring? { | ||
guard let captureRange = range(at: index, in: string) else { | ||
return nil | ||
} | ||
func stringValue(at index: Int, in string: String) -> Substring? { | ||
guard let captureRange = range(at: index, in: string) else { | ||
return nil | ||
} | ||
|
||
return string[captureRange] | ||
} | ||
return string[captureRange] | ||
} | ||
|
||
func intValue(at index: Int, in string: String) -> Int? { | ||
return stringValue(at: index, in: string).flatMap { Int($0) } | ||
} | ||
func intValue(at index: Int, in string: String) -> Int? { | ||
return stringValue(at: index, in: string).flatMap { Int($0) } | ||
} | ||
} |
Oops, something went wrong.