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

Commit c02b237

Browse files
authored
Merge pull request #390 from github/class-decorators-can-be-arbitrary-expressions
Class decorators can be (nearly) arbitrary expressions
2 parents 092a3fb + 0b386a1 commit c02b237

File tree

2 files changed

+13
-23
lines changed

2 files changed

+13
-23
lines changed

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

Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,15 @@ inherit .containing_class_value
411411
edge @comment.after_scope -> @comment.before_scope
412412
}
413413

414+
(identifier) @identifier {
415+
node @identifier.before_scope
416+
node @identifier.after_scope
417+
node @identifier.value
418+
node @identifier.covalue
419+
node @identifier.new_bindings
420+
edge @identifier.after_scope -> @identifier.before_scope
421+
}
422+
414423

415424

416425

@@ -2269,7 +2278,6 @@ inherit .containing_class_value
22692278
(member_expression)
22702279
(parenthesized_expression)
22712280
(undefined)
2272-
(primary_expression/identifier)
22732281
(this)
22742282
(super)
22752283
(number)
@@ -2398,9 +2406,6 @@ inherit .containing_class_value
23982406
;; #### Variables
23992407

24002408
(primary_expression/identifier)@variable {
2401-
; scopes don't change
2402-
edge @variable.after_scope -> @variable.before_scope
2403-
24042409
; value is a lookup, ie a push
24052410
attr (@variable.value) node_reference = @variable
24062411
edge @variable.value -> @variable.before_scope
@@ -2907,16 +2912,9 @@ inherit .containing_class_value
29072912

29082913
(arrow_function
29092914
parameter:(_)@param)@fun {
2910-
2911-
node @param.after_scope
29122915
node param_arg_index
2913-
node @param.before_scope
2914-
node @param.covalue
29152916
node param_pop
29162917

2917-
; scope flows from the param right back out
2918-
edge @param.after_scope -> @param.before_scope
2919-
29202918
; but augmented with a pop, b/c it's not a pattern
29212919
attr (param_pop) node_definition = @param
29222920
edge param_pop -> @param.covalue
@@ -3785,12 +3783,6 @@ inherit .containing_class_value
37853783
name:(identifier)@element_name)
37863784
]
37873785
{
3788-
3789-
node @element_name.before_scope
3790-
node @element_name.after_scope
3791-
3792-
edge @element_name.after_scope -> @element_name.before_scope
3793-
37943786
scan (source-text @element_name) {
37953787
; standard HTML elements
37963788
"^(a|abbr|acronym|address|applet|area|article|aside|audio|b|base|basefont|bdi|bdo|big|blockquote|body|br|button|canvas|caption|center|cite|code|col|colgroup|data|datalist|dd|del|details|dfn|dialog|dir|div|dl|dt|em|embed|fieldset|figcaption|figure|font|footer|form|frame|frameset|h1|h2|h3|h4|h5|h6|head|header|hgroup|hr|html|i|iframe|input|ins|kbd|label|legend|li|link|main|map|mark|menu|meta|meter|nav|noframes|noscript|object|ol|optgroup|option|output|p|param|picture|pre|progress|q|rp|rt|ruby|s|samp|script|search|section|select|small|source|span|strike|strong|style|sub|summary|sup|svg|table|tbody|td|template|textarea|tfoot|th|thead|time|title|tr|track|tt|u|ul|var|video|wbr)$" {
@@ -3819,8 +3811,6 @@ inherit .containing_class_value
38193811
(identifier)@first_part
38203812
(identifier)@second_part)@nested_identifier
38213813
{
3822-
node @first_part.value
3823-
node @second_part.value
38243814
node guard_member
38253815

38263816
attr (@first_part.value) node_reference = @first_part
@@ -3837,7 +3827,6 @@ inherit .containing_class_value
38373827
(nested_identifier)@first_part
38383828
(identifier)@second_part)@nested_identifier
38393829
{
3840-
node @second_part.value
38413830
node guard_member
38423831

38433832
attr (@second_part.value) node_reference = @second_part
@@ -4129,13 +4118,11 @@ inherit .containing_class_value
41294118
;; ### Attributes Defined on Patterns
41304119
;; TODO
41314120
[
4132-
(assignment_expression left:(identifier)@pattern)
41334121
(assignment_pattern)@pattern
41344122
(object_pattern)@pattern
41354123
(array_pattern)@pattern
41364124
(rest_pattern)@pattern
41374125
(pair_pattern)@pattern
4138-
(pattern/identifier)@pattern
41394126
(pattern/property_identifier)@pattern
41404127
(object_assignment_pattern)@pattern
41414128
(shorthand_property_identifier_pattern)@pattern
@@ -4160,7 +4147,6 @@ inherit .containing_class_value
41604147
; scope flows through, binding via a pop edge that goes to an unknown value
41614148
attr (ident_pat_pop) node_definition = @ident_pat
41624149
edge ident_pat_pop -> @ident_pat.covalue
4163-
edge @ident_pat.after_scope -> @ident_pat.before_scope
41644150
edge @ident_pat.after_scope -> ident_pat_pop
41654151

41664152
edge @ident_pat.new_bindings -> ident_pat_pop

languages/tree-sitter-stack-graphs-javascript/test/base_syntax.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ function foo(a) { }
1212
function foo(undefined) { }
1313
function* foo() { }
1414
class Foo { }
15+
@Foo class Bar { }
16+
@Foo.Quux class Bar { }
17+
@Foo() class Bar { }
18+
@Foo.Quux() class Bar { }
1519
{ }
1620
if (true) { }
1721
if (true) { } else { }

0 commit comments

Comments
 (0)