Skip to content

Commit

Permalink
Reduce fileprivate usage
Browse files Browse the repository at this point in the history
  • Loading branch information
M0rtyMerr authored and freak4pc committed Feb 8, 2020
1 parent fbcab9b commit 60a80f0
Show file tree
Hide file tree
Showing 76 changed files with 188 additions and 188 deletions.
2 changes: 1 addition & 1 deletion Platform/DataStructures/Bag.swift
Expand Up @@ -35,7 +35,7 @@ struct Bag<T> : CustomDebugStringConvertible {

typealias Entry = (key: BagKey, value: T)

fileprivate var _nextKey: BagKey = BagKey(rawValue: 0)
private var _nextKey: BagKey = BagKey(rawValue: 0)

// data

Expand Down
2 changes: 1 addition & 1 deletion Platform/DataStructures/PriorityQueue.swift
Expand Up @@ -10,7 +10,7 @@ struct PriorityQueue<Element> {
private let _hasHigherPriority: (Element, Element) -> Bool
private let _isEqual: (Element, Element) -> Bool

fileprivate var _elements = [Element]()
private var _elements = [Element]()

init(hasHigherPriority: @escaping (Element, Element) -> Bool, isEqual: @escaping (Element, Element) -> Bool) {
_hasHigherPriority = hasHigherPriority
Expand Down
4 changes: 2 additions & 2 deletions RxBlocking/BlockingObservable+Operators.swift
Expand Up @@ -101,7 +101,7 @@ extension BlockingObservable {
}

extension BlockingObservable {
fileprivate func materializeResult(max: Int? = nil, predicate: @escaping (Element) throws -> Bool = { _ in true }) -> MaterializedSequenceResult<Element> {
private func materializeResult(max: Int? = nil, predicate: @escaping (Element) throws -> Bool = { _ in true }) -> MaterializedSequenceResult<Element> {
var elements = [Element]()
var error: Swift.Error?

Expand Down Expand Up @@ -159,7 +159,7 @@ extension BlockingObservable {
return MaterializedSequenceResult.completed(elements: elements)
}

fileprivate func elementsOrThrow(_ results: MaterializedSequenceResult<Element>) throws -> [Element] {
private func elementsOrThrow(_ results: MaterializedSequenceResult<Element>) throws -> [Element] {
switch results {
case .failed(_, let error):
throw error
Expand Down
6 changes: 3 additions & 3 deletions RxCocoa/Common/DelegateProxy.swift
Expand Up @@ -26,8 +26,8 @@
/// Parent object associated with delegate proxy.
private weak var _parentObject: ParentObject?

fileprivate let _currentDelegateFor: (ParentObject) -> AnyObject?
fileprivate let _setCurrentDelegateTo: (AnyObject?, ParentObject) -> Void
private let _currentDelegateFor: (ParentObject) -> AnyObject?
private let _setCurrentDelegateTo: (AnyObject?, ParentObject) -> Void

/// Initializes new instance.
///
Expand Down Expand Up @@ -258,7 +258,7 @@

private let mainScheduler = MainScheduler()

fileprivate final class MessageDispatcher {
private final class MessageDispatcher {
private let dispatcher: PublishSubject<[Any]>
private let result: Observable<[Any]>

Expand Down
8 changes: 4 additions & 4 deletions RxCocoa/Common/DelegateProxyType.swift
Expand Up @@ -240,18 +240,18 @@ extension DelegateProxyType {
}


// fileprivate extensions
// private extensions
extension DelegateProxyType {
fileprivate static var factory: DelegateProxyFactory {
private static var factory: DelegateProxyFactory {
return DelegateProxyFactory.sharedFactory(for: self)
}

fileprivate static func assignedProxy(for object: ParentObject) -> AnyObject? {
private static func assignedProxy(for object: ParentObject) -> AnyObject? {
let maybeDelegate = objc_getAssociatedObject(object, self.identifier)
return castOptionalOrFatalError(maybeDelegate)
}

fileprivate static func assignProxy(_ proxy: AnyObject, toObject object: ParentObject) {
private static func assignProxy(_ proxy: AnyObject, toObject object: ParentObject) {
objc_setAssociatedObject(object, self.identifier, proxy, .OBJC_ASSOCIATION_RETAIN)
}
}
Expand Down
16 changes: 8 additions & 8 deletions RxCocoa/Foundation/NSObject+Rx.swift
Expand Up @@ -202,7 +202,7 @@ extension Reactive where Base: AnyObject {
}
}

fileprivate func registerMessageInterceptor<T: MessageInterceptorSubject>(_ selector: Selector) throws -> T {
private func registerMessageInterceptor<T: MessageInterceptorSubject>(_ selector: Selector) throws -> T {
let rxSelector = RX_selector(selector)
let selectorReference = RX_reference_from_selector(rxSelector)

Expand Down Expand Up @@ -251,7 +251,7 @@ extension Reactive where Base: AnyObject {
var targetImplementation: IMP { get set }
}

fileprivate final class DeallocatingProxy
private final class DeallocatingProxy
: MessageInterceptorSubject
, RXDeallocatingObserver {
typealias Element = ()
Expand All @@ -276,7 +276,7 @@ extension Reactive where Base: AnyObject {
}
}

fileprivate final class MessageSentProxy
private final class MessageSentProxy
: MessageInterceptorSubject
, RXMessageSentObserver {
typealias Element = [AnyObject]
Expand Down Expand Up @@ -310,7 +310,7 @@ extension Reactive where Base: AnyObject {
#endif


fileprivate final class DeallocObservable {
private final class DeallocObservable {
let _subject = ReplaySubject<Void>.create(bufferSize:1)

init() {
Expand All @@ -333,7 +333,7 @@ private protocol KVOObservableProtocol {
var options: KeyValueObservingOptions { get }
}

fileprivate final class KVOObserver
private final class KVOObserver
: _RXKVOObserver
, Disposable {
typealias Callback = (Any?) -> Void
Expand Down Expand Up @@ -361,7 +361,7 @@ fileprivate final class KVOObserver
}
}

fileprivate final class KVOObservable<Element>
private final class KVOObservable<Element>
: ObservableType
, KVOObservableProtocol {
typealias Element = Element?
Expand Down Expand Up @@ -397,7 +397,7 @@ fileprivate final class KVOObservable<Element>

}

fileprivate extension KeyValueObservingOptions {
private extension KeyValueObservingOptions {
var nsOptions: NSKeyValueObservingOptions {
var result: UInt = 0
if self.contains(.new) {
Expand Down Expand Up @@ -438,7 +438,7 @@ fileprivate extension KeyValueObservingOptions {
return properyRuntimeInfo.range(of: ",W,") != nil
}

fileprivate extension ObservableType where Element == AnyObject? {
private extension ObservableType where Element == AnyObject? {
func finishWithNilWhenDealloc(_ target: NSObject)
-> Observable<AnyObject?> {
let deallocating = target.rx.deallocating
Expand Down
2 changes: 1 addition & 1 deletion RxCocoa/Foundation/URLSession+Rx.swift
Expand Up @@ -60,7 +60,7 @@ private func escapeTerminalString(_ value: String) -> String {
return value.replacingOccurrences(of: "\"", with: "\\\"", options:[], range: nil)
}

fileprivate func convertURLRequestToCurlCommand(_ request: URLRequest) -> String {
private func convertURLRequestToCurlCommand(_ request: URLRequest) -> String {
let method = request.httpMethod ?? "GET"
var returnValue = "curl -X \(method) "

Expand Down
Expand Up @@ -17,10 +17,10 @@ extension UICollectionView: HasPrefetchDataSource {
}

@available(iOS 10.0, tvOS 10.0, *)
fileprivate let collectionViewPrefetchDataSourceNotSet = CollectionViewPrefetchDataSourceNotSet()
private let collectionViewPrefetchDataSourceNotSet = CollectionViewPrefetchDataSourceNotSet()

@available(iOS 10.0, tvOS 10.0, *)
fileprivate final class CollectionViewPrefetchDataSourceNotSet
private final class CollectionViewPrefetchDataSourceNotSet
: NSObject
, UICollectionViewDataSourcePrefetching {

Expand Down Expand Up @@ -48,7 +48,7 @@ open class RxCollectionViewDataSourcePrefetchingProxy
self.register { RxCollectionViewDataSourcePrefetchingProxy(collectionView: $0) }
}

fileprivate var _prefetchItemsPublishSubject: PublishSubject<[IndexPath]>?
private var _prefetchItemsPublishSubject: PublishSubject<[IndexPath]>?

/// Optimized version used for observing prefetch items callbacks.
internal var prefetchItemsPublishSubject: PublishSubject<[IndexPath]> {
Expand Down
4 changes: 2 additions & 2 deletions RxCocoa/iOS/Proxies/RxCollectionViewDataSourceProxy.swift
Expand Up @@ -15,9 +15,9 @@ extension UICollectionView: HasDataSource {
public typealias DataSource = UICollectionViewDataSource
}

fileprivate let collectionViewDataSourceNotSet = CollectionViewDataSourceNotSet()
private let collectionViewDataSourceNotSet = CollectionViewDataSourceNotSet()

fileprivate final class CollectionViewDataSourceNotSet
private final class CollectionViewDataSourceNotSet
: NSObject
, UICollectionViewDataSource {

Expand Down
4 changes: 2 additions & 2 deletions RxCocoa/iOS/Proxies/RxScrollViewDelegateProxy.swift
Expand Up @@ -38,8 +38,8 @@ open class RxScrollViewDelegateProxy
self.register { RxTextViewDelegateProxy(textView: $0) }
}

fileprivate var _contentOffsetBehaviorSubject: BehaviorSubject<CGPoint>?
fileprivate var _contentOffsetPublishSubject: PublishSubject<()>?
private var _contentOffsetBehaviorSubject: BehaviorSubject<CGPoint>?
private var _contentOffsetPublishSubject: PublishSubject<()>?

/// Optimized version used for observing content offset changes.
internal var contentOffsetBehaviorSubject: BehaviorSubject<CGPoint> {
Expand Down
Expand Up @@ -17,10 +17,10 @@ extension UITableView: HasPrefetchDataSource {
}

@available(iOS 10.0, tvOS 10.0, *)
fileprivate let tableViewPrefetchDataSourceNotSet = TableViewPrefetchDataSourceNotSet()
private let tableViewPrefetchDataSourceNotSet = TableViewPrefetchDataSourceNotSet()

@available(iOS 10.0, tvOS 10.0, *)
fileprivate final class TableViewPrefetchDataSourceNotSet
private final class TableViewPrefetchDataSourceNotSet
: NSObject
, UITableViewDataSourcePrefetching {

Expand Down Expand Up @@ -48,7 +48,7 @@ open class RxTableViewDataSourcePrefetchingProxy
self.register { RxTableViewDataSourcePrefetchingProxy(tableView: $0) }
}

fileprivate var _prefetchRowsPublishSubject: PublishSubject<[IndexPath]>?
private var _prefetchRowsPublishSubject: PublishSubject<[IndexPath]>?

/// Optimized version used for observing prefetch rows callbacks.
internal var prefetchRowsPublishSubject: PublishSubject<[IndexPath]> {
Expand Down
6 changes: 3 additions & 3 deletions RxCocoa/iOS/Proxies/RxTableViewDataSourceProxy.swift
Expand Up @@ -15,9 +15,9 @@ extension UITableView: HasDataSource {
public typealias DataSource = UITableViewDataSource
}

fileprivate let tableViewDataSourceNotSet = TableViewDataSourceNotSet()
private let tableViewDataSourceNotSet = TableViewDataSourceNotSet()

fileprivate final class TableViewDataSourceNotSet
private final class TableViewDataSourceNotSet
: NSObject
, UITableViewDataSource {

Expand Down Expand Up @@ -50,7 +50,7 @@ open class RxTableViewDataSourceProxy
self.register { RxTableViewDataSourceProxy(tableView: $0) }
}

fileprivate weak var _requiredMethodsDataSource: UITableViewDataSource? = tableViewDataSourceNotSet
private weak var _requiredMethodsDataSource: UITableViewDataSource? = tableViewDataSourceNotSet

// MARK: delegate

Expand Down
2 changes: 1 addition & 1 deletion RxCocoa/iOS/UIBarButtonItem+Rx.swift
Expand Up @@ -11,7 +11,7 @@
import UIKit
import RxSwift

fileprivate var rx_tap_key: UInt8 = 0
private var rx_tap_key: UInt8 = 0

extension Reactive where Base: UIBarButtonItem {

Expand Down
4 changes: 2 additions & 2 deletions RxExample/Extensions/CLLocationManager+Rx.swift
Expand Up @@ -207,15 +207,15 @@ extension Reactive where Base: CLLocationManager {
}


fileprivate func castOrThrow<T>(_ resultType: T.Type, _ object: Any) throws -> T {
private func castOrThrow<T>(_ resultType: T.Type, _ object: Any) throws -> T {
guard let returnValue = object as? T else {
throw RxCocoaError.castingError(object: object, targetType: resultType)
}

return returnValue
}

fileprivate func castOptionalOrThrow<T>(_ resultType: T.Type, _ object: Any) throws -> T? {
private func castOptionalOrThrow<T>(_ resultType: T.Type, _ object: Any) throws -> T? {
if NSNull().isEqual(object) {
return nil
}
Expand Down
2 changes: 1 addition & 1 deletion RxExample/Extensions/UIImagePickerController+Rx.swift
Expand Up @@ -39,7 +39,7 @@

#endif

fileprivate func castOrThrow<T>(_ resultType: T.Type, _ object: Any) throws -> T {
private func castOrThrow<T>(_ resultType: T.Type, _ object: Any) throws -> T {
guard let returnValue = object as? T else {
throw RxCocoaError.castingError(object: object, targetType: resultType)
}
Expand Down
2 changes: 1 addition & 1 deletion RxExample/RxDataSources/Differentiator/Diff.swift
Expand Up @@ -8,7 +8,7 @@

import Foundation

fileprivate extension AnimatableSectionModelType {
private extension AnimatableSectionModelType {
init(safeOriginal: Self, safeItems: [Item]) throws {
self.init(original: safeOriginal, items: safeItems)

Expand Down
Expand Up @@ -53,7 +53,7 @@ class GitHubSearchRepositoriesAPI {
// *****************************************************************************************
static let sharedAPI = GitHubSearchRepositoriesAPI(reachabilityService: try! DefaultReachabilityService())

fileprivate let _reachabilityService: ReachabilityService
private let _reachabilityService: ReachabilityService

private init(reachabilityService: ReachabilityService) {
_reachabilityService = reachabilityService
Expand Down Expand Up @@ -94,7 +94,7 @@ extension GitHubSearchRepositoriesAPI {
private static let parseLinksPattern = "\\s*,?\\s*<([^\\>]*)>\\s*;\\s*rel=\"([^\"]*)\""
private static let linksRegex = try! NSRegularExpression(pattern: parseLinksPattern, options: [.allowCommentsAndWhitespace])

fileprivate static func parseLinks(_ links: String) throws -> [String: String] {
private static func parseLinks(_ links: String) throws -> [String: String] {

let length = (links as NSString).length
let matches = GitHubSearchRepositoriesAPI.linksRegex.matches(in: links, options: NSRegularExpression.MatchingOptions(), range: NSRange(location: 0, length: length))
Expand All @@ -119,7 +119,7 @@ extension GitHubSearchRepositoriesAPI {
return result
}

fileprivate static func parseNextURL(_ httpResponse: HTTPURLResponse) throws -> URL? {
private static func parseNextURL(_ httpResponse: HTTPURLResponse) throws -> URL? {
guard let serializedLinks = httpResponse.allHeaderFields["Link"] as? String else {
return nil
}
Expand All @@ -137,7 +137,7 @@ extension GitHubSearchRepositoriesAPI {
return nextUrl
}

fileprivate static func parseJSON(_ httpResponse: HTTPURLResponse, data: Data) throws -> AnyObject {
private static func parseJSON(_ httpResponse: HTTPURLResponse, data: Data) throws -> AnyObject {
if !(200 ..< 300 ~= httpResponse.statusCode) {
throw exampleError("Call failed")
}
Expand Down
Expand Up @@ -10,8 +10,8 @@ import UIKit
import RxSwift
import RxCocoa

fileprivate let minimalUsernameLength = 5
fileprivate let minimalPasswordLength = 5
private let minimalUsernameLength = 5
private let minimalPasswordLength = 5

class SimpleValidationViewController : ViewController {

Expand Down
Expand Up @@ -72,7 +72,7 @@ public class WikipediaSearchCell: UITableViewCell {

}

fileprivate protocol ReusableView: class {
private protocol ReusableView: class {
var disposeBag: DisposeBag? { get }
func prepareForReuse()
}
Expand All @@ -85,7 +85,7 @@ extension CollectionViewImageCell : ReusableView {

}

fileprivate extension ReusableView {
private extension ReusableView {
func installHackBecauseOfAutomationLeaksOnIOS10(firstViewThatDoesntLeak: UIView) {
if #available(iOS 10.0, *) {
if OSApplication.isInUITest {
Expand Down
2 changes: 1 addition & 1 deletion RxExample/RxExample/Feedbacks.swift
Expand Up @@ -281,7 +281,7 @@ extension Observable {
- `events` map events from UI to events of a given system.
*/
public class Bindings<Event>: Disposable {
fileprivate let subscriptions: [Disposable]
private let subscriptions: [Disposable]
fileprivate let events: [Observable<Event>]

/**
Expand Down

0 comments on commit 60a80f0

Please sign in to comment.