Skip to content
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

Fix Xcode 10b / Swift 4.2 compiler issue (type-checker timeout) #93

Merged
merged 1 commit into from
Jul 21, 2018
Merged
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
* Fixed using filter expression in call node.
[Ilya Puchka](https://github.com/ilyapuchka)
[#85](https://github.com/SwiftGen/StencilSwiftKit/pull/85)
* Fixed compilation issue with Xcode 10 & Swift 4.2 by adding hints to help the compiler.
[Olivier Halligon](https://github.com/AliSoftware)
[#93](https://github.com/SwiftGen/StencilSwiftKit/pull/93)

### Breaking Changes

Expand Down
69 changes: 53 additions & 16 deletions Sources/SwiftIdentifier.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,34 +6,71 @@

import Foundation

private func mr(_ char: Int) -> CountableClosedRange<Int> {
typealias CharRange = CountableClosedRange<Int>

private func mr(_ char: Int) -> CharRange {
return char...char
}

// Official list of valid identifier characters
// swiftlint:disable:next line_length
// from: https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/LexicalStructure.html#//apple_ref/doc/uid/TP40014097-CH30-ID410
private let headRanges: [CountableClosedRange<Int>] = [
0x61...0x7a, 0x41...0x5a, mr(0x5f), mr(0xa8), mr(0xaa), mr(0xad), mr(0xaf),
0xb2...0xb5, 0xb7...0xba, 0xbc...0xbe, 0xc0...0xd6, 0xd8...0xf6, 0xf8...0xff,
0x100...0x2ff, 0x370...0x167f, 0x1681...0x180d, 0x180f...0x1dbf,
0x1e00...0x1fff, 0x200b...0x200d, 0x202a...0x202e, mr(0x203F), mr(0x2040),
mr(0x2054), 0x2060...0x206f, 0x2070...0x20cf, 0x2100...0x218f, 0x2460...0x24ff,
0x2776...0x2793, 0x2c00...0x2dff, 0x2e80...0x2fff, 0x3004...0x3007,
0x3021...0x302f, 0x3031...0x303f, 0x3040...0xd7ff, 0xf900...0xfd3d,
0xfd40...0xfdcf, 0xfdf0...0xfe1f, 0xfe30...0xfe44, 0xfe47...0xfffd,
0x10000...0x1fffd, 0x20000...0x2fffd, 0x30000...0x3fffd, 0x40000...0x4fffd,
0x50000...0x5fffd, 0x60000...0x6fffd, 0x70000...0x7fffd, 0x80000...0x8fffd,
0x90000...0x9fffd, 0xa0000...0xafffd, 0xb0000...0xbfffd, 0xc0000...0xcfffd,
0xd0000...0xdfffd, 0xe0000...0xefffd
private let headRanges: [CharRange] = [
0x61...0x7a as CharRange,
0x41...0x5a as CharRange,
mr(0x5f), mr(0xa8), mr(0xaa), mr(0xad), mr(0xaf),
0xb2...0xb5 as CharRange,
0xb7...0xba as CharRange,
0xbc...0xbe as CharRange,
0xc0...0xd6 as CharRange,
0xd8...0xf6 as CharRange,
0xf8...0xff as CharRange,
0x100...0x2ff as CharRange,
0x370...0x167f as CharRange,
0x1681...0x180d as CharRange,
0x180f...0x1dbf as CharRange,
0x1e00...0x1fff as CharRange,
0x200b...0x200d as CharRange,
0x202a...0x202e as CharRange,
mr(0x203F), mr(0x2040), mr(0x2054),
0x2060...0x206f as CharRange,
0x2070...0x20cf as CharRange,
0x2100...0x218f as CharRange,
0x2460...0x24ff as CharRange,
0x2776...0x2793 as CharRange,
0x2c00...0x2dff as CharRange,
0x2e80...0x2fff as CharRange,
0x3004...0x3007 as CharRange,
0x3021...0x302f as CharRange,
0x3031...0x303f as CharRange,
0x3040...0xd7ff as CharRange,
0xf900...0xfd3d as CharRange,
0xfd40...0xfdcf as CharRange,
0xfdf0...0xfe1f as CharRange,
0xfe30...0xfe44 as CharRange,
0xfe47...0xfffd as CharRange,
0x10000...0x1fffd as CharRange,
0x20000...0x2fffd as CharRange,
0x30000...0x3fffd as CharRange,
0x40000...0x4fffd as CharRange,
0x50000...0x5fffd as CharRange,
0x60000...0x6fffd as CharRange,
0x70000...0x7fffd as CharRange,
0x80000...0x8fffd as CharRange,
0x90000...0x9fffd as CharRange,
0xa0000...0xafffd as CharRange,
0xb0000...0xbfffd as CharRange,
0xc0000...0xcfffd as CharRange,
0xd0000...0xdfffd as CharRange,
0xe0000...0xefffd as CharRange
]

private let tailRanges: [CountableClosedRange<Int>] = [
private let tailRanges: [CharRange] = [
0x30...0x39, 0x300...0x36F, 0x1dc0...0x1dff, 0x20d0...0x20ff, 0xfe20...0xfe2f
]

private func identifierCharacterSets(exceptions: String) -> (head: NSMutableCharacterSet, tail: NSMutableCharacterSet) {
let addRange: (NSMutableCharacterSet, CountableClosedRange<Int>) -> Void = { mcs, range in
let addRange: (NSMutableCharacterSet, CharRange) -> Void = { mcs, range in
mcs.addCharacters(in: NSRange(location: range.lowerBound, length: range.count))
}

Expand Down