|
9 | 9 | [elin.util.sexpr :as e.u.sexpr]
|
10 | 10 | [malli.core :as m]))
|
11 | 11 |
|
| 12 | +(m/=> validate-code-and-position [:=> [:cat e.s.host/?CodeAndPosition] (e.schema/error-or e.s.host/?CodeAndPosition)]) |
| 13 | +(defn- validate-code-and-position |
| 14 | + [{:as code-and-position :keys [code]}] |
| 15 | + (if (seq code) |
| 16 | + code-and-position |
| 17 | + (e/not-found))) |
| 18 | + |
12 | 19 | (m/=> get-top-list [:function
|
13 | 20 | [:-> e.s.handler/?Elin int? int? (e.schema/error-or e.s.host/?CodeAndPosition)]
|
14 | 21 | [:-> e.s.handler/?Elin string? int? int? (e.schema/error-or e.s.host/?CodeAndPosition)]])
|
15 | 22 | (defn get-top-list
|
16 | 23 | ([{:component/keys [host]} lnum col]
|
17 |
| - (async/<!! (e.p.host/get-top-list-sexpr! host lnum col))) |
| 24 | + (e/-> (async/<!! (e.p.host/get-top-list-sexpr! host lnum col)) |
| 25 | + (validate-code-and-position))) |
18 | 26 | ([{:component/keys [host]} path lnum col]
|
19 |
| - (async/<!! (e.p.host/get-top-list-sexpr! host path lnum col)))) |
| 27 | + (e/-> (async/<!! (e.p.host/get-top-list-sexpr! host path lnum col)) |
| 28 | + (validate-code-and-position)))) |
20 | 29 |
|
21 | 30 | (m/=> get-list [:function
|
22 | 31 | [:-> e.s.handler/?Elin int? int? (e.schema/error-or e.s.host/?CodeAndPosition)]
|
23 | 32 | [:-> e.s.handler/?Elin string? int? int? (e.schema/error-or e.s.host/?CodeAndPosition)]])
|
24 | 33 | (defn get-list
|
25 | 34 | ([{:component/keys [host]} lnum col]
|
26 |
| - (async/<!! (e.p.host/get-list-sexpr! host lnum col))) |
| 35 | + (e/-> (async/<!! (e.p.host/get-list-sexpr! host lnum col)) |
| 36 | + (validate-code-and-position))) |
27 | 37 | ([{:component/keys [host]} path lnum col]
|
28 |
| - (async/<!! (e.p.host/get-list-sexpr! host path lnum col)))) |
| 38 | + (e/-> (async/<!! (e.p.host/get-list-sexpr! host path lnum col)) |
| 39 | + (validate-code-and-position)))) |
29 | 40 |
|
30 | 41 | (m/=> get-expr [:function
|
31 | 42 | [:-> e.s.handler/?Elin int? int? (e.schema/error-or e.s.host/?CodeAndPosition)]
|
32 | 43 | [:-> e.s.handler/?Elin string? int? int? (e.schema/error-or e.s.host/?CodeAndPosition)]])
|
33 | 44 | (defn get-expr
|
34 | 45 | ([{:component/keys [host]} lnum col]
|
35 |
| - (async/<!! (e.p.host/get-single-sexpr! host lnum col))) |
| 46 | + (e/-> (async/<!! (e.p.host/get-single-sexpr! host lnum col)) |
| 47 | + (validate-code-and-position))) |
36 | 48 | ([{:component/keys [host]} path lnum col]
|
37 |
| - (async/<!! (e.p.host/get-single-sexpr! host path lnum col)))) |
| 49 | + (e/-> (async/<!! (e.p.host/get-single-sexpr! host path lnum col)) |
| 50 | + (validate-code-and-position)))) |
38 | 51 |
|
39 | 52 | (m/=> get-namespace-sexpr [:function
|
40 | 53 | [:=> [:cat e.s.handler/?Elin] (e.schema/error-or e.s.host/?CodeAndPosition)]
|
41 | 54 | [:=> [:cat e.s.handler/?Elin string?] (e.schema/error-or e.s.host/?CodeAndPosition)]])
|
42 | 55 | (defn get-namespace-sexpr
|
43 | 56 | ([{:component/keys [host]}]
|
44 |
| - (async/<!! (e.p.host/get-namespace-sexpr! host))) |
| 57 | + (e/-> (async/<!! (e.p.host/get-namespace-sexpr! host)) |
| 58 | + (validate-code-and-position))) |
45 | 59 | ([{:component/keys [host]} path]
|
46 |
| - (async/<!! (e.p.host/get-namespace-sexpr! host path)))) |
| 60 | + (e/-> (async/<!! (e.p.host/get-namespace-sexpr! host path)) |
| 61 | + (validate-code-and-position)))) |
47 | 62 |
|
48 | 63 | (m/=> replace-list-sexpr [:=> [:cat e.s.handler/?Elin int? int? string?] (e.schema/error-or [:maybe string?])])
|
49 | 64 | (defn replace-list-sexpr
|
|
0 commit comments