Creating separate resolve scope for specific files

Answered

My plugin provides support for Clojure files. A project which is gaining popularity recently is Babashka, which uses Clojure for shell scripting. Babashka provides an executable with a lot of built-in libraries, but I'm not sure how to support this.

The basic problem is that there is nothing distinguishing Babashka files from Clojure files, and they tend to be mixed into the same project in arbitrary locations. My plan is to allow the user to specify which files are Babashka files, and then symbol resolution within those files will have to take into account the extra dependencies and other semantic elements available to Babashka scripts by default.

I've added a Babashka facet, and from a user-specified path to the executable I can get the required dependencies and download them using Maven. But I'm not sure how to attach them to the project. If I attach them to the module as libraries, then they will be available to normal Clojure code, which is incorrect. I need a way to be able to create a completely separate resolve scope, almost like a separate module. I considered using a separate Babashka module, but since the Babashka scripts are often intermingled in with the Clojure files managing the content roots would be difficult. Could I do this by using a separate module with no content roots to manage the Babashka dependencies, and then use that module's resolve scope when resolving some files in the original module using ResolveScopeProvider or something similar?

Any suggestions for the best way to handle this?

1 comment
Comment actions Permalink

It's possible to add individual files as content roots, but this may be inconvenient. You may try adding these additional dependencies via ResolveScopeEnlarger extension point instead.

0

Please sign in to leave a comment.