From b650b22d3d27f2d9976a8f51864079cec7e3cc93 Mon Sep 17 00:00:00 2001 From: fidgetingbits Date: Mon, 17 Jun 2024 11:15:53 +0800 Subject: [PATCH 1/2] initial next-gen shellscript support --- .../languages/shellscript/changeArg.yml | 23 ++ .../languages/shellscript/changeArg2.yml | 23 ++ .../languages/shellscript/changeArg3.yml | 23 ++ .../languages/shellscript/changeArg4.yml | 23 ++ .../languages/shellscript/changeArg5.yml | 25 ++ .../languages/shellscript/changeArgBat.yml | 29 ++ .../languages/shellscript/changeArgRed.yml | 29 ++ .../languages/shellscript/changeBranch.yml | 31 ++ .../languages/shellscript/changeBranch2.yml | 35 ++ .../languages/shellscript/changeBranch3.yml | 31 ++ .../languages/shellscript/changeBranch4.yml | 31 ++ .../languages/shellscript/changeBranch5.yml | 31 ++ .../languages/shellscript/changeBranch6.yml | 31 ++ .../languages/shellscript/changeBranch7.yml | 45 +++ .../languages/shellscript/changeCall.yml | 23 ++ .../languages/shellscript/changeCallee.yml | 23 ++ .../languages/shellscript/changeCommand.yml | 23 ++ .../languages/shellscript/changeComment.yml | 23 ++ .../languages/shellscript/changeCondition.yml | 33 ++ .../shellscript/changeCondition2.yml | 39 +++ .../shellscript/changeCondition3.yml | 47 +++ .../shellscript/changeConditionEach.yml | 37 +++ .../shellscript/changeConditionFive.yml | 35 ++ .../languages/shellscript/changeEveryArg.yml | 27 ++ .../shellscript/changeEveryArgInsideFine.yml | 32 ++ .../shellscript/changeEveryArgInsideFine2.yml | 32 ++ .../shellscript/changeEveryArgInsideTrap.yml | 32 ++ .../shellscript/changeEveryArgInsideTrap2.yml | 32 ++ .../shellscript/changeEveryBranch.yml | 35 ++ .../languages/shellscript/changeEveryItem.yml | 29 ++ .../languages/shellscript/changeFunk.yml | 26 ++ .../languages/shellscript/changeFunkName.yml | 29 ++ .../languages/shellscript/changeIfState.yml | 28 ++ .../languages/shellscript/changeInside.yml | 22 ++ .../languages/shellscript/changeInside2.yml | 22 ++ .../shellscript/changeInsideBranch.yml | 34 ++ .../shellscript/changeInsideBranch2.yml | 38 +++ .../shellscript/changeInsideBranch3.yml | 33 ++ .../shellscript/changeInsideBranch4.yml | 43 +++ .../shellscript/changeInsideBranch5.yml | 42 +++ .../shellscript/changeInsideBranch6.yml | 45 +++ .../shellscript/changeInsideBranch7.yml | 44 +++ .../shellscript/changeInsideBranch8.yml | 48 +++ .../shellscript/changeInsideEveryBranch.yml | 43 +++ .../shellscript/changeInsideEveryBranch2.yml | 47 +++ .../shellscript/changeInsideEveryBranch3.yml | 52 +++ .../shellscript/changeInsideFirstBranch.yml | 36 ++ .../shellscript/changeInsideFunk.yml | 30 ++ .../shellscript/changeInsideList.yml | 24 ++ .../languages/shellscript/changeKeyCrunch.yml | 33 ++ .../languages/shellscript/changeList.yml | 23 ++ .../languages/shellscript/changeName.yml | 23 ++ .../languages/shellscript/changeName2.yml | 27 ++ .../languages/shellscript/changeName3.yml | 29 ++ .../languages/shellscript/changeRegexZero.yml | 41 +++ .../languages/shellscript/changeState.yml | 23 ++ .../languages/shellscript/changeState2.yml | 23 ++ .../languages/shellscript/changeState3.yml | 23 ++ .../languages/shellscript/changeString.yml | 23 ++ .../languages/shellscript/changeValue.yml | 23 ++ .../languages/shellscript/changeValueOne.yml | 35 ++ .../languages/shellscript/changeValueVest.yml | 33 ++ .../languages/shellscript/chuckArg.yml | 23 ++ .../languages/shellscript/chuckArg2.yml | 23 ++ .../languages/shellscript/chuckArgZip.yml | 29 ++ .../shellscript/chuckInsideBranch.yml | 47 +++ .../languages/shellscript/chuckItem.yml | 25 ++ .../languages/shellscript/chuckItem2.yml | 25 ++ .../languages/shellscript/chuckName.yml | 23 ++ .../shellscript/chuckNameGreenSit.yml | 35 ++ .../languages/shellscript/chuckValue.yml | 23 ++ .../languages/shellscript/chuckValue2.yml | 25 ++ .../languages/shellscript/chuckValueOne.yml | 35 ++ .../fixtures/scopes/shellscript/command.scope | 10 + data/fixtures/scopes/shellscript/list.scope | 10 + .../scopes/shellscript/name.assignment.scope | 20 ++ .../scopes/shellscript/name.assignment2.scope | 20 ++ .../scopes/shellscript/name.assignment3.scope | 20 ++ .../scopes/shellscript/value.assignment.scope | 20 ++ data/fixtures/subtoken.fixture.ts | 87 +++++ data/playground/shellscript/shellscript.sh | 172 ++++++++++ .../languageScopeSupport.ts | 2 + .../src/scopeSupportFacets/shellscript.ts | 15 + queries/shellscript.scm | 311 ++++++++++++++++++ 84 files changed, 2957 insertions(+) create mode 100644 data/fixtures/recorded/languages/shellscript/changeArg.yml create mode 100644 data/fixtures/recorded/languages/shellscript/changeArg2.yml create mode 100644 data/fixtures/recorded/languages/shellscript/changeArg3.yml create mode 100644 data/fixtures/recorded/languages/shellscript/changeArg4.yml create mode 100644 data/fixtures/recorded/languages/shellscript/changeArg5.yml create mode 100644 data/fixtures/recorded/languages/shellscript/changeArgBat.yml create mode 100644 data/fixtures/recorded/languages/shellscript/changeArgRed.yml create mode 100644 data/fixtures/recorded/languages/shellscript/changeBranch.yml create mode 100644 data/fixtures/recorded/languages/shellscript/changeBranch2.yml create mode 100644 data/fixtures/recorded/languages/shellscript/changeBranch3.yml create mode 100644 data/fixtures/recorded/languages/shellscript/changeBranch4.yml create mode 100644 data/fixtures/recorded/languages/shellscript/changeBranch5.yml create mode 100644 data/fixtures/recorded/languages/shellscript/changeBranch6.yml create mode 100644 data/fixtures/recorded/languages/shellscript/changeBranch7.yml create mode 100644 data/fixtures/recorded/languages/shellscript/changeCall.yml create mode 100644 data/fixtures/recorded/languages/shellscript/changeCallee.yml create mode 100644 data/fixtures/recorded/languages/shellscript/changeCommand.yml create mode 100644 data/fixtures/recorded/languages/shellscript/changeComment.yml create mode 100644 data/fixtures/recorded/languages/shellscript/changeCondition.yml create mode 100644 data/fixtures/recorded/languages/shellscript/changeCondition2.yml create mode 100644 data/fixtures/recorded/languages/shellscript/changeCondition3.yml create mode 100644 data/fixtures/recorded/languages/shellscript/changeConditionEach.yml create mode 100644 data/fixtures/recorded/languages/shellscript/changeConditionFive.yml create mode 100644 data/fixtures/recorded/languages/shellscript/changeEveryArg.yml create mode 100644 data/fixtures/recorded/languages/shellscript/changeEveryArgInsideFine.yml create mode 100644 data/fixtures/recorded/languages/shellscript/changeEveryArgInsideFine2.yml create mode 100644 data/fixtures/recorded/languages/shellscript/changeEveryArgInsideTrap.yml create mode 100644 data/fixtures/recorded/languages/shellscript/changeEveryArgInsideTrap2.yml create mode 100644 data/fixtures/recorded/languages/shellscript/changeEveryBranch.yml create mode 100644 data/fixtures/recorded/languages/shellscript/changeEveryItem.yml create mode 100644 data/fixtures/recorded/languages/shellscript/changeFunk.yml create mode 100644 data/fixtures/recorded/languages/shellscript/changeFunkName.yml create mode 100644 data/fixtures/recorded/languages/shellscript/changeIfState.yml create mode 100644 data/fixtures/recorded/languages/shellscript/changeInside.yml create mode 100644 data/fixtures/recorded/languages/shellscript/changeInside2.yml create mode 100644 data/fixtures/recorded/languages/shellscript/changeInsideBranch.yml create mode 100644 data/fixtures/recorded/languages/shellscript/changeInsideBranch2.yml create mode 100644 data/fixtures/recorded/languages/shellscript/changeInsideBranch3.yml create mode 100644 data/fixtures/recorded/languages/shellscript/changeInsideBranch4.yml create mode 100644 data/fixtures/recorded/languages/shellscript/changeInsideBranch5.yml create mode 100644 data/fixtures/recorded/languages/shellscript/changeInsideBranch6.yml create mode 100644 data/fixtures/recorded/languages/shellscript/changeInsideBranch7.yml create mode 100644 data/fixtures/recorded/languages/shellscript/changeInsideBranch8.yml create mode 100644 data/fixtures/recorded/languages/shellscript/changeInsideEveryBranch.yml create mode 100644 data/fixtures/recorded/languages/shellscript/changeInsideEveryBranch2.yml create mode 100644 data/fixtures/recorded/languages/shellscript/changeInsideEveryBranch3.yml create mode 100644 data/fixtures/recorded/languages/shellscript/changeInsideFirstBranch.yml create mode 100644 data/fixtures/recorded/languages/shellscript/changeInsideFunk.yml create mode 100644 data/fixtures/recorded/languages/shellscript/changeInsideList.yml create mode 100644 data/fixtures/recorded/languages/shellscript/changeKeyCrunch.yml create mode 100644 data/fixtures/recorded/languages/shellscript/changeList.yml create mode 100644 data/fixtures/recorded/languages/shellscript/changeName.yml create mode 100644 data/fixtures/recorded/languages/shellscript/changeName2.yml create mode 100644 data/fixtures/recorded/languages/shellscript/changeName3.yml create mode 100644 data/fixtures/recorded/languages/shellscript/changeRegexZero.yml create mode 100644 data/fixtures/recorded/languages/shellscript/changeState.yml create mode 100644 data/fixtures/recorded/languages/shellscript/changeState2.yml create mode 100644 data/fixtures/recorded/languages/shellscript/changeState3.yml create mode 100644 data/fixtures/recorded/languages/shellscript/changeString.yml create mode 100644 data/fixtures/recorded/languages/shellscript/changeValue.yml create mode 100644 data/fixtures/recorded/languages/shellscript/changeValueOne.yml create mode 100644 data/fixtures/recorded/languages/shellscript/changeValueVest.yml create mode 100644 data/fixtures/recorded/languages/shellscript/chuckArg.yml create mode 100644 data/fixtures/recorded/languages/shellscript/chuckArg2.yml create mode 100644 data/fixtures/recorded/languages/shellscript/chuckArgZip.yml create mode 100644 data/fixtures/recorded/languages/shellscript/chuckInsideBranch.yml create mode 100644 data/fixtures/recorded/languages/shellscript/chuckItem.yml create mode 100644 data/fixtures/recorded/languages/shellscript/chuckItem2.yml create mode 100644 data/fixtures/recorded/languages/shellscript/chuckName.yml create mode 100644 data/fixtures/recorded/languages/shellscript/chuckNameGreenSit.yml create mode 100644 data/fixtures/recorded/languages/shellscript/chuckValue.yml create mode 100644 data/fixtures/recorded/languages/shellscript/chuckValue2.yml create mode 100644 data/fixtures/recorded/languages/shellscript/chuckValueOne.yml create mode 100644 data/fixtures/scopes/shellscript/command.scope create mode 100644 data/fixtures/scopes/shellscript/list.scope create mode 100644 data/fixtures/scopes/shellscript/name.assignment.scope create mode 100644 data/fixtures/scopes/shellscript/name.assignment2.scope create mode 100644 data/fixtures/scopes/shellscript/name.assignment3.scope create mode 100644 data/fixtures/scopes/shellscript/value.assignment.scope create mode 100644 data/fixtures/subtoken.fixture.ts create mode 100755 data/playground/shellscript/shellscript.sh create mode 100644 packages/common/src/scopeSupportFacets/shellscript.ts create mode 100644 queries/shellscript.scm diff --git a/data/fixtures/recorded/languages/shellscript/changeArg.yml b/data/fixtures/recorded/languages/shellscript/changeArg.yml new file mode 100644 index 0000000000..dd3d786468 --- /dev/null +++ b/data/fixtures/recorded/languages/shellscript/changeArg.yml @@ -0,0 +1,23 @@ +languageId: shellscript +command: + version: 6 + spokenForm: change arg + action: + name: clearAndSetSelection + target: + type: primitive + modifiers: + - type: containingScope + scopeType: {type: argumentOrParameter} + usePrePhraseSnapshot: true +initialState: + documentContents: var="foo ${bar}" + selections: + - anchor: {line: 0, character: 13} + active: {line: 0, character: 13} + marks: {} +finalState: + documentContents: var="foo " + selections: + - anchor: {line: 0, character: 9} + active: {line: 0, character: 9} diff --git a/data/fixtures/recorded/languages/shellscript/changeArg2.yml b/data/fixtures/recorded/languages/shellscript/changeArg2.yml new file mode 100644 index 0000000000..784d5d5a76 --- /dev/null +++ b/data/fixtures/recorded/languages/shellscript/changeArg2.yml @@ -0,0 +1,23 @@ +languageId: shellscript +command: + version: 6 + spokenForm: change arg + action: + name: clearAndSetSelection + target: + type: primitive + modifiers: + - type: containingScope + scopeType: {type: argumentOrParameter} + usePrePhraseSnapshot: true +initialState: + documentContents: var="foo $bar" + selections: + - anchor: {line: 0, character: 10} + active: {line: 0, character: 10} + marks: {} +finalState: + documentContents: var="foo " + selections: + - anchor: {line: 0, character: 9} + active: {line: 0, character: 9} diff --git a/data/fixtures/recorded/languages/shellscript/changeArg3.yml b/data/fixtures/recorded/languages/shellscript/changeArg3.yml new file mode 100644 index 0000000000..c57d0c9088 --- /dev/null +++ b/data/fixtures/recorded/languages/shellscript/changeArg3.yml @@ -0,0 +1,23 @@ +languageId: shellscript +command: + version: 6 + spokenForm: change arg + action: + name: clearAndSetSelection + target: + type: primitive + modifiers: + - type: containingScope + scopeType: {type: argumentOrParameter} + usePrePhraseSnapshot: true +initialState: + documentContents: echo "foo" + selections: + - anchor: {line: 0, character: 6} + active: {line: 0, character: 6} + marks: {} +finalState: + documentContents: "echo " + selections: + - anchor: {line: 0, character: 5} + active: {line: 0, character: 5} diff --git a/data/fixtures/recorded/languages/shellscript/changeArg4.yml b/data/fixtures/recorded/languages/shellscript/changeArg4.yml new file mode 100644 index 0000000000..adcae9517b --- /dev/null +++ b/data/fixtures/recorded/languages/shellscript/changeArg4.yml @@ -0,0 +1,23 @@ +languageId: shellscript +command: + version: 6 + spokenForm: change arg + action: + name: clearAndSetSelection + target: + type: primitive + modifiers: + - type: containingScope + scopeType: {type: argumentOrParameter} + usePrePhraseSnapshot: true +initialState: + documentContents: echo "foo" "bar" + selections: + - anchor: {line: 0, character: 15} + active: {line: 0, character: 15} + marks: {} +finalState: + documentContents: "echo \"foo\" " + selections: + - anchor: {line: 0, character: 11} + active: {line: 0, character: 11} diff --git a/data/fixtures/recorded/languages/shellscript/changeArg5.yml b/data/fixtures/recorded/languages/shellscript/changeArg5.yml new file mode 100644 index 0000000000..1fcae07e87 --- /dev/null +++ b/data/fixtures/recorded/languages/shellscript/changeArg5.yml @@ -0,0 +1,25 @@ +languageId: shellscript +command: + version: 6 + spokenForm: change arg + action: + name: clearAndSetSelection + target: + type: primitive + modifiers: + - type: containingScope + scopeType: {type: argumentOrParameter} + usePrePhraseSnapshot: true +initialState: + documentContents: | + echo "Foo ${BAR}" + selections: + - anchor: {line: 0, character: 12} + active: {line: 0, character: 12} + marks: {} +finalState: + documentContents: | + echo "Foo " + selections: + - anchor: {line: 0, character: 10} + active: {line: 0, character: 10} diff --git a/data/fixtures/recorded/languages/shellscript/changeArgBat.yml b/data/fixtures/recorded/languages/shellscript/changeArgBat.yml new file mode 100644 index 0000000000..13834d9ec3 --- /dev/null +++ b/data/fixtures/recorded/languages/shellscript/changeArgBat.yml @@ -0,0 +1,29 @@ +languageId: shellscript +command: + version: 6 + spokenForm: change arg bat + action: + name: clearAndSetSelection + target: + type: primitive + mark: {type: decoratedSymbol, symbolColor: default, character: b} + modifiers: + - type: containingScope + scopeType: {type: argumentOrParameter} + usePrePhraseSnapshot: true +initialState: + documentContents: | + echo "Foo ${BAR} ${BAZ} bar" + selections: + - anchor: {line: 0, character: 28} + active: {line: 0, character: 28} + marks: + default.b: + start: {line: 0, character: 12} + end: {line: 0, character: 15} +finalState: + documentContents: | + echo "Foo ${BAZ} bar" + selections: + - anchor: {line: 0, character: 10} + active: {line: 0, character: 10} diff --git a/data/fixtures/recorded/languages/shellscript/changeArgRed.yml b/data/fixtures/recorded/languages/shellscript/changeArgRed.yml new file mode 100644 index 0000000000..a83ac5f9a6 --- /dev/null +++ b/data/fixtures/recorded/languages/shellscript/changeArgRed.yml @@ -0,0 +1,29 @@ +languageId: shellscript +command: + version: 6 + spokenForm: change arg red + action: + name: clearAndSetSelection + target: + type: primitive + mark: {type: decoratedSymbol, symbolColor: default, character: r} + modifiers: + - type: containingScope + scopeType: {type: argumentOrParameter} + usePrePhraseSnapshot: true +initialState: + documentContents: | + echo "Foo $BAR as $BAZ" + selections: + - anchor: {line: 0, character: 9} + active: {line: 0, character: 9} + marks: + default.r: + start: {line: 0, character: 11} + end: {line: 0, character: 14} +finalState: + documentContents: | + echo "Foo as $BAZ" + selections: + - anchor: {line: 0, character: 10} + active: {line: 0, character: 10} diff --git a/data/fixtures/recorded/languages/shellscript/changeBranch.yml b/data/fixtures/recorded/languages/shellscript/changeBranch.yml new file mode 100644 index 0000000000..3152de1f4d --- /dev/null +++ b/data/fixtures/recorded/languages/shellscript/changeBranch.yml @@ -0,0 +1,31 @@ +languageId: shellscript +command: + version: 6 + spokenForm: change branch + action: + name: clearAndSetSelection + target: + type: primitive + modifiers: + - type: containingScope + scopeType: {type: branch} + usePrePhraseSnapshot: true +initialState: + documentContents: |- + if [ "$number" -eq 42 ]; then + echo "The number is 42" + else + echo "The number is not 42" + fi + selections: + - anchor: {line: 3, character: 10} + active: {line: 3, character: 10} + marks: {} +finalState: + documentContents: |- + if [ "$number" -eq 42 ]; then + echo "The number is 42" + fi + selections: + - anchor: {line: 2, character: 0} + active: {line: 2, character: 0} diff --git a/data/fixtures/recorded/languages/shellscript/changeBranch2.yml b/data/fixtures/recorded/languages/shellscript/changeBranch2.yml new file mode 100644 index 0000000000..9b7b1c57e3 --- /dev/null +++ b/data/fixtures/recorded/languages/shellscript/changeBranch2.yml @@ -0,0 +1,35 @@ +languageId: shellscript +command: + version: 6 + spokenForm: change branch + action: + name: clearAndSetSelection + target: + type: primitive + modifiers: + - type: containingScope + scopeType: {type: branch} + usePrePhraseSnapshot: true +initialState: + documentContents: |- + if [ "$number" -eq 42 ]; then + echo "The number is 42" + elif [ "$number" -gt 42 ]; then + echo "The number is greater than 42" + else + echo "The number is less than than 42" + fi + selections: + - anchor: {line: 3, character: 10} + active: {line: 3, character: 10} + marks: {} +finalState: + documentContents: |- + if [ "$number" -eq 42 ]; then + echo "The number is 42" + else + echo "The number is less than than 42" + fi + selections: + - anchor: {line: 2, character: 0} + active: {line: 2, character: 0} diff --git a/data/fixtures/recorded/languages/shellscript/changeBranch3.yml b/data/fixtures/recorded/languages/shellscript/changeBranch3.yml new file mode 100644 index 0000000000..1b13c1718e --- /dev/null +++ b/data/fixtures/recorded/languages/shellscript/changeBranch3.yml @@ -0,0 +1,31 @@ +languageId: shellscript +command: + version: 6 + spokenForm: change branch + action: + name: clearAndSetSelection + target: + type: primitive + modifiers: + - type: containingScope + scopeType: {type: branch} + usePrePhraseSnapshot: true +initialState: + documentContents: |+ + if [ $value -le 0 ]; then + fi + + + selections: + - anchor: {line: 0, character: 0} + active: {line: 0, character: 0} + marks: {} +finalState: + documentContents: |+ + + fi + + + selections: + - anchor: {line: 0, character: 0} + active: {line: 0, character: 0} diff --git a/data/fixtures/recorded/languages/shellscript/changeBranch4.yml b/data/fixtures/recorded/languages/shellscript/changeBranch4.yml new file mode 100644 index 0000000000..b422d8f65a --- /dev/null +++ b/data/fixtures/recorded/languages/shellscript/changeBranch4.yml @@ -0,0 +1,31 @@ +languageId: shellscript +command: + version: 6 + spokenForm: change branch + action: + name: clearAndSetSelection + target: + type: primitive + modifiers: + - type: containingScope + scopeType: {type: branch} + usePrePhraseSnapshot: true +initialState: + documentContents: |+ + if [ $value -le 0 ]; then + else + fi + + selections: + - anchor: {line: 1, character: 2} + active: {line: 1, character: 2} + marks: {} +finalState: + documentContents: |+ + if [ $value -le 0 ]; then + + fi + + selections: + - anchor: {line: 1, character: 0} + active: {line: 1, character: 0} diff --git a/data/fixtures/recorded/languages/shellscript/changeBranch5.yml b/data/fixtures/recorded/languages/shellscript/changeBranch5.yml new file mode 100644 index 0000000000..8092389892 --- /dev/null +++ b/data/fixtures/recorded/languages/shellscript/changeBranch5.yml @@ -0,0 +1,31 @@ +languageId: shellscript +command: + version: 6 + spokenForm: change branch + action: + name: clearAndSetSelection + target: + type: primitive + modifiers: + - type: containingScope + scopeType: {type: branch} + usePrePhraseSnapshot: true +initialState: + documentContents: |+ + if [ $value -le 0 ]; then + else + fi + + selections: + - anchor: {line: 0, character: 2} + active: {line: 0, character: 2} + marks: {} +finalState: + documentContents: |+ + + else + fi + + selections: + - anchor: {line: 0, character: 0} + active: {line: 0, character: 0} diff --git a/data/fixtures/recorded/languages/shellscript/changeBranch6.yml b/data/fixtures/recorded/languages/shellscript/changeBranch6.yml new file mode 100644 index 0000000000..c0703b6ef3 --- /dev/null +++ b/data/fixtures/recorded/languages/shellscript/changeBranch6.yml @@ -0,0 +1,31 @@ +languageId: shellscript +command: + version: 6 + spokenForm: change branch + action: + name: clearAndSetSelection + target: + type: primitive + modifiers: + - type: containingScope + scopeType: {type: branch} + usePrePhraseSnapshot: true +initialState: + documentContents: | + if [ $value -le 0 ]; then + elif [ $value -le 0 ]; then + else + fi + selections: + - anchor: {line: 1, character: 4} + active: {line: 1, character: 4} + marks: {} +finalState: + documentContents: | + if [ $value -le 0 ]; then + + else + fi + selections: + - anchor: {line: 1, character: 0} + active: {line: 1, character: 0} diff --git a/data/fixtures/recorded/languages/shellscript/changeBranch7.yml b/data/fixtures/recorded/languages/shellscript/changeBranch7.yml new file mode 100644 index 0000000000..8225b8c671 --- /dev/null +++ b/data/fixtures/recorded/languages/shellscript/changeBranch7.yml @@ -0,0 +1,45 @@ +languageId: shellscript +command: + version: 6 + spokenForm: change branch + action: + name: clearAndSetSelection + target: + type: primitive + modifiers: + - type: containingScope + scopeType: {type: branch} + usePrePhraseSnapshot: true +initialState: + documentContents: | + # Case statement + case "$number" in + 1) + echo "Number is 1" + ;; + 2) + echo "Number is 2" + ;; + *) + echo "Number is not recognized" + ;; + esac + selections: + - anchor: {line: 4, character: 4} + active: {line: 4, character: 4} + marks: {} +finalState: + documentContents: | + # Case statement + case "$number" in + + 2) + echo "Number is 2" + ;; + *) + echo "Number is not recognized" + ;; + esac + selections: + - anchor: {line: 2, character: 0} + active: {line: 2, character: 0} diff --git a/data/fixtures/recorded/languages/shellscript/changeCall.yml b/data/fixtures/recorded/languages/shellscript/changeCall.yml new file mode 100644 index 0000000000..f669569513 --- /dev/null +++ b/data/fixtures/recorded/languages/shellscript/changeCall.yml @@ -0,0 +1,23 @@ +languageId: shellscript +command: + version: 6 + spokenForm: change call + action: + name: clearAndSetSelection + target: + type: primitive + modifiers: + - type: containingScope + scopeType: {type: functionCall} + usePrePhraseSnapshot: true +initialState: + documentContents: echo "foo" + selections: + - anchor: {line: 0, character: 10} + active: {line: 0, character: 10} + marks: {} +finalState: + documentContents: "" + selections: + - anchor: {line: 0, character: 0} + active: {line: 0, character: 0} diff --git a/data/fixtures/recorded/languages/shellscript/changeCallee.yml b/data/fixtures/recorded/languages/shellscript/changeCallee.yml new file mode 100644 index 0000000000..e2518f8f5c --- /dev/null +++ b/data/fixtures/recorded/languages/shellscript/changeCallee.yml @@ -0,0 +1,23 @@ +languageId: shellscript +command: + version: 6 + spokenForm: change callee + action: + name: clearAndSetSelection + target: + type: primitive + modifiers: + - type: containingScope + scopeType: {type: functionCallee} + usePrePhraseSnapshot: true +initialState: + documentContents: echo "foo" + selections: + - anchor: {line: 0, character: 10} + active: {line: 0, character: 10} + marks: {} +finalState: + documentContents: " \"foo\"" + selections: + - anchor: {line: 0, character: 0} + active: {line: 0, character: 0} diff --git a/data/fixtures/recorded/languages/shellscript/changeCommand.yml b/data/fixtures/recorded/languages/shellscript/changeCommand.yml new file mode 100644 index 0000000000..b1fcd5b055 --- /dev/null +++ b/data/fixtures/recorded/languages/shellscript/changeCommand.yml @@ -0,0 +1,23 @@ +languageId: shellscript +command: + version: 6 + spokenForm: change command + action: + name: clearAndSetSelection + target: + type: primitive + modifiers: + - type: containingScope + scopeType: {type: command} + usePrePhraseSnapshot: true +initialState: + documentContents: ls non_existent_file || echo "File not found" + selections: + - anchor: {line: 0, character: 26} + active: {line: 0, character: 26} + marks: {} +finalState: + documentContents: "ls non_existent_file || " + selections: + - anchor: {line: 0, character: 24} + active: {line: 0, character: 24} diff --git a/data/fixtures/recorded/languages/shellscript/changeComment.yml b/data/fixtures/recorded/languages/shellscript/changeComment.yml new file mode 100644 index 0000000000..c95882fe57 --- /dev/null +++ b/data/fixtures/recorded/languages/shellscript/changeComment.yml @@ -0,0 +1,23 @@ +languageId: shellscript +command: + version: 6 + spokenForm: change comment + action: + name: clearAndSetSelection + target: + type: primitive + modifiers: + - type: containingScope + scopeType: {type: comment} + usePrePhraseSnapshot: true +initialState: + documentContents: "# foo" + selections: + - anchor: {line: 0, character: 5} + active: {line: 0, character: 5} + marks: {} +finalState: + documentContents: "" + selections: + - anchor: {line: 0, character: 0} + active: {line: 0, character: 0} diff --git a/data/fixtures/recorded/languages/shellscript/changeCondition.yml b/data/fixtures/recorded/languages/shellscript/changeCondition.yml new file mode 100644 index 0000000000..cddbd5978e --- /dev/null +++ b/data/fixtures/recorded/languages/shellscript/changeCondition.yml @@ -0,0 +1,33 @@ +languageId: shellscript +command: + version: 6 + spokenForm: change condition + action: + name: clearAndSetSelection + target: + type: primitive + modifiers: + - type: containingScope + scopeType: {type: condition} + usePrePhraseSnapshot: true +initialState: + documentContents: |- + if [ "$number" -eq 42 ]; then + echo "The number is 42" + else + echo "The number is not 42" + fi + selections: + - anchor: {line: 0, character: 8} + active: {line: 0, character: 8} + marks: {} +finalState: + documentContents: |- + if ; then + echo "The number is 42" + else + echo "The number is not 42" + fi + selections: + - anchor: {line: 0, character: 3} + active: {line: 0, character: 3} diff --git a/data/fixtures/recorded/languages/shellscript/changeCondition2.yml b/data/fixtures/recorded/languages/shellscript/changeCondition2.yml new file mode 100644 index 0000000000..c86baf27d8 --- /dev/null +++ b/data/fixtures/recorded/languages/shellscript/changeCondition2.yml @@ -0,0 +1,39 @@ +languageId: shellscript +command: + version: 6 + spokenForm: change condition + action: + name: clearAndSetSelection + target: + type: primitive + modifiers: + - type: containingScope + scopeType: {type: condition} + usePrePhraseSnapshot: true +initialState: + documentContents: | + + if [["$number" -eq 42 ]]; then + echo "number match" + elif [[ $number -lt 20 ]]; then + echo "< 20" + else + echo "No match" + fi + selections: + - anchor: {line: 4, character: 6} + active: {line: 4, character: 6} + marks: {} +finalState: + documentContents: | + + if [["$number" -eq 42 ]]; then + echo "number match" + elif ; then + echo "< 20" + else + echo "No match" + fi + selections: + - anchor: {line: 3, character: 5} + active: {line: 3, character: 5} diff --git a/data/fixtures/recorded/languages/shellscript/changeCondition3.yml b/data/fixtures/recorded/languages/shellscript/changeCondition3.yml new file mode 100644 index 0000000000..11880bdc83 --- /dev/null +++ b/data/fixtures/recorded/languages/shellscript/changeCondition3.yml @@ -0,0 +1,47 @@ +languageId: shellscript +command: + version: 6 + spokenForm: change condition + action: + name: clearAndSetSelection + target: + type: primitive + modifiers: + - type: containingScope + scopeType: {type: condition} + usePrePhraseSnapshot: true +initialState: + documentContents: | + # Case statement + case "$number" in + 1) + echo "Number is 1" + ;; + 2) + echo "Number is 2" + ;; + *) + echo "Number is not recognized" + ;; + esac + selections: + - anchor: {line: 3, character: 9} + active: {line: 3, character: 9} + marks: {} +finalState: + documentContents: | + # Case statement + case "$number" in + ) + echo "Number is 1" + ;; + 2) + echo "Number is 2" + ;; + *) + echo "Number is not recognized" + ;; + esac + selections: + - anchor: {line: 2, character: 0} + active: {line: 2, character: 0} diff --git a/data/fixtures/recorded/languages/shellscript/changeConditionEach.yml b/data/fixtures/recorded/languages/shellscript/changeConditionEach.yml new file mode 100644 index 0000000000..dfbdf5cb14 --- /dev/null +++ b/data/fixtures/recorded/languages/shellscript/changeConditionEach.yml @@ -0,0 +1,37 @@ +languageId: shellscript +command: + version: 6 + spokenForm: change condition each + action: + name: clearAndSetSelection + target: + type: primitive + mark: {type: decoratedSymbol, symbolColor: default, character: e} + modifiers: + - type: containingScope + scopeType: {type: condition} + usePrePhraseSnapshot: true +initialState: + documentContents: |- + until [ $counter -gt 5 ] + do + echo "Iteration: $counter" + ((counter++)) + done + selections: + - anchor: {line: 4, character: 4} + active: {line: 4, character: 4} + marks: + default.e: + start: {line: 0, character: 9} + end: {line: 0, character: 16} +finalState: + documentContents: |- + until + do + echo "Iteration: $counter" + ((counter++)) + done + selections: + - anchor: {line: 0, character: 6} + active: {line: 0, character: 6} diff --git a/data/fixtures/recorded/languages/shellscript/changeConditionFive.yml b/data/fixtures/recorded/languages/shellscript/changeConditionFive.yml new file mode 100644 index 0000000000..36444036f6 --- /dev/null +++ b/data/fixtures/recorded/languages/shellscript/changeConditionFive.yml @@ -0,0 +1,35 @@ +languageId: shellscript +command: + version: 6 + spokenForm: change condition five + action: + name: clearAndSetSelection + target: + type: primitive + mark: {type: decoratedSymbol, symbolColor: default, character: '5'} + modifiers: + - type: containingScope + scopeType: {type: condition} + usePrePhraseSnapshot: true +initialState: + documentContents: |2 + # C-style for loop + for ((i = 1; i <= 5; i++)); do + echo "C-style loop iteration: $i" + done + selections: + - anchor: {line: 1, character: 19} + active: {line: 1, character: 19} + marks: + default.5: + start: {line: 1, character: 20} + end: {line: 1, character: 21} +finalState: + documentContents: |2 + # C-style for loop + for ((i = 1; ; i++)); do + echo "C-style loop iteration: $i" + done + selections: + - anchor: {line: 1, character: 15} + active: {line: 1, character: 15} diff --git a/data/fixtures/recorded/languages/shellscript/changeEveryArg.yml b/data/fixtures/recorded/languages/shellscript/changeEveryArg.yml new file mode 100644 index 0000000000..edefcf2efb --- /dev/null +++ b/data/fixtures/recorded/languages/shellscript/changeEveryArg.yml @@ -0,0 +1,27 @@ +languageId: shellscript +command: + version: 6 + spokenForm: change every arg + action: + name: clearAndSetSelection + target: + type: primitive + modifiers: + - type: everyScope + scopeType: {type: argumentOrParameter} + usePrePhraseSnapshot: true +initialState: + documentContents: echo a b c + selections: + - anchor: {line: 0, character: 10} + active: {line: 0, character: 10} + marks: {} +finalState: + documentContents: "echo " + selections: + - anchor: {line: 0, character: 5} + active: {line: 0, character: 5} + - anchor: {line: 0, character: 6} + active: {line: 0, character: 6} + - anchor: {line: 0, character: 7} + active: {line: 0, character: 7} diff --git a/data/fixtures/recorded/languages/shellscript/changeEveryArgInsideFine.yml b/data/fixtures/recorded/languages/shellscript/changeEveryArgInsideFine.yml new file mode 100644 index 0000000000..1123e85397 --- /dev/null +++ b/data/fixtures/recorded/languages/shellscript/changeEveryArgInsideFine.yml @@ -0,0 +1,32 @@ +languageId: shellscript +command: + version: 6 + spokenForm: change every arg inside fine + action: + name: clearAndSetSelection + target: + type: primitive + mark: {type: decoratedSymbol, symbolColor: default, character: f} + modifiers: + - type: everyScope + scopeType: {type: argumentOrParameter} + - {type: interiorOnly} + usePrePhraseSnapshot: true +initialState: + documentContents: | + echo "Foo ${BAR} as ${BAZ}" + selections: + - anchor: {line: 0, character: 19} + active: {line: 0, character: 19} + marks: + default.f: + start: {line: 0, character: 6} + end: {line: 0, character: 9} +finalState: + documentContents: | + echo "Foo as " + selections: + - anchor: {line: 0, character: 10} + active: {line: 0, character: 10} + - anchor: {line: 0, character: 14} + active: {line: 0, character: 14} diff --git a/data/fixtures/recorded/languages/shellscript/changeEveryArgInsideFine2.yml b/data/fixtures/recorded/languages/shellscript/changeEveryArgInsideFine2.yml new file mode 100644 index 0000000000..a81c48d13a --- /dev/null +++ b/data/fixtures/recorded/languages/shellscript/changeEveryArgInsideFine2.yml @@ -0,0 +1,32 @@ +languageId: shellscript +command: + version: 6 + spokenForm: change every arg inside fine + action: + name: clearAndSetSelection + target: + type: primitive + mark: {type: decoratedSymbol, symbolColor: default, character: f} + modifiers: + - type: everyScope + scopeType: {type: argumentOrParameter} + - {type: interiorOnly} + usePrePhraseSnapshot: true +initialState: + documentContents: | + echo "Foo $BAR as $BAZ" + selections: + - anchor: {line: 0, character: 9} + active: {line: 0, character: 9} + marks: + default.f: + start: {line: 0, character: 6} + end: {line: 0, character: 9} +finalState: + documentContents: | + echo "Foo as " + selections: + - anchor: {line: 0, character: 10} + active: {line: 0, character: 10} + - anchor: {line: 0, character: 14} + active: {line: 0, character: 14} diff --git a/data/fixtures/recorded/languages/shellscript/changeEveryArgInsideTrap.yml b/data/fixtures/recorded/languages/shellscript/changeEveryArgInsideTrap.yml new file mode 100644 index 0000000000..c29a2eb9f5 --- /dev/null +++ b/data/fixtures/recorded/languages/shellscript/changeEveryArgInsideTrap.yml @@ -0,0 +1,32 @@ +languageId: shellscript +command: + version: 6 + spokenForm: change every arg inside trap + action: + name: clearAndSetSelection + target: + type: primitive + mark: {type: decoratedSymbol, symbolColor: default, character: t} + modifiers: + - type: everyScope + scopeType: {type: argumentOrParameter} + - {type: interiorOnly} + usePrePhraseSnapshot: true +initialState: + documentContents: | + echo "Test ${foo} ${bar}" + selections: + - anchor: {line: 0, character: 13} + active: {line: 0, character: 13} + marks: + default.t: + start: {line: 0, character: 6} + end: {line: 0, character: 10} +finalState: + documentContents: | + echo "Test " + selections: + - anchor: {line: 0, character: 11} + active: {line: 0, character: 11} + - anchor: {line: 0, character: 12} + active: {line: 0, character: 12} diff --git a/data/fixtures/recorded/languages/shellscript/changeEveryArgInsideTrap2.yml b/data/fixtures/recorded/languages/shellscript/changeEveryArgInsideTrap2.yml new file mode 100644 index 0000000000..d9945e986a --- /dev/null +++ b/data/fixtures/recorded/languages/shellscript/changeEveryArgInsideTrap2.yml @@ -0,0 +1,32 @@ +languageId: shellscript +command: + version: 6 + spokenForm: change every arg inside trap + action: + name: clearAndSetSelection + target: + type: primitive + mark: {type: decoratedSymbol, symbolColor: default, character: t} + modifiers: + - type: everyScope + scopeType: {type: argumentOrParameter} + - {type: interiorOnly} + usePrePhraseSnapshot: true +initialState: + documentContents: | + echo "Test $foo $bar" + selections: + - anchor: {line: 0, character: 14} + active: {line: 0, character: 14} + marks: + default.t: + start: {line: 0, character: 6} + end: {line: 0, character: 10} +finalState: + documentContents: | + echo "Test " + selections: + - anchor: {line: 0, character: 11} + active: {line: 0, character: 11} + - anchor: {line: 0, character: 12} + active: {line: 0, character: 12} diff --git a/data/fixtures/recorded/languages/shellscript/changeEveryBranch.yml b/data/fixtures/recorded/languages/shellscript/changeEveryBranch.yml new file mode 100644 index 0000000000..389567ccea --- /dev/null +++ b/data/fixtures/recorded/languages/shellscript/changeEveryBranch.yml @@ -0,0 +1,35 @@ +languageId: shellscript +command: + version: 6 + spokenForm: change every branch + action: + name: clearAndSetSelection + target: + type: primitive + modifiers: + - type: everyScope + scopeType: {type: branch} + usePrePhraseSnapshot: true +initialState: + documentContents: | + if [ $value -le 0 ]; then + elif [ $value -le 0 ]; then + else + fi + selections: + - anchor: {line: 1, character: 4} + active: {line: 1, character: 4} + marks: {} +finalState: + documentContents: | + + + + fi + selections: + - anchor: {line: 0, character: 0} + active: {line: 0, character: 0} + - anchor: {line: 1, character: 0} + active: {line: 1, character: 0} + - anchor: {line: 2, character: 0} + active: {line: 2, character: 0} diff --git a/data/fixtures/recorded/languages/shellscript/changeEveryItem.yml b/data/fixtures/recorded/languages/shellscript/changeEveryItem.yml new file mode 100644 index 0000000000..f6d40ec02f --- /dev/null +++ b/data/fixtures/recorded/languages/shellscript/changeEveryItem.yml @@ -0,0 +1,29 @@ +languageId: shellscript +command: + version: 6 + spokenForm: change every item + action: + name: clearAndSetSelection + target: + type: primitive + modifiers: + - type: everyScope + scopeType: {type: collectionItem} + usePrePhraseSnapshot: true +initialState: + documentContents: | + array=("apple" "banana" "cherry") + selections: + - anchor: {line: 0, character: 9} + active: {line: 0, character: 9} + marks: {} +finalState: + documentContents: | + array=( ) + selections: + - anchor: {line: 0, character: 7} + active: {line: 0, character: 7} + - anchor: {line: 0, character: 8} + active: {line: 0, character: 8} + - anchor: {line: 0, character: 9} + active: {line: 0, character: 9} diff --git a/data/fixtures/recorded/languages/shellscript/changeFunk.yml b/data/fixtures/recorded/languages/shellscript/changeFunk.yml new file mode 100644 index 0000000000..3a9da4ccb7 --- /dev/null +++ b/data/fixtures/recorded/languages/shellscript/changeFunk.yml @@ -0,0 +1,26 @@ +languageId: shellscript +command: + version: 6 + spokenForm: change funk + action: + name: clearAndSetSelection + target: + type: primitive + modifiers: + - type: containingScope + scopeType: {type: namedFunction} + usePrePhraseSnapshot: true +initialState: + documentContents: |- + function foo() { + echo "foo" + } + selections: + - anchor: {line: 0, character: 7} + active: {line: 0, character: 7} + marks: {} +finalState: + documentContents: "" + selections: + - anchor: {line: 0, character: 0} + active: {line: 0, character: 0} diff --git a/data/fixtures/recorded/languages/shellscript/changeFunkName.yml b/data/fixtures/recorded/languages/shellscript/changeFunkName.yml new file mode 100644 index 0000000000..9adeb34434 --- /dev/null +++ b/data/fixtures/recorded/languages/shellscript/changeFunkName.yml @@ -0,0 +1,29 @@ +languageId: shellscript +command: + version: 6 + spokenForm: change funk name + action: + name: clearAndSetSelection + target: + type: primitive + modifiers: + - type: containingScope + scopeType: {type: functionName} + usePrePhraseSnapshot: true +initialState: + documentContents: |- + function foo() { + echo "foo" + } + selections: + - anchor: {line: 1, character: 5} + active: {line: 1, character: 5} + marks: {} +finalState: + documentContents: |- + function () { + echo "foo" + } + selections: + - anchor: {line: 0, character: 9} + active: {line: 0, character: 9} diff --git a/data/fixtures/recorded/languages/shellscript/changeIfState.yml b/data/fixtures/recorded/languages/shellscript/changeIfState.yml new file mode 100644 index 0000000000..a328ac933f --- /dev/null +++ b/data/fixtures/recorded/languages/shellscript/changeIfState.yml @@ -0,0 +1,28 @@ +languageId: shellscript +command: + version: 6 + spokenForm: change if state + action: + name: clearAndSetSelection + target: + type: primitive + modifiers: + - type: containingScope + scopeType: {type: ifStatement} + usePrePhraseSnapshot: true +initialState: + documentContents: |- + if [ "$number" -eq 42 ]; then + echo "The number is 42" + else + echo "The number is not 42" + fi + selections: + - anchor: {line: 3, character: 8} + active: {line: 3, character: 8} + marks: {} +finalState: + documentContents: "" + selections: + - anchor: {line: 0, character: 0} + active: {line: 0, character: 0} diff --git a/data/fixtures/recorded/languages/shellscript/changeInside.yml b/data/fixtures/recorded/languages/shellscript/changeInside.yml new file mode 100644 index 0000000000..c3353063d0 --- /dev/null +++ b/data/fixtures/recorded/languages/shellscript/changeInside.yml @@ -0,0 +1,22 @@ +languageId: shellscript +command: + version: 6 + spokenForm: change inside + action: + name: clearAndSetSelection + target: + type: primitive + modifiers: + - {type: interiorOnly} + usePrePhraseSnapshot: true +initialState: + documentContents: var="fo(o)" + selections: + - anchor: {line: 0, character: 9} + active: {line: 0, character: 9} + marks: {} +finalState: + documentContents: var="fo()" + selections: + - anchor: {line: 0, character: 8} + active: {line: 0, character: 8} diff --git a/data/fixtures/recorded/languages/shellscript/changeInside2.yml b/data/fixtures/recorded/languages/shellscript/changeInside2.yml new file mode 100644 index 0000000000..88b884dedf --- /dev/null +++ b/data/fixtures/recorded/languages/shellscript/changeInside2.yml @@ -0,0 +1,22 @@ +languageId: shellscript +command: + version: 6 + spokenForm: change inside + action: + name: clearAndSetSelection + target: + type: primitive + modifiers: + - {type: interiorOnly} + usePrePhraseSnapshot: true +initialState: + documentContents: "# fo(o)" + selections: + - anchor: {line: 0, character: 5} + active: {line: 0, character: 5} + marks: {} +finalState: + documentContents: "# fo()" + selections: + - anchor: {line: 0, character: 5} + active: {line: 0, character: 5} diff --git a/data/fixtures/recorded/languages/shellscript/changeInsideBranch.yml b/data/fixtures/recorded/languages/shellscript/changeInsideBranch.yml new file mode 100644 index 0000000000..562e179da2 --- /dev/null +++ b/data/fixtures/recorded/languages/shellscript/changeInsideBranch.yml @@ -0,0 +1,34 @@ +languageId: shellscript +command: + version: 6 + spokenForm: change inside branch + action: + name: clearAndSetSelection + target: + type: primitive + modifiers: + - {type: interiorOnly} + - type: containingScope + scopeType: {type: branch} + usePrePhraseSnapshot: true +initialState: + documentContents: |- + if [ "$number" -eq 42 ]; then + echo "The number is 42" + else + echo "The number is not 42" + fi + selections: + - anchor: {line: 3, character: 10} + active: {line: 3, character: 10} + marks: {} +finalState: + documentContents: |- + if [ "$number" -eq 42 ]; then + echo "The number is 42" + else + + fi + selections: + - anchor: {line: 3, character: 4} + active: {line: 3, character: 4} diff --git a/data/fixtures/recorded/languages/shellscript/changeInsideBranch2.yml b/data/fixtures/recorded/languages/shellscript/changeInsideBranch2.yml new file mode 100644 index 0000000000..5b10df8e3b --- /dev/null +++ b/data/fixtures/recorded/languages/shellscript/changeInsideBranch2.yml @@ -0,0 +1,38 @@ +languageId: shellscript +command: + version: 6 + spokenForm: change inside branch + action: + name: clearAndSetSelection + target: + type: primitive + modifiers: + - {type: interiorOnly} + - type: containingScope + scopeType: {type: branch} + usePrePhraseSnapshot: true +initialState: + documentContents: |- + if [ "$number" -eq 42 ]; then + echo "The number is 42" + elif [ "$number" -gt 42 ]; then + echo "The number is greater than 42" + else + echo "The number is less than than 42" + fi + selections: + - anchor: {line: 3, character: 16} + active: {line: 3, character: 16} + marks: {} +finalState: + documentContents: |- + if [ "$number" -eq 42 ]; then + echo "The number is 42" + elif [ "$number" -gt 42 ]; then + + else + echo "The number is less than than 42" + fi + selections: + - anchor: {line: 3, character: 4} + active: {line: 3, character: 4} diff --git a/data/fixtures/recorded/languages/shellscript/changeInsideBranch3.yml b/data/fixtures/recorded/languages/shellscript/changeInsideBranch3.yml new file mode 100644 index 0000000000..3a1eaa76f8 --- /dev/null +++ b/data/fixtures/recorded/languages/shellscript/changeInsideBranch3.yml @@ -0,0 +1,33 @@ +languageId: shellscript +command: + version: 6 + spokenForm: change inside branch + action: + name: clearAndSetSelection + target: + type: primitive + modifiers: + - {type: interiorOnly} + - type: containingScope + scopeType: {type: branch} + usePrePhraseSnapshot: true +initialState: + documentContents: |+ + if [ $value -le 0 ]; then + echo "foo1" + echo "foo1" + fi + + selections: + - anchor: {line: 1, character: 15} + active: {line: 1, character: 15} + marks: {} +finalState: + documentContents: |+ + if [ $value -le 0 ]; then + + fi + + selections: + - anchor: {line: 1, character: 4} + active: {line: 1, character: 4} diff --git a/data/fixtures/recorded/languages/shellscript/changeInsideBranch4.yml b/data/fixtures/recorded/languages/shellscript/changeInsideBranch4.yml new file mode 100644 index 0000000000..ec6299e434 --- /dev/null +++ b/data/fixtures/recorded/languages/shellscript/changeInsideBranch4.yml @@ -0,0 +1,43 @@ +languageId: shellscript +command: + version: 6 + spokenForm: change inside branch + action: + name: clearAndSetSelection + target: + type: primitive + modifiers: + - {type: interiorOnly} + - type: containingScope + scopeType: {type: branch} + usePrePhraseSnapshot: true +initialState: + documentContents: |+ + if [ $value -le 0 ]; then + echo "foo1" + echo "foo1" + else + echo "foo1" + echo "foo1" + fi + + + + selections: + - anchor: {line: 4, character: 9} + active: {line: 4, character: 9} + marks: {} +finalState: + documentContents: |+ + if [ $value -le 0 ]; then + echo "foo1" + echo "foo1" + else + + fi + + + + selections: + - anchor: {line: 4, character: 4} + active: {line: 4, character: 4} diff --git a/data/fixtures/recorded/languages/shellscript/changeInsideBranch5.yml b/data/fixtures/recorded/languages/shellscript/changeInsideBranch5.yml new file mode 100644 index 0000000000..89bb109fb1 --- /dev/null +++ b/data/fixtures/recorded/languages/shellscript/changeInsideBranch5.yml @@ -0,0 +1,42 @@ +languageId: shellscript +command: + version: 6 + spokenForm: change inside branch + action: + name: clearAndSetSelection + target: + type: primitive + modifiers: + - {type: interiorOnly} + - type: containingScope + scopeType: {type: branch} + usePrePhraseSnapshot: true +initialState: + documentContents: |+ + if [ $value -le 0 ]; then + echo "foo1" + echo "foo1" + else + echo "foo1" + fi + + + + selections: + - anchor: {line: 4, character: 4} + active: {line: 4, character: 4} + marks: {} +finalState: + documentContents: |+ + if [ $value -le 0 ]; then + echo "foo1" + echo "foo1" + else + + fi + + + + selections: + - anchor: {line: 4, character: 4} + active: {line: 4, character: 4} diff --git a/data/fixtures/recorded/languages/shellscript/changeInsideBranch6.yml b/data/fixtures/recorded/languages/shellscript/changeInsideBranch6.yml new file mode 100644 index 0000000000..aabefdf6cc --- /dev/null +++ b/data/fixtures/recorded/languages/shellscript/changeInsideBranch6.yml @@ -0,0 +1,45 @@ +languageId: shellscript +command: + version: 6 + spokenForm: change inside branch + action: + name: clearAndSetSelection + target: + type: primitive + modifiers: + - {type: interiorOnly} + - type: containingScope + scopeType: {type: branch} + usePrePhraseSnapshot: true +initialState: + documentContents: |+ + if [ $value -le 0 ]; then + echo "foo1" + echo "foo1" + elif [ $value -le 0 ]; then + echo "foo1" + echo "foo1" + else + echo "foo1" + echo "foo1" + fi + + selections: + - anchor: {line: 8, character: 3} + active: {line: 8, character: 3} + marks: {} +finalState: + documentContents: |+ + if [ $value -le 0 ]; then + echo "foo1" + echo "foo1" + elif [ $value -le 0 ]; then + echo "foo1" + echo "foo1" + else + + fi + + selections: + - anchor: {line: 7, character: 4} + active: {line: 7, character: 4} diff --git a/data/fixtures/recorded/languages/shellscript/changeInsideBranch7.yml b/data/fixtures/recorded/languages/shellscript/changeInsideBranch7.yml new file mode 100644 index 0000000000..eeec2cf349 --- /dev/null +++ b/data/fixtures/recorded/languages/shellscript/changeInsideBranch7.yml @@ -0,0 +1,44 @@ +languageId: shellscript +command: + version: 6 + spokenForm: change inside branch + action: + name: clearAndSetSelection + target: + type: primitive + modifiers: + - {type: interiorOnly} + - type: containingScope + scopeType: {type: branch} + usePrePhraseSnapshot: true +initialState: + documentContents: |+ + if [ $value -le 0 ]; then + echo "foo1" + echo "foo1" + elif [ $value -le 0 ]; then + echo "foo1" + echo "foo1" + else + echo "foo1" + fi + + selections: + - anchor: {line: 7, character: 0} + active: {line: 7, character: 0} + marks: {} +finalState: + documentContents: |+ + if [ $value -le 0 ]; then + echo "foo1" + echo "foo1" + elif [ $value -le 0 ]; then + echo "foo1" + echo "foo1" + else + + fi + + selections: + - anchor: {line: 7, character: 4} + active: {line: 7, character: 4} diff --git a/data/fixtures/recorded/languages/shellscript/changeInsideBranch8.yml b/data/fixtures/recorded/languages/shellscript/changeInsideBranch8.yml new file mode 100644 index 0000000000..9ee82ccc9f --- /dev/null +++ b/data/fixtures/recorded/languages/shellscript/changeInsideBranch8.yml @@ -0,0 +1,48 @@ +languageId: shellscript +command: + version: 6 + spokenForm: change inside branch + action: + name: clearAndSetSelection + target: + type: primitive + modifiers: + - {type: interiorOnly} + - type: containingScope + scopeType: {type: branch} + usePrePhraseSnapshot: true +initialState: + documentContents: | + # Case statement + case "$number" in + 1) + echo "Number is 1" + ;; + 2) + echo "Number is 2" + ;; + *) + echo "Number is not recognized" + ;; + esac + selections: + - anchor: {line: 6, character: 2} + active: {line: 6, character: 20} + marks: {} +finalState: + documentContents: | + # Case statement + case "$number" in + 1) + echo "Number is 1" + ;; + 2) + + ;; + *) + echo "Number is not recognized" + ;; + esac + selections: + - anchor: {line: 6, character: 2} + active: {line: 6, character: 2} diff --git a/data/fixtures/recorded/languages/shellscript/changeInsideEveryBranch.yml b/data/fixtures/recorded/languages/shellscript/changeInsideEveryBranch.yml new file mode 100644 index 0000000000..ee01fe954c --- /dev/null +++ b/data/fixtures/recorded/languages/shellscript/changeInsideEveryBranch.yml @@ -0,0 +1,43 @@ +languageId: shellscript +command: + version: 6 + spokenForm: change inside every branch + action: + name: clearAndSetSelection + target: + type: primitive + modifiers: + - {type: interiorOnly} + - type: everyScope + scopeType: {type: branch} + usePrePhraseSnapshot: true +initialState: + documentContents: |+ + if [ $value -le 0 ]; then + echo "foo1" + echo "foo1" + else + echo "foo1" + fi + + + + selections: + - anchor: {line: 4, character: 4} + active: {line: 4, character: 4} + marks: {} +finalState: + documentContents: |+ + if [ $value -le 0 ]; then + + else + + fi + + + + selections: + - anchor: {line: 1, character: 4} + active: {line: 1, character: 4} + - anchor: {line: 3, character: 4} + active: {line: 3, character: 4} diff --git a/data/fixtures/recorded/languages/shellscript/changeInsideEveryBranch2.yml b/data/fixtures/recorded/languages/shellscript/changeInsideEveryBranch2.yml new file mode 100644 index 0000000000..9a06c07ac8 --- /dev/null +++ b/data/fixtures/recorded/languages/shellscript/changeInsideEveryBranch2.yml @@ -0,0 +1,47 @@ +languageId: shellscript +command: + version: 6 + spokenForm: change inside every branch + action: + name: clearAndSetSelection + target: + type: primitive + modifiers: + - {type: interiorOnly} + - type: everyScope + scopeType: {type: branch} + usePrePhraseSnapshot: true +initialState: + documentContents: |+ + if [ $value -le 0 ]; then + echo "foo1" + echo "foo1" + elif [ $value -le 0 ]; then + echo "foo1" + echo "foo1" + else + echo "foo1" + echo "foo1" + fi + + selections: + - anchor: {line: 8, character: 3} + active: {line: 8, character: 3} + marks: {} +finalState: + documentContents: |+ + if [ $value -le 0 ]; then + + elif [ $value -le 0 ]; then + + else + + fi + + selections: + - anchor: {line: 1, character: 4} + active: {line: 1, character: 4} + - anchor: {line: 3, character: 4} + active: {line: 3, character: 4} + - anchor: {line: 5, character: 4} + active: {line: 5, character: 4} diff --git a/data/fixtures/recorded/languages/shellscript/changeInsideEveryBranch3.yml b/data/fixtures/recorded/languages/shellscript/changeInsideEveryBranch3.yml new file mode 100644 index 0000000000..8295f3a98b --- /dev/null +++ b/data/fixtures/recorded/languages/shellscript/changeInsideEveryBranch3.yml @@ -0,0 +1,52 @@ +languageId: shellscript +command: + version: 6 + spokenForm: change inside every branch + action: + name: clearAndSetSelection + target: + type: primitive + modifiers: + - {type: interiorOnly} + - type: everyScope + scopeType: {type: branch} + usePrePhraseSnapshot: true +initialState: + documentContents: | + # Case statement + case "$number" in + 1) + echo "Number is 1" + ;; + 2) + echo "Number is 2" + ;; + *) + echo "Number is not recognized" + ;; + esac + selections: + - anchor: {line: 3, character: 9} + active: {line: 3, character: 9} + marks: {} +finalState: + documentContents: | + # Case statement + case "$number" in + 1) + + ;; + 2) + + ;; + *) + + ;; + esac + selections: + - anchor: {line: 3, character: 2} + active: {line: 3, character: 2} + - anchor: {line: 6, character: 2} + active: {line: 6, character: 2} + - anchor: {line: 9, character: 2} + active: {line: 9, character: 2} diff --git a/data/fixtures/recorded/languages/shellscript/changeInsideFirstBranch.yml b/data/fixtures/recorded/languages/shellscript/changeInsideFirstBranch.yml new file mode 100644 index 0000000000..747b3b902b --- /dev/null +++ b/data/fixtures/recorded/languages/shellscript/changeInsideFirstBranch.yml @@ -0,0 +1,36 @@ +languageId: shellscript +command: + version: 6 + spokenForm: change inside first branch + action: + name: clearAndSetSelection + target: + type: primitive + modifiers: + - {type: interiorOnly} + - type: ordinalScope + scopeType: {type: branch} + start: 0 + length: 1 + usePrePhraseSnapshot: true +initialState: + documentContents: | + if [ "$number" -eq 42 ]; then + echo "The number is 42" + else + echo "The number is not 42" + fi + selections: + - anchor: {line: 3, character: 2} + active: {line: 3, character: 2} + marks: {} +finalState: + documentContents: | + if [ "$number" -eq 42 ]; then + + else + echo "The number is not 42" + fi + selections: + - anchor: {line: 1, character: 4} + active: {line: 1, character: 4} diff --git a/data/fixtures/recorded/languages/shellscript/changeInsideFunk.yml b/data/fixtures/recorded/languages/shellscript/changeInsideFunk.yml new file mode 100644 index 0000000000..a5756df267 --- /dev/null +++ b/data/fixtures/recorded/languages/shellscript/changeInsideFunk.yml @@ -0,0 +1,30 @@ +languageId: shellscript +command: + version: 6 + spokenForm: change inside funk + action: + name: clearAndSetSelection + target: + type: primitive + modifiers: + - {type: interiorOnly} + - type: containingScope + scopeType: {type: namedFunction} + usePrePhraseSnapshot: true +initialState: + documentContents: |- + function foo() { + echo "foo" + } + selections: + - anchor: {line: 1, character: 8} + active: {line: 1, character: 8} + marks: {} +finalState: + documentContents: |- + function foo() { + + } + selections: + - anchor: {line: 1, character: 4} + active: {line: 1, character: 4} diff --git a/data/fixtures/recorded/languages/shellscript/changeInsideList.yml b/data/fixtures/recorded/languages/shellscript/changeInsideList.yml new file mode 100644 index 0000000000..47c5241bc7 --- /dev/null +++ b/data/fixtures/recorded/languages/shellscript/changeInsideList.yml @@ -0,0 +1,24 @@ +languageId: shellscript +command: + version: 6 + spokenForm: change inside list + action: + name: clearAndSetSelection + target: + type: primitive + modifiers: + - {type: interiorOnly} + - type: containingScope + scopeType: {type: list} + usePrePhraseSnapshot: true +initialState: + documentContents: array=("a" "b" "c") + selections: + - anchor: {line: 0, character: 13} + active: {line: 0, character: 13} + marks: {} +finalState: + documentContents: array=() + selections: + - anchor: {line: 0, character: 7} + active: {line: 0, character: 7} diff --git a/data/fixtures/recorded/languages/shellscript/changeKeyCrunch.yml b/data/fixtures/recorded/languages/shellscript/changeKeyCrunch.yml new file mode 100644 index 0000000000..2696735c94 --- /dev/null +++ b/data/fixtures/recorded/languages/shellscript/changeKeyCrunch.yml @@ -0,0 +1,33 @@ +languageId: shellscript +command: + version: 6 + spokenForm: change key crunch + action: + name: clearAndSetSelection + target: + type: primitive + mark: {type: decoratedSymbol, symbolColor: default, character: k} + modifiers: + - type: containingScope + scopeType: {type: collectionKey} + usePrePhraseSnapshot: true +initialState: + documentContents: |- + declare -A arr + arr["key1"]=val1 + arr+=([key2]=val2 ["key3"]=val3) + selections: + - anchor: {line: 2, character: 17} + active: {line: 2, character: 17} + marks: + default.k: + start: {line: 2, character: 7} + end: {line: 2, character: 11} +finalState: + documentContents: |- + declare -A arr + arr["key1"]=val1 + arr+=([]=val2 ["key3"]=val3) + selections: + - anchor: {line: 2, character: 7} + active: {line: 2, character: 7} diff --git a/data/fixtures/recorded/languages/shellscript/changeList.yml b/data/fixtures/recorded/languages/shellscript/changeList.yml new file mode 100644 index 0000000000..62881938cc --- /dev/null +++ b/data/fixtures/recorded/languages/shellscript/changeList.yml @@ -0,0 +1,23 @@ +languageId: shellscript +command: + version: 6 + spokenForm: change list + action: + name: clearAndSetSelection + target: + type: primitive + modifiers: + - type: containingScope + scopeType: {type: list} + usePrePhraseSnapshot: true +initialState: + documentContents: array=("a" "b" "c") + selections: + - anchor: {line: 0, character: 13} + active: {line: 0, character: 13} + marks: {} +finalState: + documentContents: array= + selections: + - anchor: {line: 0, character: 6} + active: {line: 0, character: 6} diff --git a/data/fixtures/recorded/languages/shellscript/changeName.yml b/data/fixtures/recorded/languages/shellscript/changeName.yml new file mode 100644 index 0000000000..c4c036b27d --- /dev/null +++ b/data/fixtures/recorded/languages/shellscript/changeName.yml @@ -0,0 +1,23 @@ +languageId: shellscript +command: + version: 6 + spokenForm: change name + action: + name: clearAndSetSelection + target: + type: primitive + modifiers: + - type: containingScope + scopeType: {type: name} + usePrePhraseSnapshot: true +initialState: + documentContents: foo="bar" + selections: + - anchor: {line: 0, character: 9} + active: {line: 0, character: 9} + marks: {} +finalState: + documentContents: "=\"bar\"" + selections: + - anchor: {line: 0, character: 0} + active: {line: 0, character: 0} diff --git a/data/fixtures/recorded/languages/shellscript/changeName2.yml b/data/fixtures/recorded/languages/shellscript/changeName2.yml new file mode 100644 index 0000000000..61cb56765a --- /dev/null +++ b/data/fixtures/recorded/languages/shellscript/changeName2.yml @@ -0,0 +1,27 @@ +languageId: shellscript +command: + version: 6 + spokenForm: change name + action: + name: clearAndSetSelection + target: + type: primitive + modifiers: + - type: containingScope + scopeType: {type: name} + usePrePhraseSnapshot: true +initialState: + documentContents: |+ + local local_var="Local Variable" + + selections: + - anchor: {line: 0, character: 18} + active: {line: 0, character: 18} + marks: {} +finalState: + documentContents: |+ + local ="Local Variable" + + selections: + - anchor: {line: 0, character: 6} + active: {line: 0, character: 6} diff --git a/data/fixtures/recorded/languages/shellscript/changeName3.yml b/data/fixtures/recorded/languages/shellscript/changeName3.yml new file mode 100644 index 0000000000..fdafe523ad --- /dev/null +++ b/data/fixtures/recorded/languages/shellscript/changeName3.yml @@ -0,0 +1,29 @@ +languageId: shellscript +command: + version: 6 + spokenForm: change name + action: + name: clearAndSetSelection + target: + type: primitive + modifiers: + - type: containingScope + scopeType: {type: name} + usePrePhraseSnapshot: true +initialState: + documentContents: |- + for ((i = 1; i <= 5; i++)); do + echo "C-style loop iteration: $i" + done + selections: + - anchor: {line: 0, character: 8} + active: {line: 0, character: 8} + marks: {} +finalState: + documentContents: |- + for (( = 1; i <= 5; i++)); do + echo "C-style loop iteration: $i" + done + selections: + - anchor: {line: 0, character: 6} + active: {line: 0, character: 6} diff --git a/data/fixtures/recorded/languages/shellscript/changeRegexZero.yml b/data/fixtures/recorded/languages/shellscript/changeRegexZero.yml new file mode 100644 index 0000000000..ddf64e8a34 --- /dev/null +++ b/data/fixtures/recorded/languages/shellscript/changeRegexZero.yml @@ -0,0 +1,41 @@ +languageId: shellscript +command: + version: 6 + spokenForm: change regex zero + action: + name: clearAndSetSelection + target: + type: primitive + mark: {type: decoratedSymbol, symbolColor: default, character: '0'} + modifiers: + - type: containingScope + scopeType: {type: regularExpression} + usePrePhraseSnapshot: true +initialState: + documentContents: |+ + + string="The date is 2023-01-01." + if [[ $string =~ ([0-9]{4}-[0-9]{2}-[0-9]{2}) ]]; then + matched_date="${BASH_REMATCH[1]}" + echo "Matched date: $matched_date" + fi + + selections: + - anchor: {line: 2, character: 5} + active: {line: 2, character: 5} + marks: + default.0: + start: {line: 2, character: 19} + end: {line: 2, character: 22} +finalState: + documentContents: |+ + + string="The date is 2023-01-01." + if [[ $string =~ ]]; then + matched_date="${BASH_REMATCH[1]}" + echo "Matched date: $matched_date" + fi + + selections: + - anchor: {line: 2, character: 17} + active: {line: 2, character: 17} diff --git a/data/fixtures/recorded/languages/shellscript/changeState.yml b/data/fixtures/recorded/languages/shellscript/changeState.yml new file mode 100644 index 0000000000..11e006bc7a --- /dev/null +++ b/data/fixtures/recorded/languages/shellscript/changeState.yml @@ -0,0 +1,23 @@ +languageId: shellscript +command: + version: 6 + spokenForm: change state + action: + name: clearAndSetSelection + target: + type: primitive + modifiers: + - type: containingScope + scopeType: {type: statement} + usePrePhraseSnapshot: true +initialState: + documentContents: var="foo" + selections: + - anchor: {line: 0, character: 2} + active: {line: 0, character: 2} + marks: {} +finalState: + documentContents: "" + selections: + - anchor: {line: 0, character: 0} + active: {line: 0, character: 0} diff --git a/data/fixtures/recorded/languages/shellscript/changeState2.yml b/data/fixtures/recorded/languages/shellscript/changeState2.yml new file mode 100644 index 0000000000..f1201ad27f --- /dev/null +++ b/data/fixtures/recorded/languages/shellscript/changeState2.yml @@ -0,0 +1,23 @@ +languageId: shellscript +command: + version: 6 + spokenForm: change state + action: + name: clearAndSetSelection + target: + type: primitive + modifiers: + - type: containingScope + scopeType: {type: statement} + usePrePhraseSnapshot: true +initialState: + documentContents: cat ----------< + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/shellscript/list.scope b/data/fixtures/scopes/shellscript/list.scope new file mode 100644 index 0000000000..cd12626c82 --- /dev/null +++ b/data/fixtures/scopes/shellscript/list.scope @@ -0,0 +1,10 @@ +declare -a arr=("apple" "banana" "cherry") +--- + +[Content] = +[Removal] = +[Domain] = 0:15-0:42 +0| declare -a arr=("apple" "banana" "cherry") + >---------------------------< + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/shellscript/name.assignment.scope b/data/fixtures/scopes/shellscript/name.assignment.scope new file mode 100644 index 0000000000..8d80e21011 --- /dev/null +++ b/data/fixtures/scopes/shellscript/name.assignment.scope @@ -0,0 +1,20 @@ +local local_var="hello" +--- + +[Content] = 0:6-0:15 +0| local local_var="hello" + >---------< + +[Removal] = 0:0-0:16 +0| local local_var="hello" + >----------------< + +[Leading delimiter] = 0:5-0:6 +0| local local_var="hello" + >-< + +[Domain] = 0:0-0:23 +0| local local_var="hello" + >-----------------------< + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/shellscript/name.assignment2.scope b/data/fixtures/scopes/shellscript/name.assignment2.scope new file mode 100644 index 0000000000..8ebf2cfa10 --- /dev/null +++ b/data/fixtures/scopes/shellscript/name.assignment2.scope @@ -0,0 +1,20 @@ +declare local_var="hello" +--- + +[Content] = 0:8-0:17 +0| declare local_var="hello" + >---------< + +[Removal] = 0:0-0:18 +0| declare local_var="hello" + >------------------< + +[Leading delimiter] = 0:7-0:8 +0| declare local_var="hello" + >-< + +[Domain] = 0:0-0:25 +0| declare local_var="hello" + >-------------------------< + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/shellscript/name.assignment3.scope b/data/fixtures/scopes/shellscript/name.assignment3.scope new file mode 100644 index 0000000000..3260c937a0 --- /dev/null +++ b/data/fixtures/scopes/shellscript/name.assignment3.scope @@ -0,0 +1,20 @@ +local local_var +--- + +[Content] = 0:6-0:15 +0| local local_var + >---------< + +[Removal] = 0:5-0:15 +0| local local_var + >----------< + +[Leading delimiter] = 0:5-0:6 +0| local local_var + >-< + +[Domain] = 0:0-0:15 +0| local local_var + >---------------< + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/shellscript/value.assignment.scope b/data/fixtures/scopes/shellscript/value.assignment.scope new file mode 100644 index 0000000000..18456d54cd --- /dev/null +++ b/data/fixtures/scopes/shellscript/value.assignment.scope @@ -0,0 +1,20 @@ +local name="Hello world" +--- + +[Content] = 0:11-0:24 +0| local name="Hello world" + >-------------< + +[Removal] = 0:10-0:24 +0| local name="Hello world" + >--------------< + +[Leading delimiter] = 0:10-0:11 +0| local name="Hello world" + >-< + +[Domain] = 0:0-0:24 +0| local name="Hello world" + >------------------------< + +[Insertion delimiter] = " " diff --git a/data/fixtures/subtoken.fixture.ts b/data/fixtures/subtoken.fixture.ts new file mode 100644 index 0000000000..7916fa3baf --- /dev/null +++ b/data/fixtures/subtoken.fixture.ts @@ -0,0 +1,87 @@ +interface Fixture { + input: string; + expectedOutput: string[]; +} + +export const subtokenFixture: Fixture[] = [ + { + input: "QuickBrownFox", + expectedOutput: ["Quick", "Brown", "Fox"], + }, + { + input: "quickBrownFox", + expectedOutput: ["quick", "Brown", "Fox"], + }, + { + input: "quick_brown_fox", + expectedOutput: ["quick", "brown", "fox"], + }, + { + input: "QUICK_BROWN_FOX", + expectedOutput: ["QUICK", "BROWN", "FOX"], + }, + { + input: "quick-brown-fox", + expectedOutput: ["quick", "brown", "fox"], + }, + { + input: "QUICK-BROWN-FOX", + expectedOutput: ["QUICK", "BROWN", "FOX"], + }, + { + input: "quick.brown.fox", + expectedOutput: ["quick", "brown", "fox"], + }, + { + input: "QUICK.BROWN.FOX", + expectedOutput: ["QUICK", "BROWN", "FOX"], + }, + { + input: "../quick/brown/.fox", + expectedOutput: ["quick", "brown", "fox"], + }, + { + input: "../QUICK/BROWN/.FOX", + expectedOutput: ["QUICK", "BROWN", "FOX"], + }, + { + input: "quick::brown::fox", + expectedOutput: ["quick", "brown", "fox"], + }, + { + input: "QUICK::BROWN::FOX", + expectedOutput: ["QUICK", "BROWN", "FOX"], + }, + { + input: "APIClientFactory", + expectedOutput: ["API", "Client", "Factory"], + }, + { + input: "MockAPIClientFactory", + expectedOutput: ["Mock", "API", "Client", "Factory"], + }, + { + input: "mockAPIClientFactory", + expectedOutput: ["mock", "API", "Client", "Factory"], + }, + { + input: "mockAPIClient123FactoryV1", + expectedOutput: ["mock", "API", "Client", "123", "Factory", "V", "1"], + }, + { + input: "mock_api_client_123_factory_v1", + expectedOutput: ["mock", "api", "client", "123", "factory", "v1"], + }, + { + input: "v1", + expectedOutput: ["v", "1"], + }, + { + input: "aaBbÄä", + expectedOutput: ["aa", "Bb", "Ää"], + }, + { + input: "_quickBrownFox_", + expectedOutput: ["quick", "Brown", "Fox"], + }, +]; diff --git a/data/playground/shellscript/shellscript.sh b/data/playground/shellscript/shellscript.sh new file mode 100755 index 0000000000..85cda440fb --- /dev/null +++ b/data/playground/shellscript/shellscript.sh @@ -0,0 +1,172 @@ +#!/bin/bash + + +# Variable declaration +var="Hello, World" +array=("apple" "banana" "cherry") + +# Output variables +echo "String variable: $var" +echo "Number variable: $number" +echo "Array variable: ${array[*]}" +echo A B C +# If statement +if [ "$number" -eq 42 ]; then + echo "The number is 42" +else + echo "The number is not 42" +fi + +# For loop +for item in "${array[@]}"; do + echo "Fruit: $item" +done + +# While loop +count=0 +while [ $count -lt 3 ]; do + echo "Count: $count" + ((count++)) +done + +# Function declaration +my_function() { + local local_var="Local Variable" + echo "Function argument: $1" + echo "$local_var from function" +} + +sub_function() (foo) +sub_function() ((foo++)) + +my_function "Function Argument" + +# Case statement +case "$number" in +1) + echo "Number is 1" + ;; +2) + echo "Number is 2" + ;; +42) + echo "Number is the answer to everything" + ;; +*) + echo "Number is not recognized" + ;; +esac + +# Advanced constructs +# Command substitution +current_date=$(date) + +# Conditional execution +ls non_existent_file || echo "File not found" + +# Here document +cat < "{1..5} + +# Extended globbing +shopt -s extglob +files="file1.txt file2.txt file3.log" +echo "Extended Globbing: ${files%%.*(txt|log)}" + +# Conditional execution and redirection +false && echo "This won't execute" +true || echo "This will execute" + +# Input redirection +cat = scala: scalaScopeSupport, scm: scmScopeSupport, scss: scssScopeSupport, + shellscript: shellscriptScopeSupport, talon: talonScopeSupport, typescript: typescriptScopeSupport, typescriptreact: typescriptreactScopeSupport, diff --git a/packages/common/src/scopeSupportFacets/shellscript.ts b/packages/common/src/scopeSupportFacets/shellscript.ts new file mode 100644 index 0000000000..59cd692ec9 --- /dev/null +++ b/packages/common/src/scopeSupportFacets/shellscript.ts @@ -0,0 +1,15 @@ +/* eslint-disable @typescript-eslint/naming-convention */ + +import { + LanguageScopeSupportFacetMap, + ScopeSupportFacetLevel, +} from "./scopeSupportFacets.types"; + +const { supported } = ScopeSupportFacetLevel; + +export const shellscriptScopeSupport: LanguageScopeSupportFacetMap = { + list: supported, + command: supported, + "name.assignment": supported, + "value.assignment": supported, +}; diff --git a/queries/shellscript.scm b/queries/shellscript.scm new file mode 100644 index 0000000000..0dcd771648 --- /dev/null +++ b/queries/shellscript.scm @@ -0,0 +1,311 @@ +;; +;; Statements +;; + +( + (program + (_) @statement + ) + (#not-type? @statement comment) +) +[ + (if_statement) + (while_statement) + (for_statement) + (function_definition) + (declaration_command) + (case_statement) + (subshell) + (list) + (redirected_statement) +] @statement + +;;FIXME: Make the #not-parent-type? thing a list of nodes +( + (_ + [ + (variable_assignment) + (command) + ] @statement + (#not-parent-type? @statement declaration_command c_style_for_statement list redirected_statement) + ) +) + +;; +;; Conditionals +;; + +(if_statement) @ifStatement @branch.iteration @condition.iteration + +;;!! if [ $value -le 0 ]; then +;;!! fi +(if_statement + "if" @condition.domain.start.startOf @branch.start.startOf + (_) @condition + "then" @condition.domain.end.endOf @branch.end.endOf + . + "fi" +) + +;;!! if [ $value -le 0 ]; then +;;!! else +(if_statement + "if" @condition.domain.start.startOf @branch.start.startOf + (_) @condition + "then" @condition.domain.end.endOf @branch.end.endOf + . + (else_clause) +) + +;;!! if [ $value -le 0 ]; then +;;!! elif +(if_statement + "if" @condition.domain.start.startOf @branch.start.startOf + (_) @condition + "then" @condition.domain.end.endOf @branch.end.endOf + . + (elif_clause) +) + +;;!! if [ $value -le 0 ]; then +;;!! echo foo +;;!! fi +( + (if_statement + "if" @condition.domain.start.startOf @branch.start.startOf + (_) @condition + "then" @branch.interior.start.endOf + (_) @dummy + . + "fi" @condition.domain.end.startOf @branch.end.startOf @branch.interior.end.startOf + ) + (#not-type? @dummy else_clause elif_clause) +) + +;;!! if [ $value -le 0 ]; then +;;!! echo foo +;;!! elif [ $value -le 0 ]; then +;;!! fi +( + (if_statement + "if" @condition.domain.start.startOf @branch.start.startOf + (_) @condition + "then" @branch.interior.start.endOf + (_) + (elif_clause) @condition.domain.end.startOf @branch.end.startOf @branch.interior.end.startOf + ) +) + +;;!! if [ $value -le 0 ]; then +;;!! echo foo +;;!! else [ $value -le 0 ]; then +;;!! fi +( + (if_statement + "if" @condition.domain.start.startOf @branch.start.startOf + (_) @condition + "then" @branch.interior.start.endOf + (_) @dummy + . + (else_clause) @condition.domain.end.startOf @branch.end.startOf @branch.interior.end.startOf + ) + (#not-type? @dummy elif_clause) +) + +;;!! elif [ $value -le 0 ]; then +;;!! else +(elif_clause + (_) @condition + "then" + . +) @branch @_.domain + +;;!! elif [ $value -le 0 ]; then +;;!! echo "foo1" +;;!! echo "foo1" +(elif_clause + (_) @condition + "then" @branch.interior.start.endOf + (_) +) @branch @_.domain @branch.interior.end.endOf + +;;!! else +;;!! fi +(else_clause + "else" + . +) @branch + +;;!! else +;;!! echo "foo1" +;;!! echo "foo1" +;;!! fi +(else_clause + "else" @branch.interior.start.endOf + (_) +) @branch @branch.interior.end.endOf + +(_ + condition: (_) @condition +) + +(case_statement) @branch.iteration @condition.iteration +(case_item + value: (_) @condition + . + ")" @branch.interior.start.endOf + (_) @branch.interior.end.endOf + . + ";;" +) @branch @_.domain + +;; Lists and maps +;; + +;;!! array=("a" "b" "c") +;;! ^^^^^^^^^^^^^ +;;! ------------- +(array + "(" @_.interior.start.endOf + (_)? @collectionItem + ")" @_.interior.end.startOf +) @list @collectionItem.iteration + +;;!! FIXME: I will file an issue in tree-sitter-bash as I think the grammar is +;;!! bad. But the below does work for now +;;!! arr+=(["key2"]=val2 ["key3"]=val3) +(array + ( + (concatenation + ;; This matches the [ which is (word) for some reason + (_) @collectionKey.leading.start + (_) @collectionKey + ;; This matches the ] which is also (word) for some reason + (_) @collectionKey.trailing.end + (_) @value + ) @collectionItem + (#shrink-to-match! @value "\=(?.*)") + ) +) + +;; +;; Strings +;; + +;;!! # foo +;;! ^^^^^ +(comment) @comment @textFragment + +;;!! var="foo" +;;! ^^^^^ +(string) @string @textFragment + +;;!! var="foo ${bar}" +;;! ^^^^^^ +;;! xxxxxx +(string + ( + (expansion) @argumentOrParameter + ;; FIXME: This is due to a tree-sitter-bash bug (imo) where given: "Foo ${BAR} ${BAZ}" + ;; ${BAZ} incorrectly includes preceding space + (#shrink-to-match! @argumentOrParameter "\\s*(?.*)") + ) +) +(string + (simple_expansion) @argumentOrParameter + (#shrink-to-match! @argumentOrParameter "\\s*(?.*)") +) + +;; +;; Functions +;; + +;;!! echo "foo" +;;! ^^^^^ +(_ + argument: (_) @argumentOrParameter +) @_.iteration + +;; call: +;;!! echo "foo" +;;! ^^^^^^^^^^ +;; callee: +;;!! echo "foo" +;;! ^^^^ +;;! ---------- +(command + name: (_) @functionCallee +) @_.domain @functionCall @command + +;;!! function foo() { +;;! ^^^ +;;! ---------------- +;;!! echo "foo" +;;! ---------- +;;!! } +;;! - +(function_definition + name: (_) @functionName +) @_.domain + +;; FIXME: Need to support redirections +;; interior: +;;!! function foo() { +;;! ---------------- +;;!! echo "foo" +;;! ^^^^^^^^^^ +;;! ---------- +;;!! } +;;! - +(function_definition + body: (_ + (_)? @_.interior + ) +) @namedFunction @_.domain + +;; +;; Names, values, and types +;; + +;;!! for ((i = 1; i <= 5; i++)); do +;;! ^ +;;! xxxx +;;! ----- +( + (variable_assignment + name: (_) @name @value.leading.endOf + value: (_) @value @name.trailing.startOf + ) @dummy @_.domain + (#not-parent-type? @dummy declaration_command) +) + +;;!! local foo="bar" +;;! ^^^ +;;! xxxxxxxxxx +;;! --------------- +(declaration_command + (variable_assignment + name: (_) @name + value: (_) @_.removal.end.startOf + ) +) @_.domain @_.removal.start.startOf + +;;!! local foo="bar" +;;! ^^^ +;;! xxxxxxxxxx +;;! --------------- +(declaration_command + (variable_assignment + name: (_) @_.leading.endOf + value: (_) @value + ) +) @_.domain + +;;!! local foo +;;! ^^^ +;;! --------- +(declaration_command + (variable_name) @name +) @_.domain + +(regex) @regularExpression @textFragment From 42f1f4b81fe4758a979725d1cf8a09a4055fe381 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci-lite[bot]" <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com> Date: Mon, 5 Aug 2024 01:11:28 +0000 Subject: [PATCH 2/2] [pre-commit.ci lite] apply automatic fixes --- packages/common/src/scopeSupportFacets/shellscript.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/packages/common/src/scopeSupportFacets/shellscript.ts b/packages/common/src/scopeSupportFacets/shellscript.ts index 59cd692ec9..d92261456a 100644 --- a/packages/common/src/scopeSupportFacets/shellscript.ts +++ b/packages/common/src/scopeSupportFacets/shellscript.ts @@ -1,9 +1,7 @@ /* eslint-disable @typescript-eslint/naming-convention */ -import { - LanguageScopeSupportFacetMap, - ScopeSupportFacetLevel, -} from "./scopeSupportFacets.types"; +import type { LanguageScopeSupportFacetMap } from "./scopeSupportFacets.types"; +import { ScopeSupportFacetLevel } from "./scopeSupportFacets.types"; const { supported } = ScopeSupportFacetLevel;