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 inaccur...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.展开更多
基金Project supported by the National Natural Science Foundation of China(Nos.61902181 and 62002161)the China Postdoctoral Science Foundation(No.2020M671489)+1 种基金the CCF-Tencent Open Research Fund(No.RAGR20200106)and the Nanjing University of Aeronautics and Astronautics Postgraduate Research and Practice Innovation Program(No.xcxjh20211612)。
文摘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.