Code Chunking Why AST-Based Chunking Character splitters can split a function mid-body, separating a signature from its return statement. AST chunking respects function and class boundaries so each chunk is a self-contained semantic unit - dramatically better retrieval and generation quality for code. tree-sitter (Python bindings) Preserving Imports and Module Context LangChain Language Splitter The language-aware splitter uses language-specific separators (e.g., , , ) which beats generic character splitting but still does not understand AST scope. LlamaIndex CodeSplitter CodeSplitter wraps t…