Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/languages/ruby.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,8 @@ const nodeMatchers: Partial<
ifStatement: "if",
functionCall: "call",
comment: "comment",
namedFunction: "method",
functionName: "method[name]",
namedFunction: ["method", "singleton_method"],
functionName: ["method[name]", "singleton_method[name]"],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please also add to name (line 187 below), and add a test for that. Just one test for that one is fine

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry I missed this suggestion in the issue @richardmcmillen!

anonymousFunction: cascadingMatcher(
patternMatcher("lambda", "do_block"),
matcher(blockFinder)
Expand All @@ -189,6 +189,7 @@ const nodeMatchers: Partial<
"operator_assignment[left]",
"class[name]",
"method[name]",
"singleton_method[name]",
],
value: leadingMatcher(
[
Expand Down
29 changes: 29 additions & 0 deletions src/test/suite/fixtures/recorded/languages/ruby/changeFunk2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
languageId: ruby
command:
spokenForm: change funk
version: 2
targets:
- type: primitive
modifiers:
- type: containingScope
scopeType: {type: namedFunction}
usePrePhraseSnapshot: true
action: {name: clearAndSetSelection}
initialState:
documentContents: |-
def self.hello_world
puts "hi"
end
selections:
- anchor: {line: 1, character: 2}
active: {line: 1, character: 2}
marks: {}
finalState:
documentContents: ""
selections:
- anchor: {line: 0, character: 0}
active: {line: 0, character: 0}
thatMark:
- anchor: {line: 0, character: 0}
active: {line: 0, character: 0}
fullTargets: [{type: primitive, mark: {type: cursor}, modifiers: [{type: containingScope, scopeType: {type: namedFunction}}]}]
29 changes: 29 additions & 0 deletions src/test/suite/fixtures/recorded/languages/ruby/changeFunk3.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
languageId: ruby
command:
spokenForm: change funk
version: 2
targets:
- type: primitive
modifiers:
- type: containingScope
scopeType: {type: namedFunction}
usePrePhraseSnapshot: true
action: {name: clearAndSetSelection}
initialState:
documentContents: |-
def Thing.hello_world
puts "hi"
end
selections:
- anchor: {line: 1, character: 2}
active: {line: 1, character: 2}
marks: {}
finalState:
documentContents: ""
selections:
- anchor: {line: 0, character: 0}
active: {line: 0, character: 0}
thatMark:
- anchor: {line: 0, character: 0}
active: {line: 0, character: 0}
fullTargets: [{type: primitive, mark: {type: cursor}, modifiers: [{type: containingScope, scopeType: {type: namedFunction}}]}]
38 changes: 38 additions & 0 deletions src/test/suite/fixtures/recorded/languages/ruby/changeFunk4.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
languageId: ruby
command:
spokenForm: change funk
version: 2
targets:
- type: primitive
modifiers:
- type: containingScope
scopeType: {type: namedFunction}
usePrePhraseSnapshot: true
action: {name: clearAndSetSelection}
initialState:
documentContents: |-
class Test
class << self
def hello_world
puts "hi"
end
end
end
selections:
- anchor: {line: 3, character: 6}
active: {line: 3, character: 6}
marks: {}
finalState:
documentContents: |-
class Test
class << self

end
end
selections:
- anchor: {line: 2, character: 4}
active: {line: 2, character: 4}
thatMark:
- anchor: {line: 2, character: 4}
active: {line: 2, character: 4}
fullTargets: [{type: primitive, mark: {type: cursor}, modifiers: [{type: containingScope, scopeType: {type: namedFunction}}]}]
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
languageId: ruby
command:
spokenForm: change funk name
version: 2
targets:
- type: primitive
modifiers:
- type: containingScope
scopeType: {type: functionName}
usePrePhraseSnapshot: true
action: {name: clearAndSetSelection}
initialState:
documentContents: |-
def self.hello_world
puts "hi"
end
selections:
- anchor: {line: 1, character: 2}
active: {line: 1, character: 2}
marks: {}
finalState:
documentContents: |-
def self.
puts "hi"
end
selections:
- anchor: {line: 0, character: 9}
active: {line: 0, character: 9}
thatMark:
- anchor: {line: 0, character: 9}
active: {line: 0, character: 9}
fullTargets: [{type: primitive, mark: {type: cursor}, modifiers: [{type: containingScope, scopeType: {type: functionName}}]}]
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
languageId: ruby
command:
spokenForm: change funk name
version: 2
targets:
- type: primitive
modifiers:
- type: containingScope
scopeType: {type: functionName}
usePrePhraseSnapshot: true
action: {name: clearAndSetSelection}
initialState:
documentContents: |-
def Thing.hello_world
puts "hi"
end
selections:
- anchor: {line: 1, character: 2}
active: {line: 1, character: 2}
marks: {}
finalState:
documentContents: |-
def Thing.
puts "hi"
end
selections:
- anchor: {line: 0, character: 10}
active: {line: 0, character: 10}
thatMark:
- anchor: {line: 0, character: 10}
active: {line: 0, character: 10}
fullTargets: [{type: primitive, mark: {type: cursor}, modifiers: [{type: containingScope, scopeType: {type: functionName}}]}]
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
languageId: ruby
command:
spokenForm: change funk name
version: 2
targets:
- type: primitive
modifiers:
- type: containingScope
scopeType: {type: functionName}
usePrePhraseSnapshot: true
action: {name: clearAndSetSelection}
initialState:
documentContents: |-
class Test
class << self
def hello_world
puts "hi"
end
end
end
selections:
- anchor: {line: 3, character: 6}
active: {line: 3, character: 6}
marks: {}
finalState:
documentContents: |-
class Test
class << self
def
puts "hi"
end
end
end
selections:
- anchor: {line: 2, character: 8}
active: {line: 2, character: 8}
thatMark:
- anchor: {line: 2, character: 8}
active: {line: 2, character: 8}
fullTargets: [{type: primitive, mark: {type: cursor}, modifiers: [{type: containingScope, scopeType: {type: functionName}}]}]
32 changes: 32 additions & 0 deletions src/test/suite/fixtures/recorded/languages/ruby/changeName3.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
languageId: ruby
command:
spokenForm: change name
version: 2
targets:
- type: primitive
modifiers:
- type: containingScope
scopeType: {type: name}
usePrePhraseSnapshot: true
action: {name: clearAndSetSelection}
initialState:
documentContents: |-
def self.hello_world
puts "hi"
end
selections:
- anchor: {line: 1, character: 2}
active: {line: 1, character: 2}
marks: {}
finalState:
documentContents: |-
def self.
puts "hi"
end
selections:
- anchor: {line: 0, character: 9}
active: {line: 0, character: 9}
thatMark:
- anchor: {line: 0, character: 9}
active: {line: 0, character: 9}
fullTargets: [{type: primitive, mark: {type: cursor}, modifiers: [{type: containingScope, scopeType: {type: name}}]}]
32 changes: 32 additions & 0 deletions src/test/suite/fixtures/recorded/languages/ruby/chuckArg4.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
languageId: ruby
command:
spokenForm: chuck arg
version: 2
targets:
- type: primitive
modifiers:
- type: containingScope
scopeType: {type: argumentOrParameter}
usePrePhraseSnapshot: true
action: {name: remove}
initialState:
documentContents: |-
def self.hello(name)

end
selections:
- anchor: {line: 0, character: 15}
active: {line: 0, character: 15}
marks: {}
finalState:
documentContents: |-
def self.hello()

end
selections:
- anchor: {line: 0, character: 15}
active: {line: 0, character: 15}
thatMark:
- anchor: {line: 0, character: 15}
active: {line: 0, character: 15}
fullTargets: [{type: primitive, mark: {type: cursor}, modifiers: [{type: containingScope, scopeType: {type: argumentOrParameter}}]}]