mirror of
https://github.com/DeusData/codebase-memory-mcp.git
synced 2026-11-04 10:48:20 +00:00
fix(go): a definition with no name is no definition, not the key 12:(null)
GCC's production build refused the null %s, with -Werror. Also the Lua and Shell adapters' cppcheck items: an always-false check and three scopes that can narrow. Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
This commit is contained in:
1 parent
0507bbf295
commit
3ca4d91b96
3 files changed
+15
-10
No files matched your search
@@ -1486,8 +1486,10 @@ static void member_domains(go_collect_t *c, TSNode node, const char *name, const
|
||||
}
|
||||
|
||||
static const CBMDefinition *definition(go_collect_t *c, TSNode node, TSNode name) {
|
||||
const char *key = cbm_arena_sprintf(&c->call_arena, "%u:%s", ts_node_start_point(node).row + 1,
|
||||
text(c, name));
|
||||
const char *spelled = text(c, name);
|
||||
const char *key = spelled ? cbm_arena_sprintf(&c->call_arena, "%u:%s",
|
||||
ts_node_start_point(node).row + 1, spelled)
|
||||
: NULL;
|
||||
const void *value = key ? cbm_ht_get(c->definitions, key) : NULL;
|
||||
return value == c ? NULL : value;
|
||||
}
|
||||
|
||||
@@ -830,10 +830,12 @@ static lua_value_t lua_eval_uncached(lua_ctx_t *ctx, const char *encoded, unsign
|
||||
lua_value_t value = lua_eval_root(ctx, root, depth);
|
||||
while (step) {
|
||||
const char *next = strchr(step + 1, LUA_STEP[0]);
|
||||
const char *part =
|
||||
next ? cbm_arena_strndup(walk->arena, step + 1, (size_t)(next - step - 1)) : step + 1;
|
||||
if (!part)
|
||||
return lua_unknown("lua_value_allocation");
|
||||
const char *part = step + 1;
|
||||
if (next) {
|
||||
part = cbm_arena_strndup(walk->arena, step + 1, (size_t)(next - step - 1));
|
||||
if (!part)
|
||||
return lua_unknown("lua_value_allocation");
|
||||
}
|
||||
value = part[0] == '.' ? lua_member(ctx, value, part + 1, depth)
|
||||
: part[0] == '#' ? lua_call_value_at(ctx, value, part + 1, depth)
|
||||
: lua_call_result(ctx, value, depth);
|
||||
@@ -1525,9 +1527,9 @@ static void lua_visit_table(lua_ctx_t *ctx, TSNode node, unsigned depth) {
|
||||
cbm_source_walk_t *walk = ctx->walk;
|
||||
const char *owner = ctx->collecting ? lua_identity(ctx, 'T', ts_node_start_byte(node)) : NULL;
|
||||
const char *pending = NULL;
|
||||
uint32_t pending_row = 0;
|
||||
TSTreeCursor cursor = ts_tree_cursor_new(node);
|
||||
if (ts_tree_cursor_goto_first_child(&cursor)) {
|
||||
uint32_t pending_row = 0;
|
||||
do {
|
||||
TSNode field = ts_tree_cursor_current_node(&cursor);
|
||||
if (cbm_source_is(field, "comment")) {
|
||||
@@ -1784,9 +1786,9 @@ static void lua_visit_statements(lua_ctx_t *ctx, TSNode node, unsigned depth) {
|
||||
/* `local` and `global` are field names on the statement, not kinds. */
|
||||
lua_doc_t doc = {0};
|
||||
lua_doc_t *outer = ctx->doc;
|
||||
uint32_t last_row = UINT32_MAX;
|
||||
TSTreeCursor cursor = ts_tree_cursor_new(node);
|
||||
if (ts_tree_cursor_goto_first_child(&cursor)) {
|
||||
uint32_t last_row = UINT32_MAX;
|
||||
do {
|
||||
TSNode child = ts_tree_cursor_current_node(&cursor);
|
||||
if (!ts_node_is_named(child))
|
||||
|
||||
@@ -215,12 +215,13 @@ static void shell_collect_walk(shell_ctx_t *ctx, TSNode node, unsigned depth) {
|
||||
return;
|
||||
if (cbm_source_is(node, "function_definition")) {
|
||||
const char *name = cbm_source_text(walk, cbm_source_field(node, "name"));
|
||||
uint32_t line = ts_node_start_point(node).row + 1;
|
||||
const cbm_source_decl_t *first =
|
||||
name ? cbm_source_lookup(walk, ctx->functions, name) : NULL;
|
||||
if (name && !first)
|
||||
if (name && !first) {
|
||||
uint32_t line = ts_node_start_point(node).row + 1;
|
||||
(void)cbm_source_declare(walk, ctx->functions, name,
|
||||
cbm_source_def_qn_at(walk, name, line), 0, line);
|
||||
}
|
||||
} else if (cbm_source_is(node, "command")) {
|
||||
const char *word = shell_command_word(walk, node);
|
||||
if (word && (!strcmp(word, "source") || !strcmp(word, ".")))
|
||||
|
||||
Reference in new issue
Block a user