From 7b5228b0ef8d1b235e5438b70ad2861e8e511738 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Fabianski?= Date: Thu, 21 Sep 2023 13:54:32 +0200 Subject: [PATCH] feat(javascript): improve as_expression support --- internal/languages/javascript/analyzer/analyzer.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/internal/languages/javascript/analyzer/analyzer.go b/internal/languages/javascript/analyzer/analyzer.go index a0cfe6aaa..20e6d159a 100644 --- a/internal/languages/javascript/analyzer/analyzer.go +++ b/internal/languages/javascript/analyzer/analyzer.go @@ -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": @@ -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")