Publishing Service

Polishing & Checking

Frontiers of Information Technology & Electronic Engineering

ISSN 2095-9184 (print), ISSN 2095-9230 (online)

Toward an accurate method renaming approach via structural and lexical analyses

Abstract: Methods in programs must be accurately named to facilitate source code analysis and comprehension. With the evolution of software, method names may be inconsistent with their implemented method bodies, leading to inaccurate or buggy method names. Debugging method names remains an important topic in the literature. Although researchers have proposed several approaches to suggest accurate method names once the method bodies have been modified, two main drawbacks remain to be solved: there is no analysis of method name structure, and the programming context information is not captured efficiently. To resolve these drawbacks and suggest more accurate method names, we propose a novel automated approach based on the analysis of the method name structure and lexical analysis with the programming context information. Our approach first leverages deep feature representation to embed method names and method bodies in vectors. Then, it obtains useful verb-tokens from a large method corpus through structural analysis and noun-tokens from method bodies through lexical analysis. Finally, our approach dynamically combines these tokens to form and recommend high-quality and project-specific method names. Experimental results over 2111 Java testing methods show that the proposed approach can achieve a Hit Ratio, or Hit@5, of 33.62% and outperform the state-of-the-art approach by 14.12% in suggesting accurate method names. We also demonstrate the effectiveness of structural and lexical analyses in our approach.

Key words: Method renaming; Code refactor; Deep learning; Convolutional neural networks

Chinese Summary  <21> 一种基于结构和词汇分析的精确重命名方法

骆君鹏1,张静宣1,2,黄志球1,徐勇3,孙辰星3
1南京航空航天大学计算机科学与技术学院,中国南京市,211106
2软件新技术与产业化协同创新中心,中国南京市,210023
3腾讯科技有限公司(深圳),中国深圳市,518054
摘要:程序中的方法必须准确命名,以便于源代码分析和理解。随着软件的演变,方法名称可能与其实现的方法体不一致,导致方法名称不准确或有缺陷。调试方法名称仍然是文献中的一个重要主题。尽管研究人员已提出一些方法,用于在方法体被修改后给出准确的方法名称建议,但有两个主要不足仍待解决:对方法名称结构未加以分析,且未能有效捕获编程环境上下文信息。为避免上述不足,并给出更准确的方法名称建议,提出一种基于方法名称结构分析和编程上下文信息词法分析的新颖自动化方法。首先,利用深层特征表示,将方法名称和方法体嵌入向量中;然后,通过结构分析从大型方法语料库中获取有用的动词标记,通过词汇分析从方法体中获取名词标记;最后,动态结合这些标记,形成并推荐高质量和特定于项目的方法名称。在2111个Java测试方法上的实验结果表明,所提方法可以达到33.62%的命中率(Hit@5),并且在建议准确方法名称方面比最先进的方法高出14.12%。此外,展示了所提方法对结构和词汇分析的有效性。

关键词组:方法重命名;代码重构;深度学习;卷积神经网络


Share this article to: More

Go to Contents

References:

<Show All>

Open peer comments: Debate/Discuss/Question/Opinion

<1>

Please provide your name, email address and a comment





DOI:

10.1631/FITEE.2100470

CLC number:

TP311

Download Full Text:

Click Here

Downloaded:

1706

Download summary:

<Click Here> 

Downloaded:

329

Clicked:

2080

Cited:

0

On-line Access:

2022-05-19

Received:

2021-09-30

Revision Accepted:

2022-05-19

Crosschecked:

2022-02-28

Journal of Zhejiang University-SCIENCE, 38 Zheda Road, Hangzhou 310027, China
Tel: +86-571-87952276; Fax: +86-571-87952331; E-mail: jzus@zju.edu.cn
Copyright © 2000~ Journal of Zhejiang University-SCIENCE