[InterfaceGen] Print abstract accessors in protocols (#19379)

* [InterfaceGen] Print abstract accessors in protocols

This patch slightly cleans up printing accessors and ensures we print
accessors abstractly in protocol context for textual interfaces.

It also removes some assuptions around the FunctionBody callback and
makes them more explicit.

* Print getter and setter for didSet decls

* Test _read and _modify

* Fix logic for skipping willSet/didSet

* Update 'final' test for new getter printing behavior
This commit is contained in:
Harlan
2018-09-20 15:43:01 -07:00
committed by GitHub
parent bbbf02e5f8
commit 8ba8222333
5 changed files with 128 additions and 28 deletions

View File

@@ -135,13 +135,32 @@ struct PrintOptions {
/// \brief Whether to print *any* accessors on properties.
bool PrintPropertyAccessors = true;
/// \brief Whether to print the accessors of a property abstractly,
/// i.e. always as get and set rather than the specific accessors
/// actually used to implement the property.
/// Whether to print the accessors of a property abstractly,
/// i.e. always as:
/// ```
/// var x: Int { get set }
/// ```
/// rather than the specific accessors actually used to implement the
/// property.
///
/// Printing function definitions takes priority over this setting.
bool AbstractAccessors = true;
/// Whether to print a property with only a single getter using the shorthand
/// ```
/// var x: Int { return y }
/// ```
/// vs.
/// ```
/// var x: Int {
/// get { return y }
/// }
/// ```
bool CollapseSingleGetterProperty = true;
/// Whether to print the bodies of accessors in protocol context.
bool PrintAccessorBodiesInProtocols = false;
/// \brief Whether to print type definitions.
bool TypeDefinitions = false;