Skip to content

Commit

Permalink
Fix override specifier ordering
Browse files Browse the repository at this point in the history
  • Loading branch information
nicklockwood committed May 1, 2020
1 parent 16292d4 commit 9ba3b7b
Show file tree
Hide file tree
Showing 14 changed files with 152 additions and 152 deletions.
4 changes: 2 additions & 2 deletions Rules.md
Expand Up @@ -1268,8 +1268,8 @@ Use consistent ordering for member specifiers.
```

```diff
- override public final func foo()
+ public final override func foo()
- final public override func foo()
+ override public final func foo()
```

```diff
Expand Down
2 changes: 1 addition & 1 deletion Snapshots/Layout/Layout/LayoutNode.swift
Expand Up @@ -275,7 +275,7 @@ public class LayoutNode: NSObject {
}
}

public override func observeValue(
override public func observeValue(
forKeyPath _: String?,
of _: Any?,
change _: [NSKeyValueChangeKey: Any]?,
Expand Down
6 changes: 3 additions & 3 deletions Snapshots/Layout/Layout/RuntimeType.swift
Expand Up @@ -375,7 +375,7 @@ public class RuntimeType: NSObject {
availability = .available
}

public override var description: String {
override public var description: String {
switch availability {
case .available:
return kind.description
Expand All @@ -384,7 +384,7 @@ public class RuntimeType: NSObject {
}
}

public override func isEqual(_ object: Any?) -> Bool {
override public func isEqual(_ object: Any?) -> Bool {
guard let object = object as? RuntimeType else {
return false
}
Expand All @@ -401,7 +401,7 @@ public class RuntimeType: NSObject {
}
}

public override var hash: Int {
override public var hash: Int {
return description.hashValue
}

Expand Down
2 changes: 1 addition & 1 deletion Snapshots/Layout/Layout/Shared/XMLParser.swift
Expand Up @@ -144,7 +144,7 @@ class XMLParser: NSObject, XMLParserDelegate {
super.init()
}

private override init() {
override private init() {
preconditionFailure()
}

Expand Down
46 changes: 23 additions & 23 deletions Snapshots/Layout/Layout/UICollectionView+Layout.swift
Expand Up @@ -29,7 +29,7 @@ extension UICollectionViewLayout {
}

private class LayoutCollectionView: UICollectionView {
open override var intrinsicContentSize: CGSize {
override open var intrinsicContentSize: CGSize {
guard layoutNode != nil else {
return super.intrinsicContentSize
}
Expand All @@ -39,7 +39,7 @@ private class LayoutCollectionView: UICollectionView {
)
}

open override var contentSize: CGSize {
override open var contentSize: CGSize {
didSet {
if oldValue != contentSize, let layoutNode = layoutNode {
layoutNode.contentSizeChanged()
Expand Down Expand Up @@ -79,7 +79,7 @@ private extension UICollectionView {
}

extension UICollectionView: LayoutBacked {
open override class func create(with node: LayoutNode) throws -> UICollectionView {
override open class func create(with node: LayoutNode) throws -> UICollectionView {
// UICollectionView cannot be created with a nil collectionViewLayout
// so we cannot allow create(with:) to throw. Instead, we'll intercept the error
let layout = node.attempt {
Expand All @@ -103,7 +103,7 @@ extension UICollectionView: LayoutBacked {
return collectionView
}

open override class var expressionTypes: [String: RuntimeType] {
override open class var expressionTypes: [String: RuntimeType] {
var types = super.expressionTypes
for (key, type) in UICollectionViewFlowLayout.allPropertyTypes() {
types["collectionViewLayout.\(key)"] = type
Expand All @@ -122,7 +122,7 @@ extension UICollectionView: LayoutBacked {
return types
}

open override func setAnimatedValue(_ value: Any, forExpression name: String) throws {
override open func setAnimatedValue(_ value: Any, forExpression name: String) throws {
switch name {
case "collectionViewLayout":
setCollectionViewLayout(value as! UICollectionViewLayout, animated: true)
Expand All @@ -131,7 +131,7 @@ extension UICollectionView: LayoutBacked {
}
}

open override func setValue(_ value: Any, forExpression name: String) throws {
override open func setValue(_ value: Any, forExpression name: String) throws {
switch name {
case "reorderingCadence", "collectionViewLayout.sectionInsetReference":
// Does nothing on iOS 10 and earlier
Expand All @@ -143,7 +143,7 @@ extension UICollectionView: LayoutBacked {
}
}

open override func shouldInsertChildNode(_ node: LayoutNode, at _: Int) -> Bool {
override open func shouldInsertChildNode(_ node: LayoutNode, at _: Int) -> Bool {
if node.viewClass is UICollectionViewCell.Type {
do {
if let reuseIdentifier = try node.value(forExpression: "reuseIdentifier") as? String {
Expand All @@ -159,15 +159,15 @@ extension UICollectionView: LayoutBacked {
return true
}

open override func didInsertChildNode(_ node: LayoutNode, at index: Int) {
override open func didInsertChildNode(_ node: LayoutNode, at index: Int) {
if backgroundView == nil {
backgroundView = node.view // TODO: this is a bit inconsistent with UITableView - reconsider?
} else {
super.didInsertChildNode(node, at: index)
}
}

open override func willRemoveChildNode(_ node: LayoutNode, at index: Int) {
override open func willRemoveChildNode(_ node: LayoutNode, at index: Int) {
let hadView = (node._view != nil)
super.willRemoveChildNode(node, at: index)
if node._view == backgroundView {
Expand All @@ -178,7 +178,7 @@ extension UICollectionView: LayoutBacked {
assert(hadView || node._view == nil)
}

open override func didUpdateLayout(for _: LayoutNode) {
override open func didUpdateLayout(for _: LayoutNode) {
for cell in visibleCells {
cell.layoutNode?.update()
}
Expand All @@ -195,7 +195,7 @@ extension UICollectionView: LayoutDelegate {
}

extension UICollectionViewController: LayoutBacked {
open override class func create(with node: LayoutNode) throws -> UICollectionViewController {
override open class func create(with node: LayoutNode) throws -> UICollectionViewController {
let layout = try node.value(forExpression: "collectionViewLayout") as? UICollectionViewLayout ?? .defaultLayout(for: node)
let viewController = self.init(collectionViewLayout: layout)
guard let collectionView = viewController.collectionView else {
Expand All @@ -209,7 +209,7 @@ extension UICollectionViewController: LayoutBacked {
return viewController
}

open override class var expressionTypes: [String: RuntimeType] {
override open class var expressionTypes: [String: RuntimeType] {
var types = super.expressionTypes
types["collectionViewLayout"] = RuntimeType(UICollectionViewFlowLayout.self)
for (key, type) in UICollectionViewFlowLayout.allPropertyTypes() {
Expand All @@ -223,7 +223,7 @@ extension UICollectionViewController: LayoutBacked {
return types
}

open override func setValue(_ value: Any, forExpression name: String) throws {
override open func setValue(_ value: Any, forExpression name: String) throws {
switch name {
case "collectionViewLayout":
collectionView?.collectionViewLayout = value as! UICollectionViewLayout
Expand All @@ -236,7 +236,7 @@ extension UICollectionViewController: LayoutBacked {
}
}

open override func shouldInsertChildNode(_ node: LayoutNode, at index: Int) -> Bool {
override open func shouldInsertChildNode(_ node: LayoutNode, at index: Int) -> Bool {
switch node.viewClass {
case is UICollectionViewCell.Type:
return collectionView?.shouldInsertChildNode(node, at: index) ?? false
Expand All @@ -245,7 +245,7 @@ extension UICollectionViewController: LayoutBacked {
}
}

open override func didInsertChildNode(_ node: LayoutNode, at index: Int) {
override open func didInsertChildNode(_ node: LayoutNode, at index: Int) {
// TODO: what if more than one collectionView is added?
if node.viewClass is UICollectionView.Type {
let wasLoaded = (viewIfLoaded != nil)
Expand All @@ -258,7 +258,7 @@ extension UICollectionViewController: LayoutBacked {
collectionView?.didInsertChildNode(node, at: index)
}

open override func willRemoveChildNode(_ node: LayoutNode, at index: Int) {
override open func willRemoveChildNode(_ node: LayoutNode, at index: Int) {
if node.viewClass is UICollectionView.Type {
collectionView = nil
return
Expand Down Expand Up @@ -383,14 +383,14 @@ extension UICollectionView {
}

private class LayoutCollectionViewCell: UICollectionViewCell {
open override var intrinsicContentSize: CGSize {
override open var intrinsicContentSize: CGSize {
guard let layoutNode = layoutNode, layoutNode.children.isEmpty else {
return super.intrinsicContentSize
}
return CGSize(width: UIView.noIntrinsicMetric, height: 44)
}

open override func sizeThatFits(_ size: CGSize) -> CGSize {
override open func sizeThatFits(_ size: CGSize) -> CGSize {
if let layoutNode = layoutNode {
let height = (try? layoutNode.doubleValue(forSymbol: "height")) ?? 0
return CGSize(width: size.width, height: CGFloat(height))
Expand Down Expand Up @@ -427,15 +427,15 @@ private extension UICollectionViewCell {
}

extension UICollectionViewCell: LayoutBacked {
open override class func create(with _: LayoutNode) throws -> UICollectionViewCell {
override open class func create(with _: LayoutNode) throws -> UICollectionViewCell {
throw LayoutError.message("UICollectionViewCells must be created by UICollectionView")
}

open override class var parameterTypes: [String: RuntimeType] {
override open class var parameterTypes: [String: RuntimeType] {
return ["reuseIdentifier": .string]
}

open override class var expressionTypes: [String: RuntimeType] {
override open class var expressionTypes: [String: RuntimeType] {
var types = super.expressionTypes
for (key, type) in UIView.cachedExpressionTypes {
types["contentView.\(key)"] = type
Expand All @@ -445,7 +445,7 @@ extension UICollectionViewCell: LayoutBacked {
return types
}

open override func setValue(_ value: Any, forExpression name: String) throws {
override open func setValue(_ value: Any, forExpression name: String) throws {
if name.hasPrefix("backgroundView."), backgroundView == nil {
// Add a backgroundView view if required
backgroundView = UIView(frame: bounds)
Expand All @@ -456,7 +456,7 @@ extension UICollectionViewCell: LayoutBacked {
try super.setValue(value, forExpression: name)
}

open override func didInsertChildNode(_ node: LayoutNode, at index: Int) {
override open func didInsertChildNode(_ node: LayoutNode, at index: Int) {
// Insert child views into `contentView` instead of directly
contentView.didInsertChildNode(node, at: index)
}
Expand Down
8 changes: 4 additions & 4 deletions Snapshots/Layout/Layout/UIScrollView+Layout.swift
Expand Up @@ -3,7 +3,7 @@
import Foundation

extension UIScrollView {
open override class var expressionTypes: [String: RuntimeType] {
override open class var expressionTypes: [String: RuntimeType] {
var types = super.expressionTypes
types["contentInsetAdjustmentBehavior"] = .uiScrollViewContentInsetAdjustmentBehavior
types["indicatorStyle"] = .uiScrollViewIndicatorStyle
Expand Down Expand Up @@ -38,7 +38,7 @@ extension UIScrollView {
return types
}

open override func setAnimatedValue(_ value: Any, forExpression name: String) throws {
override open func setAnimatedValue(_ value: Any, forExpression name: String) throws {
switch name {
case "contentOffset":
setContentOffset(value as! CGPoint, animated: true)
Expand All @@ -55,7 +55,7 @@ extension UIScrollView {
}
}

open override func setValue(_ value: Any, forExpression name: String) throws {
override open func setValue(_ value: Any, forExpression name: String) throws {
switch name {
case "contentInsetAdjustmentBehavior":
// Does nothing on iOS 10 and earlier
Expand All @@ -67,7 +67,7 @@ extension UIScrollView {
}
}

open override func didUpdateLayout(for _: LayoutNode) {
override open func didUpdateLayout(for _: LayoutNode) {
// Prevents contentOffset glitch when rotating from portrait to landscape
// TODO: needs improvement - result can be off by one page sometimes
if isPagingEnabled {
Expand Down
8 changes: 4 additions & 4 deletions Snapshots/Layout/Layout/UIStackView+Layout.swift
Expand Up @@ -3,7 +3,7 @@
import UIKit

extension UIStackView {
open override class var expressionTypes: [String: RuntimeType] {
override open class var expressionTypes: [String: RuntimeType] {
var types = super.expressionTypes
types["axis"] = .uiLayoutConstraintAxis
types["distribution"] = .uiStackViewDistribution
Expand Down Expand Up @@ -34,17 +34,17 @@ extension UIStackView {
return types
}

open override func didInsertChildNode(_ node: LayoutNode, at index: Int) {
override open func didInsertChildNode(_ node: LayoutNode, at index: Int) {
super.didInsertChildNode(node, at: index)
addArrangedSubview(node.view)
}

open override func willRemoveChildNode(_ node: LayoutNode, at index: Int) {
override open func willRemoveChildNode(_ node: LayoutNode, at index: Int) {
(node._view as UIView?).map(removeArrangedSubview)
super.willRemoveChildNode(node, at: index)
}

open override class var defaultExpressions: [String: String] {
override open class var defaultExpressions: [String: String] {
return [
"width": "auto",
"height": "auto",
Expand Down

0 comments on commit 9ba3b7b

Please sign in to comment.