Ragex.Editor.Types
(Ragex v0.10.1)
View Source
Common types and structs for the editor module.
Defines data structures for changes, backups, and operation results.
Summary
Types
Information about a backup.
A single change to apply to a file.
Type of edit operation.
Result of an edit operation.
Validation error.
Functions
Creates a backup info struct.
Creates a delete change struct.
Creates an edit result struct.
Creates an insert change struct.
Creates a replace change struct.
Validates a change struct.
Creates a validation error struct.
Types
@type backup_info() :: %{ id: String.t(), path: String.t(), backup_path: String.t(), size: non_neg_integer(), created_at: DateTime.t(), original_mtime: integer() }
Information about a backup.
@type change() :: %{ type: change_type(), line_start: pos_integer(), line_end: pos_integer() | nil, content: String.t() | nil }
A single change to apply to a file.
@type change_type() :: :replace | :insert | :delete
Type of edit operation.
@type edit_result() :: %{ path: String.t(), backup_id: String.t() | nil, changes_applied: non_neg_integer(), lines_changed: non_neg_integer(), validation_performed: boolean(), timestamp: DateTime.t() }
Result of an edit operation.
@type validation_error() :: %{ line: pos_integer() | nil, column: pos_integer() | nil, message: String.t(), severity: :error | :warning }
Validation error.
Functions
@spec backup_info(String.t(), String.t(), String.t(), keyword()) :: backup_info()
Creates a backup info struct.
@spec delete(pos_integer(), pos_integer()) :: change()
Creates a delete change struct.
Examples
iex> Types.delete(5, 8)
%{type: :delete, line_start: 5, line_end: 8, content: nil}
@spec edit_result( String.t(), keyword() ) :: edit_result()
Creates an edit result struct.
@spec insert(pos_integer(), String.t()) :: change()
Creates an insert change struct.
Examples
iex> Types.insert(20, "inserted line")
%{type: :insert, line_start: 20, line_end: nil, content: "inserted line"}
@spec replace(pos_integer(), pos_integer(), String.t()) :: change()
Creates a replace change struct.
Examples
iex> Types.replace(10, 15, "new content")
%{type: :replace, line_start: 10, line_end: 15, content: "new content"}
Validates a change struct.
Returns :ok if valid, {:error, reason} otherwise.
@spec validation_error( String.t(), keyword() ) :: validation_error()
Creates a validation error struct.