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

Function findMatchingBracket

scripts/sync-sidebar.js:389–454  ·  view source on GitHub ↗
(source, openIndex)

Source from the content-addressed store, hash-verified

387}
388
389function findMatchingBracket(source, openIndex) {
390 let depth = 0;
391 let quote = null;
392 let escaped = false;
393 let lineComment = false;
394 let blockComment = false;
395
396 for (let index = openIndex; index < source.length; index += 1) {
397 const char = source[index];
398 const next = source[index + 1];
399
400 if (lineComment) {
401 if (char === "\n") {
402 lineComment = false;
403 }
404 continue;
405 }
406
407 if (blockComment) {
408 if (char === "*" && next === "/") {
409 blockComment = false;
410 index += 1;
411 }
412 continue;
413 }
414
415 if (quote) {
416 if (escaped) {
417 escaped = false;
418 } else if (char === "\\") {
419 escaped = true;
420 } else if (char === quote) {
421 quote = null;
422 }
423 continue;
424 }
425
426 if (char === "/" && next === "/") {
427 lineComment = true;
428 index += 1;
429 continue;
430 }
431
432 if (char === "/" && next === "*") {
433 blockComment = true;
434 index += 1;
435 continue;
436 }
437
438 if (char === '"' || char === "'" || char === "`") {
439 quote = char;
440 continue;
441 }
442
443 if (char === "[") {
444 depth += 1;
445 } else if (char === "]") {
446 depth -= 1;

Callers 2

findFallbackChildrenFunction · 0.85
findRouteArrayFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected