Minga.Parser.SnippetState (Minga v0.1.0)

Copy Markdown View Source

Owned state for isolated synchronous snippet-highlight requests.

Summary

Functions

Allocates an isolated parser buffer and records its request.

Fetches a pending snippet request.

Constructs empty snippet request state.

Returns the parser buffer ID allocated by the next request.

Removes a pending snippet request.

Updates a pending snippet request.

Removes every pending snippet request.

Types

pending_highlight()

@type pending_highlight() :: %{
  from: GenServer.from(),
  names: [String.t()] | nil,
  spans: [Minga.Language.Highlight.Span.t()] | nil,
  timer_ref: reference()
}

t()

@type t() :: %Minga.Parser.SnippetState{
  next_buffer_id: non_neg_integer(),
  pending: %{required(non_neg_integer()) => pending_highlight()}
}

Functions

allocate(state, request)

@spec allocate(t(), pending_highlight()) :: {non_neg_integer(), t()}

Allocates an isolated parser buffer and records its request.

fetch(state, buffer_id)

@spec fetch(t(), non_neg_integer()) :: {:ok, pending_highlight()} | :error

Fetches a pending snippet request.

new()

@spec new() :: t()

Constructs empty snippet request state.

next_buffer_id(snippet_state)

@spec next_buffer_id(t()) :: non_neg_integer()

Returns the parser buffer ID allocated by the next request.

pop(state, buffer_id)

@spec pop(t(), non_neg_integer()) :: {pending_highlight() | nil, t()}

Removes a pending snippet request.

put(state, buffer_id, request)

@spec put(t(), non_neg_integer(), pending_highlight()) :: t()

Updates a pending snippet request.

take_all(state)

@spec take_all(t()) :: {[pending_highlight()], t()}

Removes every pending snippet request.