-
Notifications
You must be signed in to change notification settings - Fork 649
Finish implementing sourceFileMayBeEmitted, JSON emit #1245
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
base: main
Are you sure you want to change the base?
Conversation
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 implements changes to the emission logic for source files, with particular attention to JSON modules and their output paths. Key changes include:
- Refining the handling of immediately invoked functions in JSON files (printer.go).
- Renaming and updating the helper function for generating output file paths (outputpaths.go).
- Introducing a new host interface and updating the logic for sourceFileMayBeEmitted (emitter.go).
Reviewed Changes
Copilot reviewed 71 out of 71 changed files in this pull request and generated 1 comment.
File | Description |
---|---|
internal/printer/printer.go | Adjusts expression emission for JSON files by checking the ScriptKind and avoiding parentheses for certain expressions. |
internal/outputpaths/outputpaths.go | Renames the helper function to follow Go naming conventions and updates its call site. |
internal/compiler/emitter.go | Refactors sourceFileMayBeEmitted by introducing a new host interface and adding conditions to decide file emission based on compiler options. |
@@ -3175,7 +3175,10 @@ func (p *Printer) emitEmptyStatement(node *ast.EmptyStatement, isEmbeddedStateme | |||
func (p *Printer) emitExpressionStatement(node *ast.ExpressionStatement) { | |||
state := p.enterNode(node.AsNode()) | |||
|
|||
if isImmediatelyInvokedFunctionExpressionOrArrowFunction(node.Expression) { | |||
if p.currentSourceFile != nil && p.currentSourceFile.ScriptKind == core.ScriptKindJSON { |
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.
The JSON-specific branch uses a hack comment referencing an undefined parenthesizerRule. Consider refactoring this block to either integrate a proper parenthesizing solution for JSON files or add a more descriptive comment on why the current approach is necessary.
Copilot uses AI. Check for mistakes.
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.
Ah yes, it's that simple
Fixes #660
I'm not happy with the emit change, but I don't know what the right fix is. Strada did parenthesizing completely differently.