The Symbol is the primary way developers interact with code in Codegen. It maps to how developers think about code - as functions, classes, variables, and other named entities. Both the Function and Class symbols are subclasses of the Symbol class.Documentation Index
Fetch the complete documentation index at: https://codegeninc-fix-system-prompt-typo.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
Accessing Symbols
The Codebase class provides getters and iterators for functions, classes and symbols:Shared APIs
All symbols share common APIs for manipulation:- The Editable API
- Metadata
- Edit operations
- Graph relations (See Usages and Dependencies)
Name operations
Function Statement Manipulation
Functions provide special APIs for adding statements to their body:- Function.prepend_statements - add statements to the start of the function body
- Function.add_statements - add statements to the end of the function body
The statement manipulation APIs (
prepend_statements and add_statements)
are only available on Function objects. For other symbols, use the general
Editable APIs like insert_before and insert_after.Common Patterns
Most Codegen programs focus on finding and manipulating symbols:The Symbol API is designed to be intuitive and match how developers think
about code. Most transformations start with finding relevant symbols and then
applying changes to them.