TypeScript: skip ! when parsing variable statements#4389
TypeScript: skip ! when parsing variable statements#4389masatake merged 2 commits intouniversal-ctags:masterfrom
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #4389 +/- ##
=======================================
Coverage 86.02% 86.02%
=======================================
Files 253 253
Lines 63506 63506
=======================================
Hits 54634 54634
Misses 8872 8872 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
416d9c3 to
feb392b
Compare
There was a problem hiding this comment.
Pull request overview
This PR adds support for TypeScript's non-null assertion operator (!) in the parser, ensuring it is properly skipped and doesn't interfere with parsing variable statements and class properties.
Changes:
- Added
TOKEN_BANGto handle the!operator in TypeScript - Updated parser logic to skip
!tokens in variable and class body parsing contexts - Added comprehensive test cases for both definite assignment assertions and non-null assertions
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| parsers/typescript.c | Added TOKEN_BANG token type and updated parsers to handle ! in variable statements and class properties |
| Units/parser-typescript.r/skip-bang.d/validator | Added validator file specifying TypeScript compiler for test validation |
| Units/parser-typescript.r/skip-bang.d/input.ts | Added test case for non-null assertion in ternary expression |
| Units/parser-typescript.r/skip-bang.d/input-0.ts | Added test case for definite assignment assertions on class properties |
| Units/parser-typescript.r/skip-bang.d/expected.tags | Added expected parser output for the test cases |
| Units/parser-typescript.r/skip-bang.d/args.ctags | Added test configuration to disable sorting |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Fixes universal-ctags#4384 Suggested-by: Rimvydas Naktinis (@naktinis) Signed-off-by: Masatake YAMATO <yamato@redhat.com>
feb392b to
730354d
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| TOKEN_QUESTION_MARK, TOKEN_COLON, TOKEN_SEMICOLON, TOKEN_EQUAL_SIGN, | ||
| TOKEN_QUESTION_MARK, TOKEN_BANG, TOKEN_COLON, TOKEN_SEMICOLON, TOKEN_EQUAL_SIGN, | ||
| TOKEN_MINUS, TOKEN_PLUS, TOKEN_DIV, TOKEN_POWER, | ||
| TOKEN_GREATER, TOKEN_LOWER, TOKEN_PERIOD, TOKEN_COMMA, |
There was a problem hiding this comment.
In ClassBodyAfterCurlyChars, the character list contains <> (i.e., < then >), but the corresponding token list maps them as TOKEN_GREATER, TOKEN_LOWER. Because parseChar() indexes by the character position, this will classify < as TOKEN_GREATER and > as TOKEN_LOWER. Swap the token order (or the character order) so < maps to TOKEN_LOWER and > maps to TOKEN_GREATER consistently (as in VariableChars).
| TOKEN_GREATER, TOKEN_LOWER, TOKEN_PERIOD, TOKEN_COMMA, | |
| TOKEN_LOWER, TOKEN_GREATER, TOKEN_PERIOD, TOKEN_COMMA, |
There was a problem hiding this comment.
Seems to make sense, but unrelated to this PR
There was a problem hiding this comment.
I will reconsider this comment from the copilot in another pull request that may fix #4000.
There was a problem hiding this comment.
The token types neither TOKEN_LOWER nor TOKEN_GENERATOR are not considered in the code executed after calling ClassBodyAfterCurlyChars(). So this mismatch has not been a trouble. Anyway, I will make a pull request.
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
730354d to
f03070c
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 7 out of 7 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Fixes #4384