mirror of
https://github.com/cursorless-dev/cursorless.git
synced 2024-10-05 05:17:38 +03:00
Supports states scope for interface properties (#1065)
* Supports states scope for interface properties * Remove trailing semi * Added test * Add class fields * Use extend past optional finder * updated test * Added inline test * Updated state definition for typescript * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Add "item" tests Co-authored-by: Pokey Rule <755842+pokey@users.noreply.github.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
parent
ba9644becb
commit
78fa2b38b4
@ -200,7 +200,20 @@ const nodeMatchers: Partial<
|
||||
childRangeSelector(["arguments"], []),
|
||||
),
|
||||
),
|
||||
statement: STATEMENT_TYPES.map((type) => `export_statement?.${type}`),
|
||||
statement: cascadingMatcher(
|
||||
matcher(
|
||||
patternFinder(
|
||||
"property_signature",
|
||||
"public_field_definition",
|
||||
"abstract_method_signature",
|
||||
),
|
||||
extendForwardPastOptional(";"),
|
||||
),
|
||||
patternMatcher(
|
||||
...STATEMENT_TYPES.map((type) => `export_statement?.${type}`),
|
||||
"method_definition",
|
||||
),
|
||||
),
|
||||
condition: cascadingMatcher(
|
||||
patternMatcher("ternary_expression[condition]"),
|
||||
conditionMatcher(
|
||||
|
@ -0,0 +1,31 @@
|
||||
languageId: typescript
|
||||
command:
|
||||
spokenForm: chuck state
|
||||
version: 3
|
||||
targets:
|
||||
- type: primitive
|
||||
modifiers:
|
||||
- type: containingScope
|
||||
scopeType: {type: statement}
|
||||
usePrePhraseSnapshot: true
|
||||
action: {name: remove}
|
||||
initialState:
|
||||
documentContents: |-
|
||||
interface Foo {
|
||||
bar: Bar;
|
||||
baz: Baz;
|
||||
}
|
||||
selections:
|
||||
- anchor: {line: 1, character: 2}
|
||||
active: {line: 1, character: 2}
|
||||
marks: {}
|
||||
finalState:
|
||||
documentContents: |-
|
||||
interface Foo {
|
||||
|
||||
baz: Baz;
|
||||
}
|
||||
selections:
|
||||
- anchor: {line: 1, character: 0}
|
||||
active: {line: 1, character: 0}
|
||||
fullTargets: [{type: primitive, mark: {type: cursor}, modifiers: [{type: containingScope, scopeType: {type: statement}}]}]
|
@ -0,0 +1,29 @@
|
||||
languageId: typescript
|
||||
command:
|
||||
spokenForm: chuck state
|
||||
version: 3
|
||||
targets:
|
||||
- type: primitive
|
||||
modifiers:
|
||||
- type: containingScope
|
||||
scopeType: {type: statement}
|
||||
usePrePhraseSnapshot: true
|
||||
action: {name: remove}
|
||||
initialState:
|
||||
documentContents: |-
|
||||
class Foo {
|
||||
private value: string;
|
||||
}
|
||||
selections:
|
||||
- anchor: {line: 1, character: 4}
|
||||
active: {line: 1, character: 4}
|
||||
marks: {}
|
||||
finalState:
|
||||
documentContents: |-
|
||||
class Foo {
|
||||
|
||||
}
|
||||
selections:
|
||||
- anchor: {line: 1, character: 0}
|
||||
active: {line: 1, character: 0}
|
||||
fullTargets: [{type: primitive, mark: {type: cursor}, modifiers: [{type: containingScope, scopeType: {type: statement}}]}]
|
@ -0,0 +1,23 @@
|
||||
languageId: typescript
|
||||
command:
|
||||
spokenForm: clear item
|
||||
version: 3
|
||||
targets:
|
||||
- type: primitive
|
||||
modifiers:
|
||||
- type: containingScope
|
||||
scopeType: {type: collectionItem}
|
||||
usePrePhraseSnapshot: true
|
||||
action: {name: clearAndSetSelection}
|
||||
initialState:
|
||||
documentContents: "let foo: { a: string };"
|
||||
selections:
|
||||
- anchor: {line: 0, character: 11}
|
||||
active: {line: 0, character: 11}
|
||||
marks: {}
|
||||
finalState:
|
||||
documentContents: "let foo: { };"
|
||||
selections:
|
||||
- anchor: {line: 0, character: 11}
|
||||
active: {line: 0, character: 11}
|
||||
fullTargets: [{type: primitive, mark: {type: cursor}, modifiers: [{type: containingScope, scopeType: {type: collectionItem}}]}]
|
@ -0,0 +1,23 @@
|
||||
languageId: typescript
|
||||
command:
|
||||
spokenForm: clear item
|
||||
version: 3
|
||||
targets:
|
||||
- type: primitive
|
||||
modifiers:
|
||||
- type: containingScope
|
||||
scopeType: {type: collectionItem}
|
||||
usePrePhraseSnapshot: true
|
||||
action: {name: clearAndSetSelection}
|
||||
initialState:
|
||||
documentContents: "let foo: { a: string, b: string };"
|
||||
selections:
|
||||
- anchor: {line: 0, character: 11}
|
||||
active: {line: 0, character: 11}
|
||||
marks: {}
|
||||
finalState:
|
||||
documentContents: "let foo: { , b: string };"
|
||||
selections:
|
||||
- anchor: {line: 0, character: 11}
|
||||
active: {line: 0, character: 11}
|
||||
fullTargets: [{type: primitive, mark: {type: cursor}, modifiers: [{type: containingScope, scopeType: {type: collectionItem}}]}]
|
@ -0,0 +1,23 @@
|
||||
languageId: typescript
|
||||
command:
|
||||
spokenForm: clear item
|
||||
version: 3
|
||||
targets:
|
||||
- type: primitive
|
||||
modifiers:
|
||||
- type: containingScope
|
||||
scopeType: {type: collectionItem}
|
||||
usePrePhraseSnapshot: true
|
||||
action: {name: clearAndSetSelection}
|
||||
initialState:
|
||||
documentContents: "let foo: { a: string, b: string };"
|
||||
selections:
|
||||
- anchor: {line: 0, character: 22}
|
||||
active: {line: 0, character: 22}
|
||||
marks: {}
|
||||
finalState:
|
||||
documentContents: "let foo: { a: string, };"
|
||||
selections:
|
||||
- anchor: {line: 0, character: 22}
|
||||
active: {line: 0, character: 22}
|
||||
fullTargets: [{type: primitive, mark: {type: cursor}, modifiers: [{type: containingScope, scopeType: {type: collectionItem}}]}]
|
@ -0,0 +1,31 @@
|
||||
languageId: typescript
|
||||
command:
|
||||
spokenForm: clear state
|
||||
version: 3
|
||||
targets:
|
||||
- type: primitive
|
||||
modifiers:
|
||||
- type: containingScope
|
||||
scopeType: {type: statement}
|
||||
usePrePhraseSnapshot: true
|
||||
action: {name: clearAndSetSelection}
|
||||
initialState:
|
||||
documentContents: |-
|
||||
interface Foo {
|
||||
bar: Bar;
|
||||
baz: Baz;
|
||||
}
|
||||
selections:
|
||||
- anchor: {line: 1, character: 2}
|
||||
active: {line: 1, character: 2}
|
||||
marks: {}
|
||||
finalState:
|
||||
documentContents: |-
|
||||
interface Foo {
|
||||
|
||||
baz: Baz;
|
||||
}
|
||||
selections:
|
||||
- anchor: {line: 1, character: 2}
|
||||
active: {line: 1, character: 2}
|
||||
fullTargets: [{type: primitive, mark: {type: cursor}, modifiers: [{type: containingScope, scopeType: {type: statement}}]}]
|
@ -0,0 +1,29 @@
|
||||
languageId: typescript
|
||||
command:
|
||||
spokenForm: clear state
|
||||
version: 3
|
||||
targets:
|
||||
- type: primitive
|
||||
modifiers:
|
||||
- type: containingScope
|
||||
scopeType: {type: statement}
|
||||
usePrePhraseSnapshot: true
|
||||
action: {name: clearAndSetSelection}
|
||||
initialState:
|
||||
documentContents: |-
|
||||
type Foo = {
|
||||
bar: string;
|
||||
}
|
||||
selections:
|
||||
- anchor: {line: 1, character: 2}
|
||||
active: {line: 1, character: 2}
|
||||
marks: {}
|
||||
finalState:
|
||||
documentContents: |-
|
||||
type Foo = {
|
||||
|
||||
}
|
||||
selections:
|
||||
- anchor: {line: 1, character: 2}
|
||||
active: {line: 1, character: 2}
|
||||
fullTargets: [{type: primitive, mark: {type: cursor}, modifiers: [{type: containingScope, scopeType: {type: statement}}]}]
|
@ -0,0 +1,29 @@
|
||||
languageId: typescript
|
||||
command:
|
||||
spokenForm: clear state
|
||||
version: 3
|
||||
targets:
|
||||
- type: primitive
|
||||
modifiers:
|
||||
- type: containingScope
|
||||
scopeType: {type: statement}
|
||||
usePrePhraseSnapshot: true
|
||||
action: {name: clearAndSetSelection}
|
||||
initialState:
|
||||
documentContents: |-
|
||||
class Foo {
|
||||
private value: string;
|
||||
}
|
||||
selections:
|
||||
- anchor: {line: 1, character: 4}
|
||||
active: {line: 1, character: 4}
|
||||
marks: {}
|
||||
finalState:
|
||||
documentContents: |-
|
||||
class Foo {
|
||||
|
||||
}
|
||||
selections:
|
||||
- anchor: {line: 1, character: 4}
|
||||
active: {line: 1, character: 4}
|
||||
fullTargets: [{type: primitive, mark: {type: cursor}, modifiers: [{type: containingScope, scopeType: {type: statement}}]}]
|
@ -0,0 +1,23 @@
|
||||
languageId: typescript
|
||||
command:
|
||||
spokenForm: clear state
|
||||
version: 3
|
||||
targets:
|
||||
- type: primitive
|
||||
modifiers:
|
||||
- type: containingScope
|
||||
scopeType: {type: statement}
|
||||
usePrePhraseSnapshot: true
|
||||
action: {name: clearAndSetSelection}
|
||||
initialState:
|
||||
documentContents: "let foo: { a: string };"
|
||||
selections:
|
||||
- anchor: {line: 0, character: 12}
|
||||
active: {line: 0, character: 12}
|
||||
marks: {}
|
||||
finalState:
|
||||
documentContents: "let foo: { };"
|
||||
selections:
|
||||
- anchor: {line: 0, character: 11}
|
||||
active: {line: 0, character: 11}
|
||||
fullTargets: [{type: primitive, mark: {type: cursor}, modifiers: [{type: containingScope, scopeType: {type: statement}}]}]
|
@ -0,0 +1,41 @@
|
||||
languageId: typescript
|
||||
command:
|
||||
spokenForm: clear state
|
||||
version: 3
|
||||
targets:
|
||||
- type: primitive
|
||||
modifiers:
|
||||
- type: containingScope
|
||||
scopeType: {type: statement}
|
||||
usePrePhraseSnapshot: true
|
||||
action: {name: clearAndSetSelection}
|
||||
initialState:
|
||||
documentContents: |-
|
||||
abstract class Foo {
|
||||
value: string;
|
||||
abstract bar(): void;
|
||||
baz() { }
|
||||
}
|
||||
selections:
|
||||
- anchor: {line: 1, character: 4}
|
||||
active: {line: 1, character: 4}
|
||||
- anchor: {line: 2, character: 4}
|
||||
active: {line: 2, character: 4}
|
||||
- anchor: {line: 3, character: 4}
|
||||
active: {line: 3, character: 4}
|
||||
marks: {}
|
||||
finalState:
|
||||
documentContents: |-
|
||||
abstract class Foo {
|
||||
|
||||
|
||||
|
||||
}
|
||||
selections:
|
||||
- anchor: {line: 1, character: 4}
|
||||
active: {line: 1, character: 4}
|
||||
- anchor: {line: 2, character: 4}
|
||||
active: {line: 2, character: 4}
|
||||
- anchor: {line: 3, character: 4}
|
||||
active: {line: 3, character: 4}
|
||||
fullTargets: [{type: primitive, mark: {type: cursor}, modifiers: [{type: containingScope, scopeType: {type: statement}}]}]
|
Loading…
Reference in New Issue
Block a user