deephaven / deephaven-core

Deephaven Community Core
Other
256 stars 80 forks source link

Groovy console import management #4161

Open niloc132 opened 1 year ago

niloc132 commented 1 year ago

In https://github.com/deephaven/deephaven-core/issues/4160, the groovy closure source() or sourceOnce() may be used to include another .groovy file as if its contents were pasted into the console. There are also other tools to manage imports in the console, such as GroovyDeephavenSession.addScriptImportClass() and addScriptImportClass(). These function by adding import lines that are used to prefix every other command that is run in the console.

We might consider a different way of making it easier to add or otherwise manage common imports in bulk, as a standard feature of the console experience, since we track those imports as state between commands.

While considering this, it might be worth looking at the groovysh project, especially import management, and see if there are other cues we could take from them on how to consistently manage imports so as to match other expectations a groovy developer might have. https://github.com/apache/groovy/blob/632d14f37e24c4e21265b53a761667e43414b54b/subprojects/groovy-groovysh/src/main/groovy/org/apache/groovy/groovysh/commands/ImportCommand.groovy#L82-L136 Basic behavior is roughly the same, but imports are removed when re-added to avoid duplicates.

rcaudy commented 1 year ago

source() and sourceOnce() are being removed.