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

Function parse_dep_entry

internal/cbm/lsp/rust_cargo.c:141–186  ·  view source on GitHub ↗

For the `[dependencies]` / `[dev-dependencies]` / `[workspace.dependencies]` * sections, parse `key = value` lines until the next section. The value * may be a string (the version) or an inline table. We capture both * shapes — only the key (crate name) and optional `path = "..."` field * matter for us. */

Source from the content-addressed store, hash-verified

139 * shapes — only the key (crate name) and optional `path = "..."` field
140 * matter for us. */
141static int parse_dep_entry(CBMArena* a, const char* s, int len, int from,
142 CBMCargoManifest* out) {
143 from = skip_ws_and_comment(s, len, from);
144 if (from >= len || s[from] == '[') return from;
145 const char* key = NULL;
146 from = parse_key(a, s, len, from, &key);
147 from = skip_ws_and_comment(s, len, from);
148 if (from < len && s[from] == '=') {
149 from++;
150 from = skip_ws_and_comment(s, len, from);
151 }
152 const char* path_val = NULL;
153 if (from < len && s[from] == '{') {
154 /* Inline table — scan for `path = "..."`. */
155 int depth = 1;
156 from++;
157 while (from < len && depth > 0) {
158 from = skip_ws_and_comment(s, len, from);
159 if (from >= len) break;
160 char c = s[from];
161 if (c == '}') { depth--; from++; continue; }
162 if (c == ',') { from++; continue; }
163 /* sub-key */
164 const char* sub_key = NULL;
165 from = parse_key(a, s, len, from, &sub_key);
166 from = skip_ws_and_comment(s, len, from);
167 if (from < len && s[from] == '=') {
168 from++;
169 from = skip_ws_and_comment(s, len, from);
170 }
171 if (sub_key && strcmp(sub_key, "path") == 0) {
172 from = parse_string(a, s, len, from, &path_val);
173 } else {
174 from = skip_value(s, len, from);
175 }
176 }
177 } else {
178 from = skip_value(s, len, from);
179 }
180 if (key && out->dep_count < CBM_CARGO_MAX_DEPS) {
181 out->deps[out->dep_count].name = key;
182 out->deps[out->dep_count].path = path_val;
183 out->dep_count++;
184 }
185 return from;
186}
187
188/* ── Section dispatcher ──────────────────────────────────────── */
189

Callers 1

cbm_cargo_parseFunction · 0.85

Calls 4

skip_ws_and_commentFunction · 0.85
parse_keyFunction · 0.85
parse_stringFunction · 0.85
skip_valueFunction · 0.85

Tested by

no test coverage detected