File tree Expand file tree Collapse file tree 1 file changed +11
-0
lines changed
drjava/src/edu/rice/cs/drjava/model/repl/newjvm Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -296,15 +296,26 @@ private InterpretResult interpretWithJShell(StringBuilder input_buf) throws Inte
296296 output_buf .setLength (output_buf .length () - 1 );
297297 }
298298
299+ boolean hasError = false ;
300+
299301 //TODO Jshell adds a lot of fluff to the output, try and only get the cause of the error
300302 for (SnippetEvent e : events ) {
301303 if (e .status () == Snippet .Status .REJECTED ) {
302304 Diag diagnostics = _js .diagnostics (e .snippet ()).collect (Collectors .toList ()).get (0 );
303305 output_buf .append (diagnostics .getMessage (Locale .getDefault ()));
304306 res = InterpretResult .exception (new EvaluatorException (new Throwable (output_buf .toString ())));
307+ hasError = true ;
308+ } else if (e .value () != null ) {
309+ output_buf .append (e .value ()).append ("\n " );
305310 }
306311 }
307312
313+ if (!hasError && output_buf .length () > 0 ) {
314+ // Remove the last newline character added
315+ output_buf .setLength (output_buf .length () - 1 );
316+ res = InterpretResult .objectValue (output_buf .toString (), "JShellOutput" );
317+ }
318+
308319 if (res == null ) {
309320 //Setting InterpretResult as an object value rather than doing case work as JShell will internally keep track of state, bypassing need for us to do so
310321 res = InterpretResult .objectValue (output_buf .toString (), "JShellOutput" );
You can’t perform that action at this time.
0 commit comments