What is under the cursor in a recipe group buffer.
When the buffer parses, Composer.Recipe.Locator answers. Otherwise a
line scan finds the string literal enclosing the cursor: a {:use, ...}
target when {:use, precedes it, a reference otherwise. The scan knows
string literals, the {:use, prefix and keys (steps:) and nothing
else; references are parsed by Composer.Ref.
Lines and columns are 1-based, columns in graphemes, as the locator's.
Summary
Functions
What is at line, column of text, or nil.
The completion context at line, column of text, by line scan:
{:steps | :use, prefix, replace_range} inside a string literal of a
steps: list (:use after {:use,), else nil. replace_range
covers the literal's contents.
The string literal on line_text enclosing column: its value, the
column of its opening quote and the column after its closing quote
(nil when the line ends inside it). The cursor is inside from the
opening quote up to the closing one.
Every string literal on line_text, in order (see literal_at/2).
The cookbook aliases written in text, read by scanning aliases:
lists and the top-level bindings aliases: names, the nearest one
starting on or above line first. Best effort, for a buffer that does not parse.
Types
@type literal() :: %{ value: String.t(), start: pos_integer(), end: pos_integer() | nil }
@type range() :: Composer.Lint.Diagnostic.range()
Functions
@spec at(String.t(), Path.t(), pos_integer(), pos_integer()) :: t() | nil
What is at line, column of text, or nil.
@spec context(String.t(), pos_integer(), pos_integer()) :: {:steps | :use, String.t(), range()} | nil
The completion context at line, column of text, by line scan:
{:steps | :use, prefix, replace_range} inside a string literal of a
steps: list (:use after {:use,), else nil. replace_range
covers the literal's contents.
@spec literal_at(String.t(), pos_integer()) :: literal() | nil
The string literal on line_text enclosing column: its value, the
column of its opening quote and the column after its closing quote
(nil when the line ends inside it). The cursor is inside from the
opening quote up to the closing one.
Every string literal on line_text, in order (see literal_at/2).
@spec scan_aliases(String.t(), pos_integer()) :: %{required(String.t()) => String.t()}
The cookbook aliases written in text, read by scanning aliases:
lists and the top-level bindings aliases: names, the nearest one
starting on or above line first. Best effort, for a buffer that does not parse.