Skip to content

Commit 4d71327

Browse files
committed
fix(python): extract a decorated class nested in a class body
push_nested_class_nodes descended into field/template/declaration and conditional wrappers but not into Python's decorated_definition, so a decorated nested class (`@dataclass class Meta:` inside a class) was never extracted: no Class node, no Method nodes, and the calls in it fell to the FILE node. Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
1 parent 4b59b9a commit 4d71327

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

‎internal/cbm/extract_defs.c‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11493,9 +11493,12 @@ static void push_nested_class_nodes(TSNode body, const CBMLangSpec *spec, wd_sta
1149311493
wd_push(s, child, enclosing_qn);
1149411494
} else {
1149511495
const char *ck = ts_node_type(child);
11496-
/* A nested class inside #if/#else is still nested here. */
11496+
/* A nested class inside #if/#else is still nested here, and so is
11497+
* a decorated one (Python `@dataclass class Meta:` in a class
11498+
* body): the decorated_definition wraps the class_definition. */
1149711499
if (strcmp(ck, "field_declaration") == 0 ||
1149811500
strcmp(ck, "template_declaration") == 0 || strcmp(ck, "declaration") == 0 ||
11501+
(ctx->language == CBM_LANG_PYTHON && strcmp(ck, "decorated_definition") == 0) ||
1149911502
cbm_kind_in_set(child, cbm_conditional_block_types(spec->language))) {
1150011503
ts_nstack_push(&nc_stack, child);
1150111504
}

0 commit comments

Comments
 (0)