Skip to content
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

feat(javascript): improve as_expression support #1287

Merged
merged 1 commit into from
Sep 21, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions internal/languages/javascript/analyzer/analyzer.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ func (analyzer *analyzer) Analyze(node *sitter.Node, visitChildren func() error)
})
case "assignment_expression":
return analyzer.analyzeAssignment(node, visitChildren)
case "as_expression":
return analyzer.analyzeAsExpression(node, visitChildren)
case "augmented_assignment_expression":
return analyzer.analyzeAugmentedAssignment(node, visitChildren)
case "variable_declarator":
Expand Down Expand Up @@ -87,6 +89,14 @@ func (analyzer *analyzer) Analyze(node *sitter.Node, visitChildren func() error)
}
}

func (analyzer *analyzer) analyzeAsExpression(node *sitter.Node, visitChildren func() error) error {
analyzer.builder.Alias(node, node.Child(0))

err := visitChildren()

return err
}

// user = ...
func (analyzer *analyzer) analyzeAssignment(node *sitter.Node, visitChildren func() error) error {
left := node.ChildByFieldName("left")
Expand Down
Loading