Learning and remembering to use APIs are difficult. Several techniques have been proposed to assist developers in using APIs. Most existing techniques focus on recommending the right API methods to call, but very few techniques focus on recommending API arguments. In this paper, we propose ARIST, a novel automated argument recommendation approach which suggests arguments by predicting developers' expectations when they define and use API methods. To implement this idea in the recommendation process, ARIST combines program analysis (PA), language models (LMs), and several features specialized for the recommendation task which consider the functionality of formal parameters and the positional information of code elements (e.g., variables or method calls) in the given context. In ARIST, the LMs and the recommending features are used to suggest the promising candidates identified by PA. Meanwhile, PA navigates the LMs and the features working on the set of the valid candidates which satisfy syntax, accessibility, and type-compatibility constraints defined by the programming language in use. Our evaluation on a large dataset of real-world projects shows that ARIST improves the state-of-the-art approach by 19% and 18% in top-1 precision and recall for recommending arguments of frequently-used libraries. For general argument recommendation task, i.e., recommending arguments for every method call, ARIST outperforms the baseline approaches by up to 125% top-1 accuracy. Moreover, for newly-encountered projects, ARIST achieves more than 60% top-3 accuracy when evaluating on a larger dataset. For working/maintaining projects, with a personalized LM to capture developers' coding practice, ARIST can productively rank the expected arguments at the top-1 position in 7/10 requests.
翻译:学习和记忆如何使用API是一项困难的任务。已有多种技术被提出以帮助开发者使用API,但现有大多数技术集中于推荐正确的API方法调用,而极少有技术专注于推荐API参数。本文提出ARIST,一种新颖的自动化参数推荐方法,通过预测开发者在定义和使用API方法时的预期来推荐参数。为实现这一思想,ARIST在推荐过程中结合了程序分析(PA)、语言模型(LM)以及若干专为推荐任务设计的特征,这些特征考虑了形式参数的功能性以及给定上下文中代码元素(如变量或方法调用)的位置信息。在ARIST中,LM和推荐特征用于筛选PA识别出的有潜力候选参数;同时,PA引导LM和推荐特征在满足编程语言定义的语法、可访问性和类型兼容性约束的有效候选参数集合上运行。我们在大型真实项目数据集上的评估表明,对于常用库的参数推荐,ARIST在top-1精确率和召回率上分别比现有最先进方法提高了19%和18%。对于通用参数推荐任务(即为每次方法调用推荐参数),ARIST在top-1准确率上比基线方法最高提升125%。此外,针对新接触的项目,在更大数据集上评估时,ARIST的top-3准确率超过60%。对于正在维护或持续开发的项目,通过个性化LM捕捉开发者的编码习惯,ARIST能在7/10的请求中将预期参数高效地排在top-1位置。