Swiftify-Corp / Swiftify

42 stars 24 forks source link

Wrong handling of _ prefix #215

Closed AlexanderJ closed 2 years ago

AlexanderJ commented 2 years ago

If I use the underscore in property names. E.g. _prop and then use _prop somewhere in the code. The double underscore is translated back to swift. However, here it should be change to single (one less underscore) as __prop is only a shorthand for self._prop.

See example: https://swiftify.me/7qawlu

alex-swiftify commented 2 years ago

Related: review the handling of underscores according to this comment.

alex-swiftify commented 2 years ago

Fixed. Converter output:

class PREConverseGoalsContainerViewController {
    var _emptyViewMessage: String?
    var _emptyViewImage: UIImage?
    var _emptyViewLoading = false

    func setupGoals() {
        if !goalsCVC {
            goalsCVC = PREConverseGoalsCollectionViewController()
            goalsCVC.coordinator = self
            goalsCVC.cellWidth = goalCellWidth

            goalsCVC.goalId = goalId
            goalsVM.caseId = caseId
        }

        goalsCVC.displayPlaceholder(withMessage: _emptyViewMessage, image: _emptyViewImage, loading: _emptyViewLoading)

        if goalsCVC.parent == nil {
            addChildViewController(goalsCVC)
            goalButtonsContainerView.addSubview(goalsCVC.view)
            goalsCVC.fitAnchorConstraints(onViewContainer: goalButtonsContainerView)
            goalsCVC.didMove(toParent: self)
        }
        goalsCVC.viewModel = goalsVM

        if String.isNotNilNorEmpty(goalId) && String.isNotNilNorEmpty(caseId) {
            goalsVM.fetchData(forDelegate: goalsCVC, completion: nil)
        }
    }
}