-
-
Notifications
You must be signed in to change notification settings - Fork 88
Initial Perl support and some tests #1301
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
Leeft
wants to merge
29
commits into
cursorless-dev:main
Choose a base branch
from
Leeft:perl-support
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 20 commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
5f35c86
Initial Perl support and some tests
Leeft cbc72ff
Initial review notes: improve tests, few new tests
Leeft 580f55d
Remove all unused variables
Leeft 3175e6b
Fix item in hash not selecting both key and value
Leeft c4c6afa
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 2abccee
Initial review notes: improve tests, few new tests
Leeft b406a48
Fix item in hash not selecting both key and value
Leeft 2a70959
Move perl tests to match pnpm updates
Leeft fa494ec
Better regular expression handling and more tests
Leeft fe039a6
Fix "class name"
Leeft 8de6370
Remove TODO comment
Leeft e8ed2bc
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 726cab0
Fix `arg` and more tests
Leeft f7a0fcf
Fix hash key matching, add more tests
Leeft 3596f1f
Simplify string processing; make chuck round work
Leeft 65d7a59
Merge branch 'perl-support' of github.com:Leeft/cursorless into perl-…
Leeft 37aa1b4
Merge branch 'main' into perl-support
Leeft 521f2e0
Implement `callee`
Leeft a052de0
Merge remote-tracking branch 'origin/main' into perl-support
Leeft 12a1a22
Add class support
Leeft d287a38
Improve arg behaviour
Leeft c6cb621
Add test for change class name in lexical package
Leeft b40ff3d
Suggested "item" tests for array assignment
Leeft 70bed59
Improved condition scope with for loop support
Leeft c0187b2
Fix scope condition for C-style for loops
Leeft a0bb761
Add if and unless support for condition scope
Leeft 64a9894
Initial name scope support
Leeft dd0d992
Initial value scope support
Leeft 3846418
Partial branch scope support; ternary not yet done
Leeft File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import { | ||
cascadingMatcher, | ||
createPatternMatchers, | ||
matcher, | ||
patternMatcher, | ||
} from "../util/nodeMatchers"; | ||
import { NodeMatcherAlternative } from "../typings/Types"; | ||
import { SimpleScopeTypeType } from "@cursorless/common"; | ||
import { | ||
childRangeSelector, | ||
unwrapSelectionExtractor, | ||
} from "../util/nodeSelectors"; | ||
import { patternFinder } from "../util/nodeFinders"; | ||
|
||
const nodeMatchers: Partial< | ||
Record<SimpleScopeTypeType, NodeMatcherAlternative> | ||
> = { | ||
map: "hash", | ||
list: "array", | ||
condition: matcher( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. missing ternaries. prob not a showstopper to ship without it; depending how common ternaries are in Perl |
||
patternFinder("while_statement[condition]"), | ||
unwrapSelectionExtractor, | ||
), | ||
string: [ | ||
"string_single_quoted", | ||
"string_double_quoted", | ||
"string_q_quoted", | ||
"string_qq_quoted", | ||
], | ||
ifStatement: "if_statement", | ||
functionCall: [ | ||
"call_expression", | ||
"call_expression_with_just_name", | ||
"method_invocation", | ||
], | ||
functionCallee: cascadingMatcher( | ||
patternMatcher("call_expression_with_just_name"), | ||
matcher( | ||
patternFinder("call_expression", "method_invocation"), | ||
childRangeSelector( | ||
["arguments", "argument", "empty_parenthesized_argument"], | ||
[], | ||
), | ||
), | ||
), | ||
comment: "comments", | ||
namedFunction: ["function_definition"], | ||
anonymousFunction: "anonymous_function", | ||
regularExpression: [ | ||
"patter_matcher_m", // Mistype (?) but that is the name in tree-sitter-perl; it must come before pattern_matcher | ||
"pattern_matcher", | ||
"regex_pattern_qr", | ||
"substitution_pattern_s", | ||
], | ||
collectionKey: "key_value_pair[key]", | ||
collectionItem: "hash[variable]", | ||
argumentOrParameter: ["argument", "parenthesized_argument.arguments!"], | ||
class: [ | ||
"package_statement!.block[body]", | ||
"source_file!.package_statement", | ||
"package_statement", | ||
"source_file", | ||
], | ||
className: "package_statement.package_name!", | ||
}; | ||
|
||
export const patternMatchers = createPatternMatchers(nodeMatchers); |
22 changes: 22 additions & 0 deletions
22
packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/perl/changeArg.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
languageId: perl | ||
Leeft marked this conversation as resolved.
Show resolved
Hide resolved
|
||
command: | ||
version: 4 | ||
spokenForm: change arg | ||
action: { name: clearAndSetSelection } | ||
targets: | ||
- type: primitive | ||
modifiers: | ||
- type: containingScope | ||
scopeType: { type: argumentOrParameter } | ||
usePrePhraseSnapshot: true | ||
initialState: | ||
documentContents: some_funky_func( "and", "three", "args" ) | ||
selections: | ||
- anchor: { line: 0, character: 36 } | ||
active: { line: 0, character: 36 } | ||
marks: {} | ||
finalState: | ||
documentContents: some_funky_func( "and", "three", ) | ||
selections: | ||
- anchor: { line: 0, character: 33 } | ||
active: { line: 0, character: 33 } |
22 changes: 22 additions & 0 deletions
22
packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/perl/changeArg2.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
languageId: perl | ||
command: | ||
version: 4 | ||
spokenForm: change arg | ||
action: {name: clearAndSetSelection} | ||
targets: | ||
- type: primitive | ||
modifiers: | ||
- type: containingScope | ||
scopeType: {type: argumentOrParameter} | ||
usePrePhraseSnapshot: true | ||
initialState: | ||
documentContents: some_funky_func( "and", "three", "args" ) | ||
selections: | ||
- anchor: {line: 0, character: 29} | ||
active: {line: 0, character: 29} | ||
marks: {} | ||
finalState: | ||
documentContents: some_funky_func( "and", , "args" ) | ||
selections: | ||
- anchor: {line: 0, character: 24} | ||
active: {line: 0, character: 24} |
22 changes: 22 additions & 0 deletions
22
packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/perl/changeArg3.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
languageId: perl | ||
command: | ||
version: 4 | ||
spokenForm: change arg | ||
action: {name: clearAndSetSelection} | ||
targets: | ||
- type: primitive | ||
modifiers: | ||
- type: containingScope | ||
scopeType: {type: argumentOrParameter} | ||
usePrePhraseSnapshot: true | ||
initialState: | ||
documentContents: some_funky_func( "and", "three", "args" ) | ||
selections: | ||
- anchor: {line: 0, character: 21} | ||
active: {line: 0, character: 21} | ||
marks: {} | ||
finalState: | ||
documentContents: some_funky_func( , "three", "args" ) | ||
selections: | ||
- anchor: {line: 0, character: 17} | ||
active: {line: 0, character: 17} |
22 changes: 22 additions & 0 deletions
22
packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/perl/changeArg4.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
languageId: perl | ||
command: | ||
version: 4 | ||
spokenForm: change arg | ||
action: {name: clearAndSetSelection} | ||
targets: | ||
- type: primitive | ||
modifiers: | ||
- type: containingScope | ||
scopeType: {type: argumentOrParameter} | ||
usePrePhraseSnapshot: true | ||
initialState: | ||
documentContents: some_funky_func( "and", "three", "args" ) | ||
selections: | ||
- anchor: {line: 0, character: 16} | ||
active: {line: 0, character: 16} | ||
marks: {} | ||
finalState: | ||
documentContents: some_funky_func( ) | ||
pokey marked this conversation as resolved.
Show resolved
Hide resolved
|
||
selections: | ||
- anchor: {line: 0, character: 17} | ||
active: {line: 0, character: 17} |
28 changes: 28 additions & 0 deletions
28
packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/perl/changeCall.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
languageId: perl | ||
command: | ||
version: 4 | ||
spokenForm: change call | ||
action: { name: clearAndSetSelection } | ||
targets: | ||
- type: primitive | ||
modifiers: | ||
- type: containingScope | ||
scopeType: { type: functionCall } | ||
usePrePhraseSnapshot: true | ||
initialState: | ||
documentContents: |- | ||
my $var = 1; | ||
$var = func(); | ||
$var = 2; | ||
selections: | ||
- anchor: { line: 1, character: 12 } | ||
active: { line: 1, character: 12 } | ||
marks: {} | ||
finalState: | ||
documentContents: |- | ||
my $var = 1; | ||
$var = ; | ||
$var = 2; | ||
selections: | ||
- anchor: { line: 1, character: 7 } | ||
active: { line: 1, character: 7 } |
28 changes: 28 additions & 0 deletions
28
packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/perl/changeCall2.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
languageId: perl | ||
command: | ||
version: 4 | ||
spokenForm: change call | ||
action: { name: clearAndSetSelection } | ||
targets: | ||
- type: primitive | ||
modifiers: | ||
- type: containingScope | ||
scopeType: { type: functionCall } | ||
usePrePhraseSnapshot: true | ||
initialState: | ||
documentContents: |- | ||
my $var = 1; | ||
$var = func_with_params( $var ); | ||
$var = 2; | ||
selections: | ||
- anchor: { line: 1, character: 27 } | ||
active: { line: 1, character: 27 } | ||
marks: {} | ||
finalState: | ||
documentContents: |- | ||
my $var = 1; | ||
$var = ; | ||
$var = 2; | ||
selections: | ||
- anchor: { line: 1, character: 7 } | ||
active: { line: 1, character: 7 } |
28 changes: 28 additions & 0 deletions
28
packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/perl/changeCall3.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
languageId: perl | ||
command: | ||
version: 4 | ||
spokenForm: change call | ||
action: { name: clearAndSetSelection } | ||
targets: | ||
- type: primitive | ||
modifiers: | ||
- type: containingScope | ||
scopeType: { type: functionCall } | ||
usePrePhraseSnapshot: true | ||
initialState: | ||
documentContents: |- | ||
my $var = 1; | ||
$var = $object->method( ); | ||
$var = 2; | ||
selections: | ||
- anchor: { line: 1, character: 24 } | ||
active: { line: 1, character: 24 } | ||
marks: {} | ||
finalState: | ||
documentContents: |- | ||
my $var = 1; | ||
$var = ; | ||
$var = 2; | ||
selections: | ||
- anchor: { line: 1, character: 7 } | ||
active: { line: 1, character: 7 } |
28 changes: 28 additions & 0 deletions
28
packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/perl/changeCall4.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
languageId: perl | ||
command: | ||
version: 4 | ||
spokenForm: change call | ||
action: { name: clearAndSetSelection } | ||
targets: | ||
- type: primitive | ||
modifiers: | ||
- type: containingScope | ||
scopeType: { type: functionCall } | ||
usePrePhraseSnapshot: true | ||
initialState: | ||
documentContents: |- | ||
my $var = 1; | ||
$var = Other::Package::func(); | ||
$var = 2; | ||
Leeft marked this conversation as resolved.
Show resolved
Hide resolved
|
||
selections: | ||
- anchor: { line: 1, character: 24 } | ||
active: { line: 1, character: 24 } | ||
marks: {} | ||
finalState: | ||
documentContents: |- | ||
my $var = 1; | ||
$var = ; | ||
$var = 2; | ||
selections: | ||
- anchor: { line: 1, character: 7 } | ||
active: { line: 1, character: 7 } |
22 changes: 22 additions & 0 deletions
22
packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/perl/changeCallee.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
languageId: perl | ||
command: | ||
version: 5 | ||
spokenForm: change callee | ||
action: {name: clearAndSetSelection} | ||
targets: | ||
- type: primitive | ||
modifiers: | ||
- type: containingScope | ||
scopeType: {type: functionCallee} | ||
usePrePhraseSnapshot: true | ||
initialState: | ||
documentContents: foo(); | ||
selections: | ||
- anchor: {line: 0, character: 4} | ||
active: {line: 0, character: 4} | ||
marks: {} | ||
finalState: | ||
documentContents: (); | ||
selections: | ||
- anchor: {line: 0, character: 0} | ||
active: {line: 0, character: 0} |
22 changes: 22 additions & 0 deletions
22
packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/perl/changeCallee2.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
languageId: perl | ||
command: | ||
version: 5 | ||
spokenForm: change callee | ||
action: {name: clearAndSetSelection} | ||
targets: | ||
- type: primitive | ||
modifiers: | ||
- type: containingScope | ||
scopeType: {type: functionCallee} | ||
usePrePhraseSnapshot: true | ||
initialState: | ||
documentContents: $thing->method( $arg ); | ||
selections: | ||
- anchor: {line: 0, character: 19} | ||
active: {line: 0, character: 19} | ||
marks: {} | ||
finalState: | ||
documentContents: ( $arg ); | ||
selections: | ||
- anchor: {line: 0, character: 0} | ||
active: {line: 0, character: 0} |
22 changes: 22 additions & 0 deletions
22
packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/perl/changeCallee3.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
languageId: perl | ||
command: | ||
version: 5 | ||
spokenForm: change callee | ||
action: {name: clearAndSetSelection} | ||
targets: | ||
- type: primitive | ||
modifiers: | ||
- type: containingScope | ||
scopeType: {type: functionCallee} | ||
usePrePhraseSnapshot: true | ||
initialState: | ||
documentContents: $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} |
22 changes: 22 additions & 0 deletions
22
packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/perl/changeCallee4.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
languageId: perl | ||
command: | ||
version: 5 | ||
spokenForm: change callee | ||
action: {name: clearAndSetSelection} | ||
targets: | ||
- type: primitive | ||
modifiers: | ||
- type: containingScope | ||
scopeType: {type: functionCallee} | ||
usePrePhraseSnapshot: true | ||
initialState: | ||
documentContents: foo( $bar ); | ||
selections: | ||
- anchor: {line: 0, character: 7} | ||
active: {line: 0, character: 7} | ||
marks: {} | ||
finalState: | ||
documentContents: ( $bar ); | ||
selections: | ||
- anchor: {line: 0, character: 0} | ||
active: {line: 0, character: 0} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing "state" (
statement
)