HACKER Q&A
📣 dmortin

Why are there no powerful free refactoring libraries for text editors?


Editors like Emacs, VI, etc. are great, but IDEs can do much for you if they know the language more intimately like IntelliJ knows Java.

But why are there no free alternatives for refactoring? Is there some difficult technical problem?

If we consider, for example, Java and refactoring then Rename Variable, Extract Method and similar features do not look very hard to implement. There are libraries for parsing Java and if we have the syntax tree then it's just a matter of performing the modifications on it.

Parsing broken code may be a challenge, but a powerful refactoring library would be very helpful even if it could work only on compilable code. Text editors could just call the library and reload the source files after the refactoring is done.

LSP is a step in the good direction by providing completion, jump to definition, etc. Why are there no similar libraries for source code refactorings? What is the difficulty here?


  👤 tobltobs Accepted Answer ✓
Using Emacs or VI for Java is something for masochists. Helping them with refactoring support would take away their fun/pain. Doesn't use the Java LSP the Eclipse IDE? Maybe it would just be easier to configure your IDE like emacs.

👤 whb07
You are mainly talking about compile time checking. But due to the weak types in Java, you’ll end up with uncaught compile and runtime errors.

I’d look into a strong type system like Haskell, F#, shoot even Rust will help in large refactorings being easier