Skip to content

Commit

Permalink
feat(javascript): improve as_expression support (#1287)
Browse files Browse the repository at this point in the history
  • Loading branch information
cfabianski authored Sep 21, 2023
1 parent 3adeffd commit 088e299
Showing 1 changed file with 10 additions and 0 deletions.
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

0 comments on commit 088e299

Please sign in to comment.