| 1448 | } cbm_error_regions_t; |
| 1449 | |
| 1450 | static void cbm_error_regions_push(cbm_error_regions_t *acc, TSNode n) { |
| 1451 | TSPoint start = ts_node_start_point(n); |
| 1452 | TSPoint end = ts_node_end_point(n); |
| 1453 | uint32_t start_line = start.row + 1; |
| 1454 | uint32_t end_line = end.row + 1; |
| 1455 | |
| 1456 | /* A node that ends at column 0 stopped right after the previous line's |
| 1457 | * newline, so it holds no text on the row it points at. Counting that row |
| 1458 | * named a line past the end of the file whenever the region ran to EOF: |
| 1459 | * scripts/setup-windows.ps1 has 326 lines and reported "245-327". */ |
| 1460 | if (end.column == 0 && end.row > start.row) { |
| 1461 | end_line = end.row; |
| 1462 | } |
| 1463 | |
| 1464 | /* One line can carry several error nodes, and repeating the same line range |
| 1465 | * says nothing new. Line 113 of scripts/setup-windows.ps1 has two error |
| 1466 | * nodes, at columns 25-29 and 31-32, and the report read "113-113,113-113". |
| 1467 | * Drop the repeat. |
| 1468 | * |
| 1469 | * Only an EXACT repeat of the range already open is dropped. Do not merge |
| 1470 | * ranges that merely overlap. Each range is judged separately later by |
| 1471 | * cbm_region_is_recovered, which asks whether definitions starting inside |
| 1472 | * that range cover it. Two ranges with the same numbers always get the same |
| 1473 | * verdict, so collapsing them changes nothing. Two DIFFERENT ranges do not: |
| 1474 | * merging 3-3 into 2-3 hands the wider range's covering definition to an |
| 1475 | * error the definition does not explain, and a real parse failure then |
| 1476 | * disappears from the report. tests/test_parse_coverage.c pins that case in |
| 1477 | * perl_malformed_source_remains_partial_issue1838. |
| 1478 | * |
| 1479 | * This runs BEFORE the cap check, so a dropped repeat never counts as a |
| 1480 | * range the cap threw away. */ |
| 1481 | if (acc->count > 0 && start_line == acc->starts[acc->count - 1] && |
| 1482 | end_line == acc->ends[acc->count - 1]) { |
| 1483 | return; |
| 1484 | } |
| 1485 | |
| 1486 | if (acc->count >= CBM_MAX_ERROR_REGIONS) { |
| 1487 | acc->dropped++; |
| 1488 | return; |
| 1489 | } |
| 1490 | acc->starts[acc->count] = start_line; |
| 1491 | acc->ends[acc->count] = end_line; |
| 1492 | acc->count++; |
| 1493 | } |
| 1494 | |
| 1495 | /* #1610: a file that does not end with a newline leaves the grammar's |
| 1496 | * mandatory line terminator MISSING. That node is ZERO-WIDTH and sits at EOF. |
no outgoing calls
no test coverage detected