Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Project analysis is constrained to .clj files #396

Closed
vemv opened this issue Jul 13, 2023 · 1 comment
Closed

Project analysis is constrained to .clj files #396

vemv opened this issue Jul 13, 2023 · 1 comment

Comments

@vemv
Copy link
Member

vemv commented Jul 13, 2023

means that
(defn warm-ast-cache []
(doseq [f (tracker/project-files-in-topo-order true)]
(try
(ns-ast (slurp f))
(catch Throwable th
(when (System/getProperty "refactor-nrepl.internal.log-exceptions")
(-> th .printStackTrace))
nil ; noop, ast-status will be reported separately
)))
(ast-stats))
will only see .clj files.

That's mostly desired behavior, since tools.analyzer only works for JVM Clojure.

However, we could also pick up .cljc files and tell tools.analyzer, if needed, to read them with :read-cond :allow :features #{:clj}.

This would result in a more complete analysis which therefore would be less prone to errors.

@vemv
Copy link
Member Author

vemv commented Jul 15, 2023

...I wrote something but deleted it.

Here goes a more accurate analysis:

  • slurp in the snippet above is used but for relatively minor purposes (parsing the ns and aliases)
    • worth updating slurp to a proper tools.reader/read reader-opts, so that we can also parse .cljc files
  • the main analysis is performed in
    (assoc-in (aj/analyze-ns ns (aj/empty-env) opts) [0 :alias-info] aliases))))))
    • this already implies tools.reader/read with :features #{:clj
    • so there's nothing to do here
  • after fixing the first bullet point, it's safe to fix to also include .cljc files.

vemv pushed a commit that referenced this issue Jul 21, 2023
@vemv vemv closed this as completed in 05485fb Jul 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant