< prev index next >

src/jdk.scripting.nashorn.shell/share/classes/jdk/nashorn/tools/jjs/Main.java

Print this page

        

@@ -83,10 +83,11 @@
      */
     public static int main(final InputStream in, final OutputStream out, final OutputStream err, final String[] args) throws IOException {
         return new Main().run(in, out, err, args);
     }
 
+
     /**
      * read-eval-print loop for Nashorn shell.
      *
      * @param context the nashorn context
      * @param global  global scope object to use

@@ -96,11 +97,11 @@
         final ScriptEnvironment env = context.getEnv();
         final String prompt = bundle.getString("shell.prompt");
         final PrintWriter err = context.getErr();
         final Global oldGlobal = Context.getGlobal();
         final boolean globalChanged = (oldGlobal != global);
-        final Completer completer = new NashornCompleter(context, global);
+        final Completer completer = new NashornCompleter(context, global, this);
 
         try (final Console in = new Console(System.in, System.out, HIST_FILE, completer)) {
             if (globalChanged) {
                 Context.setGlobal(global);
             }

@@ -150,6 +151,12 @@
             }
         }
 
         return SUCCESS;
     }
+
+    // This override exists precisely give access to this method to NashornCompleter!
+    @Override
+    protected int getLastExpressionStart(final Context context, final String code) {
+        return super.getLastExpressionStart(context, code);
+    }
 }
< prev index next >