Open hinerm opened 8 years ago
@ctrueden @imagejan - any complaints?
Firstly: cool idea.
Questions and concerns:
ScriptLanguage
, perhaps? And then each scripting-<foo>
component can implement it the way it needs to—so scripting-java
would have the reflections
dependency. Does this make sense?TODO
you mention: allowing extensions to the package prefixes which are searched. I think the current solution of hardcoding is a (small) problem regardless, since it hardcodes sc.fiji
in a net.imagej
component, which we try very hard not to do. Or: we could just can everything on the classpath. Isn't that the behavior the user expects anyway? Auto-import any available class?Performance of classpath scanning en masse?
Slow. Takes a second or two. So you can tell it's happening but it doesn't feel ridiculous.
That said, I wrote it so that it only scans once and caches the discovered collection. Iterating the org-filtered collection of items is not really noticeable on subsequent adds.
Regardless, we could possibly add a progress bar.
The auto-imports feature in general should be in a UI-agnostic layer in SciJava Common probably.
Yep I agree with this plan.
since it hardcodes sc.fiji in a net.imagej component, which we try very hard not to do.
Agreed that this should be changed; that was a primary motivator for the TODO
:smile: . I guess I can put a plugin for sc.fiji
in https://github.com/fiji/fiji now that it has a src directory!
I guess I can put a plugin for
sc.fiji
in https://github.com/fiji/fiji now that it has a src directory!
Or perhaps repurpose the fiji-scripting project. I dunno.
Isn't that the behavior the user expects anyway? Auto-import any available class?
Yes, I would rather do this. But on my computer it takes 9s to scan all resources without filters, and 1.5s with filters. Anyway if we use an extensible model we can easily add more packages as needed.
The auto-imports feature in general should be in a UI-agnostic layer in SciJava Common probably. Part of the ScriptLanguage, perhaps? And then each scripting-
component can implement it the way it needs to—so scripting-java would have the reflections dependency. Does this make sense?
@ctrueden - after further thought here is my take on the architecture:
ResourceScannerService
with a ScannedPackage
singleton plugin type. The ScannedPackage
plugins would have API to return a list of the package strings to include. The service would have a getReflections
method which, the first time called, would combine all the packages from all ScannedPackage
plugins discovered and use that to build the filter list for reflections - which would put the reflections dependency in SJC.ScriptLanguage
iface would gain a getImport(String)
method which, given a class name, returns a properly formatted import statement.getImport(String)
ScannedPackage
plugin.any concerns?
Yes, I would rather do this. But on my computer it takes 9s to scan all resources without filters, and 1.5s with filters. Anyway if we use an extensible model we can easily add more packages as needed.
per @ctrueden's suggestion we can just run this initialization on a background thread at startup
The TextEditor
now lives in scijava/script-editor
, so we should move this PR over there.
Allows package detection of imports in Java in the script editor.
See http://fiji.sc/bugzilla/show_bug.cgi?id=817