< prev index next >
src/jdk.scripting.nashorn.shell/share/classes/jdk/nashorn/tools/jjs/Main.java
Print this page
*** 83,92 ****
--- 83,93 ----
*/
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,106 ****
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);
try (final Console in = new Console(System.in, System.out, HIST_FILE, completer)) {
if (globalChanged) {
Context.setGlobal(global);
}
--- 97,107 ----
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, this);
try (final Console in = new Console(System.in, System.out, HIST_FILE, completer)) {
if (globalChanged) {
Context.setGlobal(global);
}
*** 150,155 ****
--- 151,162 ----
}
}
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 >