Hacker News new | ask | show | jobs
by fridder 13 days ago
don't LSPs and IDE's help with that?
2 comments

I'm right there with you - prefer classic, deterministic tools wherever possible - but there's a limit. E.g. it's easy to rename a single getter from classic enterprise java `Foo getFoo() {..}` to a modern style `Foo foo() {..}` ... but to rename dozens of getters/setters across hundreds of classes is still tedious.

Even harder would be to update your setters from `void setFoo(Foo f) { this.foo = f; }` to fluent-style `Parent foo(Foo f) { this.foo = f; return this; }` - I'd be surprised if there's an LSP action for that at all. (I'd love to be proven wrong though)

Not sure about LSP, but IntelliJ has had a "structural search and replace" feature for many years, and it can easily handle changes like the one in your second paragraph. It's conceptually like a regex search, but it matches language-specific AST subtrees instead of character sequences.
I've found that for super large but simple refactors, codex and Claude struggle and will just quietly stop doing what you asked it if it's a long running task.

I actually had better luck asking codex to write temporary sed scripts based on the requirements then apply them.

Perhaps, but do they handle all the other aspects of refactoring, too?
Yes, LSPs can supply a variety of refactoring commands (rename, extract to, inline, etc.) that the LSP server can implement directly, deterministically, locally.