For Swift files, Xcode should be able to hide non-public implementation details

Originator:waupacalarson
Number:rdar://17764302 Date Originated:7/22/2014
Status:Open Resolved:
Product:Developer Tools Product Version:Xcode 6 beta 4
Classification:Enhancement Reproducible:N/A
 
Swift no longer provides explicit interface files for classes, like Objective-C did. When designing a Swift framework or module, it can be hard to express an interface that's easily readable by users of this framework. Implementation code is in line with the interface for a Swift class, struct, or function. Additionally, with the recent introduction of access control to Swift, private methods or properties are shown alongside public ones.

Xcode may be able to make this a lot more readable by hiding implementation details and elements that are not public within the current target's scope. This could take the form of a visibility toggle like with code folding, and for external modules and sub-projects could even be enabled by default. The parser already understands where implementation details start, and the public visibility of elements, so it should be able to intelligently hide these within the editor.

For example, in the sample code provided with the Xcode beta 4 release notes:

public var text: String
    public var isComplete: Bool
    private(set) var UUID: NSUUID
    public init(text: String, completed: Bool, UUID: NSUUID) {
        self.text = text
        self.isComplete = completed
        self.UUID = UUID
    }
    func refreshIdentity() {
        self.UUID = NSUUID()
    }
    public override func isEqual(object: AnyObject?) -> Bool {
        if let item = object as? ListItem {
            return self.UUID == item.UUID
        }
        return false
    }
}

such a toggle could simplify the display to this:

public var text: String
    public var isComplete: Bool
    public init(text: String, completed: Bool, UUID: NSUUID)

    public override func isEqual(object: AnyObject?) -> Bool 

}

when viewing this framework source as part of a target other than the framework itself. Such a simplified view only exposes the information needed to interface with this framework and its classes, and makes things much more readable for end users of this framework.

Even within the framework target, it might be useful to have some sort of toggle to only expose the publicly available methods and properties for at-a-glance auditing of the framework API.

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!