File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -4583,13 +4583,22 @@ function closeModal(divId) {
45834583// All of the Java frontend code in this function was written by David
45844584// Pritchard and Will Gwozdz, and integrated by Philip Guo
45854585ExecutionVisualizer . prototype . activateJavaFrontend = function ( ) {
4586- // super hack by Philip that reverses the direction of the stack so
4587- // that it grows DOWN and renders the same way as the Python and JS
4588- // visualizer stacks
4586+ var prevLine = null ;
45894587 this . curTrace . forEach ( function ( e , i ) {
4588+ // ugh the Java backend doesn't attach line numbers to exception
4589+ // events, so just take the previous line number as our best guess
4590+ if ( e . event === 'exception' && ! e . line ) {
4591+ e . line = prevLine ;
4592+ }
4593+
4594+ // super hack by Philip that reverses the direction of the stack so
4595+ // that it grows DOWN and renders the same way as the Python and JS
4596+ // visualizer stacks
45904597 if ( e . stack_to_render !== undefined ) {
45914598 e . stack_to_render . reverse ( ) ;
45924599 }
4600+
4601+ prevLine = e . line ;
45934602 } ) ;
45944603
45954604 this . add_pytutor_hook (
Original file line number Diff line number Diff line change @@ -216,9 +216,10 @@ export class ExecutionVisualizer {
216216 this . domRootD3 = tmpRootD3 . select ( 'div.ExecutionVisualizer' ) ;
217217
218218 if ( this . params . lang === 'java' ) {
219- this . activateJavaFrontend ( ) ; // ohhhh yeah!
219+ this . activateJavaFrontend ( ) ; // ohhhh yeah! do this before initializing codeOutputLines (ugh order dependency)
220220 }
221221
222+
222223 var lines = this . curInputCode . split ( '\n' ) ;
223224 for ( var i = 0 ; i < lines . length ; i ++ ) {
224225 var cod = lines [ i ] ;
@@ -710,13 +711,22 @@ export class ExecutionVisualizer {
710711 // All of the Java frontend code in this function was written by David
711712 // Pritchard and Will Gwozdz, and integrated into pytutor.js by Philip Guo
712713 activateJavaFrontend ( ) {
713- // super hack by Philip that reverses the direction of the stack so
714- // that it grows DOWN and renders the same way as the Python and JS
715- // visualizer stacks
716- this . curTrace . forEach ( function ( e , i ) {
714+ var prevLine = null ;
715+ this . curTrace . forEach ( ( e , i ) => {
716+ // ugh the Java backend doesn't attach line numbers to exception
717+ // events, so just take the previous line number as our best guess
718+ if ( e . event === 'exception' && ! e . line ) {
719+ e . line = prevLine ;
720+ }
721+
722+ // super hack by Philip that reverses the direction of the stack so
723+ // that it grows DOWN and renders the same way as the Python and JS
724+ // visualizer stacks
717725 if ( e . stack_to_render !== undefined ) {
718726 e . stack_to_render . reverse ( ) ;
719727 }
728+
729+ prevLine = e . line ;
720730 } ) ;
721731
722732 this . add_pytutor_hook (
You can’t perform that action at this time.
0 commit comments