General s-expression refactoring framework
Common Lisp is an extremely complicated language to statically (or just at read time) determine where a symbol is located, or if that is indeed correct, so refactoring utilities are very primitive (most of the time) even the mighty SLIME doesn't even have one.
There are other languages that have IDEs that are really good with this task (Intellij with Java for example) they are able to replace expressions in every corner of the code base and have a lot of utilities to manage complex code structures.
This can be done mostly because JetBrains has some of the most advance static analyzers for Java in the industry (thanks in part of the amount of money they are able to gather).
So, my idea here is to present a roadmap to write a Refactoring Framework that with the help of contextual and static information can apply a range of common code manipulation. The main target of this project would be of course Common Lisp, but the core idea is that it should be able to get extensible to more s-expression base languages (so a common interface).
I think we can also separate two kind of refactoring utilities:
- local context: They work on a local-context, so parsing it it usually easier.
- dynamic context: They work with a whole system (in the case of Lisp, the entire image) and the changes can be catastrophic if doing incorrectly.
This is an arbitrary separation, and usually some refactoring involve a mix of both, so, specifically for CL I think we can start with the first one.
Helpful links:
- https://github.com/s-expressionists/Eclector#concrete-syntax-trees
- https://github.com/s-expressionists/editing-requirements
- https://github.com/Wilfred/emacs-refactor
- https://github.com/scymtym/s-expression-syntax
- https://github.com/hyotang666/null-package
(JetBrain refactor for reference https://www.jetbrains.com/help/idea/refactoring-source-code.html#refactoring_invoke )
This is a very good perspective. We will be able to offer more value by completing this feature.
see also https://github.com/fstamour/breeze/ It currently has a lossless parser (keeps comments) and helpers: insert a defpackage, insert a test, etc (https://github.com/fstamour/breeze/blob/master/tests/refactor.lisp not proper refactoring yet).