Research of possibilities of default refactoring actions in Swift language
DOI:
https://doi.org/10.15587/2706-5448.2022.266061Keywords:
Swift programming language, refactoring, open-source code, sourcekit componentAbstract
The object of research in the paper is a built-in refactoring mechanism in the Swift programming language. Swift has gained a lot of popularity recently, which is why there are many new challenges associated with the need to support and modify the source code written in this programming language. The problem is that the more powerful refactoring mechanism that can be applied to Swift is proprietary and cannot be used by other software. Moreover, even closed-source refactoring software tools are not capable of performing more complex queries.
To explore the possibilities of expanding the built-in refactoring, it is suggested to investigate the software implementation of the sourcekit component of the Swift programming language, which is responsible for working with «raw» source code, and to implement new refactoring action in practice. To implement the research plan, one refactoring activity that was not present in the refactoring utilities (adding an implementation of the Equatable protocol) was chosen. Its implementation was developed using the components and resources provided within the sourcekit component. To check the correctness and compliance with the development conditions, several tests were created and conducted.
It has been discovered that both refactoring mechanisms supported by the Swift programming language have a limited context and a limited scope and application. That is why the possibility of expanding the functionality should not be based on the local level of code processing, but on the upper level, where it is possible to combine several source files, which often happens in projects. The work was directed to the development of the own refactoring action to analyze and obtain a perfect representation of the advantages and disadvantages of the existing component. As a result, a new approach to refactoring was proposed, which will allow solving the problems described above.
References
- Sandoval Alcocer, J. P., Siles Antezana, A., Santos, G., Bergel, A. (2020). Improving the success rate of applying the extract method refactoring. Science of Computer Programming, 195, 102475. https://doi.org/10.1016/j.scico.2020.102475
- Kaur, G., Singh, B. (2017). Improving the quality of software by refactoring. 2017 International Conference on Intelligent Computing and Control Systems (ICICCS), 185–191.
- Saca, M. A. (2017). Refactoring improving the design of existing code. 2017 IEEE 37th Central America and Panama Convention (CONCAPAN XXXVII). doi: https://doi.org/10.1109/concapan.2017.8278488
- Simmonds, J. (2002). A Comparison of Software Refactoring Tools. Available at: https://www.researchgate.net/publication/2946408_A_Comparison_of_Software_Refactoring_Tools
- Chouchen, M., Olongo, J., Ouni, A., Mkaouer, M. W. (2021). Predicting Code Review Completion Time in Modern Code Review. ArXiv. doi: https://doi.org/10.48550/arXiv.2109.15141
- Inoue, K., Roy. C. K. (2021). Code Clone Analysis. Singapore: Springer. doi: https://doi.org/10.1007/978-981-16-1927-4
- Swift Issues. Available at: https://github.com/apple/swift/issues/
- Lacerda, G., Petrillo, F., Pimenta, M. S., Guéhéneuc, Y. (2020). Code Smells and Refactoring: A Tertiary Systematic Review of Challenges and Observations. ArXiv. doi: https://doi.org/10.48550/arXiv.2004.10777
- Swift Local Refactoring. Available at: https://swift.org/blog/swift-local-refactoring/
- Improving Swift Tools with libSyntax. Available at: https://academy.realm.io/posts/improving-swift-tools-with-libsyntax-try-swift-haskin-2017/
Downloads
Published
How to Cite
Issue
Section
License
Copyright (c) 2022 Andrii Tkachuk, Bogdan Bulakh
This work is licensed under a Creative Commons Attribution 4.0 International License.
The consolidation and conditions for the transfer of copyright (identification of authorship) is carried out in the License Agreement. In particular, the authors reserve the right to the authorship of their manuscript and transfer the first publication of this work to the journal under the terms of the Creative Commons CC BY license. At the same time, they have the right to conclude on their own additional agreements concerning the non-exclusive distribution of the work in the form in which it was published by this journal, but provided that the link to the first publication of the article in this journal is preserved.