In Line with Context: Repository-Level Code Generation via Context Inlining

📅 2026-01-01
🏛️ arXiv.org
📈 Citations: 1
Influential: 0
📄 PDF
🤖 AI Summary
Existing repository-level code generation approaches struggle to accurately model complex dependencies across functions, classes, and modules, often suffering from insufficient semantic understanding due to reliance on superficial similarity. This work proposes InlineCoder, a novel framework that introduces anchor drafts and a bidirectional inlining mechanism—comprising upstream inlining and downstream retrieval—to inline incomplete functions into their call graphs, thereby transforming repository-level tasks into more tractable function-level generation problems. By integrating call graph analysis, contextual inlining, and perplexity-based confidence estimation, InlineCoder substantially improves the accuracy and contextual consistency of generated code, effectively enhancing large language models’ comprehension of overall project structure.

Technology Category

Application Category

📝 Abstract
Repository-level code generation has attracted growing attention in recent years. Unlike function-level code generation, it requires the model to understand the entire repository, reasoning over complex dependencies across functions, classes, and modules. However, existing approaches such as retrieval-augmented generation (RAG) or context-based function selection often fall short: they primarily rely on surface-level similarity and struggle to capture the rich dependencies that govern repository-level semantics. In this paper, we introduce InlineCoder, a novel framework for repository-level code generation. InlineCoder enhances the understanding of repository context by inlining the unfinished function into its call graph, thereby reframing the challenging repository understanding as an easier function-level coding task. Given a function signature, InlineCoder first generates a draft completion, termed an anchor, which approximates downstream dependencies and enables perplexity-based confidence estimation. This anchor drives a bidirectional inlining process: (i) Upstream Inlining, which embeds the anchor into its callers to capture diverse usage scenarios; and (ii) Downstream Retrieval, which integrates the anchor's callees into the prompt to provide precise dependency context. The enriched context, combining draft completion with upstream and downstream perspectives, equips the LLM with a comprehensive repository view.
Problem

Research questions and friction points this paper is trying to address.

repository-level code generation
code dependencies
context understanding
large language models
software semantics
Innovation

Methods, ideas, or system contributions that make the work stand out.

repository-level code generation
context inlining
anchor-based drafting
bidirectional inlining
call graph reasoning