一句话:提出 APIZATOR,用静态分析自动将 StackOverflow 代码片段转化为含参数与返回值的方法声明。
StackOverflow 等开发者论坛已成为现代软件开发的重要资源,但其中的代码片段往往缺少完整的方法声明,直接复用并不现实:开发者必须手动将变量参数化并确定返回值,这一过程被称为代码片段的 APIzation,既繁琐又耗时。本文提出 APIZATOR,用于自动完成 JAVA 代码片段的 APIzation。作者通过研究 GitHub 上真实的 APIzation 提炼出四种常见模式,并据此设计了一个静态分析算法,自动提取方法参数与 return 语句。评估采用 20 名开发者标注的 200 个 APIzation 作为 ground truth:在 113 个(56.50%)和 115 个(57.50%)案例中,APIZATOR 提取的参数与返回值分别与开发者完全一致;在 163 个(81.50%)案例中,参数或返回值至少有一项与开发者一致。
Developer forums like StackOverflow have become essential resources to modern software development practices. However, many code snippets lack a well-defined method declaration, and thus they are often incomplete for immediate reuse. Developers must adapt the retrieved code snippets by parameterizing the variables involved and identifying the return value. This activity, which we call APIzation of a code snippet, can be tedious and time-consuming. In this paper, we present APIZATOR to perform APIzations of JAVA code snippets automatically. APIZATOR is grounded by four common patterns that we extracted by studying real APIzations in GitHub. APIZATOR presents a static analysis algorithm that automatically extracts the method parameters and return statements. We evaluated APIZATOR with a ground-truth of 200 APIzations collected from 20 developers. For 113 (56.50 %) and 115 (57.50 %) APIzations, APIZATOR and the developers extracted identical parameters and return statements, respectively. For 163 (81.50 %) APIzations, either the parameters or the return statements were identical.
DOI 原文 ·
@inproceedings{paperbot6540,
title = {APIzation: Generating Reusable APIs from StackOverflow Code Snippets},
author = {Valerio Terragni and Pasquale Salza},
booktitle = {ASE},
year = {2021},
doi = {10.1109/ase51524.2021.9678576}
}