@@ -1886,6 +1886,18 @@ static int collect_modifier_decorators(CBMArena *a, TSNode modifiers, const char
18861886 return idx ;
18871887}
18881888
1889+ /* Comments are NAMED nodes in tree-sitter, so a comment interleaved in a
1890+ * decorator run would end the walk and silently drop every decorator above it:
1891+ *
1892+ * @Post('login') <-- lost
1893+ * @HttpCode(HttpStatus.OK) <-- lost
1894+ * // why this route is throttled <-- walk stopped here
1895+ * @Throttle({ ... }) <-- kept
1896+ * async login(...)
1897+ *
1898+ * Documenting a decorator must not make it disappear from the graph, so treat
1899+ * comments as transparent — like the anonymous tokens already skipped below.
1900+ * (is_comment_node() is defined above, near the docstring helpers.) */
18891901static const char * * extract_decorators (CBMArena * a , TSNode node , const char * source ,
18901902 CBMLanguage lang , const CBMLangSpec * spec ) {
18911903 if (!spec -> decorator_node_types || !spec -> decorator_node_types [0 ]) {
@@ -1897,10 +1909,11 @@ static const char **extract_decorators(CBMArena *a, TSNode node, const char *sou
18971909 while (!ts_node_is_null (prev )) {
18981910 if (cbm_kind_in_set (prev , spec -> decorator_node_types )) {
18991911 count ++ ;
1900- } else if (ts_node_is_named (prev )) {
1912+ } else if (ts_node_is_named (prev ) && ! is_comment_node ( ts_node_type ( prev )) ) {
19011913 /* A real preceding construct ends the decorator run. Anonymous
19021914 * tokens (e.g. TS `export` between `@Decorator` and the
1903- * `class_declaration`) are skipped so the decorator is still seen. */
1915+ * `class_declaration`) and comments are skipped so the decorator
1916+ * is still seen. */
19041917 break ;
19051918 }
19061919 prev = ts_node_prev_sibling (prev );
@@ -1937,7 +1950,7 @@ static const char **extract_decorators(CBMArena *a, TSNode node, const char *sou
19371950 while (!ts_node_is_null (prev ) && idx < count ) {
19381951 if (cbm_kind_in_set (prev , spec -> decorator_node_types )) {
19391952 result [idx ++ ] = cbm_node_text (a , prev , source );
1940- } else if (ts_node_is_named (prev )) {
1953+ } else if (ts_node_is_named (prev ) && ! is_comment_node ( ts_node_type ( prev )) ) {
19411954 break ;
19421955 }
19431956 prev = ts_node_prev_sibling (prev );
0 commit comments