(source_file: &SourceFile, location: PySourceRange)
| 254 | } |
| 255 | |
| 256 | fn source_range_to_text_range(source_file: &SourceFile, location: PySourceRange) -> TextRange { |
| 257 | let index = LineIndex::from_source_text(source_file.clone().source_text()); |
| 258 | let source = &source_file.source_text(); |
| 259 | |
| 260 | if source.is_empty() { |
| 261 | return TextRange::new(TextSize::new(0), TextSize::new(0)); |
| 262 | } |
| 263 | |
| 264 | let start = index.offset( |
| 265 | location.start.to_source_location(), |
| 266 | source, |
| 267 | PositionEncoding::Utf8, |
| 268 | ); |
| 269 | let end = index.offset( |
| 270 | location.end.to_source_location(), |
| 271 | source, |
| 272 | PositionEncoding::Utf8, |
| 273 | ); |
| 274 | |
| 275 | TextRange::new(start, end) |
| 276 | } |
| 277 | |
| 278 | fn node_add_location( |
| 279 | dict: &Py<PyDict>, |
no test coverage detected