Researchers from Google Brain have proposed a method for predicting code from previous edits. The novel method, based on deep neural networks is able to learn a sequence of code edits which can then be used as a generative model.
Arguing that previous methods i.e. generative models tacking this problem have been framed in terms of generating static code, researchers propose a novel method that treats source code a dynamic object.
In fact, their idea was to model the intent of the developers between subsequent code edits and by doing so to be able to learn challenging edit patterns.
To do so, they introduce two representations: explicit representations, which instantiate edits in the sequence and implicit representations which instantiate subsequent edits. Then, they trained a number of neural network models taking into account the initial code, the edits, and contexts.
The models were trained both using synthetic data and real data from a Google code base containing more than eight million edits from more than 5000 Python developers. The evaluation showed that the models are able to predict the parts of the code where an edit needs to be made and also they successfully predict the necessary content of those edits.
This work carried by researchers at Google Brain confirmed the feasibility of developing a tool that will fully (or partially) automate the process of source code edits. More in detail about the approach can be read in the official preprint paper published on arxiv.