JDK-8165445 : jshell tool: Completion for /set exports or /retain exports
  • Type: Bug
  • Component: tools
  • Sub-Component: jshell
  • Priority: P4
  • Status: Closed
  • Resolution: Not an Issue
  • OS: generic
  • CPU: generic
  • Submitted: 2016-09-05
  • Updated: 2016-09-15
  • Resolved: 2016-09-15
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 10
10Resolved
Related Reports
Relates :  
Description
jshell> /set 
editor        exports       feedback      format        mode          prompt        start         truncation    

jshell> /set exports j
java.base                java.compact1            java.compact2            java.compact3            java.compiler            java.datatransfer        
java.desktop             java.httpclient          java.instrument          java.logging             java.management          java.naming              
java.prefs               java.rmi                 java.scripting           java.se                  java.security.jgss       java.security.sasl       
java.smartcardio         java.sql                 java.sql.rowset          java.xml                 java.xml.crypto          jdk.accessibility        
jdk.attach               jdk.charsets             jdk.compiler             jdk.crypto.ec            jdk.crypto.pkcs11        jdk.dynalink             
jdk.httpserver           jdk.internal.le          jdk.internal.opt         jdk.jartool              jdk.javadoc              jdk.jconsole             
jdk.jdeps                jdk.jdi                  jdk.jlink                jdk.jshell               jdk.jsobject             jdk.jstatd               
jdk.jvmstat              jdk.localedata           jdk.management           jdk.naming.dns           jdk.naming.rmi           jdk.net                  
jdk.scripting.nashorn    jdk.sctp                 jdk.security.auth        jdk.security.jgss        jdk.unsupported          jdk.vm.ci                
jdk.xml.dom              jdk.zipfs                

jshell> /set exports jdk.jshell jdk.
jdk.internal.jshell.debug            jdk.internal.jshell.tool             jdk.internal.jshell.tool.resources   jdk.jshell                           
jdk.jshell.execution                 jdk.jshell.execution.code            jdk.jshell.execution.extention       jdk.jshell.resources                 
jdk.jshell.spi                       

jshell> /set exports jdk.jshell jdk.


test cases:

                a -> assertCompletionContains(a, "/set exports |", false, "java.base ", "jdk.jconsole "),
                a -> assertCompletionContains(a, "/set exports java.base |", false, "java.util", "jdk.internal.misc"),
                a -> assertCompletionContains(a, "/set ex jdk.jconsole |", false, "sun.tools.jconsole"),
                a -> assertCompletionContains(a, "/set ex jdk.jshell jdk.in|", false, "jdk.internal.jshell.tool"),
                a -> assertCompletionContains(a, "/set ex jdk.jconsole |", false, "sun.tools.jconsole"),
                a -> assertCompletion(a, "/set ex not.found |", false),


                a -> assertCompletionContains(a, "/retain exports |", false, "java.base ", "jdk.jconsole "),
                a -> assertCompletionContains(a, "/retain exports java.base |", false, "java.util", "jdk.internal.misc"),
                a -> assertCompletionContains(a, "/retain ex jdk.jconsole |", false, "sun.tools.jconsole"),
                a -> assertCompletionContains(a, "/retain ex jdk.jshell jdk.in|", false, "jdk.internal.jshell.tool"),
                a -> assertCompletion(a, "/retain ex not.found |", false),
Comments
/set exports and /retain exports will not be implemented
15-09-2016

Shinya's original code. Needs new source of available modules/packages --- 978 static final class FixedCompletionProvider implements CompletionProvider { 979 980 private Supplier<String[]> alternativesSupplier; 981 private String[] alternatives; 982 983 public FixedCompletionProvider(String... alternatives) { 984 this.alternatives = alternatives; 985 } 986 987 public FixedCompletionProvider(Supplier<String[]> alternativesSupplier) { 988 this.alternativesSupplier = alternativesSupplier; 989 } 990 991 @Override 992 public List<Suggestion> completionSuggestions(String input, int cursor, int[] anchor) { 993 if (alternatives == null) { // XXX: THIS IS NOT THREAD SAFE!! 994 alternatives = alternativesSupplier.get(); 995 } 996 997 List<Suggestion> result = new ArrayList<>(); 998 999 for (String alternative : alternatives) { 1000 if (alternative.startsWith(input)) { 1001 result.add(new ArgSuggestion(alternative)); 1002 } 1003 } 1004 1005 anchor[0] = 0; 1006 1007 return result; 1008 } 1009 1010 } 1011 1012 ..... 1168 CompletionProvider moduleThenPackageCompletionProvider() { 1169 return new ContinuousCompletionProvider(() -> 1170 state.availableModules() 1171 .collect(toMap(Function.identity(), 1172 m -> new FixedCompletionProvider( 1173 () -> state.availablePackages(m).toArray(String[]::new)))), 1174 PERFECT_MATCHER); 1175 } 1176
05-09-2016

Robert says: (2) Not support them and not support command completion for /set exports. Command completion is not supported in much more common cases. Then we could support command completion in the future (see (3)). (3) What these commands do is simply execute an expression on the remote side. But we already have a mechanism to execute expressions on the remote side: Snippets. That leaves a problem: we wouldn't want these Snippets to be seen by the user, but we have a solution for that the tool uses the idGenerator. Another problem is that, by default and with no current way around the default, expressions generate temp-variables. My intention was to make this configurable -- see Eval.shouldGenTempVar(...). One goal I've been using in the design of the API is to keep it as small and simple as possible. This improves maintainability, but much more importantly makes the API easier to learn and use. So, for something to warrant inclusion it should be generally useful and have no other way of being achieved -- neither is true of these two queries.
05-09-2016