A Structural Model for Contextual Code Changes

05/27/2020
by   Shaked Brody, et al.
0

We address the problem of predicting edit completions based on a learned model that was trained on past edits. Given a code snippet that is partially edited, our goal is to predict a completion of the edit for the rest of the snippet. We refer to this task as the EditCompletion task and present a novel approach for tackling it. The main idea is to directly represent structural edits. This allows us to model the likelihood of the edit itself, rather than learning the likelihood of the edited code. We represent an edit operation as a path in the program's Abstract Syntax Tree (AST), originating from the source of the edit to the target of the edit. Using this representation, we present a powerful and lightweight neural model for the EditCompletion task. We conduct a thorough evaluation, comparing our approach to a variety of representation and modeling approaches that are driven by multiple strong models such as LSTMs, Transformers, and neural CRFs. Our experiments show that our model achieves a 28 and 2x higher accuracy than syntactic models that learn to generate the edited code, as opposed to modeling the edits directly. Our code, dataset, and trained models are publicly available at https://github.com/tech-srl/c3po/ .

READ FULL TEXT

page 2

page 19

research
06/11/2021

Assessing the Effectiveness of Syntactic Structure to Learn Code Edit Representations

In recent times, it has been shown that one can use code as data to aid ...
research
10/31/2018

Learning to Represent Edits

We introduce the problem of learning distributed representations of edit...
research
01/28/2021

Learning Structural Edits via Incremental Tree Transformations

While most neural generative models generate outputs in a single pass, t...
research
09/30/2019

Structural Language Models of Code

We address the problem of any-code completion - generating a missing pie...
research
03/17/2021

Code Completion by Modeling Flattened Abstract Syntax Trees as Graphs

Code completion has become an essential component of integrated developm...
research
08/02/2021

Learning Domain-Specific Edit Operations from Model Repositories with Frequent Subgraph Mining

Model transformations play a fundamental role in model-driven software d...
research
05/05/2022

Assistive Recipe Editing through Critiquing

There has recently been growing interest in the automatic generation of ...

Please sign up or login with your details

Forgot password? Click here to reset