| 157 | |
| 158 | |
| 159 | def match_from_span(node, blob: str) -> str: |
| 160 | # logger.warn('From version 0.0.6, we move `match_from_span` to `get_node_text`') |
| 161 | lines = blob.split('\n') |
| 162 | line_start = node.start_point[0] |
| 163 | line_end = node.end_point[0] |
| 164 | char_start = node.start_point[1] |
| 165 | char_end = node.end_point[1] |
| 166 | if line_start != line_end: |
| 167 | return '\n'.join([lines[line_start][char_start:]] + lines[line_start+1:line_end] + [lines[line_end][:char_end]]) |
| 168 | else: |
| 169 | return lines[line_start][char_start:char_end] |
| 170 | |
| 171 | |
| 172 | def match_from_spans(nodes, blob: str) -> str: |