public List < GeneratedPosition > allGeneratedPositionsFor ( int line , Integer column , String source ) { // When there is no exact match, BasicSourceMapConsumer.prototype._findMapping // returns the index of the closest mapping less than the needle. By // setting needle.originalColumn to 0, we thus find the last mapping for // the given line, provided such a mapping exists. ParsedMapping needle = new ParsedMapping ( null , null , line , column == null ? 0 : column , null , null ) ; if ( this . sourceRoot != null ) { source = Util . relative ( this . sourceRoot , source ) ; } if ( ! this . _sources . has ( source ) ) { return Collections . emptyList ( ) ; } needle . source = this . _sources . indexOf ( source ) ; List < GeneratedPosition > mappings = new ArrayList <> ( ) ; int index = _findMapping ( needle , this . _originalMappings ( ) , "originalLine" , "originalColumn" , ( mapping1 , mapping2 ) -> Util . compareByOriginalPositions ( mapping1 , mapping2 , true ) , BinarySearch . Bias . LEAST_UPPER_BOUND ) ; if ( index >= 0 ) { ParsedMapping mapping = this . _originalMappings ( ) . get ( index ) ; if ( column == null ) { int originalLine = mapping . originalLine ; // Iterate until either we run out of mappings, or we run into // a mapping for a different line than the one we found. Since // mappings are sorted, this is guaranteed to find all mappings for // the line we found. while ( mapping != null && mapping . originalLine == originalLine ) { mappings . add ( new GeneratedPosition ( mapping . generatedLine , mapping . generatedColumn , mapping . lastGeneratedColumn ) ) ; index ++ ; if ( index >= this . _originalMappings ( ) . size ( ) ) { mapping = null ; } else { mapping = this . _originalMappings ( ) . get ( index ) ; } } } else { int originalColumn = mapping . originalColumn ; // Iterate until either we run out of mappings, or we run into // a mapping for a different line than the one we were searching for. // Since mappings are sorted, this is guaranteed to find all mappings for // the line we are searching for. while ( mapping != null && mapping . originalLine == line && mapping . originalColumn == originalColumn ) { mappings . add ( new GeneratedPosition ( mapping . generatedLine , mapping . generatedColumn , mapping . lastGeneratedColumn ) ) ; index ++ ; if ( index >= this . _originalMappings ( ) . size ( ) ) { mapping = null ; } else { mapping = this . _originalMappings ( ) . get ( index ) ; } } } } return mappings ; }
Returns all generated line and column information for the original source line and column provided . If no column is provided returns all mappings corresponding to a either the line we are searching for or the next closest line that has any mappings . Otherwise returns all mappings corresponding to the given line and either the column we are searching for or the next closest column that has any offsets .