| Descriptive and intelligible comprehensive method names contribute a lot to improve the program readability and facilitate software development and maintenance.However,improper method names are common during actual software development,which leads to the reconstruction of method names as the most frequent refactoring operation.Therefore,how to automatically generate accurate method names has become a hot research field,and many method name generation models based on deep learning have proposed.Method name are the extreme summarization of source code,which are much shorter compared to the longer code sequence.Thus,it is very difficult for model to focus on the salient information from complicated code snippet.To tackle the above challenges,we propose two models based on the salient information in source code,which are explicit keywords guided method name generator and implicit salient information modeling method name generator respectively.The intuition of explicit keywords guidance comes from a fact that method name and method body share a lot of common tokens.The approach decomposes the method naming task into keyword extraction task and keywords guided method naming task.Firstly,we construct the code graph based on the structure information in abstract syntax tree and semantic information in code sequence.Then,we develop a GNN based keywords extractor to obtain the keywords set of code snippet.Finally,we propose a graph to sequence model under the keywords guidance to generate accurate method name.The intuition of implicit salient information modeling comes from the information representation and discrimination of code snippet.Firstly,in the information representation step,the approach uses a GNN component to learn the structure and sematic information of code graph.Then,in the information discrimination step,we incorporate a salient information selection component based on code semantics into encoder.Finally,a salient information enhanced attention mechanism is integrated in decoder to improve the precision of copying tokens from input,and at last generate method name.The experiment in real world dataset demonstrates that the two approaches proposed in this paper can effectively pay more attention on the salient information in code snippet,which enables our model outperforms other competitive state-of-the-art models in terms of ROUGE metrics. |