MCPcopy Index your code
hub / github.com/itwanger/toBeBetterJavaer / findFallbackChildren

Function findFallbackChildren

scripts/sync-sidebar.js:347–367  ·  view source on GitHub ↗
(block, fallbackGroup)

Source from the content-addressed store, hash-verified

345}
346
347function findFallbackChildren(block, fallbackGroup) {
348 const textPattern = new RegExp(`\\btext\\s*:\\s*["']${escapeRegExp(fallbackGroup)}["']`, "g");
349 let textMatch;
350
351 while ((textMatch = textPattern.exec(block)) !== null) {
352 const childrenPattern = /\bchildren\s*:\s*\[/g;
353 childrenPattern.lastIndex = textMatch.index + textMatch[0].length;
354 const childrenMatch = childrenPattern.exec(block);
355 if (!childrenMatch) {
356 continue;
357 }
358
359 const arrayStart = childrenMatch.index + childrenMatch[0].lastIndexOf("[");
360 const arrayEnd = findMatchingBracket(block, arrayStart);
361 if (arrayEnd !== -1) {
362 return { start: arrayStart, end: arrayEnd };
363 }
364 }
365
366 return null;
367}
368
369function findLineStart(source, index) {
370 const lineBreak = source.lastIndexOf("\n", index);

Callers 1

appendMissingEntriesFunction · 0.85

Calls 2

escapeRegExpFunction · 0.85
findMatchingBracketFunction · 0.85

Tested by

no test coverage detected