(self, line: Line)
| 423 | """ |
| 424 | |
| 425 | def do_match(self, line: Line) -> TMatchResult: |
| 426 | LL = line.leaves |
| 427 | |
| 428 | is_valid_index = is_valid_index_factory(LL) |
| 429 | |
| 430 | string_indices = [] |
| 431 | idx = 0 |
| 432 | while is_valid_index(idx): |
| 433 | leaf = LL[idx] |
| 434 | if ( |
| 435 | leaf.type == token.STRING |
| 436 | and is_valid_index(idx + 1) |
| 437 | and LL[idx + 1].type == token.STRING |
| 438 | ): |
| 439 | # Let's check if the string group contains an inline comment |
| 440 | # If we have a comment inline, we don't merge the strings |
| 441 | contains_comment = False |
| 442 | i = idx |
| 443 | while is_valid_index(i): |
| 444 | if LL[i].type != token.STRING: |
| 445 | break |
| 446 | if line.comments_after(LL[i]): |
| 447 | contains_comment = True |
| 448 | break |
| 449 | i += 1 |
| 450 | |
| 451 | if not contains_comment and not is_part_of_annotation(leaf): |
| 452 | string_indices.append(idx) |
| 453 | |
| 454 | # Advance to the next non-STRING leaf. |
| 455 | idx += 2 |
| 456 | while is_valid_index(idx) and LL[idx].type == token.STRING: |
| 457 | idx += 1 |
| 458 | |
| 459 | elif leaf.type == token.STRING and "\\\n" in leaf.value: |
| 460 | string_indices.append(idx) |
| 461 | # Advance to the next non-STRING leaf. |
| 462 | idx += 1 |
| 463 | while is_valid_index(idx) and LL[idx].type == token.STRING: |
| 464 | idx += 1 |
| 465 | |
| 466 | else: |
| 467 | idx += 1 |
| 468 | |
| 469 | if string_indices: |
| 470 | return Ok(string_indices) |
| 471 | else: |
| 472 | return TErr("This line has no strings that need merging.") |
| 473 | |
| 474 | def do_transform( |
| 475 | self, line: Line, string_indices: list[int] |
nothing calls this directly
no test coverage detected