- 
                Notifications
    You must be signed in to change notification settings 
- Fork 641
[WIP] JavaScript: extract tags related to import and export statements #4318
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
[WIP] JavaScript: extract tags related to import and export statements #4318
Conversation
Signed-off-by: Masatake YAMATO <[email protected]>
Signed-off-by: Masatake YAMATO <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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) | 
    
      
    
      Copilot
AI
    
    
    
      Oct 14, 2025 
    
  
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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:*?) | 
    
      
    
      Copilot
AI
    
    
    
      Oct 14, 2025 
    
  
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 */) | 
    
      
    
      Copilot
AI
    
    
    
      Oct 14, 2025 
    
  
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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) | 
    
      
    
      Copilot
AI
    
    
    
      Oct 14, 2025 
    
  
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. */ | 
    
      
    
      Copilot
AI
    
    
    
      Oct 14, 2025 
    
  
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Corrected spelling of 'fileds' to 'fields'.
| m = makeSimpleRefTag (token->string, JSTAG_MODULE, JS_MODULE_AGGREGATED); | ||
| readToken (token); | ||
| } | ||
| /* TODO: put m to fileds of u. */ | 
    
      
    
      Copilot
AI
    
    
    
      Oct 14, 2025 
    
  
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 | |||
    
      
    
      Copilot
AI
    
    
    
      Oct 14, 2025 
    
  
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.