* 查找子级 key 行
(lines, start, end, parentIndent, key)
| 4714 | * 查找子级 key 行 |
| 4715 | */ |
| 4716 | function findChildKey(lines, start, end, parentIndent, key) { |
| 4717 | for (let i = start + 1; i < end; i++) { |
| 4718 | const line = lines[i]; |
| 4719 | if (line.trim() === '' || line.trim().startsWith('#')) continue; |
| 4720 | const indent = line.search(/\S/); |
| 4721 | if (indent <= parentIndent) break; |
| 4722 | const m = line.match(/^\s*(\S+):\s*/); |
| 4723 | const rawKey = m ? m[1].replace(/^["']|["']$/g, '') : null; |
| 4724 | if (m && rawKey === key && indent === parentIndent + 2) { |
| 4725 | return i; |
| 4726 | } |
| 4727 | } |
| 4728 | return -1; |
| 4729 | } |
| 4730 | |
| 4731 | /** |
| 4732 | * 找一个 block 的结束行号(下一个同级或更低缩进的非空非注释行) |
no outgoing calls
no test coverage detected