[WIP] JavaScript: extract tags related to import and export statements#4318
[WIP] JavaScript: extract tags related to import and export statements#4318masatake wants to merge 2 commits intouniversal-ctags:masterfrom
Conversation
Signed-off-by: Masatake YAMATO <[email protected]>
Signed-off-by: Masatake YAMATO <[email protected]>
There was a problem hiding this comment.
Pull Request Overview
This PR extracts tags related to import and export statements in JavaScript, enhancing the parser to handle ES6 module syntax. It introduces new tag kinds and roles for tracking imported/exported modules and identifiers.
- Adds new JavaScript tag kinds:
moduleandunknownwith associated roles for import/export handling - Implements parsing functions for import and export statements with destructuring support
- Updates parsing logic to extract local variables at non-global scopes
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 7 comments.
| File | Description |
|---|---|
| parsers/x-jscript.h | Adds JSTAG_MODULE and JSTAG_UNKNOWN enum values |
| parsers/jscript.c | Main implementation with new keywords, roles, parsing functions for import/export |
| Units/parser-javascript.r/es-export.d/input.mjs | Test file with various export statement examples |
| Tmain/list-roles.d/stdout-expected.txt | Updates expected output to include new module and unknown roles |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| * | ||
| * import * as Y from "X"; | ||
| * X = (kind:module, role:imported) | ||
| * Y = (kind:unknown?, nameref:*?, module:X) |
There was a problem hiding this comment.
Corrected spelling of 'Y = (kind:unknown?, nameref:*?, module:X)' - question marks should be removed as they appear to be placeholder notation.
| * import Y, * as Z from "X"; | ||
| * X = (kind:module, role:imported) | ||
| * Y = (kind:unknown, role:importedAsDefault, module:X) | ||
| * Z = (kind:unknown?, nameref:*?) |
There was a problem hiding this comment.
Corrected spelling of 'Z = (kind:unknown?, nameref:*?)' - question marks should be removed as they appear to be placeholder notation.
| else if (! isType (token, TOKEN_KEYWORD) && true | ||
| /* token->nestLevel == 0 && state->isGlobal */) |
There was a problem hiding this comment.
Replace hardcoded true with a meaningful condition or variable. The commented-out condition suggests this change may be temporary for testing purposes.
| else if (! isType (token, TOKEN_KEYWORD) && true | |
| /* token->nestLevel == 0 && state->isGlobal */) | |
| else if (! isType (token, TOKEN_KEYWORD) && token->nestLevel == 0 && state->isGlobal) |
| readToken(token); | ||
|
|
||
| if (state.isGlobal) | ||
| if (state.isGlobal || 1) |
There was a problem hiding this comment.
Replace hardcoded 1 with a meaningful condition or boolean variable. This appears to be a temporary change that makes the condition always true.
| if (state.isGlobal || 1) | |
| if (state.isGlobal) |
| m = makeSimpleRefTag (token->string, JSTAG_MODULE, JS_MODULE_AGGREGATED); | ||
| readToken (token); | ||
| } | ||
| /* TODO: put m to fileds of tags in us. */ |
There was a problem hiding this comment.
Corrected spelling of 'fileds' to 'fields'.
| m = makeSimpleRefTag (token->string, JSTAG_MODULE, JS_MODULE_AGGREGATED); | ||
| readToken (token); | ||
| } | ||
| /* TODO: put m to fileds of u. */ |
There was a problem hiding this comment.
Corrected spelling of 'fileds' to 'fields'.
| /* TODO: put m to fileds of u. */ | |
| /* TODO: put m to fields of u. */ |
| @@ -0,0 +1,32 @@ | |||
| // Derrived from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/export | |||
There was a problem hiding this comment.
Corrected spelling of 'Derrived' to 'Derived'.
| // Derrived from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/export | |
| // Derived from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/export |
Extract local variables, too.