module

Xerp::Query::Snippet

Constants

CLUSTER_GAP = 4

Gap threshold - hits within this many lines are merged into one cluster.

DEFAULT_CONTEXT = 2

Context lines around each hit cluster.

ELLIPSIS = "..."

Ellipsis marker for non-contiguous regions.

HEADER_LINES = 2

Number of header lines to always include.

MAX_SNIPPET_LINES = 50

Maximum snippet size in lines (excluding ellipsis markers).

Class methods

extract(workspace_root : String, rel_path : String, block : Store::BlockRow, hit_lines : Array(Int32), max_lines : Int32 = MAX_SNIPPET_LINES, context_lines : Int32 = DEFAULT_CONTEXT) : String

Extracts a snippet from a file for a given block and hit lines.

Source
extract_raw(workspace_root : String, rel_path : String, line_start : Int32, line_end : Int32) : String

Extracts just the raw lines without formatting.

Source
extract_with_error(workspace_root : String, rel_path : String, block : Store::BlockRow, hit_lines : Array(Int32), max_lines : Int32 = MAX_SNIPPET_LINES, context_lines : Int32 = DEFAULT_CONTEXT) : SnippetResult

Extracts a snippet with error reporting.

Source
format_with_line_numbers(content : String, line_start : Int32) : String

Formats raw snippet content with line number prefixes for display. Handles "..." ellipsis markers specially (no line number).

Source

Nested types