Ragex.Editor.Visualize (Ragex v0.8.0)

View Source

Visualization utilities for refactoring operations.

Generates visual representations of:

  • Call graph changes before/after refactoring
  • Impact radius (affected functions and modules)
  • Risk analysis based on centrality and dependencies

Supports multiple output formats:

  • Graphviz DOT (for rendering with dot/neato/etc.)
  • D3.js JSON (for web visualization)
  • ASCII art (for terminal display)

Summary

Functions

Analyzes the impact of changes to a set of files.

Generates a diff visualization showing before/after state.

Visualizes the impact radius of a refactoring operation.

Types

impact_data()

@type impact_data() :: %{
  affected_functions: [node_id()],
  affected_modules: [module_name()],
  impact_radius: non_neg_integer(),
  risk_score: float(),
  centrality_metrics: map()
}

module_name()

@type module_name() :: atom()

node_id()

@type node_id() :: term()

visualization_format()

@type visualization_format() :: :graphviz | :d3_json | :ascii

Functions

analyze_impact(affected_files, depth \\ 1, include_risk \\ true)

@spec analyze_impact([String.t()], non_neg_integer(), boolean()) ::
  {:ok, impact_data()} | {:error, term()}

Analyzes the impact of changes to a set of files.

Returns comprehensive impact data including affected nodes, impact radius, and risk analysis.

Parameters

  • affected_files: List of file paths
  • depth: How many levels to traverse (default: 1)
  • include_risk: Compute risk metrics (default: true)

Returns

  • {:ok, impact_data} with analysis results
  • {:error, reason} on failure

visualize_diff(before_nodes, after_nodes, format \\ :ascii)

@spec visualize_diff([node_id()], [node_id()], visualization_format()) ::
  {:ok, String.t() | map()} | {:error, term()}

Generates a diff visualization showing before/after state.

Useful for visualizing graph structure changes.

Parameters

  • before_nodes: Nodes before refactoring
  • after_nodes: Nodes after refactoring
  • format: Output format

Returns

  • {:ok, visualization} with diff representation

visualize_impact(affected_files, format \\ :graphviz, opts \\ [])

@spec visualize_impact([String.t()], visualization_format(), keyword()) ::
  {:ok, String.t() | map()} | {:error, term()}

Visualizes the impact radius of a refactoring operation.

Highlights the affected nodes and their immediate neighbors in the call graph.

Parameters

  • affected_files: List of file paths modified by refactoring
  • format: Output format (:graphviz, :d3_json, or :ascii)
  • opts: Options
    • :depth - How many levels of neighbors to include (default: 1)
    • :include_risk - Include risk analysis (default: true)
    • :color_by_risk - Color nodes by risk score (default: true)

Returns

  • {:ok, visualization_string} for :graphviz or :ascii
  • {:ok, json_map} for :d3_json
  • {:error, reason} on failure