Skip to content

Commit 37f7493

Browse files
authored
Merge pull request swiftlang#14690 from cwakamo/introducing-CustomPlaygroundDisplayConvertible
This implements SE-0198 by introducing the `CustomPlaygroundDisplayConvertible` protocol and deprecating `PlaygroundQuickLook`/`CustomPlaygroundQuickLookable` in advance of removal from the standard library in the future.
2 parents 01c2c85 + b3d1a83 commit 37f7493

21 files changed

+118
-0
lines changed

stdlib/public/SDK/AppKit/AppKit.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import Foundation
1414
@_exported import AppKit
1515

1616
extension NSCursor : _DefaultCustomPlaygroundQuickLookable {
17+
@available(*, deprecated, message: "NSCursor._defaultCustomPlaygroundQuickLook will be removed in a future Swift version")
1718
public var _defaultCustomPlaygroundQuickLook: PlaygroundQuickLook {
1819
return .image(image)
1920
}
@@ -24,6 +25,7 @@ internal struct _NSViewQuickLookState {
2425
}
2526

2627
extension NSView : _DefaultCustomPlaygroundQuickLookable {
28+
@available(*, deprecated, message: "NSView._defaultCustomPlaygroundQuickLook will be removed in a future Swift version")
2729
public var _defaultCustomPlaygroundQuickLook: PlaygroundQuickLook {
2830
// if you set NSView.needsDisplay, you can get yourself in a recursive scenario where the same view
2931
// could need to draw itself in order to get a QLObject for itself, which in turn if your code was

stdlib/public/SDK/CoreGraphics/CoreGraphics.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,7 @@ extension CGPoint : CustomReflectable, CustomPlaygroundQuickLookable {
232232
return Mirror(self, children: ["x": x, "y": y], displayStyle: .`struct`)
233233
}
234234

235+
@available(*, deprecated, message: "CGPoint.customPlaygroundQuickLook will be removed in a future Swift version")
235236
public var customPlaygroundQuickLook: PlaygroundQuickLook {
236237
return .point(Double(x), Double(y))
237238
}
@@ -299,6 +300,7 @@ extension CGSize : CustomReflectable, CustomPlaygroundQuickLookable {
299300
displayStyle: .`struct`)
300301
}
301302

303+
@available(*, deprecated, message: "CGSize.customPlaygroundQuickLook will be removed in a future Swift version")
302304
public var customPlaygroundQuickLook: PlaygroundQuickLook {
303305
return .size(Double(width), Double(height))
304306
}
@@ -436,6 +438,7 @@ extension CGRect : CustomReflectable, CustomPlaygroundQuickLookable {
436438
displayStyle: .`struct`)
437439
}
438440

441+
@available(*, deprecated, message: "CGRect.customPlaygroundQuickLook will be removed in a future Swift version")
439442
public var customPlaygroundQuickLook: PlaygroundQuickLook {
440443
return .rectangle(
441444
Double(origin.x), Double(origin.y),

stdlib/public/SDK/Foundation/Date.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,7 @@ extension Date : CustomPlaygroundQuickLookable {
280280
return df.string(from: self)
281281
}
282282

283+
@available(*, deprecated, message: "Date.customPlaygroundQuickLook will be removed in a future Swift version")
283284
public var customPlaygroundQuickLook: PlaygroundQuickLook {
284285
return .text(summary)
285286
}

stdlib/public/SDK/Foundation/NSDate.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ extension NSDate : CustomPlaygroundQuickLookable {
2121
return df.string(from: self as Date)
2222
}
2323

24+
@available(*, deprecated, message: "NSDate.customPlaygroundQuickLook will be removed in a future Swift version")
2425
public var customPlaygroundQuickLook: PlaygroundQuickLook {
2526
return .text(summary)
2627
}

stdlib/public/SDK/Foundation/NSRange.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ extension NSRange : CustomReflectable {
198198
}
199199

200200
extension NSRange : CustomPlaygroundQuickLookable {
201+
@available(*, deprecated, message: "NSRange.customPlaygroundQuickLook will be removed in a future Swift version")
201202
public var customPlaygroundQuickLook: PlaygroundQuickLook {
202203
return .range(Int64(location), Int64(length))
203204
}

stdlib/public/SDK/Foundation/NSString.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ extension NSString {
113113
}
114114

115115
extension NSString : CustomPlaygroundQuickLookable {
116+
@available(*, deprecated, message: "NSString.customPlaygroundQuickLook will be removed in a future Swift version")
116117
public var customPlaygroundQuickLook: PlaygroundQuickLook {
117118
return .text(self as String)
118119
}

stdlib/public/SDK/Foundation/NSURL.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
@_exported import Foundation // Clang module
1414

1515
extension NSURL : CustomPlaygroundQuickLookable {
16+
@available(*, deprecated, message: "NSURL.customPlaygroundQuickLook will be removed in a future Swift version")
1617
public var customPlaygroundQuickLook: PlaygroundQuickLook {
1718
guard let str = absoluteString else { return .text("Unknown URL") }
1819
return .url(str)

stdlib/public/SDK/Foundation/URL.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1202,6 +1202,7 @@ extension NSURL : _HasCustomAnyHashableRepresentation {
12021202
}
12031203

12041204
extension URL : CustomPlaygroundQuickLookable {
1205+
@available(*, deprecated, message: "URL.customPlaygroundQuickLook will be removed in a future Swift version")
12051206
public var customPlaygroundQuickLook: PlaygroundQuickLook {
12061207
return .url(absoluteString)
12071208
}

stdlib/public/SDK/SpriteKit/SpriteKitQuickLooks.swift.gyb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
% for Self in ['SKShapeNode', 'SKSpriteNode', 'SKTextureAtlas', 'SKTexture']:
1616

1717
extension ${Self} : CustomPlaygroundQuickLookable {
18+
@available(*, deprecated, message: "${Self}.customPlaygroundQuickLook will be removed in a future Swift version")
1819
public var customPlaygroundQuickLook: PlaygroundQuickLook {
1920
let data = (self as AnyObject)._copyImageData?() as Data?
2021

stdlib/public/SDK/UIKit/UIKit.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,7 @@ internal struct _UIViewQuickLookState {
231231
}
232232

233233
extension UIView : _DefaultCustomPlaygroundQuickLookable {
234+
@available(*, deprecated, message: "UIView._defaultCustomPlaygroundQuickLook will be removed in a future Swift version")
234235
public var _defaultCustomPlaygroundQuickLook: PlaygroundQuickLook {
235236
if _UIViewQuickLookState.views.contains(self) {
236237
return .view(UIImage())

0 commit comments

Comments
 (0)