Groovy Autocomplete based on Runtime Introspection?
- Dominant language
- Jupyter Notebook
- Stars
- 2.9k
- Forks
- 383
- PR merge metrics
- No merged PRs in 30d
Description
I've been browsing the code and notice that there is quite sophisticated support for Groovy autocomplete based on a fully integrated parser / lexer that can infer the static type of expressions and determine their methods etc. Using this I can get autocomplete for some things eg:

However I find that this almost never works for anything other than highly explicit cases where the types are either declared or explicitly inferrable through static analysis. However this is not how Groovy code is normally written so in practice this is unfortunately limited in how often it actually works. For example, I can get autocomplete to work on a String:

But not a map:

I am not sure if it's a bug that this doesn't work or just a consequence of the current parser and how it statically infers types.
Either way, I'm posting this issue to query whether consideration has been given to returning autocomplete results based not just on static parsing of the cell, but supplementing that with dynamic introspection of the properties and methods of the object under the cursor. This would allow for a huge increase in the possible autocomplete results and, I think, make the Groovy kernel much easier for beginners to get started with.
There would be some obvious downsides to doing this. Primarily, dynamic introspection of the properties can actually cause code execution in certain cases and that in turn can end up with the kernel even hanging if the code does something crazy or is blocked unexpectedly eg: on I/O.
Overall though, I think this would be a win - it is, after all, the behavior that is implemented in `groovysh`.
Would be great to hear thoughts on (a) whether this is feasible, or (b) desirable. If it's thought to be so, I'd be happy to (at least try) and have a go at implementing it. Alternatively if all this is acutally supposed to be implemented already and it just needs some diagnosing or bug fixing, I'd be happy to look at that too!
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.