This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-09-30
Channels
- # aleph (1)
- # announcements (7)
- # aws (4)
- # beginners (52)
- # calva (11)
- # cider (20)
- # clj-kondo (36)
- # clojure (53)
- # clojure-austin (1)
- # clojure-brasil (1)
- # clojure-conj (1)
- # clojure-europe (27)
- # clojure-italy (17)
- # clojure-nl (11)
- # clojure-norway (2)
- # clojure-spec (41)
- # clojure-uk (39)
- # clojuredesign-podcast (2)
- # clojurescript (22)
- # clojutre (14)
- # community-development (24)
- # cursive (6)
- # data-science (1)
- # datomic (38)
- # duct (3)
- # figwheel-main (8)
- # fulcro (34)
- # funcool (8)
- # jackdaw (3)
- # jobs (2)
- # off-topic (84)
- # pathom (3)
- # re-frame (4)
- # shadow-cljs (8)
- # tools-deps (5)
- # vim (7)
i'm looking at the analysis export in the var-usages section -- one of the map entries i see is roughly like:
{:filename "src/augistints/src/augistints/gen.cljc",
:row 11,
:col 17,
:from augistints.gen,
:to rewrite-clj.zip,
:name string,
:arity 1,
:lang :clj}
i looked in the source file and what i see on row / line 11 is:
(let [fn-name (rz/string (:fn-name studied))]
there is the following bit in the ns declaration at the top of the file:
[rewrite-clj.zip :as rz]))
so it looks like the analysis data doesn't retain the alias info within the map entry in this case (though perhaps the info about rz == rewrite-clj.zip is retained elsewhere in the analysis info).
is there a way to get it to do that?
is it correct that there's no way currently to distinguish between occurrences of:
1) rewrite-clj.zip/string
2) rz/string
without visitng the file to check?the alias is included in other parts of the analysis information so you might be able to get it like that.
in emacs, the default M-. behavior detects namespaces so i wanted to create indices where the identifiers can also have ns / alias info with them.
then i don't need to give instructions to override emacs behavior to throw away ns info.
i may try doing that -- there are a few things about that, possibly minor: 1) indexing will likely be slower (not sure how much, so may be once i do it, i'll have a better idea) 2) i can't distinguish from the analysis data whether the occurence is rewrite-clj.zip/string or rz/string without visiting the file -- may be that's not important though
to address the second point, i guess i can throw in extra index entries for every non-ns-prefixed entry -- so the index may grow in size
from this:
:namespace-usages [{:filename "<stdin>",
:row 1,
:col 20,
:from foo,
:to clojure.set,
:alias set}]
you can make a map from filename to namespace name + aliasbut I guess adding the alias to the var usage would also be fine, maybe call it :to-alias
or something
ah, also, i noticed that things that use (alias ...) and not require :as, don't seem to get picked up in the same way.
he he -- hopefully i'll learn enough about clj-kondo that that will be manageable before long 🙂
it's just data processing -- and there are already many other places where this data is emitted, so you can just imitate that if you're interested in doing a fix.
ah, if it's not too much trouble, would you mind pointing me at specific functions / lines of an example or two?
Sure. These are the functions through which all the data flows that ends up in the analysis export: https://github.com/borkdude/clj-kondo/blob/master/src/clj_kondo/impl/analysis.clj So you can grep for wherever these functions are called.