Remove use of deprecated String functions #2107
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Swift 4.0.2 brings a new deprecation warning for String.characters. These changes address the places where we were using the deprecated functions, and have otherwise fallen out of sync with the changes to the Swift String API.
In StringExtension, remove some functions that are no longer used, and update the rest to Swift 4's String API. lastIndexOf changes to lastIndex(of: ), matching the standard library naming conventions, and returns a String.Index? instead of an Int.
Add an implementation of Substring.hasPrefix for Linux; this is in the Apple standard library but not the Linux one. https://bugs.swift.org/browse/SR-5627
Add unit tests for StringExtension.
Rewrite ParseTreePatternMatcher to use standard library String functions and avoid our custom String extensions.
Bump the Swift download for the Travis Linux tests from 4.0 to 4.0.2. There is a bug in Substring.range(of:) in 4.0.0 (https://bugs.swift.org/browse/SR-5663) that we need to avoid.
Remove the toString implementations, in favor of CustomStringConvertible.description.
Remove the uses of StringBuilder where it is simply accumulating a String for us. In Swift we can use a var String for this; there is no need for a StringBuilder class like in Java. Change TokenStreamRewriter to use an inout String as the execute(buf:) parameter rather than StringBuilder. Remove StringBuilder entirely.
Rewrite RuntimeMetaData.getMajorMinorVersion to use standard library String functions and avoid our custom String extensions. Addtests for RuntimeMetaData.getMajorMinorVersion.
This PR depends on #2100 and #2101 due to merge conflicts.