From 62a1ff3bb22b4f0934bf8f3deba5b297340b418a Mon Sep 17 00:00:00 2001 From: Rebecca Valentine Date: Wed, 17 Jan 2024 14:06:12 -0800 Subject: [PATCH] Makes class definiens be the constructor instead of the class body --- .../src/stack-graphs.tsg | 32 ++++++++++++++----- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/languages/tree-sitter-stack-graphs-javascript/src/stack-graphs.tsg b/languages/tree-sitter-stack-graphs-javascript/src/stack-graphs.tsg index b1c6481d2..e4eb58924 100644 --- a/languages/tree-sitter-stack-graphs-javascript/src/stack-graphs.tsg +++ b/languages/tree-sitter-stack-graphs-javascript/src/stack-graphs.tsg @@ -4629,11 +4629,19 @@ inherit .return_or_yield ;; These rules are all about declarations and terms that have the names ;; directly in them. -(class_declaration - name:(_)@name - body:(_)@_body)@class_decl { +( + (class_declaration + name:(_)@name + body:(class_body + (method_definition + name:(_)@name)@constructor + ) + ) + + (#eq? @name "constructor") +) { - attr (@name.pop) definiens_node = @class_decl + attr (@name.pop) definiens_node = @constructor } @@ -4680,11 +4688,19 @@ inherit .return_or_yield } -(class - name:(_)@name - body:(_)@_body)@class { +( + (class + name:(_)@name + body:(class_body + (method_definition + name:(_)@name)@constructor + ) + ) - attr (@name.pop) definiens_node = @class + (#eq? @name "constructor") +) { + + attr (@name.pop) definiens_node = @constructor }