Prototype/experiment of add import feature for JShell

Jan Lahoda jan.lahoda at oracle.com
Fri Dec 11 11:07:37 UTC 2015


Hello,

Lately, I was experimenting with two features for JShell:
1) quickly add import for unresolvable identifiers (JDK-8131027)

when the cursor in behind an unresolvable (type) identifier, press 
"Alt-= i" (*), JShell should offer adding import for matching FQNs. The 
first invocation of this feature in a given JShell run may take a 
significant amount of time, this is a known problem. Subsequent 
invocations in the same JShell run should be significantly faster.

Currently, only classes can be imported using this feature, importing 
(static) fields/methods is under consideration.

2) quickly introduce a variable for an expression

when the cursor is at the end of a line after an expression, press 
"Alt-= v" (*), JShell should infer the type of the expression and create 
a stub of a variable from the expression automatically.

(*) note that on some platforms, it may be necessary to use ESC-= 
instead of Alt-=; this is currently a known unresolved problem. For 
Window, please apply the following patch to the jdk repository:
http://cr.openjdk.java.net/~jlahoda/8131027/prototype/jdk-alt-eq.patch

The prototype patch implementing these two features is here:
http://cr.openjdk.java.net/~jlahoda/8131027/prototype/8131027-prototype-0.diff

Any feedback on these features would be wholeheartedly welcome.

Thanks to Robert for his feedback on previous iterations of this patch.

Thanks!

Jan


More information about the kulla-dev mailing list