-
Notifications
You must be signed in to change notification settings - Fork 131
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Provide ConvertService with mapping of USRs to minimal access level r…
…equired for extended documentation to be available rdar://105460209
- Loading branch information
1 parent
88d0fd6
commit 06cb3d9
Showing
12 changed files
with
349 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
This source file is part of the Swift.org open source project | ||
|
||
Copyright (c) 2023 Apple Inc. and the Swift project authors | ||
Licensed under Apache License v2.0 with Runtime Library Exception | ||
|
||
See https://swift.org/LICENSE.txt for license information | ||
See https://swift.org/CONTRIBUTORS.txt for Swift project authors | ||
*/ | ||
|
||
import Foundation | ||
|
||
/// Defines semantic access control levels for symbols | ||
public struct AccessControlLevel: CustomStringConvertible, Codable { | ||
private let rawValue: String | ||
|
||
public var description: String { rawValue } | ||
|
||
public init(_ accessLevel: String) { self.rawValue = accessLevel } | ||
|
||
/// Represents private access level, which normally indicates the symbol is only available in the scope in which it's defined. | ||
public static let `private` = Self.init("private") | ||
/// Represents fileprivate access level, which normally indicates the symbol is only available in the file that defines it. | ||
public static let `fileprivate` = Self.init("fileprivate") | ||
/// Represents internal access level, which normally indicates the symbol is only available in the module that defines it. | ||
public static let `internal` = Self.init("internal") | ||
/// Represents public access level, which normally indicates the symbol is available to clients. | ||
public static let `public` = Self.init("public") | ||
/// Represents open access level, which normally indicates the symbol is extensible and overridable by clients. | ||
public static let `open` = Self.init("open") | ||
} | ||
|
||
extension AccessControlLevel: Comparable { | ||
private var level: UInt? { | ||
switch self { | ||
case .private : return 1 | ||
case .fileprivate: return 2 | ||
case .internal: return 3 | ||
case .public: return 4 | ||
case .open: return 5 | ||
default: | ||
assertionFailure("Unknown access control level was (with representation \(description)) used in comparison") | ||
return nil | ||
} | ||
} | ||
|
||
/// Compares the restrictiveness of access control levels. | ||
public static func < (lhs: Self, rhs: Self) -> Bool { | ||
let lhsLevel = lhs.level ?? .min | ||
let rhsLevel = rhs.level ?? .min | ||
return lhsLevel < rhsLevel | ||
} | ||
} |
Oops, something went wrong.