From db358bb7e7e06979980b36c04ed9b69b44e2732d Mon Sep 17 00:00:00 2001 From: Pokey Rule <755842+pokey@users.noreply.github.com> Date: Thu, 8 Jun 2023 14:32:51 +0100 Subject: [PATCH] Initial tree-sitter support for .scm files --- .../recorded/languages/scm/clearCall.yml | 30 ++++++ .../recorded/languages/scm/clearCallee.yml | 30 ++++++ .../recorded/languages/scm/clearComment.yml | 22 +++++ .../languages/scm/clearEveryArgue.yml | 32 +++++++ .../recorded/languages/scm/clearEveryCall.yml | 34 +++++++ .../languages/scm/clearEveryCallee.yml | 34 +++++++ .../languages/scm/clearEveryEntry.yml | 24 +++++ .../languages/scm/clearEveryEntry2.yml | 32 +++++++ .../languages/scm/clearEveryEntry3.yml | 32 +++++++ .../recorded/languages/scm/clearEveryName.yml | 24 +++++ .../languages/scm/clearEveryName2.yml | 24 +++++ .../languages/scm/clearEveryState.yml | 29 ++++++ .../recorded/languages/scm/clearItem.yml | 22 +++++ .../recorded/languages/scm/clearKey.yml | 28 ++++++ .../recorded/languages/scm/clearList.yml | 22 +++++ .../recorded/languages/scm/clearList2.yml | 22 +++++ .../recorded/languages/scm/clearName.yml | 22 +++++ .../recorded/languages/scm/clearName2.yml | 22 +++++ .../recorded/languages/scm/clearName3.yml | 22 +++++ .../recorded/languages/scm/clearName4.yml | 22 +++++ .../recorded/languages/scm/clearName5.yml | 22 +++++ .../recorded/languages/scm/clearRound.yml | 22 +++++ .../recorded/languages/scm/clearRound2.yml | 22 +++++ .../recorded/languages/scm/clearRound3.yml | 22 +++++ .../recorded/languages/scm/clearState.yml | 18 ++++ .../recorded/languages/scm/clearState2.yml | 22 +++++ .../recorded/languages/scm/clearState3.yml | 26 +++++ .../recorded/languages/scm/clearState4.yml | 26 +++++ .../recorded/languages/scm/clearState5.yml | 22 +++++ .../recorded/languages/scm/clearType.yml | 22 +++++ .../recorded/languages/scm/clearType2.yml | 22 +++++ .../recorded/languages/scm/clearValue.yml | 28 ++++++ queries/scm.scm | 94 +++++++++++++++++++ 33 files changed, 897 insertions(+) create mode 100644 packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/scm/clearCall.yml create mode 100644 packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/scm/clearCallee.yml create mode 100644 packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/scm/clearComment.yml create mode 100644 packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/scm/clearEveryArgue.yml create mode 100644 packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/scm/clearEveryCall.yml create mode 100644 packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/scm/clearEveryCallee.yml create mode 100644 packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/scm/clearEveryEntry.yml create mode 100644 packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/scm/clearEveryEntry2.yml create mode 100644 packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/scm/clearEveryEntry3.yml create mode 100644 packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/scm/clearEveryName.yml create mode 100644 packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/scm/clearEveryName2.yml create mode 100644 packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/scm/clearEveryState.yml create mode 100644 packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/scm/clearItem.yml create mode 100644 packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/scm/clearKey.yml create mode 100644 packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/scm/clearList.yml create mode 100644 packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/scm/clearList2.yml create mode 100644 packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/scm/clearName.yml create mode 100644 packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/scm/clearName2.yml create mode 100644 packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/scm/clearName3.yml create mode 100644 packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/scm/clearName4.yml create mode 100644 packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/scm/clearName5.yml create mode 100644 packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/scm/clearRound.yml create mode 100644 packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/scm/clearRound2.yml create mode 100644 packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/scm/clearRound3.yml create mode 100644 packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/scm/clearState.yml create mode 100644 packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/scm/clearState2.yml create mode 100644 packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/scm/clearState3.yml create mode 100644 packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/scm/clearState4.yml create mode 100644 packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/scm/clearState5.yml create mode 100644 packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/scm/clearType.yml create mode 100644 packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/scm/clearType2.yml create mode 100644 packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/scm/clearValue.yml create mode 100644 queries/scm.scm diff --git a/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/scm/clearCall.yml b/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/scm/clearCall.yml new file mode 100644 index 00000000000..c8fae8567b1 --- /dev/null +++ b/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/scm/clearCall.yml @@ -0,0 +1,30 @@ +languageId: scm +command: + version: 5 + spokenForm: clear call + action: {name: clearAndSetSelection} + targets: + - type: primitive + modifiers: + - type: containingScope + scopeType: {type: functionCall} + usePrePhraseSnapshot: true +initialState: + documentContents: |- + ( + (aaa) + (#bbb! @aaa) + ) + selections: + - anchor: {line: 2, character: 4} + active: {line: 2, character: 4} + marks: {} +finalState: + documentContents: |- + ( + (aaa) + + ) + selections: + - anchor: {line: 2, character: 4} + active: {line: 2, character: 4} diff --git a/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/scm/clearCallee.yml b/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/scm/clearCallee.yml new file mode 100644 index 00000000000..a0693c46bfc --- /dev/null +++ b/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/scm/clearCallee.yml @@ -0,0 +1,30 @@ +languageId: scm +command: + version: 5 + spokenForm: clear callee + action: {name: clearAndSetSelection} + targets: + - type: primitive + modifiers: + - type: containingScope + scopeType: {type: functionCallee} + usePrePhraseSnapshot: true +initialState: + documentContents: |- + ( + (aaa) + (#bbb! @aaa) + ) + selections: + - anchor: {line: 2, character: 4} + active: {line: 2, character: 4} + marks: {} +finalState: + documentContents: |- + ( + (aaa) + (#! @aaa) + ) + selections: + - anchor: {line: 2, character: 6} + active: {line: 2, character: 6} diff --git a/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/scm/clearComment.yml b/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/scm/clearComment.yml new file mode 100644 index 00000000000..4031b367847 --- /dev/null +++ b/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/scm/clearComment.yml @@ -0,0 +1,22 @@ +languageId: scm +command: + version: 5 + spokenForm: clear comment + action: {name: clearAndSetSelection} + targets: + - type: primitive + modifiers: + - type: containingScope + scopeType: {type: comment} + usePrePhraseSnapshot: true +initialState: + documentContents: ;; aaa + selections: + - anchor: {line: 0, character: 0} + active: {line: 0, character: 0} + marks: {} +finalState: + documentContents: "" + selections: + - anchor: {line: 0, character: 0} + active: {line: 0, character: 0} diff --git a/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/scm/clearEveryArgue.yml b/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/scm/clearEveryArgue.yml new file mode 100644 index 00000000000..efdad7bcc08 --- /dev/null +++ b/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/scm/clearEveryArgue.yml @@ -0,0 +1,32 @@ +languageId: scm +command: + version: 5 + spokenForm: clear every argue + action: {name: clearAndSetSelection} + targets: + - type: primitive + modifiers: + - type: everyScope + scopeType: {type: argumentOrParameter} + usePrePhraseSnapshot: true +initialState: + documentContents: |- + ( + (aaa) + (#bbb! @aaa "ccc") + ) + selections: + - anchor: {line: 2, character: 4} + active: {line: 2, character: 4} + marks: {} +finalState: + documentContents: |- + ( + (aaa) + (#bbb! ) + ) + selections: + - anchor: {line: 2, character: 11} + active: {line: 2, character: 11} + - anchor: {line: 2, character: 12} + active: {line: 2, character: 12} diff --git a/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/scm/clearEveryCall.yml b/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/scm/clearEveryCall.yml new file mode 100644 index 00000000000..748c0b926cd --- /dev/null +++ b/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/scm/clearEveryCall.yml @@ -0,0 +1,34 @@ +languageId: scm +command: + version: 5 + spokenForm: clear every call + action: {name: clearAndSetSelection} + targets: + - type: primitive + modifiers: + - type: everyScope + scopeType: {type: functionCall} + usePrePhraseSnapshot: true +initialState: + documentContents: |- + ( + (aaa) + (#bbb! @aaa) + (#ccc! @aaa) + ) + selections: + - anchor: {line: 1, character: 4} + active: {line: 1, character: 4} + marks: {} +finalState: + documentContents: |- + ( + (aaa) + + + ) + selections: + - anchor: {line: 2, character: 4} + active: {line: 2, character: 4} + - anchor: {line: 3, character: 4} + active: {line: 3, character: 4} diff --git a/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/scm/clearEveryCallee.yml b/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/scm/clearEveryCallee.yml new file mode 100644 index 00000000000..95efacdfbf2 --- /dev/null +++ b/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/scm/clearEveryCallee.yml @@ -0,0 +1,34 @@ +languageId: scm +command: + version: 5 + spokenForm: clear every callee + action: {name: clearAndSetSelection} + targets: + - type: primitive + modifiers: + - type: everyScope + scopeType: {type: functionCallee} + usePrePhraseSnapshot: true +initialState: + documentContents: |- + ( + (aaa) + (#bbb! @aaa) + (#ccc! @aaa) + ) + selections: + - anchor: {line: 1, character: 4} + active: {line: 1, character: 4} + marks: {} +finalState: + documentContents: |- + ( + (aaa) + (#! @aaa) + (#! @aaa) + ) + selections: + - anchor: {line: 2, character: 6} + active: {line: 2, character: 6} + - anchor: {line: 3, character: 6} + active: {line: 3, character: 6} diff --git a/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/scm/clearEveryEntry.yml b/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/scm/clearEveryEntry.yml new file mode 100644 index 00000000000..0508e95095d --- /dev/null +++ b/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/scm/clearEveryEntry.yml @@ -0,0 +1,24 @@ +languageId: scm +command: + version: 5 + spokenForm: clear every entry + action: {name: clearAndSetSelection} + targets: + - type: primitive + modifiers: + - type: everyScope + scopeType: {type: collectionItem} + usePrePhraseSnapshot: true +initialState: + documentContents: "[(aaa) (bbb)]" + selections: + - anchor: {line: 0, character: 1} + active: {line: 0, character: 1} + marks: {} +finalState: + documentContents: "[ ]" + selections: + - anchor: {line: 0, character: 1} + active: {line: 0, character: 1} + - anchor: {line: 0, character: 2} + active: {line: 0, character: 2} diff --git a/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/scm/clearEveryEntry2.yml b/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/scm/clearEveryEntry2.yml new file mode 100644 index 00000000000..53c01c285e3 --- /dev/null +++ b/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/scm/clearEveryEntry2.yml @@ -0,0 +1,32 @@ +languageId: scm +command: + version: 5 + spokenForm: clear every entry + action: {name: clearAndSetSelection} + targets: + - type: primitive + modifiers: + - type: everyScope + scopeType: {type: collectionItem} + usePrePhraseSnapshot: true +initialState: + documentContents: |- + ( + [(aaa) (bbb)] + (ccc) + ) + selections: + - anchor: {line: 1, character: 4} + active: {line: 1, character: 4} + marks: {} +finalState: + documentContents: |- + ( + + + ) + selections: + - anchor: {line: 1, character: 4} + active: {line: 1, character: 4} + - anchor: {line: 2, character: 4} + active: {line: 2, character: 4} diff --git a/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/scm/clearEveryEntry3.yml b/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/scm/clearEveryEntry3.yml new file mode 100644 index 00000000000..cb54dfe8825 --- /dev/null +++ b/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/scm/clearEveryEntry3.yml @@ -0,0 +1,32 @@ +languageId: scm +command: + version: 5 + spokenForm: clear every entry + action: {name: clearAndSetSelection} + targets: + - type: primitive + modifiers: + - type: everyScope + scopeType: {type: collectionItem} + usePrePhraseSnapshot: true +initialState: + documentContents: |- + (ddd + [(aaa) (bbb)] + (ccc) + ) + selections: + - anchor: {line: 0, character: 1} + active: {line: 0, character: 1} + marks: {} +finalState: + documentContents: |- + (ddd + + + ) + selections: + - anchor: {line: 1, character: 4} + active: {line: 1, character: 4} + - anchor: {line: 2, character: 4} + active: {line: 2, character: 4} diff --git a/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/scm/clearEveryName.yml b/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/scm/clearEveryName.yml new file mode 100644 index 00000000000..cc6671941de --- /dev/null +++ b/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/scm/clearEveryName.yml @@ -0,0 +1,24 @@ +languageId: scm +command: + version: 5 + spokenForm: clear every name + action: {name: clearAndSetSelection} + targets: + - type: primitive + modifiers: + - type: everyScope + scopeType: {type: name} + usePrePhraseSnapshot: true +initialState: + documentContents: (aaa) @bbb @ccc + selections: + - anchor: {line: 0, character: 0} + active: {line: 0, character: 0} + marks: {} +finalState: + documentContents: "(aaa) " + selections: + - anchor: {line: 0, character: 6} + active: {line: 0, character: 6} + - anchor: {line: 0, character: 7} + active: {line: 0, character: 7} diff --git a/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/scm/clearEveryName2.yml b/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/scm/clearEveryName2.yml new file mode 100644 index 00000000000..d19d06bb7ad --- /dev/null +++ b/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/scm/clearEveryName2.yml @@ -0,0 +1,24 @@ +languageId: scm +command: + version: 5 + spokenForm: clear every name + action: {name: clearAndSetSelection} + targets: + - type: primitive + modifiers: + - type: everyScope + scopeType: {type: name} + usePrePhraseSnapshot: true +initialState: + documentContents: "[(aaa) (bbb)] @ccc @ddd" + selections: + - anchor: {line: 0, character: 0} + active: {line: 0, character: 0} + marks: {} +finalState: + documentContents: "[(aaa) (bbb)] " + selections: + - anchor: {line: 0, character: 14} + active: {line: 0, character: 14} + - anchor: {line: 0, character: 15} + active: {line: 0, character: 15} diff --git a/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/scm/clearEveryState.yml b/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/scm/clearEveryState.yml new file mode 100644 index 00000000000..4e97985309e --- /dev/null +++ b/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/scm/clearEveryState.yml @@ -0,0 +1,29 @@ +languageId: scm +command: + version: 5 + spokenForm: clear every state + action: {name: clearAndSetSelection} + targets: + - type: primitive + modifiers: + - type: everyScope + scopeType: {type: statement} + usePrePhraseSnapshot: true +initialState: + documentContents: |- + (aaa) @bbb + ;; ccc + (ddd) @eee + selections: + - anchor: {line: 2, character: 10} + active: {line: 2, character: 10} + marks: {} +finalState: + documentContents: | + + ;; ccc + selections: + - anchor: {line: 0, character: 0} + active: {line: 0, character: 0} + - anchor: {line: 2, character: 0} + active: {line: 2, character: 0} diff --git a/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/scm/clearItem.yml b/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/scm/clearItem.yml new file mode 100644 index 00000000000..75c4ca4829b --- /dev/null +++ b/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/scm/clearItem.yml @@ -0,0 +1,22 @@ +languageId: scm +command: + version: 5 + spokenForm: clear item + action: {name: clearAndSetSelection} + targets: + - type: primitive + modifiers: + - type: containingScope + scopeType: {type: collectionItem} + usePrePhraseSnapshot: true +initialState: + documentContents: ;; (aaa) + selections: + - anchor: {line: 0, character: 4} + active: {line: 0, character: 4} + marks: {} +finalState: + documentContents: ;; () + selections: + - anchor: {line: 0, character: 4} + active: {line: 0, character: 4} diff --git a/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/scm/clearKey.yml b/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/scm/clearKey.yml new file mode 100644 index 00000000000..9b21d9353a3 --- /dev/null +++ b/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/scm/clearKey.yml @@ -0,0 +1,28 @@ +languageId: scm +command: + version: 5 + spokenForm: clear key + action: {name: clearAndSetSelection} + targets: + - type: primitive + modifiers: + - type: containingScope + scopeType: {type: collectionKey} + usePrePhraseSnapshot: true +initialState: + documentContents: |- + (aaa + bbb: (ccc) @ccc + ) + selections: + - anchor: {line: 1, character: 9} + active: {line: 1, character: 9} + marks: {} +finalState: + documentContents: |- + (aaa + : (ccc) @ccc + ) + selections: + - anchor: {line: 1, character: 4} + active: {line: 1, character: 4} diff --git a/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/scm/clearList.yml b/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/scm/clearList.yml new file mode 100644 index 00000000000..8da9af5749b --- /dev/null +++ b/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/scm/clearList.yml @@ -0,0 +1,22 @@ +languageId: scm +command: + version: 5 + spokenForm: clear list + action: {name: clearAndSetSelection} + targets: + - type: primitive + modifiers: + - type: containingScope + scopeType: {type: list} + usePrePhraseSnapshot: true +initialState: + documentContents: "[(aaa) (bbb)] @ccc" + selections: + - anchor: {line: 0, character: 0} + active: {line: 0, character: 0} + marks: {} +finalState: + documentContents: " @ccc" + selections: + - anchor: {line: 0, character: 0} + active: {line: 0, character: 0} diff --git a/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/scm/clearList2.yml b/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/scm/clearList2.yml new file mode 100644 index 00000000000..14bbebccba3 --- /dev/null +++ b/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/scm/clearList2.yml @@ -0,0 +1,22 @@ +languageId: scm +command: + version: 5 + spokenForm: clear list + action: {name: clearAndSetSelection} + targets: + - type: primitive + modifiers: + - type: containingScope + scopeType: {type: list} + usePrePhraseSnapshot: true +initialState: + documentContents: "[(aaa) (bbb)] @ccc @ddd" + selections: + - anchor: {line: 0, character: 23} + active: {line: 0, character: 23} + marks: {} +finalState: + documentContents: " @ccc @ddd" + selections: + - anchor: {line: 0, character: 0} + active: {line: 0, character: 0} diff --git a/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/scm/clearName.yml b/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/scm/clearName.yml new file mode 100644 index 00000000000..2ea01dfbc1a --- /dev/null +++ b/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/scm/clearName.yml @@ -0,0 +1,22 @@ +languageId: scm +command: + version: 5 + spokenForm: clear name + action: {name: clearAndSetSelection} + targets: + - type: primitive + modifiers: + - type: containingScope + scopeType: {type: name} + usePrePhraseSnapshot: true +initialState: + documentContents: (aaa) @bbb @ccc + selections: + - anchor: {line: 0, character: 0} + active: {line: 0, character: 0} + marks: {} +finalState: + documentContents: (aaa) @ccc + selections: + - anchor: {line: 0, character: 6} + active: {line: 0, character: 6} diff --git a/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/scm/clearName2.yml b/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/scm/clearName2.yml new file mode 100644 index 00000000000..83a236f529b --- /dev/null +++ b/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/scm/clearName2.yml @@ -0,0 +1,22 @@ +languageId: scm +command: + version: 5 + spokenForm: clear name + action: {name: clearAndSetSelection} + targets: + - type: primitive + modifiers: + - type: containingScope + scopeType: {type: name} + usePrePhraseSnapshot: true +initialState: + documentContents: (aaa) @bbb @ccc + selections: + - anchor: {line: 0, character: 11} + active: {line: 0, character: 11} + marks: {} +finalState: + documentContents: "(aaa) @bbb " + selections: + - anchor: {line: 0, character: 11} + active: {line: 0, character: 11} diff --git a/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/scm/clearName3.yml b/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/scm/clearName3.yml new file mode 100644 index 00000000000..d50de14ee67 --- /dev/null +++ b/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/scm/clearName3.yml @@ -0,0 +1,22 @@ +languageId: scm +command: + version: 5 + spokenForm: clear name + action: {name: clearAndSetSelection} + targets: + - type: primitive + modifiers: + - type: containingScope + scopeType: {type: name} + usePrePhraseSnapshot: true +initialState: + documentContents: (aaa) @bbb + selections: + - anchor: {line: 0, character: 0} + active: {line: 0, character: 0} + marks: {} +finalState: + documentContents: "(aaa) " + selections: + - anchor: {line: 0, character: 6} + active: {line: 0, character: 6} diff --git a/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/scm/clearName4.yml b/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/scm/clearName4.yml new file mode 100644 index 00000000000..a7684710f8f --- /dev/null +++ b/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/scm/clearName4.yml @@ -0,0 +1,22 @@ +languageId: scm +command: + version: 5 + spokenForm: clear name + action: {name: clearAndSetSelection} + targets: + - type: primitive + modifiers: + - type: containingScope + scopeType: {type: name} + usePrePhraseSnapshot: true +initialState: + documentContents: "\"aaa\" @bbb" + selections: + - anchor: {line: 0, character: 0} + active: {line: 0, character: 0} + marks: {} +finalState: + documentContents: "\"aaa\" " + selections: + - anchor: {line: 0, character: 6} + active: {line: 0, character: 6} diff --git a/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/scm/clearName5.yml b/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/scm/clearName5.yml new file mode 100644 index 00000000000..27e950614b0 --- /dev/null +++ b/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/scm/clearName5.yml @@ -0,0 +1,22 @@ +languageId: scm +command: + version: 5 + spokenForm: clear name + action: {name: clearAndSetSelection} + targets: + - type: primitive + modifiers: + - type: containingScope + scopeType: {type: name} + usePrePhraseSnapshot: true +initialState: + documentContents: "[(aaa) (bbb)] @ccc" + selections: + - anchor: {line: 0, character: 0} + active: {line: 0, character: 0} + marks: {} +finalState: + documentContents: "[(aaa) (bbb)] " + selections: + - anchor: {line: 0, character: 14} + active: {line: 0, character: 14} diff --git a/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/scm/clearRound.yml b/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/scm/clearRound.yml new file mode 100644 index 00000000000..fc35836e332 --- /dev/null +++ b/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/scm/clearRound.yml @@ -0,0 +1,22 @@ +languageId: scm +command: + version: 5 + spokenForm: clear round + action: {name: clearAndSetSelection} + targets: + - type: primitive + modifiers: + - type: containingScope + scopeType: {type: surroundingPair, delimiter: parentheses} + usePrePhraseSnapshot: true +initialState: + documentContents: (aaa) + selections: + - anchor: {line: 0, character: 0} + active: {line: 0, character: 0} + marks: {} +finalState: + documentContents: "" + selections: + - anchor: {line: 0, character: 0} + active: {line: 0, character: 0} diff --git a/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/scm/clearRound2.yml b/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/scm/clearRound2.yml new file mode 100644 index 00000000000..994802b1a13 --- /dev/null +++ b/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/scm/clearRound2.yml @@ -0,0 +1,22 @@ +languageId: scm +command: + version: 5 + spokenForm: clear round + action: {name: clearAndSetSelection} + targets: + - type: primitive + modifiers: + - type: containingScope + scopeType: {type: surroundingPair, delimiter: parentheses} + usePrePhraseSnapshot: true +initialState: + documentContents: ;; (aaa) + selections: + - anchor: {line: 0, character: 3} + active: {line: 0, character: 3} + marks: {} +finalState: + documentContents: ";; " + selections: + - anchor: {line: 0, character: 3} + active: {line: 0, character: 3} diff --git a/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/scm/clearRound3.yml b/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/scm/clearRound3.yml new file mode 100644 index 00000000000..f4ca0c459b4 --- /dev/null +++ b/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/scm/clearRound3.yml @@ -0,0 +1,22 @@ +languageId: scm +command: + version: 5 + spokenForm: clear round + action: {name: clearAndSetSelection} + targets: + - type: primitive + modifiers: + - type: containingScope + scopeType: {type: surroundingPair, delimiter: parentheses} + usePrePhraseSnapshot: true +initialState: + documentContents: "\"(aaa)\" @bbb" + selections: + - anchor: {line: 0, character: 1} + active: {line: 0, character: 1} + marks: {} +finalState: + documentContents: "\"\" @bbb" + selections: + - anchor: {line: 0, character: 1} + active: {line: 0, character: 1} diff --git a/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/scm/clearState.yml b/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/scm/clearState.yml new file mode 100644 index 00000000000..1d6f44b0839 --- /dev/null +++ b/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/scm/clearState.yml @@ -0,0 +1,18 @@ +languageId: scm +command: + version: 5 + spokenForm: clear state + action: {name: clearAndSetSelection} + targets: + - type: primitive + modifiers: + - type: containingScope + scopeType: {type: statement} + usePrePhraseSnapshot: true +initialState: + documentContents: ;; aaa + selections: + - anchor: {line: 0, character: 0} + active: {line: 0, character: 0} + marks: {} +thrownError: {name: NoContainingScopeError} diff --git a/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/scm/clearState2.yml b/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/scm/clearState2.yml new file mode 100644 index 00000000000..44da4621aca --- /dev/null +++ b/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/scm/clearState2.yml @@ -0,0 +1,22 @@ +languageId: scm +command: + version: 5 + spokenForm: clear state + action: {name: clearAndSetSelection} + targets: + - type: primitive + modifiers: + - type: containingScope + scopeType: {type: statement} + usePrePhraseSnapshot: true +initialState: + documentContents: (aaa) @bbb + selections: + - anchor: {line: 0, character: 0} + active: {line: 0, character: 0} + marks: {} +finalState: + documentContents: "" + selections: + - anchor: {line: 0, character: 0} + active: {line: 0, character: 0} diff --git a/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/scm/clearState3.yml b/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/scm/clearState3.yml new file mode 100644 index 00000000000..caa6560abd2 --- /dev/null +++ b/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/scm/clearState3.yml @@ -0,0 +1,26 @@ +languageId: scm +command: + version: 5 + spokenForm: clear state + action: {name: clearAndSetSelection} + targets: + - type: primitive + modifiers: + - type: containingScope + scopeType: {type: statement} + usePrePhraseSnapshot: true +initialState: + documentContents: |- + ( + (aaa) @bbb + (#ccc? @bbb) + ) + selections: + - anchor: {line: 1, character: 4} + active: {line: 1, character: 4} + marks: {} +finalState: + documentContents: "" + selections: + - anchor: {line: 0, character: 0} + active: {line: 0, character: 0} diff --git a/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/scm/clearState4.yml b/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/scm/clearState4.yml new file mode 100644 index 00000000000..d107fb47f52 --- /dev/null +++ b/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/scm/clearState4.yml @@ -0,0 +1,26 @@ +languageId: scm +command: + version: 5 + spokenForm: clear state + action: {name: clearAndSetSelection} + targets: + - type: primitive + modifiers: + - type: containingScope + scopeType: {type: statement} + usePrePhraseSnapshot: true +initialState: + documentContents: |- + ( + (aaa) @bbb + (#ccc? @bbb) + ) + selections: + - anchor: {line: 2, character: 4} + active: {line: 2, character: 4} + marks: {} +finalState: + documentContents: "" + selections: + - anchor: {line: 0, character: 0} + active: {line: 0, character: 0} diff --git a/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/scm/clearState5.yml b/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/scm/clearState5.yml new file mode 100644 index 00000000000..952bd0184e2 --- /dev/null +++ b/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/scm/clearState5.yml @@ -0,0 +1,22 @@ +languageId: scm +command: + version: 5 + spokenForm: clear state + action: {name: clearAndSetSelection} + targets: + - type: primitive + modifiers: + - type: containingScope + scopeType: {type: statement} + usePrePhraseSnapshot: true +initialState: + documentContents: "[(aaa) (bbb)] @ccc" + selections: + - anchor: {line: 0, character: 0} + active: {line: 0, character: 0} + marks: {} +finalState: + documentContents: "" + selections: + - anchor: {line: 0, character: 0} + active: {line: 0, character: 0} diff --git a/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/scm/clearType.yml b/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/scm/clearType.yml new file mode 100644 index 00000000000..710b5545edc --- /dev/null +++ b/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/scm/clearType.yml @@ -0,0 +1,22 @@ +languageId: scm +command: + version: 5 + spokenForm: clear type + action: {name: clearAndSetSelection} + targets: + - type: primitive + modifiers: + - type: containingScope + scopeType: {type: type} + usePrePhraseSnapshot: true +initialState: + documentContents: (aaa) @bbb @ccc + selections: + - anchor: {line: 0, character: 0} + active: {line: 0, character: 0} + marks: {} +finalState: + documentContents: () @bbb @ccc + selections: + - anchor: {line: 0, character: 1} + active: {line: 0, character: 1} diff --git a/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/scm/clearType2.yml b/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/scm/clearType2.yml new file mode 100644 index 00000000000..12988e4419a --- /dev/null +++ b/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/scm/clearType2.yml @@ -0,0 +1,22 @@ +languageId: scm +command: + version: 5 + spokenForm: clear type + action: {name: clearAndSetSelection} + targets: + - type: primitive + modifiers: + - type: containingScope + scopeType: {type: type} + usePrePhraseSnapshot: true +initialState: + documentContents: "\"aaa\" @bbb" + selections: + - anchor: {line: 0, character: 6} + active: {line: 0, character: 6} + marks: {} +finalState: + documentContents: " @bbb" + selections: + - anchor: {line: 0, character: 0} + active: {line: 0, character: 0} diff --git a/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/scm/clearValue.yml b/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/scm/clearValue.yml new file mode 100644 index 00000000000..b2195baa3b0 --- /dev/null +++ b/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/scm/clearValue.yml @@ -0,0 +1,28 @@ +languageId: scm +command: + version: 5 + spokenForm: clear value + action: {name: clearAndSetSelection} + targets: + - type: primitive + modifiers: + - type: containingScope + scopeType: {type: value} + usePrePhraseSnapshot: true +initialState: + documentContents: |- + (aaa + bbb: (ccc) @ccc + ) + selections: + - anchor: {line: 1, character: 4} + active: {line: 1, character: 4} + marks: {} +finalState: + documentContents: |- + (aaa + bbb: + ) + selections: + - anchor: {line: 1, character: 9} + active: {line: 1, character: 9} diff --git a/queries/scm.scm b/queries/scm.scm new file mode 100644 index 00000000000..c17101604f4 --- /dev/null +++ b/queries/scm.scm @@ -0,0 +1,94 @@ +( + (program + (_) @statement + ) @_.iteration + (#not-type? @statement comment) +) + +(comment) @comment @textFragment + +(anonymous_node + name: (_) @string @textFragment +) + +(predicate + name: (identifier) @functionCallee +) @functionCall @functionCallee.domain + +(grouping) @functionCall.iteration @functionCallee.iteration + +(predicate + (parameters + (_) @argumentOrParameter + ) +) @_.iteration + +( + (named_node + "(" @collectionItem.iteration.start + name: (_) @type + (_) @collectionItem + ")" @collectionItem.iteration.end + ) @type.domain + (#end-position! @collectionItem.iteration.start) + (#start-position! @collectionItem.iteration.end) +) + +( + (grouping + "(" @collectionItem.iteration.start + (_) @collectionItem + ")" @collectionItem.iteration.end + ) + (#end-position! @collectionItem.iteration.start) + (#start-position! @collectionItem.iteration.end) +) + +(anonymous_node + name: (_) @type +) @_.domain + +( + (list + "[" @list.start @collectionItem.iteration.start + (_) @collectionItem + "]" @list.end @collectionItem.iteration.end + ) @list.domain + (#end-position! @collectionItem.iteration.start) + (#start-position! @collectionItem.iteration.end) +) + +[ + (list) + (anonymous_node) + (grouping) + (named_node) +] @name.iteration + +;; Include everything leading up to the first capture in its domain +( + (_ + (_) @dummy + . + (capture) @name @_.domain.end + ) @_.domain.start + (#not-type? @_.domain.start parameters) + (#child-range! @_.domain.start 0 0) + (#not-type? @dummy capture) +) + +;; Only include the capture itself in its domain after the first capture +( + (_ + (capture) + . + (capture) @name + ) @dummy + (#not-type? @dummy parameters) +) + +(field_definition + name: (identifier) @collectionKey + ":" + (_) @value +) @_.domain