Custom processing of setter method bodies

Description

Basically we need to avoid the following post-processor mappings:

(see ShouldRedeclareMethodAsPropertyWithSetter unit test).

Suggested implementation:
1) implement in MethodVisitor / VisitMethodDeclaration;
2) check that method is mapped to a property and has a

accessor, i.e.

3) For a setter method, wrap the implementation inside a `didSet {}` accessor, and add indentation accordingly.

Environment

None

Activity

Show:
Alex Petuschak
June 22, 2018, 9:04 AM
Edited

In the default macOS app template, here is the Objective-C declaration:

... and here is the corresponding Swift declaration:

However, after completing this task, here is the version produced by Swiftify:

Rationale: while a version with `willSet` / `didSet` accessors will look nicer, this requires detecting the code to set the superclass property, and splitting the setter method body "before" / "after" this code into `willSet` / `didSet` accessors (which is more difficult and error prone compared to the current solution).

Assignee

Alex Petuschak

Reporter

Alex Petuschak

Labels

None

Git Branch Name

None

GitHub Issue

None

Components

Fix versions

Priority

High
Configure