(source_file: &SourceFile, text_range: TextRange)
| 142 | } |
| 143 | |
| 144 | fn text_range_to_source_range(source_file: &SourceFile, text_range: TextRange) -> PySourceRange { |
| 145 | let index = LineIndex::from_source_text(source_file.clone().source_text()); |
| 146 | let source = &source_file.source_text(); |
| 147 | |
| 148 | if source.is_empty() { |
| 149 | return PySourceRange { |
| 150 | start: PySourceLocation { |
| 151 | row: Row(OneIndexed::from_zero_indexed(0)), |
| 152 | column: Column(TextSize::new(0)), |
| 153 | }, |
| 154 | end: PySourceLocation { |
| 155 | row: Row(OneIndexed::from_zero_indexed(0)), |
| 156 | column: Column(TextSize::new(0)), |
| 157 | }, |
| 158 | }; |
| 159 | } |
| 160 | |
| 161 | let start_row = index.line_index(text_range.start()); |
| 162 | let end_row = index.line_index(text_range.end()); |
| 163 | let start_col = text_range.start() - index.line_start(start_row, source); |
| 164 | let end_col = text_range.end() - index.line_start(end_row, source); |
| 165 | |
| 166 | PySourceRange { |
| 167 | start: PySourceLocation { |
| 168 | row: Row(start_row), |
| 169 | column: Column(start_col), |
| 170 | }, |
| 171 | end: PySourceLocation { |
| 172 | row: Row(end_row), |
| 173 | column: Column(end_col), |
| 174 | }, |
| 175 | } |
| 176 | } |
| 177 | |
| 178 | fn get_opt_int_field( |
| 179 | vm: &VirtualMachine, |
no test coverage detected