We identify the problem of chunking (the process of dividing documents into searchable units), which plays a crucial role in large-scale code generation based on Retrieval-Augmented Generation (RAG), and propose a structure-aware chunking methodology utilizing Abstract Syntax Trees (AST) to address this issue. The proposed methodology recursively splits AST nodes and merges sibling nodes while respecting size constraints to create self-contained units that are semantically consistent across languages and tasks. It demonstrates performance improvements across various code generation tasks, such as improving Recall@5 by 4.3 points in RepoEval retrieval and Pass@1 by 2.67 points in SWE-bench generation.