diff --git a/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/typescript/changeName6.yml b/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/typescript/changeName6.yml new file mode 100644 index 0000000000..a9f51c2bc5 --- /dev/null +++ b/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/typescript/changeName6.yml @@ -0,0 +1,31 @@ +languageId: typescript +command: + version: 6 + spokenForm: change name + action: + name: clearAndSetSelection + target: + type: primitive + modifiers: + - type: containingScope + scopeType: {type: name} + usePrePhraseSnapshot: true +initialState: + documentContents: |- + class Foo { + bar + } + + 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} diff --git a/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/typescript/changeType21.yml b/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/typescript/changeType21.yml new file mode 100644 index 0000000000..d0c99f3377 --- /dev/null +++ b/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/typescript/changeType21.yml @@ -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: |- + class Foo { + bar: string; + } + + selections: + - anchor: {line: 1, character: 4} + active: {line: 1, character: 4} + marks: {} +finalState: + documentContents: |- + class Foo { + bar: ; + } + + selections: + - anchor: {line: 1, character: 9} + active: {line: 1, character: 9} diff --git a/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/typescript/changeType22.yml b/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/typescript/changeType22.yml new file mode 100644 index 0000000000..1fc169996e --- /dev/null +++ b/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/typescript/changeType22.yml @@ -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: |- + class Foo { + bar(): string {} + } + + selections: + - anchor: {line: 1, character: 4} + active: {line: 1, character: 4} + marks: {} +finalState: + documentContents: |- + class Foo { + bar(): {} + } + + selections: + - anchor: {line: 1, character: 11} + active: {line: 1, character: 11} diff --git a/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/typescript/changeType23.yml b/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/typescript/changeType23.yml new file mode 100644 index 0000000000..854d3fe713 --- /dev/null +++ b/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/typescript/changeType23.yml @@ -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: |- + interface Foo { + bar: string; + } + selections: + - anchor: {line: 1, character: 16} + active: {line: 1, character: 16} + marks: {} +finalState: + documentContents: |- + interface Foo { + bar: ; + } + selections: + - anchor: {line: 1, character: 9} + active: {line: 1, character: 9} diff --git a/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/typescript/changeValue2.yml b/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/typescript/changeValue2.yml new file mode 100644 index 0000000000..f90f08c9cc --- /dev/null +++ b/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/typescript/changeValue2.yml @@ -0,0 +1,31 @@ +languageId: typescript +command: + version: 6 + spokenForm: change value + action: + name: clearAndSetSelection + target: + type: primitive + modifiers: + - type: containingScope + scopeType: {type: value} + usePrePhraseSnapshot: true +initialState: + documentContents: |- + class Foo { + bar: string = "baz"; + } + + selections: + - anchor: {line: 1, character: 4} + active: {line: 1, character: 4} + marks: {} +finalState: + documentContents: |- + class Foo { + bar: string = ; + } + + selections: + - anchor: {line: 1, character: 18} + active: {line: 1, character: 18} diff --git a/queries/typescript.core.scm b/queries/typescript.core.scm index f2a6998cb1..6ae7c6158e 100644 --- a/queries/typescript.core.scm +++ b/queries/typescript.core.scm @@ -63,9 +63,14 @@ ;;! -------------------------------^^^------- (public_field_definition name: (_) @name - ) @name.domain.start + type: (_ + ":" + (_) @type + )? + value: (_)? @value + ) @_.domain.start . - ";"? @name.domain.end + ";"? @_.domain.end ) [ @@ -165,7 +170,9 @@ ;;!! function ccc(): string {} ;;! ^^^^^^ -(function_declaration +;;!! ccc(): string {} +;;! ^^^^^^ +(_ parameters: (_) @type.leading.end.endOf return_type: (_ ":" @@ -266,13 +273,16 @@ ;;! ^^^^ ;;! xxxxxx ;;! ------------ -(property_signature - name: (_) @collectionKey @collectionKey.trailing.start.endOf @type.leading.start.endOf - type: (_ - ":" - (_) @type @collectionKey.trailing.end.startOf @type.leading.end.startOf - ) -) @_.domain +( + (property_signature + name: (_) @collectionKey @collectionKey.trailing.start.endOf @type.leading.start.endOf + type: (_ + ":" + (_) @type @collectionKey.trailing.end.startOf @type.leading.end.startOf + ) + ) @_.domain.start + ";"? @_.domain.end +) ;;!! interface Type { name: string; } ;;! ^^^^^^^^^^^^^^^^^