Skip to content

Commit 16dc10e

Browse files
Support value scope for yield statements (#606)
1 parent e526e60 commit 16dc10e

File tree

5 files changed

+90
-1
lines changed

5 files changed

+90
-1
lines changed

Diff for: src/languages/php.ts

+1
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ const nodeMatchers: Partial<Record<ScopeType, NodeMatcherAlternative>> = {
146146
"assignment_expression[right]",
147147
"augmented_assignment_expression[right]",
148148
"return_statement[0]",
149+
"yield_expression[0]",
149150
],
150151
assignmentOperators.concat(["=>"]),
151152
),

Diff for: src/languages/typescript.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,8 @@ const nodeMatchers: Partial<Record<ScopeType, NodeMatcherAlternative>> = {
159159
collectionItem: argumentMatcher(...mapTypes, ...listTypes),
160160
value: cascadingMatcher(
161161
valueMatcher(),
162-
patternMatcher("return_statement.~return!")
162+
patternMatcher("return_statement.~return!"),
163+
patternMatcher("yield_expression.~yield!")
163164
),
164165
ifStatement: "if_statement",
165166
anonymousFunction: [
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
languageId: php
2+
command:
3+
version: 1
4+
spokenForm: change value
5+
action: clearAndSetSelection
6+
targets:
7+
- type: primitive
8+
modifier: {type: containingScope, scopeType: value, includeSiblings: false}
9+
initialState:
10+
documentContents: |-
11+
<?php
12+
13+
yield $value;
14+
selections:
15+
- anchor: {line: 2, character: 9}
16+
active: {line: 2, character: 9}
17+
marks: {}
18+
finalState:
19+
documentContents: |-
20+
<?php
21+
22+
yield ;
23+
selections:
24+
- anchor: {line: 2, character: 6}
25+
active: {line: 2, character: 6}
26+
thatMark:
27+
- anchor: {line: 2, character: 6}
28+
active: {line: 2, character: 6}
29+
fullTargets: [{type: primitive, mark: {type: cursor}, selectionType: token, position: contents, insideOutsideType: inside, modifier: {type: containingScope, scopeType: value, includeSiblings: false}, isImplicit: false}]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
languageId: php
2+
command:
3+
version: 1
4+
spokenForm: chuck value
5+
action: remove
6+
targets:
7+
- type: primitive
8+
modifier: {type: containingScope, scopeType: value, includeSiblings: false}
9+
initialState:
10+
documentContents: |-
11+
<?php
12+
13+
yield $value;
14+
selections:
15+
- anchor: {line: 2, character: 9}
16+
active: {line: 2, character: 9}
17+
marks: {}
18+
finalState:
19+
documentContents: |-
20+
<?php
21+
22+
yield;
23+
selections:
24+
- anchor: {line: 2, character: 5}
25+
active: {line: 2, character: 5}
26+
thatMark:
27+
- anchor: {line: 2, character: 5}
28+
active: {line: 2, character: 5}
29+
fullTargets: [{type: primitive, mark: {type: cursor}, selectionType: token, position: contents, insideOutsideType: outside, modifier: {type: containingScope, scopeType: value, includeSiblings: false}, isImplicit: false}]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
languageId: typescript
2+
command:
3+
version: 1
4+
spokenForm: change value
5+
action: clearAndSetSelection
6+
targets:
7+
- type: primitive
8+
modifier: {type: containingScope, scopeType: value, includeSiblings: false}
9+
initialState:
10+
documentContents: |-
11+
function* generator(i) {
12+
yield i + 10;
13+
}
14+
selections:
15+
- anchor: {line: 1, character: 11}
16+
active: {line: 1, character: 11}
17+
marks: {}
18+
finalState:
19+
documentContents: |-
20+
function* generator(i) {
21+
yield ;
22+
}
23+
selections:
24+
- anchor: {line: 1, character: 8}
25+
active: {line: 1, character: 8}
26+
thatMark:
27+
- anchor: {line: 1, character: 8}
28+
active: {line: 1, character: 8}
29+
fullTargets: [{type: primitive, mark: {type: cursor}, selectionType: token, position: contents, insideOutsideType: inside, modifier: {type: containingScope, scopeType: value, includeSiblings: false}, isImplicit: false}]

0 commit comments

Comments
 (0)