Kreuzberg.CodeSpan (kreuzberg v4.9.5)

Copy Markdown View Source

Byte and line/column span for a code element.

Fields

  • :start_byte - Starting byte offset
  • :end_byte - Ending byte offset
  • :start_line - Starting line number
  • :start_column - Starting column number
  • :end_line - Ending line number
  • :end_column - Ending column number

Summary

Functions

Creates a CodeSpan struct from a map.

Converts a CodeSpan struct to a map.

Types

t()

@type t() :: %Kreuzberg.CodeSpan{
  end_byte: non_neg_integer(),
  end_column: non_neg_integer(),
  end_line: non_neg_integer(),
  start_byte: non_neg_integer(),
  start_column: non_neg_integer(),
  start_line: non_neg_integer()
}

Functions

from_map(data)

@spec from_map(map()) :: t()

Creates a CodeSpan struct from a map.

Examples

iex> Kreuzberg.CodeSpan.from_map(%{"start_byte" => 0, "end_byte" => 42, "start_line" => 1, "start_column" => 0, "end_line" => 3, "end_column" => 5})
%Kreuzberg.CodeSpan{start_byte: 0, end_byte: 42, start_line: 1, start_column: 0, end_line: 3, end_column: 5}

to_map(span)

@spec to_map(t()) :: map()

Converts a CodeSpan struct to a map.