Publication Type
Journal Article
Version
publishedVersion
Publication Date
8-2025
Abstract
A code context model comprises source code elements and their relations relevant to a programming task. The capture and use of code context models in software tools can benefit software development practices, such as code navigation and search. Prior research has explored approaches that leverage either the structural information of code or interaction histories of developers with integrated development environments to automate the construction of code context models. However, these approaches primarily capture shallow syntactic and lexical features of code elements, with limited ability to capture contextual and structural dependencies among neighboring code elements. In this paper, we propose GNNContext, a novel approach for predicting code context models based on Graph Neural Networks. Our approach leverages code representation learning models to capture both the syntactic and semantic features of code elements, while employing Graph Neural Networks to learn the structural and contextual information among neighboring code elements in the code context models. To evaluate the effectiveness of our approach, we apply it to a dataset comprising 3,879 code context models that we derive from three Eclipse open-source projects. The evaluation results demonstrate that our proposed approach GNNContext can significantly outperform the state-of-the-art baseline for code context prediction, achieving average improvements of 62.79%, 56.60%, 73.50% and 81.89% in mean reciprocal rank, top- 1, top-3, and top-5 recall rates, respectively, across predictions of varying steps. Moreover, our approach demonstrates robust performance in a cross-project evaluation setting.
Keywords
Codes, Context Modeling, Predictive Models, Syntactics, Programming, Graph Neural Networks, Semantics, Source Coding, History, Training, Code Context
Discipline
Software Engineering
Research Areas
Software and Cyber-Physical Systems
Areas of Excellence
Digital transformation
Publication
IEEE Transactions on Software Engineering
Volume
51
Issue
8
First Page
2268
Last Page
2284
ISSN
0098-5589
Identifier
10.1109/TSE.2025.3578390
Publisher
Institute of Electrical and Electronics Engineers
Citation
ZHENG, Xiaoye; WAN, Zhiyuan; LIU, Shun; YANG, Kaiwen; LO, David; and YANG, Xiaohu.
GNNContext: GNN-based code context prediction for programming tasks. (2025). IEEE Transactions on Software Engineering. 51, (8), 2268-2284.
Available at: https://ink.library.smu.edu.sg/sis_research/10942
Creative Commons License

This work is licensed under a Creative Commons Attribution-NonCommercial-No Derivative Works 4.0 International License.
Additional URL
https://doi.org/10.1109/TSE.2025.3578390