
Ask HN: Why are there no powerful free refactoring libraries for text editors? - dmortin
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.<p>But why are there no free alternatives for refactoring? Is there some difficult technical problem?<p>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&#x27;s just a matter of performing the modifications on it.<p>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.<p>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
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.

~~~
dmortin
Unlike VIM people don't use emacs for the keybindings, so you can't just
configure the IDE to work like emacs, because IDEs do not have those features
(e.g. creating quick throwaway functions for some current task which can be
inserted into the editor live, without restarting, etc.)

If Emacs has access to a refactoring library and completions via LSP then it
could have the strength of Emacs combined with the strong language support of
IDEs. I'm saying this as a long time Emacs user who also used Android Studio a
lot for Java programming, so I can appreciate the fortes of both sides of the
fence.

------
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

~~~
dmortin
I did not talk about compile time checking, but refactoring, making assisted
transformations on the source code.

~~~
whb07
Ok at what point does this occur, pre runtime or during runtime ?

~~~
dmortin
When you edit the source code, so pre compilation, pre running. Refactoring is
a tool to automate manual editing.

