From 0f94c539a4e232128b4b33fa05a0f4e8f103d5a9 Mon Sep 17 00:00:00 2001 From: vemv Date: Wed, 9 Feb 2022 19:18:10 +0100 Subject: [PATCH 1/6] Bump Eastwood --- project.clj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project.clj b/project.clj index 46e94ea9..3cb72409 100644 --- a/project.clj +++ b/project.clj @@ -69,7 +69,7 @@ with-debug-bindings [[:inner 0]] merge-meta [[:inner 0]] try-if-let [[:block 1]]}}}] - :eastwood {:plugins [[jonase/eastwood "1.1.1"]] + :eastwood {:plugins [[jonase/eastwood "1.2.2"]] :eastwood {;; :implicit-dependencies would fail spuriously when the CI matrix runs for Clojure < 1.10, ;; because :implicit-dependencies can only work for a certain corner case starting from 1.10. :exclude-linters [:implicit-dependencies] From c840a2c6bb504cb2328c9b248676f5229bda8f77 Mon Sep 17 00:00:00 2001 From: vemv Date: Wed, 9 Feb 2022 19:18:04 +0100 Subject: [PATCH 2/6] `read-ns-form`: rethrow `FileNotFoundException`s more informatively Fixes https://github.com/clojure-emacs/refactor-nrepl/issues/142 --- CHANGELOG.md | 1 + src/refactor_nrepl/core.clj | 39 ++++++++++++++++--------------- test/refactor_nrepl/core_test.clj | 23 ++++++++++-------- 3 files changed, 34 insertions(+), 29 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f0d19094..e3b25eea 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ * [#173](https://github.com/clojure-emacs/refactor-nrepl/issues/173): `rename-file-or-dir`: rename more kinds of constructs in dependent namespaces: namespace-qualified maps, fully-qualified functions, metadata. * [#194](https://github.com/clojure-emacs/refactor-nrepl/issues/194): Don't prune `require` forms if they are needed for a given `import` to work. +* [#142](https://github.com/clojure-emacs/refactor-nrepl/issues/142): `read-ns-form`: report more informatively when a non-existing file is being processed. ## 3.3.1 diff --git a/src/refactor_nrepl/core.clj b/src/refactor_nrepl/core.clj index 03cd1539..9b8b650c 100644 --- a/src/refactor_nrepl/core.clj +++ b/src/refactor_nrepl/core.clj @@ -10,7 +10,7 @@ [refactor-nrepl.s-expressions :as sexp] [refactor-nrepl.util :as util :refer [normalize-to-unix-path]]) (:import - (java.io File FileReader PushbackReader StringReader))) + (java.io File FileNotFoundException FileReader PushbackReader StringReader))) ;; Require our `fs` customizations before `fs` is loaded: (require '[refactor-nrepl.fs]) @@ -152,28 +152,29 @@ (defn read-ns-form ([path] - (let [^String path-string (when (string? path) - path) - ^File path-file (when-not path-string - path)] - (with-open [file-reader (or (some-> path-string FileReader.) - (some-> path-file FileReader.))] - (try - (parse/read-ns-decl (readers/indexing-push-back-reader - (PushbackReader. file-reader))) - (catch Exception _ nil))))) + (read-ns-form nil path)) ([dialect path] (let [^String path-string (when (string? path) path) ^File path-file (when-not path-string - path)] - (with-open [file-reader (or (some-> path-string FileReader.) - (some-> path-file FileReader.))] - (try - (parse/read-ns-decl (readers/indexing-push-back-reader - (PushbackReader. file-reader)) - {:read-cond :allow :features #{dialect}}) - (catch Exception _ nil)))))) + path) + ^File file (or path-file (File. path-string))] + (try + (with-open [file-reader (FileReader. file)] + (try + (parse/read-ns-decl (readers/indexing-push-back-reader + (PushbackReader. file-reader)) + (if dialect + {:read-cond :allow :features #{dialect}} + nil)) + (catch Exception _ nil))) + (catch FileNotFoundException e + (throw (ex-info (format "No such file: %s. This typically indicates an invalid request client-side." + (pr-str path)) + {:path path + :dialect dialect + :file (str file)} + e))))))) (defn cljc-extension? [^String path] (.endsWith path ".cljc")) diff --git a/test/refactor_nrepl/core_test.clj b/test/refactor_nrepl/core_test.clj index c8bd552b..e99cbac4 100644 --- a/test/refactor_nrepl/core_test.clj +++ b/test/refactor_nrepl/core_test.clj @@ -28,16 +28,19 @@ (assert-ignored-paths not-ignored false?) (assert-ignored-paths (concat always-ignored sometimes-ignored) true?))))) -(deftest test-read-ns-form - (are [input expected] (testing input - (assert (-> input File. .exists)) - (is (= expected - (sut/read-ns-form input))) - true) - "test-resources/readable_file_incorrect_aliases.clj" nil - "testproject/src/com/example/one.clj" '(ns com.example.one - (:require [com.example.two :as two :refer [foo]] - [com.example.four :as four])))) +(deftest read-ns-form-test + (let [valid-filename "testproject/src/com/example/one.clj"] + (is (= (sut/read-ns-form valid-filename) + (sut/read-ns-form :clj valid-filename))) + (are [input expected] (testing input + (assert (-> input File. .exists)) + (is (= expected + (sut/read-ns-form input))) + true) + "test-resources/readable_file_incorrect_aliases.clj" nil + valid-filename '(ns com.example.one + (:require [com.example.two :as two :refer [foo]] + [com.example.four :as four]))))) (deftest source-files-with-clj-like-extension-test (let [result (sut/source-files-with-clj-like-extension true)] From 3c40b64fca6afd882e43c92984b97fc5798abf3a Mon Sep 17 00:00:00 2001 From: vemv Date: Thu, 10 Feb 2022 13:47:33 +0100 Subject: [PATCH 3/6] Add Clojars badge --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index a2d6cacf..92ca3fe5 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ [![CircleCI](https://circleci.com/gh/clojure-emacs/refactor-nrepl/tree/master.svg?style=svg)](https://circleci.com/gh/clojure-emacs/refactor-nrepl/tree/master) +[![Clojars Project](https://img.shields.io/clojars/v/refactor-nrepl/refactor-nrepl.svg)](https://clojars.org/refactor-nrepl/refactor-nrepl) [![Dependencies Status](https://versions.deps.co/clojure-emacs/refactor-nrepl/status.svg)](https://versions.deps.co/clojure-emacs/refactor-nrepl) [![cljdoc badge](https://cljdoc.org/badge/refactor-nrepl/refactor-nrepl)](https://cljdoc.org/d/refactor-nrepl/refactor-nrepl/CURRENT) [![downloads badge](https://versions.deps.co/refactor-nrepl/refactor-nrepl/downloads.svg)](https://clojars.org/refactor-nrepl/refactor-nrepl) From 2e4b7646f832505749239c0f80d1fe149d9eda80 Mon Sep 17 00:00:00 2001 From: vemv Date: Thu, 10 Feb 2022 13:48:37 +0100 Subject: [PATCH 4/6] 3.3.2 --- CHANGELOG.md | 2 ++ README.md | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e3b25eea..133c18d0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## Unreleased +## 3.3.2 + * [#173](https://github.com/clojure-emacs/refactor-nrepl/issues/173): `rename-file-or-dir`: rename more kinds of constructs in dependent namespaces: namespace-qualified maps, fully-qualified functions, metadata. * [#194](https://github.com/clojure-emacs/refactor-nrepl/issues/194): Don't prune `require` forms if they are needed for a given `import` to work. * [#142](https://github.com/clojure-emacs/refactor-nrepl/issues/142): `read-ns-form`: report more informatively when a non-existing file is being processed. diff --git a/README.md b/README.md index 92ca3fe5..3cd017cd 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ Be aware that this isn't the case if you connect to an already running REPL proc Add the following, either in your project's `project.clj`, or in the `:user` profile found at `~/.lein/profiles.clj`: ```clojure -:plugins [[refactor-nrepl "3.3.1"] +:plugins [[refactor-nrepl "3.3.2"] [cider/cider-nrepl "0.25.9"]] ``` @@ -372,12 +372,12 @@ If you want to use `mranderson` while developing locally with the REPL, the sour When you want to release locally to the following: - PROJECT_VERSION=3.3.1 make install + PROJECT_VERSION=3.3.2 make install And here's how to deploy to Clojars: ```bash -git tag -a v3.3.1 -m "3.3.1" +git tag -a v3.3.2 -m "3.3.2" git push --tags ``` From b52d636925f85839871ff37788e5a75122067bb2 Mon Sep 17 00:00:00 2001 From: vemv Date: Thu, 10 Feb 2022 13:49:27 +0100 Subject: [PATCH 5/6] Remove Boot instructions --- README.md | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/README.md b/README.md index 3cd017cd..2726c264 100644 --- a/README.md +++ b/README.md @@ -30,21 +30,6 @@ Add the following, either in your project's `project.clj`, or in the `:user` pr [cider/cider-nrepl "0.25.9"]] ``` -### Adding the middleware via Boot - -Add the following in `~/.boot/profile.boot`: - -```clojure -(require 'boot.repl) - -(swap! boot.repl/*default-dependencies* conj - '[refactor-nrepl "3.3.1"] - '[cider/cider-nrepl "0.25.9"]) - -(swap! boot.repl/*default-middleware* conj - 'refactor-nrepl.middleware/wrap-refactor) -``` - ### Embedded nREPL You may want launch your own nREPL server with CIDER and refactor-nrepl in it. You'll be able to [`cider-connect`](https://github.com/clojure-emacs/cider/blob/6a17686799b7ef97bc15fa041016421e5c875bfb/cider.el#L1150) to said server. @@ -387,7 +372,7 @@ An extensive changelog is available [here](CHANGELOG.md). ## License -Copyright © 2013-2021 Benedek Fazekas, Magnar Sveen, Alex Baranosky, Lars Andersen, Bozhidar Batsov +Copyright © 2013-2022 Benedek Fazekas, Magnar Sveen, Alex Baranosky, Lars Andersen, Bozhidar Batsov Distributed under the Eclipse Public License, the same as Clojure. From c3d377f73b4dc68571368bcf95d6e22479cd4ea1 Mon Sep 17 00:00:00 2001 From: vemv Date: Thu, 10 Feb 2022 14:01:14 +0100 Subject: [PATCH 6/6] Disable mranderson parallelism in missing places --- .circleci/config.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index f0fa1dea..df44fd41 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -39,6 +39,7 @@ executors: - image: circleci/clojure:openjdk-11-lein-2.9.3-buster-node environment: LEIN_ROOT: "true" # we intended to run lein as root + LEIN_JVM_OPTS: -Dmranderson.internal.no-parallelism=true JVM_OPTS: -Xmx3200m --illegal-access=deny # forbid reflective access (this flag doesn't exist for JDK8 or JDK17+) <<: *defaults @@ -47,6 +48,7 @@ executors: - image: circleci/clojure:openjdk-16-lein-2.9.5-buster-node environment: LEIN_ROOT: "true" # we intended to run lein as root + LEIN_JVM_OPTS: -Dmranderson.internal.no-parallelism=true JVM_OPTS: -Xmx3200m --illegal-access=deny # forbid reflective access (this flag doesn't exist for JDK8 or JDK17+) <<: *defaults @@ -55,6 +57,7 @@ executors: - image: circleci/clojure:openjdk-17-lein-2.9.5-buster-node environment: LEIN_ROOT: "true" # we intended to run lein as root + LEIN_JVM_OPTS: -Dmranderson.internal.no-parallelism=true JVM_OPTS: -Xmx3200m <<: *defaults