From 3f0f52ab93df83c6dab5126cf997930e4144a08a Mon Sep 17 00:00:00 2001 From: Pokey Rule <755842+pokey@users.noreply.github.com> Date: Wed, 5 Jun 2024 14:21:24 +0100 Subject: [PATCH 1/3] Migrate Python branch scopes to fixtures --- .../recorded/languages/python/clearBranch.yml | 31 ------------- .../languages/python/clearBranch10.yml | 32 ------------- .../languages/python/clearBranch11.yml | 22 --------- .../languages/python/clearBranch12.yml | 22 --------- .../languages/python/clearBranch13.yml | 18 -------- .../languages/python/clearBranch2.yml | 33 -------------- .../languages/python/clearBranch3.yml | 33 -------------- .../languages/python/clearBranch4.yml | 33 -------------- .../languages/python/clearBranch5.yml | 33 -------------- .../languages/python/clearBranch6.yml | 32 ------------- .../languages/python/clearBranch7.yml | 32 ------------- .../languages/python/clearBranch8.yml | 33 -------------- .../languages/python/clearBranch9.yml | 33 -------------- .../scopes/python/branch.if.iteration.scope | 18 ++++++++ data/fixtures/scopes/python/branch.if.scope | 39 ++++++++++++++++ .../python/branch.switchCase.iteration.scope | 16 +++++++ .../scopes/python/branch.switchCase.scope | 45 +++++++++++++++++++ .../scopes/python/branch.ternary.scope | 37 +++++++++++++++ data/fixtures/scopes/python/branch.try.scope | 39 ++++++++++++++++ .../common/src/scopeSupportFacets/python.ts | 7 +++ 20 files changed, 201 insertions(+), 387 deletions(-) delete mode 100644 data/fixtures/recorded/languages/python/clearBranch.yml delete mode 100644 data/fixtures/recorded/languages/python/clearBranch10.yml delete mode 100644 data/fixtures/recorded/languages/python/clearBranch11.yml delete mode 100644 data/fixtures/recorded/languages/python/clearBranch12.yml delete mode 100644 data/fixtures/recorded/languages/python/clearBranch13.yml delete mode 100644 data/fixtures/recorded/languages/python/clearBranch2.yml delete mode 100644 data/fixtures/recorded/languages/python/clearBranch3.yml delete mode 100644 data/fixtures/recorded/languages/python/clearBranch4.yml delete mode 100644 data/fixtures/recorded/languages/python/clearBranch5.yml delete mode 100644 data/fixtures/recorded/languages/python/clearBranch6.yml delete mode 100644 data/fixtures/recorded/languages/python/clearBranch7.yml delete mode 100644 data/fixtures/recorded/languages/python/clearBranch8.yml delete mode 100644 data/fixtures/recorded/languages/python/clearBranch9.yml create mode 100644 data/fixtures/scopes/python/branch.if.iteration.scope create mode 100644 data/fixtures/scopes/python/branch.if.scope create mode 100644 data/fixtures/scopes/python/branch.switchCase.iteration.scope create mode 100644 data/fixtures/scopes/python/branch.switchCase.scope create mode 100644 data/fixtures/scopes/python/branch.ternary.scope create mode 100644 data/fixtures/scopes/python/branch.try.scope diff --git a/data/fixtures/recorded/languages/python/clearBranch.yml b/data/fixtures/recorded/languages/python/clearBranch.yml deleted file mode 100644 index 4d2e18420a..0000000000 --- a/data/fixtures/recorded/languages/python/clearBranch.yml +++ /dev/null @@ -1,31 +0,0 @@ -languageId: python -command: - spokenForm: change branch - version: 3 - targets: - - type: primitive - modifiers: - - type: containingScope - scopeType: {type: branch} - usePrePhraseSnapshot: true - action: {name: clearAndSetSelection} -initialState: - documentContents: | - match 0: - case [0]: - pass - case [1]: - pass - selections: - - anchor: {line: 2, character: 10} - active: {line: 2, character: 10} - marks: {} -finalState: - documentContents: | - match 0: - - case [1]: - pass - selections: - - anchor: {line: 1, character: 4} - active: {line: 1, character: 4} diff --git a/data/fixtures/recorded/languages/python/clearBranch10.yml b/data/fixtures/recorded/languages/python/clearBranch10.yml deleted file mode 100644 index 24a3a5d556..0000000000 --- a/data/fixtures/recorded/languages/python/clearBranch10.yml +++ /dev/null @@ -1,32 +0,0 @@ -languageId: python -command: - version: 3 - spokenForm: change branch - action: {name: clearAndSetSelection} - targets: - - type: primitive - modifiers: - - type: containingScope - scopeType: {type: branch} - usePrePhraseSnapshot: false -initialState: - documentContents: |- - try: - pass - except: - pass - finally: - pass - selections: - - anchor: {line: 5, character: 2} - active: {line: 5, character: 2} - marks: {} -finalState: - documentContents: | - try: - pass - except: - pass - selections: - - anchor: {line: 4, character: 0} - active: {line: 4, character: 0} diff --git a/data/fixtures/recorded/languages/python/clearBranch11.yml b/data/fixtures/recorded/languages/python/clearBranch11.yml deleted file mode 100644 index baf87111fc..0000000000 --- a/data/fixtures/recorded/languages/python/clearBranch11.yml +++ /dev/null @@ -1,22 +0,0 @@ -languageId: python -command: - version: 3 - spokenForm: change branch - action: {name: clearAndSetSelection} - targets: - - type: primitive - modifiers: - - type: containingScope - scopeType: {type: branch} - usePrePhraseSnapshot: true -initialState: - documentContents: aaa = bbb if ccc else ddd - selections: - - anchor: {line: 0, character: 6} - active: {line: 0, character: 6} - marks: {} -finalState: - documentContents: aaa = if ccc else ddd - selections: - - anchor: {line: 0, character: 6} - active: {line: 0, character: 6} diff --git a/data/fixtures/recorded/languages/python/clearBranch12.yml b/data/fixtures/recorded/languages/python/clearBranch12.yml deleted file mode 100644 index 3cf7fbc406..0000000000 --- a/data/fixtures/recorded/languages/python/clearBranch12.yml +++ /dev/null @@ -1,22 +0,0 @@ -languageId: python -command: - version: 3 - spokenForm: change branch - action: {name: clearAndSetSelection} - targets: - - type: primitive - modifiers: - - type: containingScope - scopeType: {type: branch} - usePrePhraseSnapshot: false -initialState: - documentContents: aaa = bbb if ccc else ddd - selections: - - anchor: {line: 0, character: 22} - active: {line: 0, character: 22} - marks: {} -finalState: - documentContents: "aaa = bbb if ccc else " - selections: - - anchor: {line: 0, character: 22} - active: {line: 0, character: 22} diff --git a/data/fixtures/recorded/languages/python/clearBranch13.yml b/data/fixtures/recorded/languages/python/clearBranch13.yml deleted file mode 100644 index 155855a26e..0000000000 --- a/data/fixtures/recorded/languages/python/clearBranch13.yml +++ /dev/null @@ -1,18 +0,0 @@ -languageId: python -command: - version: 3 - spokenForm: change branch - action: {name: clearAndSetSelection} - targets: - - type: primitive - modifiers: - - type: containingScope - scopeType: {type: branch} - usePrePhraseSnapshot: true -initialState: - documentContents: aaa = bbb if ccc else ddd - selections: - - anchor: {line: 0, character: 13} - active: {line: 0, character: 13} - marks: {} -thrownError: {name: NoContainingScopeError} diff --git a/data/fixtures/recorded/languages/python/clearBranch2.yml b/data/fixtures/recorded/languages/python/clearBranch2.yml deleted file mode 100644 index e4ecdd40c7..0000000000 --- a/data/fixtures/recorded/languages/python/clearBranch2.yml +++ /dev/null @@ -1,33 +0,0 @@ -languageId: python -command: - version: 3 - spokenForm: change branch - action: {name: clearAndSetSelection} - targets: - - type: primitive - modifiers: - - type: containingScope - scopeType: {type: branch} - usePrePhraseSnapshot: true -initialState: - documentContents: |- - if True: - pass - elif False: - pass - else: - pass - selections: - - anchor: {line: 0, character: 0} - active: {line: 0, character: 0} - marks: {} -finalState: - documentContents: |- - - elif False: - pass - else: - pass - selections: - - anchor: {line: 0, character: 0} - active: {line: 0, character: 0} diff --git a/data/fixtures/recorded/languages/python/clearBranch3.yml b/data/fixtures/recorded/languages/python/clearBranch3.yml deleted file mode 100644 index ea506bfa80..0000000000 --- a/data/fixtures/recorded/languages/python/clearBranch3.yml +++ /dev/null @@ -1,33 +0,0 @@ -languageId: python -command: - version: 3 - spokenForm: change branch - action: {name: clearAndSetSelection} - targets: - - type: primitive - modifiers: - - type: containingScope - scopeType: {type: branch} - usePrePhraseSnapshot: false -initialState: - documentContents: |- - if True: - pass - elif False: - pass - else: - pass - selections: - - anchor: {line: 1, character: 4} - active: {line: 1, character: 4} - marks: {} -finalState: - documentContents: |- - - elif False: - pass - else: - pass - selections: - - anchor: {line: 0, character: 0} - active: {line: 0, character: 0} diff --git a/data/fixtures/recorded/languages/python/clearBranch4.yml b/data/fixtures/recorded/languages/python/clearBranch4.yml deleted file mode 100644 index d5a8e86a29..0000000000 --- a/data/fixtures/recorded/languages/python/clearBranch4.yml +++ /dev/null @@ -1,33 +0,0 @@ -languageId: python -command: - version: 3 - spokenForm: change branch - action: {name: clearAndSetSelection} - targets: - - type: primitive - modifiers: - - type: containingScope - scopeType: {type: branch} - usePrePhraseSnapshot: false -initialState: - documentContents: |- - if True: - pass - elif False: - pass - else: - pass - selections: - - anchor: {line: 2, character: 0} - active: {line: 2, character: 0} - marks: {} -finalState: - documentContents: |- - if True: - pass - - else: - pass - selections: - - anchor: {line: 2, character: 0} - active: {line: 2, character: 0} diff --git a/data/fixtures/recorded/languages/python/clearBranch5.yml b/data/fixtures/recorded/languages/python/clearBranch5.yml deleted file mode 100644 index 48164a39da..0000000000 --- a/data/fixtures/recorded/languages/python/clearBranch5.yml +++ /dev/null @@ -1,33 +0,0 @@ -languageId: python -command: - version: 3 - spokenForm: change branch - action: {name: clearAndSetSelection} - targets: - - type: primitive - modifiers: - - type: containingScope - scopeType: {type: branch} - usePrePhraseSnapshot: false -initialState: - documentContents: |- - if True: - pass - elif False: - pass - else: - pass - selections: - - anchor: {line: 3, character: 4} - active: {line: 3, character: 4} - marks: {} -finalState: - documentContents: |- - if True: - pass - - else: - pass - selections: - - anchor: {line: 2, character: 0} - active: {line: 2, character: 0} diff --git a/data/fixtures/recorded/languages/python/clearBranch6.yml b/data/fixtures/recorded/languages/python/clearBranch6.yml deleted file mode 100644 index c576f21a6e..0000000000 --- a/data/fixtures/recorded/languages/python/clearBranch6.yml +++ /dev/null @@ -1,32 +0,0 @@ -languageId: python -command: - version: 3 - spokenForm: change branch - action: {name: clearAndSetSelection} - targets: - - type: primitive - modifiers: - - type: containingScope - scopeType: {type: branch} - usePrePhraseSnapshot: false -initialState: - documentContents: |- - if True: - pass - elif False: - pass - else: - pass - selections: - - anchor: {line: 4, character: 0} - active: {line: 4, character: 0} - marks: {} -finalState: - documentContents: | - if True: - pass - elif False: - pass - selections: - - anchor: {line: 4, character: 0} - active: {line: 4, character: 0} diff --git a/data/fixtures/recorded/languages/python/clearBranch7.yml b/data/fixtures/recorded/languages/python/clearBranch7.yml deleted file mode 100644 index 82c66c2a30..0000000000 --- a/data/fixtures/recorded/languages/python/clearBranch7.yml +++ /dev/null @@ -1,32 +0,0 @@ -languageId: python -command: - version: 3 - spokenForm: change branch - action: {name: clearAndSetSelection} - targets: - - type: primitive - modifiers: - - type: containingScope - scopeType: {type: branch} - usePrePhraseSnapshot: false -initialState: - documentContents: |- - if True: - pass - elif False: - pass - else: - pass - selections: - - anchor: {line: 5, character: 4} - active: {line: 5, character: 4} - marks: {} -finalState: - documentContents: | - if True: - pass - elif False: - pass - selections: - - anchor: {line: 4, character: 0} - active: {line: 4, character: 0} diff --git a/data/fixtures/recorded/languages/python/clearBranch8.yml b/data/fixtures/recorded/languages/python/clearBranch8.yml deleted file mode 100644 index ad747635a5..0000000000 --- a/data/fixtures/recorded/languages/python/clearBranch8.yml +++ /dev/null @@ -1,33 +0,0 @@ -languageId: python -command: - version: 3 - spokenForm: change branch - action: {name: clearAndSetSelection} - targets: - - type: primitive - modifiers: - - type: containingScope - scopeType: {type: branch} - usePrePhraseSnapshot: true -initialState: - documentContents: |- - try: - pass - except: - pass - finally: - pass - selections: - - anchor: {line: 1, character: 2} - active: {line: 1, character: 2} - marks: {} -finalState: - documentContents: |- - - except: - pass - finally: - pass - selections: - - anchor: {line: 0, character: 0} - active: {line: 0, character: 0} diff --git a/data/fixtures/recorded/languages/python/clearBranch9.yml b/data/fixtures/recorded/languages/python/clearBranch9.yml deleted file mode 100644 index 55dc29fb50..0000000000 --- a/data/fixtures/recorded/languages/python/clearBranch9.yml +++ /dev/null @@ -1,33 +0,0 @@ -languageId: python -command: - version: 3 - spokenForm: change branch - action: {name: clearAndSetSelection} - targets: - - type: primitive - modifiers: - - type: containingScope - scopeType: {type: branch} - usePrePhraseSnapshot: false -initialState: - documentContents: |- - try: - pass - except: - pass - finally: - pass - selections: - - anchor: {line: 3, character: 2} - active: {line: 3, character: 2} - marks: {} -finalState: - documentContents: |- - try: - pass - - finally: - pass - selections: - - anchor: {line: 2, character: 0} - active: {line: 2, character: 0} diff --git a/data/fixtures/scopes/python/branch.if.iteration.scope b/data/fixtures/scopes/python/branch.if.iteration.scope new file mode 100644 index 0000000000..f310cd6f86 --- /dev/null +++ b/data/fixtures/scopes/python/branch.if.iteration.scope @@ -0,0 +1,18 @@ +if True: + pass +elif False: + pass +else: + pass +--- + +[Range] = +[Domain] = 0:0-5:8 + >-------- +0| if True: +1| pass +2| elif False: +3| pass +4| else: +5| pass + --------< diff --git a/data/fixtures/scopes/python/branch.if.scope b/data/fixtures/scopes/python/branch.if.scope new file mode 100644 index 0000000000..def93d3f12 --- /dev/null +++ b/data/fixtures/scopes/python/branch.if.scope @@ -0,0 +1,39 @@ +if True: + pass +elif False: + pass +else: + pass +--- + +[#1 Content] = +[#1 Removal] = +[#1 Domain] = 0:0-1:8 + >-------- +0| if True: +1| pass + --------< + +[#1 Insertion delimiter] = "\n" + + +[#2 Content] = +[#2 Removal] = +[#2 Domain] = 2:0-3:8 + >----------- +2| elif False: +3| pass + --------< + +[#2 Insertion delimiter] = "\n" + + +[#3 Content] = +[#3 Removal] = +[#3 Domain] = 4:0-5:8 + >----- +4| else: +5| pass + --------< + +[#3 Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/python/branch.switchCase.iteration.scope b/data/fixtures/scopes/python/branch.switchCase.iteration.scope new file mode 100644 index 0000000000..3aa831873b --- /dev/null +++ b/data/fixtures/scopes/python/branch.switchCase.iteration.scope @@ -0,0 +1,16 @@ +match 0: + case [0]: + pass + case [1]: + pass +--- + +[Range] = +[Domain] = 0:0-4:12 + >-------- +0| match 0: +1| case [0]: +2| pass +3| case [1]: +4| pass + ------------< diff --git a/data/fixtures/scopes/python/branch.switchCase.scope b/data/fixtures/scopes/python/branch.switchCase.scope new file mode 100644 index 0000000000..51160cd9ce --- /dev/null +++ b/data/fixtures/scopes/python/branch.switchCase.scope @@ -0,0 +1,45 @@ +match 0: + case [0]: + pass + case [1]: + pass +--- + +[#1 Content] = +[#1 Domain] = 1:4-2:12 + >--------- +1| case [0]: +2| pass + ------------< + +[#1 Removal] = 1:0-2:12 + >------------- +1| case [0]: +2| pass + ------------< + +[#1 Leading delimiter] = 1:0-1:4 + >----< +1| case [0]: + +[#1 Insertion delimiter] = "\n" + + +[#2 Content] = +[#2 Domain] = 3:4-4:12 + >--------- +3| case [1]: +4| pass + ------------< + +[#2 Removal] = 3:0-4:12 + >------------- +3| case [1]: +4| pass + ------------< + +[#2 Leading delimiter] = 3:0-3:4 + >----< +3| case [1]: + +[#2 Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/python/branch.ternary.scope b/data/fixtures/scopes/python/branch.ternary.scope new file mode 100644 index 0000000000..ccd4db7038 --- /dev/null +++ b/data/fixtures/scopes/python/branch.ternary.scope @@ -0,0 +1,37 @@ +aaa = bbb if ccc else ddd +--- + +[#1 Content] = +[#1 Domain] = 0:6-0:9 + >---< +0| aaa = bbb if ccc else ddd + +[#1 Removal] = 0:6-0:10 + >----< +0| aaa = bbb if ccc else ddd + +[#1 Leading delimiter] = 0:5-0:6 + >-< +0| aaa = bbb if ccc else ddd + +[#1 Trailing delimiter] = 0:9-0:10 + >-< +0| aaa = bbb if ccc else ddd + +[#1 Insertion delimiter] = "\n" + + +[#2 Content] = +[#2 Domain] = 0:22-0:25 + >---< +0| aaa = bbb if ccc else ddd + +[#2 Removal] = 0:21-0:25 + >----< +0| aaa = bbb if ccc else ddd + +[#2 Leading delimiter] = 0:21-0:22 + >-< +0| aaa = bbb if ccc else ddd + +[#2 Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/python/branch.try.scope b/data/fixtures/scopes/python/branch.try.scope new file mode 100644 index 0000000000..fb9f51e4ab --- /dev/null +++ b/data/fixtures/scopes/python/branch.try.scope @@ -0,0 +1,39 @@ +try: + pass +except: + pass +finally: + pass +--- + +[#1 Content] = +[#1 Removal] = +[#1 Domain] = 0:0-1:8 + >---- +0| try: +1| pass + --------< + +[#1 Insertion delimiter] = "\n" + + +[#2 Content] = +[#2 Removal] = +[#2 Domain] = 2:0-3:8 + >------- +2| except: +3| pass + --------< + +[#2 Insertion delimiter] = "\n" + + +[#3 Content] = +[#3 Removal] = +[#3 Domain] = 4:0-5:8 + >-------- +4| finally: +5| pass + --------< + +[#3 Insertion delimiter] = "\n" diff --git a/packages/common/src/scopeSupportFacets/python.ts b/packages/common/src/scopeSupportFacets/python.ts index 44b57bc0d6..6ae68cc503 100644 --- a/packages/common/src/scopeSupportFacets/python.ts +++ b/packages/common/src/scopeSupportFacets/python.ts @@ -23,6 +23,13 @@ export const pythonScopeSupport: LanguageScopeSupportFacetMap = { "argument.formal": supportedLegacy, "argument.formal.iteration": supportedLegacy, + "branch.if": supported, + "branch.if.iteration": supported, + "branch.switchCase": supported, + "branch.switchCase.iteration": supported, + "branch.ternary": supported, + "branch.try": supported, + element: notApplicable, tags: notApplicable, attribute: notApplicable, From 7b9e1bff71d183f0cdc0f02093edbdff1bdd356b Mon Sep 17 00:00:00 2001 From: Pokey Rule <755842+pokey@users.noreply.github.com> Date: Wed, 5 Jun 2024 14:37:52 +0100 Subject: [PATCH 2/3] Remove a couple more tests --- .../recorded/languages/python/ditchBranch.yml | 33 ------------------- .../languages/python/ditchBranch2.yml | 32 ------------------ 2 files changed, 65 deletions(-) delete mode 100644 data/fixtures/recorded/languages/python/ditchBranch.yml delete mode 100644 data/fixtures/recorded/languages/python/ditchBranch2.yml diff --git a/data/fixtures/recorded/languages/python/ditchBranch.yml b/data/fixtures/recorded/languages/python/ditchBranch.yml deleted file mode 100644 index 2c409d1c88..0000000000 --- a/data/fixtures/recorded/languages/python/ditchBranch.yml +++ /dev/null @@ -1,33 +0,0 @@ -languageId: python -command: - version: 3 - spokenForm: chuck branch - action: {name: remove} - targets: - - type: primitive - modifiers: - - type: containingScope - scopeType: {type: branch} - usePrePhraseSnapshot: true -initialState: - documentContents: |- - if True: - pass - elif False: - pass - else: - pass - selections: - - anchor: {line: 2, character: 0} - active: {line: 2, character: 0} - marks: {} -finalState: - documentContents: |- - if True: - pass - - else: - pass - selections: - - anchor: {line: 2, character: 0} - active: {line: 2, character: 0} diff --git a/data/fixtures/recorded/languages/python/ditchBranch2.yml b/data/fixtures/recorded/languages/python/ditchBranch2.yml deleted file mode 100644 index ee845bebcf..0000000000 --- a/data/fixtures/recorded/languages/python/ditchBranch2.yml +++ /dev/null @@ -1,32 +0,0 @@ -languageId: python -command: - version: 3 - spokenForm: chuck branch - action: {name: remove} - targets: - - type: primitive - modifiers: - - type: containingScope - scopeType: {type: branch} - usePrePhraseSnapshot: false -initialState: - documentContents: |- - if True: - pass - elif False: - pass - else: - pass - selections: - - anchor: {line: 4, character: 0} - active: {line: 4, character: 0} - marks: {} -finalState: - documentContents: | - if True: - pass - elif False: - pass - selections: - - anchor: {line: 4, character: 0} - active: {line: 4, character: 0} From cc9d1736c6b0a70e542a6e510f5750e7651f9628 Mon Sep 17 00:00:00 2001 From: Pokey Rule <755842+pokey@users.noreply.github.com> Date: Wed, 5 Jun 2024 14:47:47 +0100 Subject: [PATCH 3/3] More branch tests --- .../languages/python/clearBranch14.yml | 33 ---------------- .../languages/python/clearBranch15.yml | 33 ---------------- .../languages/python/clearBranch16.yml | 32 --------------- .../languages/python/clearBranch17.yml | 28 ------------- .../languages/python/clearBranch18.yml | 29 -------------- .../languages/python/clearBranch19.yml | 28 ------------- .../languages/python/clearBranch20.yml | 29 -------------- data/fixtures/scopes/python/branch.loop.scope | 26 +++++++++++++ .../fixtures/scopes/python/branch.loop2.scope | 26 +++++++++++++ data/fixtures/scopes/python/branch.try2.scope | 39 +++++++++++++++++++ .../common/src/scopeSupportFacets/python.ts | 1 + .../scopeSupportFacetInfos.ts | 5 +++ .../scopeSupportFacets.types.ts | 1 + 13 files changed, 98 insertions(+), 212 deletions(-) delete mode 100644 data/fixtures/recorded/languages/python/clearBranch14.yml delete mode 100644 data/fixtures/recorded/languages/python/clearBranch15.yml delete mode 100644 data/fixtures/recorded/languages/python/clearBranch16.yml delete mode 100644 data/fixtures/recorded/languages/python/clearBranch17.yml delete mode 100644 data/fixtures/recorded/languages/python/clearBranch18.yml delete mode 100644 data/fixtures/recorded/languages/python/clearBranch19.yml delete mode 100644 data/fixtures/recorded/languages/python/clearBranch20.yml create mode 100644 data/fixtures/scopes/python/branch.loop.scope create mode 100644 data/fixtures/scopes/python/branch.loop2.scope create mode 100644 data/fixtures/scopes/python/branch.try2.scope diff --git a/data/fixtures/recorded/languages/python/clearBranch14.yml b/data/fixtures/recorded/languages/python/clearBranch14.yml deleted file mode 100644 index 4db98dfbf3..0000000000 --- a/data/fixtures/recorded/languages/python/clearBranch14.yml +++ /dev/null @@ -1,33 +0,0 @@ -languageId: python -command: - version: 3 - spokenForm: change branch - action: {name: clearAndSetSelection} - targets: - - type: primitive - modifiers: - - type: containingScope - scopeType: {type: branch} - usePrePhraseSnapshot: true -initialState: - documentContents: |- - try: - pass - except* ValueError as eg: - pass - else: - pass - selections: - - anchor: {line: 0, character: 0} - active: {line: 0, character: 0} - marks: {} -finalState: - documentContents: |- - - except* ValueError as eg: - pass - else: - pass - selections: - - anchor: {line: 0, character: 0} - active: {line: 0, character: 0} diff --git a/data/fixtures/recorded/languages/python/clearBranch15.yml b/data/fixtures/recorded/languages/python/clearBranch15.yml deleted file mode 100644 index e468b99fa1..0000000000 --- a/data/fixtures/recorded/languages/python/clearBranch15.yml +++ /dev/null @@ -1,33 +0,0 @@ -languageId: python -command: - version: 3 - spokenForm: change branch - action: {name: clearAndSetSelection} - targets: - - type: primitive - modifiers: - - type: containingScope - scopeType: {type: branch} - usePrePhraseSnapshot: false -initialState: - documentContents: |- - try: - pass - except* ValueError as eg: - pass - else: - pass - selections: - - anchor: {line: 2, character: 0} - active: {line: 2, character: 0} - marks: {} -finalState: - documentContents: |- - try: - pass - - else: - pass - selections: - - anchor: {line: 2, character: 0} - active: {line: 2, character: 0} diff --git a/data/fixtures/recorded/languages/python/clearBranch16.yml b/data/fixtures/recorded/languages/python/clearBranch16.yml deleted file mode 100644 index 854292a38a..0000000000 --- a/data/fixtures/recorded/languages/python/clearBranch16.yml +++ /dev/null @@ -1,32 +0,0 @@ -languageId: python -command: - version: 3 - spokenForm: change branch - action: {name: clearAndSetSelection} - targets: - - type: primitive - modifiers: - - type: containingScope - scopeType: {type: branch} - usePrePhraseSnapshot: false -initialState: - documentContents: |- - try: - pass - except* ValueError as eg: - pass - else: - pass - selections: - - anchor: {line: 4, character: 0} - active: {line: 4, character: 0} - marks: {} -finalState: - documentContents: | - try: - pass - except* ValueError as eg: - pass - selections: - - anchor: {line: 4, character: 0} - active: {line: 4, character: 0} diff --git a/data/fixtures/recorded/languages/python/clearBranch17.yml b/data/fixtures/recorded/languages/python/clearBranch17.yml deleted file mode 100644 index 38458bae38..0000000000 --- a/data/fixtures/recorded/languages/python/clearBranch17.yml +++ /dev/null @@ -1,28 +0,0 @@ -languageId: python -command: - version: 3 - spokenForm: change branch - action: {name: clearAndSetSelection} - targets: - - type: primitive - modifiers: - - type: containingScope - scopeType: {type: branch} - usePrePhraseSnapshot: true -initialState: - documentContents: |- - while True: - pass - else: - pass - selections: - - anchor: {line: 3, character: 2} - active: {line: 3, character: 2} - marks: {} -finalState: - documentContents: | - while True: - pass - selections: - - anchor: {line: 2, character: 0} - active: {line: 2, character: 0} diff --git a/data/fixtures/recorded/languages/python/clearBranch18.yml b/data/fixtures/recorded/languages/python/clearBranch18.yml deleted file mode 100644 index fbc2a39bb7..0000000000 --- a/data/fixtures/recorded/languages/python/clearBranch18.yml +++ /dev/null @@ -1,29 +0,0 @@ -languageId: python -command: - version: 3 - spokenForm: change branch - action: {name: clearAndSetSelection} - targets: - - type: primitive - modifiers: - - type: containingScope - scopeType: {type: branch} - usePrePhraseSnapshot: false -initialState: - documentContents: |- - while True: - pass - else: - pass - selections: - - anchor: {line: 1, character: 2} - active: {line: 1, character: 2} - marks: {} -finalState: - documentContents: |- - - else: - pass - selections: - - anchor: {line: 0, character: 0} - active: {line: 0, character: 0} diff --git a/data/fixtures/recorded/languages/python/clearBranch19.yml b/data/fixtures/recorded/languages/python/clearBranch19.yml deleted file mode 100644 index 893c6dce11..0000000000 --- a/data/fixtures/recorded/languages/python/clearBranch19.yml +++ /dev/null @@ -1,28 +0,0 @@ -languageId: python -command: - version: 3 - spokenForm: change branch - action: {name: clearAndSetSelection} - targets: - - type: primitive - modifiers: - - type: containingScope - scopeType: {type: branch} - usePrePhraseSnapshot: false -initialState: - documentContents: |- - for aaa in bbb: - pass - else: - pass - selections: - - anchor: {line: 3, character: 2} - active: {line: 3, character: 2} - marks: {} -finalState: - documentContents: | - for aaa in bbb: - pass - selections: - - anchor: {line: 2, character: 0} - active: {line: 2, character: 0} diff --git a/data/fixtures/recorded/languages/python/clearBranch20.yml b/data/fixtures/recorded/languages/python/clearBranch20.yml deleted file mode 100644 index d32951588f..0000000000 --- a/data/fixtures/recorded/languages/python/clearBranch20.yml +++ /dev/null @@ -1,29 +0,0 @@ -languageId: python -command: - version: 3 - spokenForm: change branch - action: {name: clearAndSetSelection} - targets: - - type: primitive - modifiers: - - type: containingScope - scopeType: {type: branch} - usePrePhraseSnapshot: false -initialState: - documentContents: |- - for aaa in bbb: - pass - else: - pass - selections: - - anchor: {line: 1, character: 2} - active: {line: 1, character: 2} - marks: {} -finalState: - documentContents: |- - - else: - pass - selections: - - anchor: {line: 0, character: 0} - active: {line: 0, character: 0} diff --git a/data/fixtures/scopes/python/branch.loop.scope b/data/fixtures/scopes/python/branch.loop.scope new file mode 100644 index 0000000000..41ab3b4189 --- /dev/null +++ b/data/fixtures/scopes/python/branch.loop.scope @@ -0,0 +1,26 @@ +while True: + pass +else: + pass +--- + +[#1 Content] = +[#1 Removal] = +[#1 Domain] = 0:0-1:8 + >----------- +0| while True: +1| pass + --------< + +[#1 Insertion delimiter] = "\n" + + +[#2 Content] = +[#2 Removal] = +[#2 Domain] = 2:0-3:8 + >----- +2| else: +3| pass + --------< + +[#2 Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/python/branch.loop2.scope b/data/fixtures/scopes/python/branch.loop2.scope new file mode 100644 index 0000000000..bedbee310d --- /dev/null +++ b/data/fixtures/scopes/python/branch.loop2.scope @@ -0,0 +1,26 @@ +for aaa in bbb: + pass +else: + pass +--- + +[#1 Content] = +[#1 Removal] = +[#1 Domain] = 0:0-1:8 + >--------------- +0| for aaa in bbb: +1| pass + --------< + +[#1 Insertion delimiter] = "\n" + + +[#2 Content] = +[#2 Removal] = +[#2 Domain] = 2:0-3:8 + >----- +2| else: +3| pass + --------< + +[#2 Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/python/branch.try2.scope b/data/fixtures/scopes/python/branch.try2.scope new file mode 100644 index 0000000000..7469d260a3 --- /dev/null +++ b/data/fixtures/scopes/python/branch.try2.scope @@ -0,0 +1,39 @@ +try: + pass +except* ValueError as eg: + pass +else: + pass +--- + +[#1 Content] = +[#1 Removal] = +[#1 Domain] = 0:0-1:8 + >---- +0| try: +1| pass + --------< + +[#1 Insertion delimiter] = "\n" + + +[#2 Content] = +[#2 Removal] = +[#2 Domain] = 2:0-3:8 + >------------------------- +2| except* ValueError as eg: +3| pass + --------< + +[#2 Insertion delimiter] = "\n" + + +[#3 Content] = +[#3 Removal] = +[#3 Domain] = 4:0-5:8 + >----- +4| else: +5| pass + --------< + +[#3 Insertion delimiter] = "\n" diff --git a/packages/common/src/scopeSupportFacets/python.ts b/packages/common/src/scopeSupportFacets/python.ts index 6ae68cc503..21080c34f5 100644 --- a/packages/common/src/scopeSupportFacets/python.ts +++ b/packages/common/src/scopeSupportFacets/python.ts @@ -29,6 +29,7 @@ export const pythonScopeSupport: LanguageScopeSupportFacetMap = { "branch.switchCase.iteration": supported, "branch.ternary": supported, "branch.try": supported, + "branch.loop": supported, element: notApplicable, tags: notApplicable, diff --git a/packages/common/src/scopeSupportFacets/scopeSupportFacetInfos.ts b/packages/common/src/scopeSupportFacets/scopeSupportFacetInfos.ts index 562b13be7e..2e412622e9 100644 --- a/packages/common/src/scopeSupportFacets/scopeSupportFacetInfos.ts +++ b/packages/common/src/scopeSupportFacets/scopeSupportFacetInfos.ts @@ -229,6 +229,11 @@ export const scopeSupportFacetInfos: Record< description: "An if/elif/else branch", scopeType: "branch", }, + "branch.loop": { + description: + "A for / while loop branch. For most languages there will just be one branch for the entire loop, but eg in Python you can have an else branch for a loop.", + scopeType: "branch", + }, "branch.if.iteration": { description: diff --git a/packages/common/src/scopeSupportFacets/scopeSupportFacets.types.ts b/packages/common/src/scopeSupportFacets/scopeSupportFacets.types.ts index 26b0966daa..650fadeffb 100644 --- a/packages/common/src/scopeSupportFacets/scopeSupportFacets.types.ts +++ b/packages/common/src/scopeSupportFacets/scopeSupportFacets.types.ts @@ -63,6 +63,7 @@ const scopeSupportFacets = [ "branch.switchCase", "branch.switchCase.iteration", "branch.ternary", + "branch.loop", "condition.if", "condition.while",