def dedupe.kept

bend-lint-rules@0.2.0.0 · layout/imports.bend:150

import bend-lint-rules@0.2.0.0/layout/imports.bend as Imports
import Base
import bend-lint-api@0.2.0.0/linter/lint.bend as Lint
import bend-lint-api@0.2.0.0/shared/names.bend as Names

150# An import read, after those before it: kept, if its file has no import yet; else dropped, with its uses pointed at
151# `first`, the alias of the file's first import. A second import Base has none to point: its uses are bare names.
152def dedupe.kept(first: Maybe<&2, String>, e: Entry, d: Deduped) -> Deduped:
153  match first e d:
154    case None{} Entry{at, base, path, +alias, +loads, text} Deduped{seen, kept, renames}:
155      Deduped{
156        Names.Named{loads, alias} <> seen,
157        Entry{at, base, path, alias, loads, text} <> kept,
158        renames
159      }
160    case Some{a} Entry{at, False{}, path, alias, loads, text} Deduped{seen, kept, renames}:
161      Deduped{seen, kept, Lint.RenameUses{at, a} <> renames}
162    case Some{a} Entry{at, True{}, path, alias, loads, text} _:
163      d

Uses (8)

Used by (1)