Hi Andy,
thanks for the useful feature request. As I need some more thoughts on how to implement this properly, I have added a new GitHub issue [1]. Currently (and I guess you do something similar), I usually open the module to be imported, I copy the module declaration, paste it to the importing module and add the relative URL.
A good alternative would be to have an "Organize Import" feature similar to the one in Eclipse (triggered e.g. by the shortcut Ctrl+Shift+O), which automatically adds modules that have not been imported yet, and removes unused imports from the query prolog.
For all of those features, we could either decide to offer straightforward solutions that work in 90% of the cases, but that are not based on parsing the code, and thus fail miserably in the remaining cases. Of course, my preference would be to do it right, but it may then happen that nothing happens at all…
Christian
[1] https://github.com/BaseXdb/basex/issues/1027
I often find myself adding module imports in the GUI and I wonder if the following suggestion might speed up that process.
Add a new menu item to the filelist right click context menu "Add as import" when the file selection is a XQuery module.
The action would be to add a line to the current edit window source with
import module namespace {$prefix} = '{$namespace}' at {$path};
Where $prefix and $namespace} are read from the source of the selected file, and $path is calculated from the relative path from the edit file source to the selected filelist source. The line would be inserted at a suitable place in the prologue or at the current location if that is too tricky.
/Andy