Heuristic and Neural Network Based Prediction of Project-Specific API Member Access

Lin Jiang, Hui Liu*, He Jiang, Lu Zhang, Hong Mei

*Corresponding author for this work

Research output: Contribution to journalArticlepeer-review

6 Citations (Scopus)

Abstract

Code completion is to predict the rest of a statement a developer is typing. Although advanced code completion approaches have greatly improved the accuracy of code completion in modern IDEs, it remains challenging to predict project-specific API method invocations or field accesses because little knowledge about such elements could be learned in advance. To this end, in this paper we propose an accurate approach called HeeNAMA to suggesting the next project-specific API member access. HeeNAMA focuses on a specific but common case of code completion: suggesting the following member access whenever a project-specific API instance is followed by a dot on the right hand side of an assignment. By focusing on such a specific case, HeeNAMA can take full advantages of the context of the code completion, including the type of the left hand side expression of the assignment, the identifier on the left hand side, the type of the base instance, and similar assignments typed in before. All such information together enables highly accurate code completion. Given an incomplete assignment, HeeNAMA generates the initial candidate set according to the type of the base instance, and excludes those candidates that are not type compatible with the left hand side of the assignment. If the enclosing project contains assignments highly similar to the incomplete assignment, it makes suggestions based on such assignments. Otherwise, it selects the one from the initial candidate set that has the greatest lexical similarity with the left hand side of the assignment. Finally, it employs a neural network to filter out risky predictions, which guarantees high precision. Evaluation results on open-source applications suggest that compared to the state-of-the-art approaches and the state-of-the-practice tools HeeNAMA improves precision and recall by 70.68 and 25.23 percent, relatively.

Original languageEnglish
Pages (from-to)1249-1267
Number of pages19
JournalIEEE Transactions on Software Engineering
Volume48
Issue number4
DOIs
Publication statusPublished - 1 Apr 2022

Keywords

  • Code completion
  • LSTM
  • deep learning
  • heuristic
  • non-API

Fingerprint

Dive into the research topics of 'Heuristic and Neural Network Based Prediction of Project-Specific API Member Access'. Together they form a unique fingerprint.

Cite this