Skip to content

Commit

Permalink
Support function declaration
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreasArvidsson committed Nov 14, 2023
1 parent b9b4464 commit 54c2eed
Show file tree
Hide file tree
Showing 7 changed files with 168 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
languageId: typescript
command:
version: 6
spokenForm: change type
action:
name: clearAndSetSelection
target:
type: primitive
modifiers:
- type: containingScope
scopeType: {type: type}
usePrePhraseSnapshot: true
initialState:
documentContents: foo<Record<string, string>>()
selections:
- anchor: {line: 0, character: 4}
active: {line: 0, character: 4}
marks: {}
finalState:
documentContents: foo<>()
selections:
- anchor: {line: 0, character: 4}
active: {line: 0, character: 4}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
languageId: typescript
command:
version: 6
spokenForm: change type
action:
name: clearAndSetSelection
target:
type: primitive
modifiers:
- type: containingScope
scopeType: {type: type}
usePrePhraseSnapshot: true
initialState:
documentContents: foo<string, string>()
selections:
- anchor: {line: 0, character: 4}
active: {line: 0, character: 4}
marks: {}
finalState:
documentContents: foo<, string>()
selections:
- anchor: {line: 0, character: 4}
active: {line: 0, character: 4}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
languageId: typescript
command:
version: 6
spokenForm: change type
action:
name: clearAndSetSelection
target:
type: primitive
modifiers:
- type: containingScope
scopeType: {type: type}
usePrePhraseSnapshot: true
initialState:
documentContents: foo<string, string>()
selections:
- anchor: {line: 0, character: 12}
active: {line: 0, character: 12}
marks: {}
finalState:
documentContents: foo<string, >()
selections:
- anchor: {line: 0, character: 12}
active: {line: 0, character: 12}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
languageId: typescript
command:
version: 6
spokenForm: change type
action:
name: clearAndSetSelection
target:
type: primitive
modifiers:
- type: containingScope
scopeType: {type: type}
usePrePhraseSnapshot: true
initialState:
documentContents: Foo<string>()
selections:
- anchor: {line: 0, character: 4}
active: {line: 0, character: 4}
marks: {}
finalState:
documentContents: Foo<>()
selections:
- anchor: {line: 0, character: 4}
active: {line: 0, character: 4}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
languageId: typescript
command:
version: 6
spokenForm: change type
action:
name: clearAndSetSelection
target:
type: primitive
modifiers:
- type: containingScope
scopeType: {type: type}
usePrePhraseSnapshot: true
initialState:
documentContents: |+
function foo<A>() {
}
selections:
- anchor: {line: 0, character: 13}
active: {line: 0, character: 13}
marks: {}
finalState:
documentContents: |+
function foo<>() {
}
selections:
- anchor: {line: 0, character: 13}
active: {line: 0, character: 13}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
languageId: typescript
command:
version: 6
spokenForm: change type
action:
name: clearAndSetSelection
target:
type: primitive
modifiers:
- type: containingScope
scopeType: {type: type}
usePrePhraseSnapshot: true
initialState:
documentContents: |
const bar = <A>() => {
}
selections:
- anchor: {line: 0, character: 13}
active: {line: 0, character: 13}
marks: {}
finalState:
documentContents: |
const bar = <>() => {
}
selections:
- anchor: {line: 0, character: 13}
active: {line: 0, character: 13}
16 changes: 16 additions & 0 deletions queries/typescript.core.scm
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,22 @@
)
)

;;!! function foo<A>() {}
;;! ^
(function_declaration
type_parameters: (type_parameters
(_) @type
)
)

;;!! const foo = <A>() => {}
;;! ^
(arrow_function
type_parameters: (type_parameters
(_) @type
)
)

;;!! interface Aaa {}
;;!! type Aaa = Bbb;
(
Expand Down

0 comments on commit 54c2eed

Please sign in to comment.