clojure-emacs / refactor-nrepl

nREPL middleware to support refactorings in an editor agnostic way
Eclipse Public License 1.0
256 stars 69 forks source link

Ignore-paths either ignored or not working? #390

Closed rmuslimov closed 1 year ago

rmuslimov commented 1 year ago

Issue

I'm trying to avoid building AST for certain file which has unfortunately incorrect entry (we have previous issue describing it). I'm setting ignore path via:

(setq cljr-middleware-ignored-paths '(".*mappers.clj"))

Assuming this var will be picked up when refactor-nrepl is called. When I call "cljr-rename-symbol" in the project after it still fails with exception

ERROR: Unhandled REPL handler exception processing message {:dir /Users/rmuslimov/workspace/plato/, :prefix-rewriting true, :ns plato.adapters.morse.core, :name render-keyboard-for-user, :file /Users/rmuslimov/workspace/plato/src/main/clj/plato/adapters/morse/core.clj, :ignore-errors [], :debug false, :op find-symbol, :column 7, :insert-newline-after-require true, :line 18, :id 98, **:ignore-paths [.*mappers.clj],** :session aa4fff30-2497-4460-a788-64ae05359664}
java.lang.IllegalStateException: refactor-nrepl is unable to build an AST for plato.lib.storage.mappers. tools.analyzer encountered the following problem: Params must be valid binding symbols, had: [clojure.lang.Symbol]
    at refactor_nrepl.analyzer$throw_ast_in_bad_state.invokeStatic(analyzer.clj:111)
    at refactor_nrepl.analyzer$throw_ast_in_bad_state.invoke(analyzer.clj:108)
    at refactor_nrepl.analyzer$ns_ast.invokeStatic(analyzer.clj:127)
    at refactor_nrepl.analyzer$ns_ast.invoke(analyzer.clj:115)

Message contains :ignore-paths [.*mappers.clj],, so I assume it passed properly. Am I doing something wrong with regex syntax, why this file still used for AST building?

I also tried corner case example of putting ".*" as regex, and error still occurs

Expected behavior

Once ignore-paths is set, file shouldnt' be used for AST building

Actual behavior

However, it is still used

Steps to reproduce the problem

above

This is extremely important! Providing us with a reliable way to reproduce a problem will expedite its solution.

Environment & Version information

clj-refactor.el and refactor-nrepl version information

clj-refactor 3.6.0 (package: 20221023.1644), refactor-nrepl 3.6.0

CIDER version information

Include here the version string displayed when CIDER's REPL is launched. Here's an example:

;; CIDER 1.6.0-snapshot (package: 20221208.1801), nREPL 1.0.0
;; Clojure 1.11.1, Java 19.0.1

deps.edn version

{:deps {io.github.clojure/tools.build {:git/tag "v0.8.1" :git/sha "7d40500"}}

Emacs version

GNU Emacs 28.2 (build 1, x86_64-apple-darwin18.7.0, NS appkit-1671.60 Version 10.14.6 (Build 18G95)) of 2022-09-12

Operating system

Macos Ventura 13.01

vemv commented 1 year ago

Thanks for the detailed report!

Unfortunately for your intent, the ignore-paths most likely don't work that way. Specifically, they're not forwarded to tools.analyzer.

Analysis works at namespace level, not a directory level, so if anywhere in your ns tree there's a reference to the problematic ns, t.ana will analyze it no matter what.

However https://github.com/AppsFlyer/pronto/pull/15 is on its way.

Cheers - V