Swift Refactoring - Intro

Introduction to a series of articles detailing how to implement a new type of Swift Local Refactoring.

So you thought about contributing to Swift code base but never knew where and how to start? Well then, Swift Local Refactoring is a very good place to start.

In a series of articles I’ll take you through my experience with implementing a single local Swift refactoring action. The refactoring action I chose as an example is “Collapse Nested If Statements”.

In short, it changes code like thisinto thisThe steps:

P.S.

You may notice that Collapse Nested If Statements refactoring action is already implemented and available in latest versions of Xcode.

A disclaimer though, I did not implement that action, but I surely took learnings from the current implementation.

The major difference between an action currently available in Xcode and the one described in these articles, is that current Xcode’s version collapses only 2 statements at a time, so if you have 3 or more nested statements, you have to repeat the action to collapse them all.

(Reload to play gifs)

Example 1

While the action implemented in these articles collapses all nested if statements at once.

Example 2


Next - Setup

Published: February 01 2019

blog comments powered by Disqus