fix(extract): keep decorators separated by a comment#1097
Open
JhohanBustamante wants to merge 1 commit into
Open
fix(extract): keep decorators separated by a comment#1097JhohanBustamante wants to merge 1 commit into
JhohanBustamante wants to merge 1 commit into
Conversation
Comments are NAMED tree-sitter nodes, so the prev-sibling walk in
extract_decorators() stopped at one — silently dropping every decorator ABOVE
an interleaved comment:
@post('login') <-- dropped
@httpcode(HttpStatus.OK) <-- dropped
// throttled per IP and account
@Throttle({ ... }) <-- kept
async login(...)
The route then vanished from decorator/route queries, so documenting a
decorator made the endpoint disappear from the graph. Real-world impact: on a
NestJS backend, 1 of 95 HTTP endpoints was missing — the one whose throttle
policy carried an explanatory comment.
Comments are now transparent to the walk, the same way anonymous tokens
(e.g. TS `export`) already were. Reuses the existing is_comment_node() helper.
Signed-off-by: KolisCode <jhohantma@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1095.
A comment between decorators drops every decorator above it
extract_decorators()walks prev-siblings and breaks on the first NAMED node.Comments are named nodes in tree-sitter, so a comment interleaved in a
decorator run ends the walk:
The route then has no
@Post, so it vanishes from any decorator-based query:documenting a decorator removes the endpoint from the graph. On the backend I was
indexing, exactly 1 of 95 HTTP endpoints was missing — the one whose throttle
policy carried an explanatory comment.
Comments are now transparent to the walk, the same way the anonymous tokens
(e.g. TS
export) already were. Reuses the existingis_comment_node()helper.Test
tests/test_extraction.c:extract_ts_decorators_survive_interleaved_commenttest-runner extraction→ 214 passed (ASan + UBSan build).Split out of #1075 per review, as one focused PR linked to its issue. The Cypher
composite-property fix is now #1096 / its own PR.