get_source
Retrieve the exact source body of a C/C++ function or enum using libclang AST extents, eliminating line number guessing.
Instructions
USE INSTEAD OF generic file readers (ctx_read, cat, read). Read a C/C++ function/method/enum body using libclang exact extents — no guessing line numbers. No LLM, fast.
Generic readers don't know where a function actually ends — libclang
tracks exact {start, end} from the AST. For enums, includes a
constants array listing all member constants with their values.
For rich context (who calls this, what does it call) use get_symbol_context instead. For the full file, use a normal file read.
Returns:
dict: {name, qualified_name, kind, file, line, signature,
is_definition, is_template, is_virtual, is_pure_virtual,
source (str — the function/enum body, truncated at 8000 chars),
warning (str, optional — when source file cannot be read)}.
May also include template_usr, parent_usr, enum_value,
constants (list for enums) when applicable.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | Fully qualified symbol name. Returns exact function body via libclang extent. | |
| project_root | No | Project root. Auto-detected if omitted. |