Skip to content

Commit

Permalink
suggest-libspecs: fuly parse Elisp format
Browse files Browse the repository at this point in the history
  • Loading branch information
vemv committed Jul 6, 2023
1 parent d916e2e commit 3bda039
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

## 3.7.1

* Fix an oversight in `suggest-libspecs`.

## 3.7.0

* Implement new middleware op: `suggest-libspecs`
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ deploy: check-env .inline-deps
jar: .inline-deps
lein with-profile -user,+$(VERSION),+plugin.mranderson/config jar

# Usage: PROJECT_VERSION=3.7.0 make install
# Usage: PROJECT_VERSION=3.7.1 make install
# PROJECT_VERSION is needed because it's not computed dynamically
install: check-install-env .inline-deps
lein with-profile -user,+$(VERSION),+plugin.mranderson/config install
LEIN_JVM_OPTS="-Dmranderson.internal.no-parallelism=true" lein with-profile -user,+$(VERSION),+plugin.mranderson/config install

check-env:
ifndef CLOJARS_USERNAME
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.7.0"]
:plugins [[refactor-nrepl "3.7.1"]
[cider/cider-nrepl "0.31.0"]]
```

Expand Down Expand Up @@ -365,7 +365,7 @@ When you want to release locally to the following:
And here's how to deploy to Clojars:

```bash
git tag -a v3.7.0 -m "3.7.0"
git tag -a v3.7.1 -m "3.7.1"
git push --tags
```

Expand Down
12 changes: 12 additions & 0 deletions src/refactor_nrepl/middleware.clj
Original file line number Diff line number Diff line change
Expand Up @@ -39,22 +39,34 @@
:err (with-out-str (print-cause-trace ex))
:status #{status :done}})

;; TODO - simplify this. I don't fully get why there are disparate keys depending on the exception class.
;; Ideally, users would always get a stacktrace (however noisy).
(defmacro ^:private with-errors-being-passed-on [transport msg & body]
`(try
~@body
(catch clojure.lang.ExceptionInfo e#
(when (System/getProperty "refactor-nrepl.internal.pst")
(-> e# .printStackTrace))
(transport/send
~transport (response-for ~msg :error (.toString e#) :status :done)))
(catch IllegalArgumentException e#
(when (System/getProperty "refactor-nrepl.internal.pst")
(-> e# .printStackTrace))
(transport/send
~transport (response-for ~msg :error (.getMessage e#) :status :done)))
(catch IllegalStateException e#
(when (System/getProperty "refactor-nrepl.internal.pst")
(-> e# .printStackTrace))
(transport/send
~transport (response-for ~msg :error (.getMessage e#) :status :done)))
(catch Exception e#
(when (System/getProperty "refactor-nrepl.internal.pst")
(-> e# .printStackTrace))
(transport/send
~transport (response-for ~msg (err-info e# :refactor-nrepl-error))))
(catch Error e#
(when (System/getProperty "refactor-nrepl.internal.pst")
(-> e# .printStackTrace))
(transport/send
~transport (response-for ~msg (err-info e# :refactor-nrepl-error))))))

Expand Down
8 changes: 7 additions & 1 deletion src/refactor_nrepl/ns/suggest_libspecs.clj
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,13 @@

(def parse-preferred-aliases
(memoize (fn parse-preferred-aliases* [preferred-aliases]
(let [m (volatile! {})]
(let [preferred-aliases (into []
(map (fn [x]
(into []
(remove #{\. '. "."})
x)))
(read-string preferred-aliases))
m (volatile! {})]
(doseq [[prefix ns-name _only-keyword only] (mapv (partial mapv (comp symbol
name)) ;; `name` for Clojure <= 1.9 compat
preferred-aliases)
Expand Down
2 changes: 1 addition & 1 deletion test/refactor_nrepl/ns/suggest_libspecs_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
(sut/suggest-libspecs-response {:lib-prefix lib-prefix
:buffer-language-context buffer-lc
:input-language-context input-lc
:preferred-aliases preferred-aliases
:preferred-aliases (some-> preferred-aliases pr-str)
:namespace-aliases-fn (when (seq project-libspecs)
;; if provided, replace `refactor-nrepl.ns.libspecs/namespace-aliases`
;; with a mocked value, for test simplicity.
Expand Down

0 comments on commit 3bda039

Please sign in to comment.