Skip to content
This repository was archived by the owner on Sep 9, 2025. It is now read-only.

Commit b785a8e

Browse files
author
Hendrik van Antwerpen
committed
Update tree-sitter-javascript to 0.20.2
1 parent 1547ea2 commit b785a8e

File tree

2 files changed

+55
-33
lines changed

2 files changed

+55
-33
lines changed

languages/tree-sitter-stack-graphs-javascript/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ serde = { version = "1.0", features = ["derive"] }
3232
serde_json = "1.0"
3333
stack-graphs = { version = "0.13", path = "../../stack-graphs" }
3434
tree-sitter-graph = "0.11.2"
35-
tree-sitter-javascript = "=0.20.1"
35+
tree-sitter-javascript = "=0.20.2"
3636
tree-sitter-stack-graphs = { version = "0.8", path = "../../tree-sitter-stack-graphs" }
3737

3838
[dev-dependencies]

languages/tree-sitter-stack-graphs-javascript/src/stack-graphs.tsg

Lines changed: 54 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2296,6 +2296,9 @@ inherit .containing_class_value
22962296
(number)
22972297
(string)
22982298
(template_string)
2299+
(template_substitution)
2300+
(string_fragment)
2301+
(escape_sequence)
22992302
(regex)
23002303
(true)
23012304
(false)
@@ -2304,7 +2307,7 @@ inherit .containing_class_value
23042307
(import)
23052308
(object)
23062309
(array)
2307-
(function)
2310+
(function_expression)
23082311
(arrow_function)
23092312
(generator_function)
23102313
(class)
@@ -2329,7 +2332,7 @@ inherit .containing_class_value
23292332
}
23302333

23312334
[
2332-
(function body:(_)@body)
2335+
(function_expression body:(_)@body)
23332336
(arrow_function body:(_)@body)
23342337
(generator_function body:(_)@body)
23352338
] {
@@ -2367,42 +2370,54 @@ inherit .containing_class_value
23672370
;; #### Template Strings
23682371

23692372
; template_strings w/ no substitutions
2370-
(template_string (_)* @substs)@template_string {
2371-
if (is-empty @substs) {
2373+
(template_string (_)* @parts)@template_string {
2374+
if (is-empty @parts) {
23722375
edge @template_string.after_scope -> @template_string.before_scope
23732376
}
23742377
}
23752378

23762379
; nonempty template string, value
23772380
; LATER-TODO this isn't really right, but it gets flows through the template string
23782381
; which may be useful
2379-
(template_string (template_substitution (_)@inner_expr))@template_string {
2382+
(template_string (_)@part)@template_string {
23802383
; the value of a template string is a template string value built from the values of its substitutions
23812384
; attr (@template_string.value) "template_string_value"
2382-
edge @template_string.value -> @inner_expr.value
2385+
edge @template_string.value -> @part.value
23832386
}
23842387

23852388
; nonempty template string, first substitution
2386-
(template_string . (template_substitution (_)@first_inner_expr))@template_string {
2389+
(template_string . (_)@first)@template_string {
23872390
; scopes propagate into the first subtitution of the template string
2388-
edge @first_inner_expr.before_scope -> @template_string.before_scope
2391+
edge @first.before_scope -> @template_string.before_scope
23892392
}
23902393

23912394
; nonempty template string, between substitutions
23922395
(template_string
2393-
(template_substitution (_)@left_inner_expr)
2396+
(_) @left
23942397
.
2395-
(template_substitution (_)@right_inner_expr))@_template_string {
2398+
(_) @right) {
23962399
; scopes propagate from left substitutions to right substitutions
2397-
edge @right_inner_expr.before_scope -> @left_inner_expr.after_scope
2400+
edge @right.before_scope -> @left.after_scope
23982401
}
23992402

24002403
; nonempty template string, last substitution
2401-
(template_string . (template_substitution (_)@last_inner_expr))@template_string {
2404+
(template_string (_) @last .)@template_string {
24022405
; scopes propagate out of the last substitution to the template string
2403-
edge @template_string.after_scope -> @last_inner_expr.after_scope
2406+
edge @template_string.after_scope -> @last.after_scope
2407+
}
2408+
2409+
[
2410+
(string_fragment)
2411+
(escape_sequence)
2412+
]@part {
2413+
edge @part.after_scope -> @part.before_scope
24042414
}
24052415

2416+
(template_substitution (_)@expr)@subst {
2417+
edge @expr.before_scope -> @subst.before_scope
2418+
edge @subst.after_scope -> @expr.after_scope
2419+
edge @subst.value -> @expr.value
2420+
}
24062421

24072422

24082423
;; #### Numbers
@@ -2785,7 +2800,7 @@ inherit .containing_class_value
27852800
;; #### Function Literals
27862801

27872802
; functions with names
2788-
(function
2803+
(function_expression
27892804
name:(_)@name
27902805
parameters:(_)@call_sig)@fun {
27912806

@@ -2800,7 +2815,7 @@ inherit .containing_class_value
28002815

28012816

28022817
; function
2803-
(function
2818+
(function_expression
28042819
parameters:(_)@call_sig
28052820
body:(_)@body)@fun {
28062821

@@ -2859,7 +2874,7 @@ inherit .containing_class_value
28592874
edge @fun.value_arg_scope -> JUMP_TO_SCOPE_NODE
28602875
}
28612876

2862-
(function
2877+
(function_expression
28632878
parameters:
28642879
(formal_parameters (_)@param))@fun {
28652880

@@ -3485,20 +3500,27 @@ inherit .containing_class_value
34853500

34863501
;; #### Comma Operator / Sequence Expressions
34873502

3488-
(sequence_expression
3489-
left: (_)@left
3490-
right: (_)@right)@sequence_expr {
3503+
(sequence_expression (_)* @elems)@sequence_expr {
3504+
if (is-empty @elems) {
3505+
edge @sequence_expr.after_scope -> @sequence_expr.before_scope
3506+
}
3507+
}
3508+
3509+
(sequence_expression . (_)@first)@sequence_expr {
3510+
edge @first.before_scope -> @sequence_expr.before_scope
3511+
}
34913512

3492-
; scopes propagate left to right
3493-
edge @left.before_scope -> @sequence_expr.before_scope
3513+
(sequence_expression (_)@left . (_)@right) {
34943514
edge @right.before_scope -> @left.after_scope
3495-
edge @sequence_expr.after_scope -> @right.after_scope
3515+
}
34963516

3497-
; the value is just the value of the right
3498-
edge @sequence_expr.value -> @right.value
3517+
(sequence_expression (_)@last .)@sequence_expr {
3518+
edge @sequence_expr.after_scope -> @last.after_scope
3519+
edge @sequence_expr.value -> @last.value
34993520
}
35003521

35013522

3523+
35023524
;; #### Ternary Expression
35033525

35043526
(ternary_expression
@@ -4716,7 +4738,7 @@ inherit .containing_class_value
47164738

47174739
}
47184740

4719-
(function
4741+
(function_expression
47204742
name:(_)@name
47214743
parameters:(_)@_call_sig)@fun {
47224744

@@ -4830,15 +4852,15 @@ inherit .containing_class_value
48304852
(variable_declarator
48314853
name:(identifier)@name
48324854
value: [
4833-
(function)
4855+
(function_expression)
48344856
(generator_function)
48354857
(arrow_function)
48364858
]))
48374859
(lexical_declaration
48384860
(variable_declarator
48394861
name:(identifier)@name
48404862
value: [
4841-
(function)
4863+
(function_expression)
48424864
(generator_function)
48434865
(arrow_function)
48444866
]))
@@ -4848,7 +4870,7 @@ inherit .containing_class_value
48484870
; (member_expression property:(_)@name) ; FIXME member expressions are references and have no .pop
48494871
]
48504872
right: [
4851-
(function)
4873+
(function_expression)
48524874
(generator_function)
48534875
(arrow_function)
48544876
])
@@ -4878,7 +4900,7 @@ inherit .containing_class_value
48784900
)
48794901
]
48804902
right: [
4881-
(function)
4903+
(function_expression)
48824904
(generator_function)
48834905
(arrow_function)
48844906
])@assignment_expr
@@ -4897,7 +4919,7 @@ inherit .containing_class_value
48974919
object:(_)@_module
48984920
property:(_)@_exports)
48994921
right: [
4900-
(function)
4922+
(function_expression)
49014923
(generator_function)
49024924
(arrow_function)
49034925
])@assignment_expr
@@ -4913,7 +4935,7 @@ inherit .containing_class_value
49134935

49144936
(export_statement "default"
49154937
value:[
4916-
(function)
4938+
(function_expression)
49174939
(generator_function)
49184940
(arrow_function)
49194941
])@export_stmt {
@@ -4927,7 +4949,7 @@ inherit .containing_class_value
49274949
(pair
49284950
key: (_)@name
49294951
value: [
4930-
(function)
4952+
(function_expression)
49314953
(generator_function)
49324954
(arrow_function)
49334955
]) {

0 commit comments

Comments
 (0)