Webstorm can do some of what you mention:
https://news.ycombinator.com/item?id=15514285
https://news.ycombinator.com/item?id=15638652
One that knows to keep things DRY and creates a function for me when it sees the same similar code written twice.
Unfortunately this is "sufficiently smart compiler" territory. I'd love to be wrong about that though.