ElixirScope.ASTRepository.Parser (elixir_scope v0.0.1)

Enhanced AST parser that assigns unique node IDs to instrumentable AST nodes, extracts instrumentation points, and builds correlation indexes for runtime correlation.

This module is the foundation for compile-time AST analysis with runtime correlation.

Summary

Functions

Assigns unique node IDs to instrumentable AST nodes.

Builds a correlation index from enhanced AST and instrumentation points.

Extracts instrumentation points from an enhanced AST.

Functions

assign_node_ids(ast)

@spec assign_node_ids(Macro.t()) :: {:ok, Macro.t()} | {:error, term()}

Assigns unique node IDs to instrumentable AST nodes.

Instrumentable nodes include:

  • Function definitions (def, defp)
  • Pipe operations (|>)
  • Case statements
  • Try-catch blocks
  • Module attributes

Returns {:ok, enhanced_ast} or {:error, reason}.

build_correlation_index(ast, instrumentation_points)

@spec build_correlation_index(Macro.t(), [map()]) :: {:ok, map()} | {:error, term()}

Builds a correlation index from enhanced AST and instrumentation points.

Returns {:ok, correlation_index} where correlation_index is a map of correlation_id -> ast_node_id.

extract_instrumentation_points(ast)

@spec extract_instrumentation_points(Macro.t()) :: {:ok, [map()]} | {:error, term()}

Extracts instrumentation points from an enhanced AST.

Returns {:ok, instrumentation_points} or {:error, reason}.