[stdlib] Deprecated PlaygroundQuickLook and CustomPlaygroundQuickLookable.

Deprecated the `PlaygroundQuickLook` enum and `CustomPlaygroundQuickLookable`
protocol. These are being targeted for removal in Swift 5, so we want to
unconditionally deprecate them now to encourage use of
`CustomPlaygroundDisplayConvertible` instead.

This commit includes deprecated the various `CustomPlaygroundQuickLookable`
conformances across the standard library and overlay libraries.
This commit is contained in:
Connor Wakamo
2018-02-16 14:42:10 -08:00
parent 4c41c12066
commit a2aacd73dd
18 changed files with 24 additions and 0 deletions

View File

@@ -14,6 +14,7 @@ import Foundation
@_exported import AppKit @_exported import AppKit
extension NSCursor : _DefaultCustomPlaygroundQuickLookable { extension NSCursor : _DefaultCustomPlaygroundQuickLookable {
@available(*, deprecated, message: "NSCursor._defaultCustomPlaygroundQuickLook will be removed in a future Swift version")
public var _defaultCustomPlaygroundQuickLook: PlaygroundQuickLook { public var _defaultCustomPlaygroundQuickLook: PlaygroundQuickLook {
return .image(image) return .image(image)
} }
@@ -24,6 +25,7 @@ internal struct _NSViewQuickLookState {
} }
extension NSView : _DefaultCustomPlaygroundQuickLookable { extension NSView : _DefaultCustomPlaygroundQuickLookable {
@available(*, deprecated, message: "NSView._defaultCustomPlaygroundQuickLook will be removed in a future Swift version")
public var _defaultCustomPlaygroundQuickLook: PlaygroundQuickLook { public var _defaultCustomPlaygroundQuickLook: PlaygroundQuickLook {
// if you set NSView.needsDisplay, you can get yourself in a recursive scenario where the same view // if you set NSView.needsDisplay, you can get yourself in a recursive scenario where the same view
// could need to draw itself in order to get a QLObject for itself, which in turn if your code was // could need to draw itself in order to get a QLObject for itself, which in turn if your code was

View File

@@ -232,6 +232,7 @@ extension CGPoint : CustomReflectable, CustomPlaygroundQuickLookable {
return Mirror(self, children: ["x": x, "y": y], displayStyle: .`struct`) return Mirror(self, children: ["x": x, "y": y], displayStyle: .`struct`)
} }
@available(*, deprecated, message: "CGPoint.customPlaygroundQuickLook will be removed in a future Swift version")
public var customPlaygroundQuickLook: PlaygroundQuickLook { public var customPlaygroundQuickLook: PlaygroundQuickLook {
return .point(Double(x), Double(y)) return .point(Double(x), Double(y))
} }
@@ -299,6 +300,7 @@ extension CGSize : CustomReflectable, CustomPlaygroundQuickLookable {
displayStyle: .`struct`) displayStyle: .`struct`)
} }
@available(*, deprecated, message: "CGSize.customPlaygroundQuickLook will be removed in a future Swift version")
public var customPlaygroundQuickLook: PlaygroundQuickLook { public var customPlaygroundQuickLook: PlaygroundQuickLook {
return .size(Double(width), Double(height)) return .size(Double(width), Double(height))
} }
@@ -436,6 +438,7 @@ extension CGRect : CustomReflectable, CustomPlaygroundQuickLookable {
displayStyle: .`struct`) displayStyle: .`struct`)
} }
@available(*, deprecated, message: "CGRect.customPlaygroundQuickLook will be removed in a future Swift version")
public var customPlaygroundQuickLook: PlaygroundQuickLook { public var customPlaygroundQuickLook: PlaygroundQuickLook {
return .rectangle( return .rectangle(
Double(origin.x), Double(origin.y), Double(origin.x), Double(origin.y),

View File

@@ -280,6 +280,7 @@ extension Date : CustomPlaygroundQuickLookable {
return df.string(from: self) return df.string(from: self)
} }
@available(*, deprecated, message: "Date.customPlaygroundQuickLook will be removed in a future Swift version")
public var customPlaygroundQuickLook: PlaygroundQuickLook { public var customPlaygroundQuickLook: PlaygroundQuickLook {
return .text(summary) return .text(summary)
} }

View File

@@ -21,6 +21,7 @@ extension NSDate : CustomPlaygroundQuickLookable {
return df.string(from: self as Date) return df.string(from: self as Date)
} }
@available(*, deprecated, message: "NSDate.customPlaygroundQuickLook will be removed in a future Swift version")
public var customPlaygroundQuickLook: PlaygroundQuickLook { public var customPlaygroundQuickLook: PlaygroundQuickLook {
return .text(summary) return .text(summary)
} }

View File

@@ -198,6 +198,7 @@ extension NSRange : CustomReflectable {
} }
extension NSRange : CustomPlaygroundQuickLookable { extension NSRange : CustomPlaygroundQuickLookable {
@available(*, deprecated, message: "NSRange.customPlaygroundQuickLook will be removed in a future Swift version")
public var customPlaygroundQuickLook: PlaygroundQuickLook { public var customPlaygroundQuickLook: PlaygroundQuickLook {
return .range(Int64(location), Int64(length)) return .range(Int64(location), Int64(length))
} }

View File

@@ -113,6 +113,7 @@ extension NSString {
} }
extension NSString : CustomPlaygroundQuickLookable { extension NSString : CustomPlaygroundQuickLookable {
@available(*, deprecated, message: "NSString.customPlaygroundQuickLook will be removed in a future Swift version")
public var customPlaygroundQuickLook: PlaygroundQuickLook { public var customPlaygroundQuickLook: PlaygroundQuickLook {
return .text(self as String) return .text(self as String)
} }

View File

@@ -13,6 +13,7 @@
@_exported import Foundation // Clang module @_exported import Foundation // Clang module
extension NSURL : CustomPlaygroundQuickLookable { extension NSURL : CustomPlaygroundQuickLookable {
@available(*, deprecated, message: "NSURL.customPlaygroundQuickLook will be removed in a future Swift version")
public var customPlaygroundQuickLook: PlaygroundQuickLook { public var customPlaygroundQuickLook: PlaygroundQuickLook {
guard let str = absoluteString else { return .text("Unknown URL") } guard let str = absoluteString else { return .text("Unknown URL") }
return .url(str) return .url(str)

View File

@@ -1202,6 +1202,7 @@ extension NSURL : _HasCustomAnyHashableRepresentation {
} }
extension URL : CustomPlaygroundQuickLookable { extension URL : CustomPlaygroundQuickLookable {
@available(*, deprecated, message: "URL.customPlaygroundQuickLook will be removed in a future Swift version")
public var customPlaygroundQuickLook: PlaygroundQuickLook { public var customPlaygroundQuickLook: PlaygroundQuickLook {
return .url(absoluteString) return .url(absoluteString)
} }

View File

@@ -15,6 +15,7 @@
% for Self in ['SKShapeNode', 'SKSpriteNode', 'SKTextureAtlas', 'SKTexture']: % for Self in ['SKShapeNode', 'SKSpriteNode', 'SKTextureAtlas', 'SKTexture']:
extension ${Self} : CustomPlaygroundQuickLookable { extension ${Self} : CustomPlaygroundQuickLookable {
@available(*, deprecated, message: "${Self}.customPlaygroundQuickLook will be removed in a future Swift version")
public var customPlaygroundQuickLook: PlaygroundQuickLook { public var customPlaygroundQuickLook: PlaygroundQuickLook {
let data = (self as AnyObject)._copyImageData?() as Data? let data = (self as AnyObject)._copyImageData?() as Data?

View File

@@ -231,6 +231,7 @@ internal struct _UIViewQuickLookState {
} }
extension UIView : _DefaultCustomPlaygroundQuickLookable { extension UIView : _DefaultCustomPlaygroundQuickLookable {
@available(*, deprecated, message: "UIView._defaultCustomPlaygroundQuickLook will be removed in a future Swift version")
public var _defaultCustomPlaygroundQuickLook: PlaygroundQuickLook { public var _defaultCustomPlaygroundQuickLook: PlaygroundQuickLook {
if _UIViewQuickLookState.views.contains(self) { if _UIViewQuickLookState.views.contains(self) {
return .view(UIImage()) return .view(UIImage())

View File

@@ -662,6 +662,7 @@ internal extension Mirror {
/// The sum of types that can be used as a Quick Look representation. /// The sum of types that can be used as a Quick Look representation.
@_fixed_layout // FIXME(sil-serialize-all) @_fixed_layout // FIXME(sil-serialize-all)
@available(*, deprecated, message: "PlaygroundQuickLook will be removed in a future Swift version. For customizing how types are presented in playgrounds, use CustomPlaygroundDisplayConvertible instead.")
public enum PlaygroundQuickLook { public enum PlaygroundQuickLook {
/// Plain text. /// Plain text.
case text(String) case text(String)
@@ -748,6 +749,7 @@ extension PlaygroundQuickLook {
/// - Parameter subject: The instance to represent with the resulting Quick /// - Parameter subject: The instance to represent with the resulting Quick
/// Look. /// Look.
@_inlineable // FIXME(sil-serialize-all) @_inlineable // FIXME(sil-serialize-all)
@available(*, deprecated, message: "PlaygroundQuickLook will be removed in a future Swift version.")
public init(reflecting subject: Any) { public init(reflecting subject: Any) {
if let customized = subject as? CustomPlaygroundQuickLookable { if let customized = subject as? CustomPlaygroundQuickLookable {
self = customized.customPlaygroundQuickLook self = customized.customPlaygroundQuickLook
@@ -773,6 +775,7 @@ extension PlaygroundQuickLook {
/// with the representation supplied for your type by default, you can make it /// with the representation supplied for your type by default, you can make it
/// conform to the `CustomPlaygroundQuickLookable` protocol and provide a /// conform to the `CustomPlaygroundQuickLookable` protocol and provide a
/// custom `PlaygroundQuickLook` instance. /// custom `PlaygroundQuickLook` instance.
@available(*, deprecated, message: "CustomPlaygroundQuickLookable will be removed in a future Swift version. For customizing how types are presented in playgrounds, use CustomPlaygroundDisplayConvertible instead.")
public protocol CustomPlaygroundQuickLookable { public protocol CustomPlaygroundQuickLookable {
/// A custom playground Quick Look for this instance. /// A custom playground Quick Look for this instance.
/// ///
@@ -784,6 +787,7 @@ public protocol CustomPlaygroundQuickLookable {
// A workaround for <rdar://problem/26182650> // A workaround for <rdar://problem/26182650>
// FIXME(ABI)#50 (Dynamic Dispatch for Class Extensions) though not if it moves out of stdlib. // FIXME(ABI)#50 (Dynamic Dispatch for Class Extensions) though not if it moves out of stdlib.
@available(*, deprecated, message: "_DefaultCustomPlaygroundQuickLookable will be removed in a future Swift version. For customizing how types are presented in playgrounds, use CustomPlaygroundDisplayConvertible instead.")
public protocol _DefaultCustomPlaygroundQuickLookable { public protocol _DefaultCustomPlaygroundQuickLookable {
var _defaultCustomPlaygroundQuickLook: PlaygroundQuickLook { get } var _defaultCustomPlaygroundQuickLook: PlaygroundQuickLook { get }
} }

View File

@@ -48,6 +48,7 @@ extension ${Type[0]} : CustomReflectable {
extension ${Type[0]} : CustomPlaygroundQuickLookable { extension ${Type[0]} : CustomPlaygroundQuickLookable {
/// A custom playground Quick Look for the `${Type[0]}` instance. /// A custom playground Quick Look for the `${Type[0]}` instance.
@_inlineable // FIXME(sil-serialize-all) @_inlineable // FIXME(sil-serialize-all)
@available(*, deprecated, message: "${Type[0]}.customPlaygroundQuickLook will be removed in a future Swift version")
public var customPlaygroundQuickLook: PlaygroundQuickLook { public var customPlaygroundQuickLook: PlaygroundQuickLook {
return ${Type[1]}(${Type[2]}) return ${Type[1]}(${Type[2]})
} }

View File

@@ -447,6 +447,7 @@ extension String.UTF16View : CustomReflectable {
extension String.UTF16View : CustomPlaygroundQuickLookable { extension String.UTF16View : CustomPlaygroundQuickLookable {
@_inlineable // FIXME(sil-serialize-all) @_inlineable // FIXME(sil-serialize-all)
@available(*, deprecated, message: "UTF16View.customPlaygroundQuickLook will be removed in a future Swift version")
public var customPlaygroundQuickLook: PlaygroundQuickLook { public var customPlaygroundQuickLook: PlaygroundQuickLook {
return .text(description) return .text(description)
} }

View File

@@ -634,6 +634,7 @@ extension String.UTF8View : CustomReflectable {
extension String.UTF8View : CustomPlaygroundQuickLookable { extension String.UTF8View : CustomPlaygroundQuickLookable {
@_inlineable // FIXME(sil-serialize-all) @_inlineable // FIXME(sil-serialize-all)
@available(*, deprecated, message: "UTF8View.customPlaygroundQuickLook will be removed in a future Swift version")
public var customPlaygroundQuickLook: PlaygroundQuickLook { public var customPlaygroundQuickLook: PlaygroundQuickLook {
return .text(description) return .text(description)
} }

View File

@@ -544,6 +544,7 @@ extension String.UnicodeScalarView : CustomReflectable {
extension String.UnicodeScalarView : CustomPlaygroundQuickLookable { extension String.UnicodeScalarView : CustomPlaygroundQuickLookable {
@_inlineable // FIXME(sil-serialize-all) @_inlineable // FIXME(sil-serialize-all)
@available(*, deprecated, message: "UnicodeScalarView.customPlaygroundQuickLook will be removed in a future Swift version")
public var customPlaygroundQuickLook: PlaygroundQuickLook { public var customPlaygroundQuickLook: PlaygroundQuickLook {
return .text(description) return .text(description)
} }

View File

@@ -338,6 +338,7 @@ extension Substring : CustomReflectable {
extension Substring : CustomPlaygroundQuickLookable { extension Substring : CustomPlaygroundQuickLookable {
@_inlineable // FIXME(sil-serialize-all) @_inlineable // FIXME(sil-serialize-all)
@available(*, deprecated, message: "Substring.customPlaygroundQuickLook will be removed in a future Swift version")
public var customPlaygroundQuickLook: PlaygroundQuickLook { public var customPlaygroundQuickLook: PlaygroundQuickLook {
return String(self).customPlaygroundQuickLook return String(self).customPlaygroundQuickLook
} }

View File

@@ -1004,6 +1004,7 @@ extension ${Self} : CustomPlaygroundQuickLookable {
} }
@_inlineable // FIXME(sil-serialize-all) @_inlineable // FIXME(sil-serialize-all)
@available(*, deprecated, message: "${Self}.customPlaygroundQuickLook will be removed in a future Swift version")
public var customPlaygroundQuickLook: PlaygroundQuickLook { public var customPlaygroundQuickLook: PlaygroundQuickLook {
return .text(summary) return .text(summary)
} }

View File

@@ -996,6 +996,7 @@ extension Unsafe${Mutable}RawPointer : CustomReflectable {
extension Unsafe${Mutable}RawPointer : CustomPlaygroundQuickLookable { extension Unsafe${Mutable}RawPointer : CustomPlaygroundQuickLookable {
@_inlineable // FIXME(sil-serialize-all) @_inlineable // FIXME(sil-serialize-all)
@_versioned // FIXME(sil-serialize-all) @_versioned // FIXME(sil-serialize-all)
@available(*, deprecated, message: "Unsafe${Mutable}RawPointer.customPlaygroundQuickLook will be removed in a future Swift version")
internal var summary: String { internal var summary: String {
let selfType = "${Self}" let selfType = "${Self}"
let ptrValue = UInt64( let ptrValue = UInt64(