module
Analyzer::Gleam::Helper
Overview
Shared helpers for the Gleam framework analyzers (Wisp, Mist).
Extended Modules
Defined in:
analyzer/analyzers/gleam/gleam_helper.crInstance Method Summary
-
#balanced_span(text : String, open_idx : Int32) : String | Nil
Returns the balanced
{…}span beginning atopen_idx, braces included, or nil if it never closes. -
#parse_segments(segments : Array(String)) : Tuple(String, Array(Param))
Renders a Gleam list pattern from a
case wisp.path_segments(req)arm into a noir URL plus its path params. -
#split_alternatives(pattern : String) : Array(String)
Splits a case pattern on its top-level
|alternates, so["a"] | ["b", _]becomes two independent path patterns. -
#split_pattern_segments(body : String) : Array(String)
Splits a case-arm list pattern body (the text between
[and]) into its top-level comma-separated segments, ignoring commas nested inside strings, brackets, parens or braces. -
#strip_gleam_comments(text : String) : String
Blank out
//line comments (this covers///and////doc comments too) while PRESERVING newlines/offsets, so a comment never collapses lines and shifts every later endpoint's reported line number.
Instance Method Detail
Returns the balanced {…} span beginning at open_idx, braces
included, or nil if it never closes. String contents are skipped so
a brace inside a literal doesn't unbalance the count — Gleam
strings may span newlines and routinely embed JS/HTML.
Renders a Gleam list pattern from a case wisp.path_segments(req)
arm into a noir URL plus its path params.
Segment forms:
"users"— a string literal segment.id— a bound variable, i.e. a path parameter._/_name— a discarded segment; still a parameter position, but unnamed, so it renders as a generic binding.../..rest— matches all remaining segments (wildcard).
Splits a case pattern on its top-level | alternates, so
["a"] | ["b", _] becomes two independent path patterns.
Splits a case-arm list pattern body (the text between [ and ])
into its top-level comma-separated segments, ignoring commas nested
inside strings, brackets, parens or braces.
Blank out // line comments (this covers /// and //// doc
comments too) while PRESERVING newlines/offsets, so a comment never
collapses lines and shifts every later endpoint's reported line
number. Gleam has no block comments.
"..." strings are skipped so a URL literal like
"https://example.com" doesn't truncate the line. Gleam strings may
span multiple lines, so the scanner tracks them across newlines.