Using Context and Hierarchy Features to Enhance Code Completion in Code Modification Scenarios
Automated software development has always been a research hotspot in the field of software engineering, and code completion can be regarded as a key technology.Currently, many studies on code completion regard the context of prediction as code that strictly appears before the cursor, and have not fully considered the use of code around the cursor for code modification scenarios.Meanwhile, the code serialization method has been developed from source code serialization to Abstract Syntax Tree (AST) serialization.However, AST serialization may lose original structure information.To solve these problems we propose contextual AST serialization (CAS) method, which can more accurately predict AST nodes by capturing the semantic association, context information and structure information between AST nodes.CAS not only converts AST nodes into sequences, but also connects AST sequences with the surrounding context to form richer representations.we conduct empirical studies using a standard Python dataset.The results demonstrate that CAS serialization method significantly improves the code prediction accuracy of the model, the MRR of various types of next token predictions is improved by 15.8% compared to TravTrans on average, and that of type node is improved by 19.4% on average.
Authors
- Ling Li (ORCID: https://orcid.org/0000-0001-7394-2515)
- Mingjie Xing (ORCID: https://orcid.org/0009-0009-5459-5779)
- Linhai Li
Publication Details
- Journal
- Proceedings/Proceedings of the ... International Conference on Software Engineering and Knowledge Engineering
- Published
- 2024-10-28
- DOI
- https://doi.org/10.18293/seke2024-123
- Primary Topic
- Model-Driven Software Engineering Techniques
- Type
- article
- Field-Weighted Citation Impact
- 0.00
Funders
- Chinese Academy of Sciences