Skip to main content
Every code element in Codegen is an Editable - meaning it can be manipulated while maintaining correctness. All higher-level code manipulation APIs are built on top of the atomic Editable API.

Core Concepts

Every Editable provides:

Basic Editing

There are several fundamental ways to modify code with Editables:

Finding and Searching

Editables provide powerful search capabilities:

Smart Formatting

Codegen handles formatting details automatically:

Safe Removals

Removing code elements is safe and clean:

Working with References

Editables track their relationships to other code elements:

Understanding Context

Editables provide rich information about their location and context in the code:

Parent Relationships

Statement Containment

The is_wrapped_in method lets you check if an Editable is contained within specific types of statements:

Common Use Cases