[英]Cannot get instrumentable syms in project via Leiningen plugin
I'm trying to write a leiningen plugin based upon clojure.spec.alpha
.我正在尝试编写一个基于
clojure.spec.alpha
的 leiningen 插件。 Among other things, I want to get all of the functions in the project that have been spec'd.除其他事项外,我想获得项目中已规范的所有功能。 This is done by calling
instrumentable-syms
in clojure.spec.test.alpha
.这是通过在
clojure.spec.test.alpha
调用instrumentable-syms
来完成的。 I have a function within my plugin that does this, but when run in the context of another project (via eval-in-project
), the list of instrumentable syms is empty.我的插件中有一个函数可以执行此操作,但是当在另一个项目的上下文中运行时(通过
eval-in-project
),可检测符号列表为空。 I suspect this is because the calls to fdef
within the project using the plugin, which are generally top-level forms within the source files and which register the specs, are not being evaluated and are thus not being picked up when calling instrumentable-syms
.我怀疑这是因为使用插件的项目中对
fdef
的调用(通常是源文件中的顶级表单并注册规范)没有被评估,因此在调用instrumentable-syms
时不会被拾取。
My question is then, how do I make sure these calls get evaluated so my plugin can find all the spec'd functions in a project.我的问题是,我如何确保这些调用得到评估,以便我的插件可以在项目中找到所有规范的函数。
Try doing something to load the relevant namespaces and thus bring your program "to life", perhaps if you have a file like src/orgname/project/core.clj
then you might try calling:尝试做一些事情来加载相关的命名空间,从而使您的程序“栩栩如生”,也许如果您有一个像
src/orgname/project/core.clj
这样的文件,那么您可以尝试调用:
(load "orgname/project/core")
From within the block of code run in the project.从项目中运行的代码块内。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.