Extract a module from a large file following ADR-0009. Moves functions to a new file, updates imports, and verifies all tests pass. Use when a file exceeds 500 lines and needs splitting.
指定されたファイルから1つのモジュールを抽出し、分割を実行する。
引数: 抽出元ファイルパス(例: packages/core/src/root.zig)
@import と関数呼び出しを修正
c. zig build でコンパイル確認
d. zig build test でユニットテスト確認
e. bash tests/differential/run.sh で差分テスト確認wc -l で元ファイルサイズを確認し報告Database structのメソッドを外部ファイルの free function に変換する:
// convert.zig
const std = @import("std");
const value_mod = @import("value.zig");
const Value = value_mod.Value;
pub fn valueToText(allocator: std.mem.Allocator, val: Value) ![]const u8 {
// self.allocator → allocator に置き換え
}
pub fn formatFloat(allocator: std.mem.Allocator, f: f64) ![]const u8 {
// ...
}
// root.zig
const convert = @import("convert.zig");
// 呼び出し側: self.valueToText(val) → convert.valueToText(self.allocator, val)
refactor: extract <module> from <source>