private int beforeHookInsertLine ( TestMethod method , int codeLineIndex ) { if ( ! isLineLastStament ( method , codeLineIndex ) ) { // don't insert the beforeHook since afterHook does not inserted to this line return - 1 ; } // so that not to insert the hook to the middle of the line, // search the line top statement and insert hook to the statement line for ( int i = codeLineIndex ; i > 0 ; i -- ) { CodeLine thisLine = method . getCodeBody ( ) . get ( i ) ; CodeLine prevLine = method . getCodeBody ( ) . get ( i - 1 ) ; assert prevLine . getEndLine ( ) <= thisLine . getEndLine ( ) ; if ( prevLine . getEndLine ( ) != thisLine . getStartLine ( ) ) { return thisLine . getStartLine ( ) ; } } return method . getCodeBody ( ) . get ( 0 ) . getStartLine ( ) ; }
Returns - 1 if beforeHook for the codeLineIndex should not be inserted