Skip to content

Commit 45db051

Browse files
authored
Merge pull request #377 from clojure-emacs/libspec-in-use-without-refer-all
`libspec-in-use-without-refer-all?`: account for `:as-alias` directives
2 parents 3824d33 + 2195743 commit 45db051

File tree

4 files changed

+15
-6
lines changed

4 files changed

+15
-6
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
## Unreleased
44

5+
## 3.5.1
6+
7+
* Refine `:as-alias` detection.
8+
59
## 3.5.0
610

711
* [#374](https://github.com/clojure-emacs/refactor-nrepl/issues/374): support Clojure 1.11's new `:as-alias` namespace directive.

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Be aware that this isn't the case if you connect to an already running REPL proc
2626
Add the following, either in your project's `project.clj`, or in the `:user` profile found at `~/.lein/profiles.clj`:
2727

2828
```clojure
29-
:plugins [[refactor-nrepl "3.5.0"]
29+
:plugins [[refactor-nrepl "3.5.1"]
3030
[cider/cider-nrepl "0.28.3"]]
3131
```
3232

@@ -360,12 +360,12 @@ If you want to use `mranderson` while developing locally with the REPL, the sour
360360

361361
When you want to release locally to the following:
362362

363-
PROJECT_VERSION=3.5.0 make install
363+
PROJECT_VERSION=3.5.1 make install
364364

365365
And here's how to deploy to Clojars:
366366

367367
```bash
368-
git tag -a v3.5.0 -m "3.5.0"
368+
git tag -a v3.5.1 -m "3.5.1"
369369
git push --tags
370370
```
371371

src/refactor_nrepl/ns/prune_dependencies.clj

+3-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
(= (lookup-symbol-ns current-ns symbol-in-file) ns))
2222

2323
(defn- libspec-in-use-without-refer-all?
24-
[{:keys [as ns refer refer-macros require-macros]} symbol-in-file]
24+
[{:keys [as as-alias ns refer refer-macros require-macros]} symbol-in-file]
2525
(or
2626
;; Used through refer clause
2727
(and (not= refer :all)
@@ -35,7 +35,8 @@
3535
;; Used as a fully qualified symbol
3636
(.startsWith ^String symbol-in-file (str ns "/"))
3737
;; Aliased symbol in use
38-
(and as (.startsWith ^String symbol-in-file (str as "/")))))
38+
(and as (.startsWith ^String symbol-in-file (str as "/")))
39+
(and as-alias (.startsWith ^String symbol-in-file (str as-alias "/")))))
3940

4041
(defn- libspec-in-use-with-rename?
4142
[{:keys [rename]} symbols-in-file]

test/refactor_nrepl/ns/prune_dependencies_test.clj

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
(ns refactor-nrepl.ns.prune-dependencies-test
22
(:require
3-
[clojure.test :refer [are deftest]]
3+
[clojure.test :refer [are is deftest]]
44
[refactor-nrepl.ns.prune-dependencies :as sut]))
55

6+
(deftest libspec-in-use-without-refer-all?
7+
(is (@#'sut/libspec-in-use-without-refer-all? '{:as-alias foo} "foo/bar"))
8+
(is (not (@#'sut/libspec-in-use-without-refer-all? '{:as-alias quux} "foo/bar"))))
9+
610
(deftest imports->namespaces
711
(are [input expected] (= expected
812
(sut/imports->namespaces input))

0 commit comments

Comments
 (0)