def add.line

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

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/strings.bend as Strings

69# The import on the line from `beg` to `end`, after the block so far.
70def add.line(
71  +text: String,
72  +beg: U32,
73  +end: U32,
74  at: Lint.Span,
75  base: Bool,
76  path: String,
77  alias: String,
78  loads: String,
79  b: Block
80) -> Block:
81  match b:
82    case Block{first, last, Nil{}}:
83      Block{beg, end, [Entry{at, base, path, alias, loads, ended(Strings.slice(text, beg, end))}]}
84    case Block{first, last, +entries}:
85      Block{
86        first,
87        end,
88        Entry{
89          at,
90          base,
91          path,
92          alias,
93          loads,
94          comments(Strings.slice(text, last, beg), "", []) ++ ended(Strings.slice(text, beg, end))
95        }
96          <> entries
97      }

Uses (11)

Used by (1)