Skip to content

Commit

Permalink
Return value for lambdas (#2086)
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreasArvidsson authored Dec 5, 2023
1 parent a4ab8da commit 009dbac
Show file tree
Hide file tree
Showing 9 changed files with 161 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
languageId: java
command:
version: 6
spokenForm: change value
action:
name: clearAndSetSelection
target:
type: primitive
modifiers:
- type: containingScope
scopeType: {type: value}
usePrePhraseSnapshot: true
initialState:
documentContents: map(str -> str.length);
selections:
- anchor: {line: 0, character: 4}
active: {line: 0, character: 4}
marks: {}
finalState:
documentContents: map(str -> );
selections:
- anchor: {line: 0, character: 11}
active: {line: 0, character: 11}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
languageId: java
command:
version: 6
spokenForm: change value
action:
name: clearAndSetSelection
target:
type: primitive
modifiers:
- type: containingScope
scopeType: {type: value}
usePrePhraseSnapshot: true
initialState:
documentContents: map(str -> 0);
selections:
- anchor: {line: 0, character: 4}
active: {line: 0, character: 4}
marks: {}
finalState:
documentContents: map(str -> );
selections:
- anchor: {line: 0, character: 11}
active: {line: 0, character: 11}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
languageId: python
command:
version: 6
spokenForm: change value
action:
name: clearAndSetSelection
target:
type: primitive
modifiers:
- type: containingScope
scopeType: {type: value}
usePrePhraseSnapshot: true
initialState:
documentContents: "map(lambda str: len(str))"
selections:
- anchor: {line: 0, character: 4}
active: {line: 0, character: 4}
marks: {}
finalState:
documentContents: "map(lambda str: )"
selections:
- anchor: {line: 0, character: 16}
active: {line: 0, character: 16}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
languageId: python
command:
version: 6
spokenForm: change value
action:
name: clearAndSetSelection
target:
type: primitive
modifiers:
- type: containingScope
scopeType: {type: value}
usePrePhraseSnapshot: true
initialState:
documentContents: "map(lambda str: 0)"
selections:
- anchor: {line: 0, character: 4}
active: {line: 0, character: 4}
marks: {}
finalState:
documentContents: "map(lambda str: )"
selections:
- anchor: {line: 0, character: 16}
active: {line: 0, character: 16}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
languageId: typescript
command:
version: 6
spokenForm: change value
action:
name: clearAndSetSelection
target:
type: primitive
modifiers:
- type: containingScope
scopeType: {type: value}
usePrePhraseSnapshot: true
initialState:
documentContents: map(str => str.length)
selections:
- anchor: {line: 0, character: 4}
active: {line: 0, character: 4}
marks: {}
finalState:
documentContents: map(str => )
selections:
- anchor: {line: 0, character: 11}
active: {line: 0, character: 11}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
languageId: typescript
command:
version: 6
spokenForm: change value
action:
name: clearAndSetSelection
target:
type: primitive
modifiers:
- type: containingScope
scopeType: {type: value}
usePrePhraseSnapshot: true
initialState:
documentContents: map(str => 0)
selections:
- anchor: {line: 0, character: 4}
active: {line: 0, character: 4}
marks: {}
finalState:
documentContents: map(str => )
selections:
- anchor: {line: 0, character: 11}
active: {line: 0, character: 11}
8 changes: 8 additions & 0 deletions queries/java.scm
Original file line number Diff line number Diff line change
Expand Up @@ -318,3 +318,11 @@
(return_statement) @value @_.domain
(#child-range! @value 1 -2)
)

;;!! str -> str.length > 0
;;! ^^^^^^^^^^^^^^
;;! ---------------------
(lambda_expression
body: (_) @value
(#not-type? @value block)
) @_.domain
8 changes: 8 additions & 0 deletions queries/javascript.core.scm
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,14 @@
(_) @value
) @_.domain

;;!! str => str.length > 0
;;! ^^^^^^^^^^^^^^
;;! ---------------------
(arrow_function
body: (_) @value
(#not-type? @value statement_block)
) @_.domain

;; name:
;;!! for (const aaa of bbb) {}
;;! ^^^
Expand Down
7 changes: 7 additions & 0 deletions queries/python.scm
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,13 @@
(_) @value
) @_.domain

;;!! lambda str: len(str) > 0
;;! ^^^^^^^^^^^^
;;! ------------------------
(lambda
body: (_) @value
) @_.domain

;; value:
;;!! for aaa in bbb:
;;! ^^^
Expand Down

0 comments on commit 009dbac

Please sign in to comment.