Reflaxe.Elixir’s long‑term goal is to provide .ex.map files that map generated Elixir code back
to original Haxe source positions, enabling:
- better error messages (Haxe file/line from Elixir stacktraces)
- LLM‑friendly navigation between generated and source code
- tooling like
mix haxe.source_map
Source mapping is implemented, but remains experimental:
- The Haxe‑side writer (
src/reflaxe/elixir/SourceMapWriter.hx) is wired into the output phase (src/reflaxe/elixir/ElixirOutputIterator.hx) and emits.ex.mapfiles when enabled. - The Elixir‑side lookup module (
lib/source_map_lookup.ex) implements Source Map v3 VLQ decoding and can resolve Elixir{file,line,column}back to Haxe positions.
- Mappings provide full line coverage (every generated line maps to a Haxe position) and add column‑level segments at many expression boundaries (AST node starts).
- Mappings are still best‑effort:
- Not every character is mapped (we map expression starts, not identifier “names”).
- Compiler‑injected lines (bootstrapping, helper shims) map to the nearest reasonable Haxe context.
Non‑alpha / production‑ready status for Reflaxe.Elixir does not require source mapping; it is opt‑in and intended as a debugging aid.
- Haxe source map writer (planned emission point):
src/reflaxe/elixir/SourceMapWriter.hx
- Elixir lookup task + runtime helpers:
lib/source_map_lookup.exlib/mix/tasks/haxe.source_map.exlib/phoenix_error_handler.ex(optional runtime enrichment)
Add a define to your Elixir build:
-D source_map_enabledThen compile normally. The compiler will emit sibling files:
lib/my_module.exlib/my_module.ex.map
Elixir tooling (ElixirLS, stacktraces, etc.) does not currently consume .ex.map files automatically.
Use the provided Mix task to bridge from a runtime Elixir position back to Haxe.
mix haxe.source_map lib/my_module.ex 45 12code --goto expects 1-based columns, so use the goto output format:
code --goto "$(mix haxe.source_map lib/my_module.ex 45 12 --format goto)"If you start from a Haxe location (for example from a type error or a log you emitted), pass a .hx file:
mix haxe.source_map src_haxe/my_module/MyMod.hx 20 0The task will auto-detect reverse mode for .hx inputs (or you can pass --reverse explicitly).
- Expand integration coverage
- Extend the fixture coverage under
test/snapshot/core/source_map_*to assert specific mappings (not just structure).
- Extend the fixture coverage under
- Polish reverse lookup UX
- If multiple modules reference the same
.hxfile, consider returning multiple candidate matches in JSON output (or add a--pickflag).
- If multiple modules reference the same
- Refine granularity vs size
- Tune which AST node types emit mapping boundaries to keep
.mapsize reasonable while still mapping meaningful expression starts.
- Tune which AST node types emit mapping boundaries to keep