Skip to content

Commit 7d741ef

Browse files
committed
Add keyword_loc to ForwardingSuperNode
They can take a block and so the keyword location is not always the entirety of the node. You can get it by constructing a location that is just the first 5 characters but why not have it be provided by prism?
1 parent ae5a82b commit 7d741ef

6 files changed

Lines changed: 15 additions & 0 deletions

File tree

config.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2627,6 +2627,14 @@ nodes:
26272627
end
26282628
- name: ForwardingSuperNode
26292629
fields:
2630+
- name: keyword_loc
2631+
type: location
2632+
comment: |
2633+
super
2634+
^^^^^
2635+
2636+
super { 123 }
2637+
^^^^^
26302638
- name: block
26312639
type: node?
26322640
kind: BlockNode

snapshots/super.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
└── body: (length: 9)
88
├── @ ForwardingSuperNode (location: (1,0)-(1,5))
99
│ ├── flags: newline
10+
│ ├── keyword_loc: (1,0)-(1,5) = "super"
1011
│ └── block: ∅
1112
├── @ SuperNode (location: (3,0)-(3,7))
1213
│ ├── flags: newline
@@ -83,6 +84,7 @@
8384
│ └── operator_loc: (11,6)-(11,7) = "&"
8485
├── @ ForwardingSuperNode (location: (13,0)-(13,8))
8586
│ ├── flags: newline
87+
│ ├── keyword_loc: (13,0)-(13,5) = "super"
8688
│ └── block:
8789
│ @ BlockNode (location: (13,6)-(13,8))
8890
│ ├── flags: ∅

snapshots/unparser/corpus/literal/super.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
└── body: (length: 11)
88
├── @ ForwardingSuperNode (location: (1,0)-(1,5))
99
│ ├── flags: newline
10+
│ ├── keyword_loc: (1,0)-(1,5) = "super"
1011
│ └── block: ∅
1112
├── @ SuperNode (location: (2,0)-(2,7))
1213
│ ├── flags: newline
@@ -170,6 +171,7 @@
170171
│ └── block: ∅
171172
├── @ ForwardingSuperNode (location: (10,0)-(12,1))
172173
│ ├── flags: newline
174+
│ ├── keyword_loc: (10,0)-(10,5) = "super"
173175
│ └── block:
174176
│ @ BlockNode (location: (10,6)-(12,1))
175177
│ ├── flags: ∅

snapshots/whitequark/super_block.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
└── body: (length: 2)
88
├── @ ForwardingSuperNode (location: (1,0)-(1,12))
99
│ ├── flags: newline
10+
│ ├── keyword_loc: (1,0)-(1,5) = "super"
1011
│ └── block:
1112
│ @ BlockNode (location: (1,6)-(1,12))
1213
│ ├── flags: ∅

snapshots/whitequark/zsuper.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@
77
└── body: (length: 1)
88
└── @ ForwardingSuperNode (location: (1,0)-(1,5))
99
├── flags: newline
10+
├── keyword_loc: (1,0)-(1,5) = "super"
1011
└── block: ∅

src/prism.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4379,6 +4379,7 @@ pm_forwarding_super_node_create(pm_parser_t *parser, const pm_token_t *token, pm
43794379
++parser->node_id,
43804380
0,
43814381
(block == NULL) ? PM_LOCATION_INIT_TOKEN(parser, token) : PM_LOCATION_INIT_TOKEN_NODE(parser, token, block),
4382+
PM_LOCATION_INIT_TOKEN(parser, token),
43824383
block
43834384
);
43844385
}

0 commit comments

Comments
 (0)