MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / jv_errors_contained

Function jv_errors_contained

internal/cbm/doclink_jvm.c:1704–1744  ·  view source on GitHub ↗

True when every parse error inside `decl` is held by braces of the text * that open and close inside it: an accessor's body, a `when`, a lambda, an * anonymous class. The declaration then ends where the tree says, whatever * went wrong within those braces. Needs the brace table (a file with * errors). */

Source from the content-addressed store, hash-verified

1702 * went wrong within those braces. Needs the brace table (a file with
1703 * errors). */
1704static bool jv_errors_contained(const jv_scan_t *s, TSNode decl) {
1705 uint32_t a = ts_node_start_byte(decl);
1706 uint32_t b = ts_node_end_byte(decl);
1707 int base = jv_depth_at(s, a);
1708 int first = jv_brace_lower(s, a);
1709 int end = jv_brace_lower(s, b);
1710 for (int i = first; i < end; i++) {
1711 int m = s->braces[i].match;
1712 if (m < first || m >= end) {
1713 return false; /* a brace whose partner is outside the declaration */
1714 }
1715 }
1716 bool contained = true;
1717 bool down = true;
1718 TSTreeCursor cur = ts_tree_cursor_new(decl);
1719 while (contained) {
1720 TSNode n = ts_tree_cursor_current_node(&cur);
1721 bool error = ts_node_is_error(n) || ts_node_is_missing(n);
1722 if (down && error) {
1723 contained = jv_depth_at(s, ts_node_start_byte(n)) > base &&
1724 jv_depth_at(s, ts_node_end_byte(n)) > base;
1725 }
1726 /* an error node is judged as a whole; only what holds one is entered */
1727 if (down && !error && ts_node_has_error(n) && ts_tree_cursor_goto_first_child(&cur)) {
1728 continue;
1729 }
1730 if (ts_node_eq(n, decl)) {
1731 break;
1732 }
1733 if (ts_tree_cursor_goto_next_sibling(&cur)) {
1734 down = true;
1735 continue;
1736 }
1737 if (!ts_tree_cursor_goto_parent(&cur)) {
1738 break;
1739 }
1740 down = false;
1741 }
1742 ts_tree_cursor_delete(&cur);
1743 return contained;
1744}
1745
1746/* True when a parse error inside `decl` may reach past it. */
1747static bool jv_errors_leak(const jv_scan_t *s, TSNode decl) {

Callers 1

jv_errors_leakFunction · 0.85

Calls 2

jv_depth_atFunction · 0.85
jv_brace_lowerFunction · 0.85

Tested by

no test coverage detected