I've prototyped something like this in the past using n-grams and it was surprisingly effective. When I think it gets really interesting is if you marry ML/NLP tactics with traditional static code analysis.
So you can imagine the ML engine generating the suggestions with the static analyzer ranking the suggestions intelligently.
It's kind of similar to the original AlphaGo where you have the model generate the potential moves that are then ranked by the Monte Carlo Tree Search algorithm.