From 3435abb02d01e327eeda90d6a894949fe02e29e7 Mon Sep 17 00:00:00 2001 From: Shagun Agrawal Date: Wed, 2 Oct 2024 23:24:01 +0530 Subject: Add function declaration and definition parsing Pass Chapter 9 tests Add function parsing --- .clj-kondo/imports/http-kit/http-kit/config.edn | 3 +++ .../imports/http-kit/http-kit/httpkit/with_channel.clj | 16 ++++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 .clj-kondo/imports/http-kit/http-kit/config.edn create mode 100644 .clj-kondo/imports/http-kit/http-kit/httpkit/with_channel.clj (limited to '.clj-kondo/imports/http-kit') diff --git a/.clj-kondo/imports/http-kit/http-kit/config.edn b/.clj-kondo/imports/http-kit/http-kit/config.edn new file mode 100644 index 0000000..e9dbcd8 --- /dev/null +++ b/.clj-kondo/imports/http-kit/http-kit/config.edn @@ -0,0 +1,3 @@ + +{:hooks + {:analyze-call {org.httpkit.server/with-channel httpkit.with-channel/with-channel}}} diff --git a/.clj-kondo/imports/http-kit/http-kit/httpkit/with_channel.clj b/.clj-kondo/imports/http-kit/http-kit/httpkit/with_channel.clj new file mode 100644 index 0000000..b429de8 --- /dev/null +++ b/.clj-kondo/imports/http-kit/http-kit/httpkit/with_channel.clj @@ -0,0 +1,16 @@ +(ns httpkit.with-channel + (:require [clj-kondo.hooks-api :as api])) + +(defn with-channel [{node :node}] + (let [[request channel & body] (rest (:children node))] + (when-not (and request channel) (throw (ex-info "No request or channel provided" {}))) + (when-not (api/token-node? channel) (throw (ex-info "Missing channel argument" {}))) + (let [new-node + (api/list-node + (list* + (api/token-node 'let) + (api/vector-node [channel (api/vector-node [])]) + request + body))] + + {:node new-node}))) -- cgit v1.2.3