In recent years, Neural Machine Translator (NMT) has shown promise in automatically editing source code. Typical NMT based code editor only considers the code that needs to be changed as input and suggests developers with a ranked list of patched code to choose from - where the correct one may not always be at the top of the list. While NMT based code editing systems generate a broad spectrum of plausible patches, the correct one depends on the developers' requirement and often on the context where the patch is applied. Thus, if developers provide some hints, using natural language, or providing patch context, NMT models can benefit from them. As a proof of concept, in this research, we leverage three modalities of information: edit location, edit code context, commit messages (as a proxy of developers' hint in natural language) to automatically generate edits with NMT models. To that end, we build MODIT, a multi-modal NMT based code editing engine. With in-depth investigation and analysis, we show that developers' hint as an input modality can narrow the search space for patches and outperform state-of-the-art models to generate correctly patched code in top-1 position.
翻译:近年来, NealMT 翻译器( NMT ) 在自动编辑源代码中表现出了希望。 典型 NMT 代码编辑器只考虑需要更改的代码作为输入, 并且建议开发者在排序排序的补丁代码列表中做出选择 - 其中正确的代码可能并不总是位于列表的顶端。 虽然基于 NMT 的代码编辑系统生成了广泛的合理补丁, 正确的代码取决于开发者的要求, 并且往往取决于补丁应用的背景。 因此, 如果开发者提供一些提示, 使用自然语言, 或提供补丁背景, NMT 模型可以从中受益。 作为概念的证明, 我们利用三种信息模式: 编辑位置、 编辑代码环境, 承诺信息( 作为开发者自然语言提示的代理) 自动生成 NMT 模型的编辑。 为此, 我们构建了基于多模式的 NMTT 代码编辑引擎。 通过深入的调查和分析, 我们显示开发者作为输入模式的提示可以缩小补丁和超常规状态模型的搜索空间。