Finds where things are written in a recipe group file, without evaluating it.
index/2 parses a group's source and records, for each recipe in the
final keyword list:
key- the range of its name key (auth:)keys- its own keys (steps:,aliases:,flags:, ...)refs- the reference strings in itssteps:, in source order, including the string of a{"ref", opts}entryuses- the strings of its{:use, ...}entriesentries- each entry's range and, when it is literal, its valuealiases- each alias name, from a literalaliases:or from the top-level binding thataliases:namesalias_targets- each alias's target, where it is a literal stringifs- eachif:flag atom
Top-level name = ... bindings are recorded too, and a steps: or
aliases: that names one is read through it.
Positions follow Composer.Lint.Diagnostic: 1-based lines, columns
counted in characters as Elixir's tokenizer counts them, and ranges
{{line, column}, {end_line, end_column}} with an exclusive end. The
index keeps each line's text (line/2), so a caller needing another
column unit (an LSP's UTF-16) can convert without parsing again.
locate/3 answers "where is this?" and always returns a range,
falling back from the literal to the recipe's steps: key, to its name
key, to line 1. at/3 answers "what is here?".
Summary
Functions
Returns what is at line, column: a reference, a {:use, ...}
target, an alias name, a recipe key or a recipe's name key, as
{kind, recipe_name, value, range}, or nil.
The range used when nothing better is known: the start of line 1.
Indexes a group file's source; path is recorded and words errors.
Returns {:error, {:group_parse, path, description, line}} when the
source does not parse.
Reads and indexes the group file at path.
Returns line n's text (without its newline), or nil.
Returns the most precise range for target in recipe name. When
target cannot be found, falls back to the recipe's steps: key (or,
for an alias, its aliases:), then its name key, then line 1.
The parse options the locator uses, for parsing other files alike.
Returns the indexed recipe named name (the first, if duplicated).
Returns the ranges of every name key name, in file order.
Returns the ranges of the reference strings (in steps: and
{:use, ...}) of recipe name that equal match, or satisfy it when
it is a function, in source order.
Types
@type range() :: Composer.Lint.Diagnostic.range()
@type recipe() :: %{ name: String.t(), key: range(), keys: %{required(atom()) => range()}, refs: [{String.t(), range()}], uses: [{String.t(), range()}], entries: [{range(), term()}], aliases: %{required(atom()) => range()}, alias_targets: %{required(atom()) => String.t()}, ifs: %{required(atom()) => range()} }
Functions
@spec at(t(), pos_integer(), pos_integer()) :: {:ref | :use | :alias | :key | :recipe, String.t(), term(), range()} | nil
Returns what is at line, column: a reference, a {:use, ...}
target, an alias name, a recipe key or a recipe's name key, as
{kind, recipe_name, value, range}, or nil.
@spec first_line() :: range()
The range used when nothing better is known: the start of line 1.
Indexes a group file's source; path is recorded and words errors.
Returns {:error, {:group_parse, path, description, line}} when the
source does not parse.
Reads and indexes the group file at path.
@spec line(t(), pos_integer()) :: String.t() | nil
Returns line n's text (without its newline), or nil.
Returns the most precise range for target in recipe name. When
target cannot be found, falls back to the recipe's steps: key (or,
for an alias, its aliases:), then its name key, then line 1.
@spec parse_opts() :: keyword()
The parse options the locator uses, for parsing other files alike.
Returns the indexed recipe named name (the first, if duplicated).
Returns the ranges of every name key name, in file order.
Returns the ranges of the reference strings (in steps: and
{:use, ...}) of recipe name that equal match, or satisfy it when
it is a function, in source order.