private ScopeBlock findScopeBlockWithTarget ( ScopeBlock sb , int start , int target ) { ScopeBlock parentBlock = null ; int finishLocation = sb . getFinish ( ) ; if ( ( sb . getStart ( ) < start ) && ( finishLocation >= start ) && ( ( finishLocation <= target ) || ( sb . isGoto ( ) && ! sb . isLoop ( ) ) ) ) { parentBlock = sb ; } List < ScopeBlock > children = sb . getChildren ( ) ; if ( children != null ) { for ( ScopeBlock child : children ) { ScopeBlock targetBlock = findScopeBlockWithTarget ( child , start , target ) ; if ( targetBlock != null ) { return targetBlock ; } } } return parentBlock ; }
returns an existing scope block that has the same target as the one looked for