Minga.Parser.BufferRegistration (Minga v0.1.0)

Copy Markdown View Source

Parser synchronization state for one registered editor buffer.

All transitions live here so the manager remains the sole process owner while registration invariants stay explicit and independently testable.

Summary

Functions

Returns whether a version belongs to the current or most recently completed parse.

Marks an asynchronous snapshot request as in flight.

Returns whether a snapshot token belongs to the current request.

Marks a parser version and snapshot target as in flight.

Completes only the matching parser version.

Completes an unchanged snapshot without parser emission.

Records the newest observed buffer change sequence.

Creates a registration that requires an initial full parse.

Returns whether an idle registration has synchronization work.

Resets volatile parser state and requires a fresh full snapshot.

Returns the cursor to request from the buffer.

Returns whether the parser is synchronized through the required buffer sequence.

Types

phase()

@type phase() ::
  :idle
  | {:awaiting_snapshot, reference()}
  | {:parsing, pos_integer(), Minga.Buffer.ChangeLog.sequence()}

t()

@type t() :: %Minga.Parser.BufferRegistration{
  config: Minga.Parser.BufferConfig.t(),
  force_full?: boolean(),
  generation: reference(),
  id: pos_integer(),
  last_completed_version: non_neg_integer(),
  latest_dirty_sequence: Minga.Buffer.ChangeLog.sequence(),
  phase: phase(),
  synced_sequence: Minga.Buffer.ChangeLog.sequence()
}

Functions

accepts_version?(buffer_registration, version)

@spec accepts_version?(t(), pos_integer()) :: boolean()

Returns whether a version belongs to the current or most recently completed parse.

await_snapshot(registration, token)

@spec await_snapshot(t(), reference()) :: t()

Marks an asynchronous snapshot request as in flight.

awaiting?(buffer_registration, token)

@spec awaiting?(t(), reference()) :: boolean()

Returns whether a snapshot token belongs to the current request.

begin_parse(registration, version, target_sequence, full?)

@spec begin_parse(t(), pos_integer(), Minga.Buffer.ChangeLog.sequence(), boolean()) ::
  t()

Marks a parser version and snapshot target as in flight.

complete_parse(registration, version)

@spec complete_parse(t(), pos_integer()) :: {:ok, t()} | :stale

Completes only the matching parser version.

complete_unchanged(registration, sequence)

@spec complete_unchanged(t(), Minga.Buffer.ChangeLog.sequence()) :: t()

Completes an unchanged snapshot without parser emission.

mark_dirty(registration, sequence)

@spec mark_dirty(t(), Minga.Buffer.ChangeLog.sequence()) :: t()

Records the newest observed buffer change sequence.

new(id, config, generation)

Creates a registration that requires an initial full parse.

pumpable?(registration)

@spec pumpable?(t()) :: boolean()

Returns whether an idle registration has synchronization work.

restart(registration)

@spec restart(t()) :: t()

Resets volatile parser state and requires a fresh full snapshot.

snapshot_cursor(buffer_registration)

@spec snapshot_cursor(t()) :: :full | Minga.Buffer.ChangeLog.sequence()

Returns the cursor to request from the buffer.

synchronized?(buffer_registration, required_sequence)

@spec synchronized?(t(), Minga.Buffer.ChangeLog.sequence()) :: boolean()

Returns whether the parser is synchronized through the required buffer sequence.