ruby-lsp-refactor 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop_todo.yml +68 -0
- data/lib/ruby/lsp/refactor/version.rb +1 -1
- data/lib/ruby_lsp/ruby_lsp_refactor/addon.rb +35 -9
- data/lib/ruby_lsp/ruby_lsp_refactor/listeners/accessor_listener.rb +156 -0
- data/lib/ruby_lsp/ruby_lsp_refactor/listeners/array_listener.rb +2 -2
- data/lib/ruby_lsp/ruby_lsp_refactor/listeners/block_style_listener.rb +117 -0
- data/lib/ruby_lsp/ruby_lsp_refactor/listeners/conditional_listener.rb +14 -14
- data/lib/ruby_lsp/ruby_lsp_refactor/listeners/constant_listener.rb +118 -0
- data/lib/ruby_lsp/ruby_lsp_refactor/listeners/enumerable_listener.rb +90 -0
- data/lib/ruby_lsp/ruby_lsp_refactor/listeners/hash_listener.rb +7 -7
- data/lib/ruby_lsp/ruby_lsp_refactor/listeners/logical_operator_listener.rb +70 -0
- data/lib/ruby_lsp/ruby_lsp_refactor/listeners/method_listener.rb +34 -34
- data/lib/ruby_lsp/ruby_lsp_refactor/listeners/raise_listener.rb +70 -0
- data/lib/ruby_lsp/ruby_lsp_refactor/listeners/rescue_listener.rb +85 -0
- data/lib/ruby_lsp/ruby_lsp_refactor/listeners/rspec_let_listener.rb +61 -0
- data/lib/ruby_lsp/ruby_lsp_refactor/listeners/string_array_listener.rb +88 -0
- data/lib/ruby_lsp/ruby_lsp_refactor/listeners/string_freeze_listener.rb +86 -0
- data/lib/ruby_lsp/ruby_lsp_refactor/listeners/string_listener.rb +2 -2
- data/lib/ruby_lsp/ruby_lsp_refactor/listeners/super_listener.rb +95 -0
- data/lib/ruby_lsp/ruby_lsp_refactor/listeners/variable_listener.rb +11 -11
- data/lib/ruby_lsp/ruby_lsp_refactor/support/node_helpers.rb +12 -12
- data/lib/ruby_lsp/test_helper.rb +5 -5
- data/test/ruby_lsp_refactor/accessor_listener_test.rb +91 -0
- data/test/ruby_lsp_refactor/block_style_listener_test.rb +98 -0
- data/test/ruby_lsp_refactor/constant_listener_test.rb +68 -0
- data/test/ruby_lsp_refactor/enumerable_listener_test.rb +80 -0
- data/test/ruby_lsp_refactor/logical_operator_listener_test.rb +66 -0
- data/test/ruby_lsp_refactor/raise_listener_test.rb +64 -0
- data/test/ruby_lsp_refactor/rescue_listener_test.rb +72 -0
- data/test/ruby_lsp_refactor/rspec_let_listener_test.rb +54 -0
- data/test/ruby_lsp_refactor/string_array_listener_test.rb +64 -0
- data/test/ruby_lsp_refactor/string_freeze_listener_test.rb +52 -0
- data/test/ruby_lsp_refactor/string_listener_test.rb +2 -2
- data/test/ruby_lsp_refactor/super_listener_test.rb +65 -0
- metadata +36 -13
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "minitest/autorun"
|
|
4
|
+
require "ruby_lsp/test_helper"
|
|
5
|
+
|
|
6
|
+
module RubyLsp
|
|
7
|
+
module Refactor
|
|
8
|
+
class LogicalOperatorListenerTest < Minitest::Test
|
|
9
|
+
include RubyLsp::Refactor::TestHelper
|
|
10
|
+
|
|
11
|
+
def find_action(actions, title_pattern)
|
|
12
|
+
actions.find { |a| a.title.match?(title_pattern) }
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def single_edit(action)
|
|
16
|
+
edits = action.edit.changes.values.flatten
|
|
17
|
+
assert_equal 1, edits.size
|
|
18
|
+
edits.first
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def test_converts_double_ampersand_to_and
|
|
22
|
+
source = "user.valid? && user.save\n"
|
|
23
|
+
actions = code_actions_for(source, line: 0)
|
|
24
|
+
action = find_action(actions, /&&.*and/)
|
|
25
|
+
refute_nil action
|
|
26
|
+
|
|
27
|
+
edit = single_edit(action)
|
|
28
|
+
assert_equal "user.valid? and user.save", edit.new_text.strip
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def test_converts_and_to_double_ampersand
|
|
32
|
+
source = "user.valid? and user.save\n"
|
|
33
|
+
actions = code_actions_for(source, line: 0)
|
|
34
|
+
action = find_action(actions, /and.*&&/)
|
|
35
|
+
refute_nil action
|
|
36
|
+
|
|
37
|
+
edit = single_edit(action)
|
|
38
|
+
assert_equal "user.valid? && user.save", edit.new_text.strip
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def test_converts_double_pipe_to_or
|
|
42
|
+
source = "a || b\n"
|
|
43
|
+
actions = code_actions_for(source, line: 0)
|
|
44
|
+
action = find_action(actions, /\|\|.*or/)
|
|
45
|
+
refute_nil action
|
|
46
|
+
|
|
47
|
+
edit = single_edit(action)
|
|
48
|
+
assert_equal "a or b", edit.new_text.strip
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def test_converts_or_to_double_pipe
|
|
52
|
+
source = "a or b\n"
|
|
53
|
+
actions = code_actions_for(source, line: 0)
|
|
54
|
+
action = find_action(actions, /or.*\|\|/)
|
|
55
|
+
refute_nil action
|
|
56
|
+
|
|
57
|
+
edit = single_edit(action)
|
|
58
|
+
assert_equal "a || b", edit.new_text.strip
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def test_does_not_raise_on_empty_source
|
|
62
|
+
assert_silent { code_actions_for("", line: 0) }
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
end
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "minitest/autorun"
|
|
4
|
+
require "ruby_lsp/test_helper"
|
|
5
|
+
|
|
6
|
+
module RubyLsp
|
|
7
|
+
module Refactor
|
|
8
|
+
class RaiseListenerTest < Minitest::Test
|
|
9
|
+
include RubyLsp::Refactor::TestHelper
|
|
10
|
+
|
|
11
|
+
def find_action(actions, title)
|
|
12
|
+
actions.find { |a| a.title == title }
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def single_edit(action)
|
|
16
|
+
edits = action.edit.changes.values.flatten
|
|
17
|
+
assert_equal 1, edits.size
|
|
18
|
+
edits.first
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def test_simplifies_raise_runtime_error
|
|
22
|
+
source = "raise RuntimeError, \"something went wrong\"\n"
|
|
23
|
+
actions = code_actions_for(source, line: 0)
|
|
24
|
+
action = find_action(actions, "Simplify raise (remove redundant RuntimeError)")
|
|
25
|
+
refute_nil action
|
|
26
|
+
|
|
27
|
+
edit = single_edit(action)
|
|
28
|
+
assert_equal 'raise "something went wrong"', edit.new_text.strip
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def test_simplifies_fail_runtime_error
|
|
32
|
+
source = "fail RuntimeError, \"oops\"\n"
|
|
33
|
+
actions = code_actions_for(source, line: 0)
|
|
34
|
+
action = find_action(actions, "Simplify raise (remove redundant RuntimeError)")
|
|
35
|
+
refute_nil action
|
|
36
|
+
|
|
37
|
+
edit = single_edit(action)
|
|
38
|
+
assert_equal 'fail "oops"', edit.new_text.strip
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def test_does_not_offer_for_other_exception_classes
|
|
42
|
+
source = "raise ArgumentError, \"bad arg\"\n"
|
|
43
|
+
actions = code_actions_for(source, line: 0)
|
|
44
|
+
assert_nil find_action(actions, "Simplify raise (remove redundant RuntimeError)")
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def test_does_not_offer_for_raise_with_string_only
|
|
48
|
+
source = "raise \"already simple\"\n"
|
|
49
|
+
actions = code_actions_for(source, line: 0)
|
|
50
|
+
assert_nil find_action(actions, "Simplify raise (remove redundant RuntimeError)")
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def test_does_not_offer_for_runtime_error_new
|
|
54
|
+
source = "raise RuntimeError.new(\"msg\")\n"
|
|
55
|
+
actions = code_actions_for(source, line: 0)
|
|
56
|
+
assert_nil find_action(actions, "Simplify raise (remove redundant RuntimeError)")
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def test_does_not_raise_on_empty_source
|
|
60
|
+
assert_silent { code_actions_for("", line: 0) }
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
end
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "minitest/autorun"
|
|
4
|
+
require "ruby_lsp/test_helper"
|
|
5
|
+
|
|
6
|
+
module RubyLsp
|
|
7
|
+
module Refactor
|
|
8
|
+
class RescueListenerTest < Minitest::Test
|
|
9
|
+
include RubyLsp::Refactor::TestHelper
|
|
10
|
+
|
|
11
|
+
def find_action(actions, title)
|
|
12
|
+
actions.find { |a| a.title == title }
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def single_edit(action)
|
|
16
|
+
edits = action.edit.changes.values.flatten
|
|
17
|
+
assert_equal 1, edits.size
|
|
18
|
+
edits.first
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def test_wraps_method_body_in_rescue
|
|
22
|
+
source = <<~RUBY
|
|
23
|
+
def call
|
|
24
|
+
do_thing
|
|
25
|
+
end
|
|
26
|
+
RUBY
|
|
27
|
+
|
|
28
|
+
actions = code_actions_for(source, line: 0)
|
|
29
|
+
action = find_action(actions, "Wrap body in rescue")
|
|
30
|
+
refute_nil action
|
|
31
|
+
|
|
32
|
+
edit = single_edit(action)
|
|
33
|
+
assert_match(/rescue StandardError => e/, edit.new_text)
|
|
34
|
+
assert_match(/do_thing/, edit.new_text)
|
|
35
|
+
assert_match(/raise/, edit.new_text)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def test_preserves_all_body_statements
|
|
39
|
+
source = <<~RUBY
|
|
40
|
+
def process
|
|
41
|
+
step_one
|
|
42
|
+
step_two
|
|
43
|
+
step_three
|
|
44
|
+
end
|
|
45
|
+
RUBY
|
|
46
|
+
|
|
47
|
+
actions = code_actions_for(source, line: 0)
|
|
48
|
+
action = find_action(actions, "Wrap body in rescue")
|
|
49
|
+
refute_nil action
|
|
50
|
+
|
|
51
|
+
edit = single_edit(action)
|
|
52
|
+
assert_match(/step_one/, edit.new_text)
|
|
53
|
+
assert_match(/step_two/, edit.new_text)
|
|
54
|
+
assert_match(/step_three/, edit.new_text)
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def test_does_not_offer_on_empty_method
|
|
58
|
+
source = <<~RUBY
|
|
59
|
+
def noop
|
|
60
|
+
end
|
|
61
|
+
RUBY
|
|
62
|
+
|
|
63
|
+
actions = code_actions_for(source, line: 0)
|
|
64
|
+
assert_nil find_action(actions, "Wrap body in rescue")
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def test_does_not_raise_on_empty_source
|
|
68
|
+
assert_silent { code_actions_for("", line: 0) }
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
end
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "minitest/autorun"
|
|
4
|
+
require "ruby_lsp/test_helper"
|
|
5
|
+
|
|
6
|
+
module RubyLsp
|
|
7
|
+
module Refactor
|
|
8
|
+
class RspecLetListenerTest < Minitest::Test
|
|
9
|
+
include RubyLsp::Refactor::TestHelper
|
|
10
|
+
|
|
11
|
+
def find_action(actions, title)
|
|
12
|
+
actions.find { |a| a.title == title }
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def single_edit(action)
|
|
16
|
+
edits = action.edit.changes.values.flatten
|
|
17
|
+
assert_equal 1, edits.size
|
|
18
|
+
edits.first
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def test_converts_let_to_let_bang
|
|
22
|
+
source = "let(:user) { User.new }\n"
|
|
23
|
+
actions = code_actions_for(source, line: 0)
|
|
24
|
+
action = find_action(actions, "Convert let to let!")
|
|
25
|
+
refute_nil action
|
|
26
|
+
|
|
27
|
+
edit = single_edit(action)
|
|
28
|
+
assert_match(/let!\(:user\)/, edit.new_text)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def test_converts_let_bang_to_let
|
|
32
|
+
source = "let!(:user) { User.new }\n"
|
|
33
|
+
actions = code_actions_for(source, line: 0)
|
|
34
|
+
action = find_action(actions, "Convert let! to let")
|
|
35
|
+
refute_nil action
|
|
36
|
+
|
|
37
|
+
edit = single_edit(action)
|
|
38
|
+
assert_match(/\blet\(:user\)/, edit.new_text)
|
|
39
|
+
refute_match(/let!/, edit.new_text)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def test_does_not_offer_for_non_let_calls
|
|
43
|
+
source = "subject { User.new }\n"
|
|
44
|
+
actions = code_actions_for(source, line: 0)
|
|
45
|
+
assert_nil find_action(actions, "Convert let to let!")
|
|
46
|
+
assert_nil find_action(actions, "Convert let! to let")
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def test_does_not_raise_on_empty_source
|
|
50
|
+
assert_silent { code_actions_for("", line: 0) }
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "minitest/autorun"
|
|
4
|
+
require "ruby_lsp/test_helper"
|
|
5
|
+
|
|
6
|
+
module RubyLsp
|
|
7
|
+
module Refactor
|
|
8
|
+
class StringArrayListenerTest < Minitest::Test
|
|
9
|
+
include RubyLsp::Refactor::TestHelper
|
|
10
|
+
|
|
11
|
+
def find_action(actions, title)
|
|
12
|
+
actions.find { |a| a.title == title }
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def single_edit(action)
|
|
16
|
+
edits = action.edit.changes.values.flatten
|
|
17
|
+
assert_equal 1, edits.size
|
|
18
|
+
edits.first
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def test_converts_bracket_string_array_to_percent_w
|
|
22
|
+
source = "[\"foo\", \"bar\", \"baz\"]\n"
|
|
23
|
+
actions = code_actions_for(source, line: 0)
|
|
24
|
+
action = find_action(actions, "Convert to string array (%w[])")
|
|
25
|
+
refute_nil action
|
|
26
|
+
|
|
27
|
+
edit = single_edit(action)
|
|
28
|
+
assert_equal "%w[foo bar baz]", edit.new_text
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def test_converts_percent_w_to_bracket_array
|
|
32
|
+
source = "%w[foo bar baz]\n"
|
|
33
|
+
actions = code_actions_for(source, line: 0)
|
|
34
|
+
action = find_action(actions, "Convert to bracket array")
|
|
35
|
+
refute_nil action
|
|
36
|
+
|
|
37
|
+
edit = single_edit(action)
|
|
38
|
+
assert_equal '["foo", "bar", "baz"]', edit.new_text
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def test_does_not_offer_percent_w_for_strings_with_spaces
|
|
42
|
+
source = "[\"hello world\", \"foo\"]\n"
|
|
43
|
+
actions = code_actions_for(source, line: 0)
|
|
44
|
+
assert_nil find_action(actions, "Convert to string array (%w[])")
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def test_does_not_offer_percent_w_for_mixed_array
|
|
48
|
+
source = "[\"foo\", 42]\n"
|
|
49
|
+
actions = code_actions_for(source, line: 0)
|
|
50
|
+
assert_nil find_action(actions, "Convert to string array (%w[])")
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def test_does_not_offer_percent_w_for_empty_array
|
|
54
|
+
source = "[]\n"
|
|
55
|
+
actions = code_actions_for(source, line: 0)
|
|
56
|
+
assert_nil find_action(actions, "Convert to string array (%w[])")
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def test_does_not_raise_on_empty_source
|
|
60
|
+
assert_silent { code_actions_for("", line: 0) }
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
end
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "minitest/autorun"
|
|
4
|
+
require "ruby_lsp/test_helper"
|
|
5
|
+
|
|
6
|
+
module RubyLsp
|
|
7
|
+
module Refactor
|
|
8
|
+
class StringFreezeListenerTest < Minitest::Test
|
|
9
|
+
include RubyLsp::Refactor::TestHelper
|
|
10
|
+
|
|
11
|
+
def find_action(actions, title)
|
|
12
|
+
actions.find { |a| a.title == title }
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def single_edit(action)
|
|
16
|
+
edits = action.edit.changes.values.flatten
|
|
17
|
+
assert_equal 1, edits.size
|
|
18
|
+
edits.first
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def test_wraps_string_in_freeze
|
|
22
|
+
source = "\"hello world\"\n"
|
|
23
|
+
actions = code_actions_for(source, line: 0)
|
|
24
|
+
action = find_action(actions, "Wrap in freeze")
|
|
25
|
+
refute_nil action
|
|
26
|
+
|
|
27
|
+
edit = single_edit(action)
|
|
28
|
+
assert_equal '"hello world".freeze', edit.new_text
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def test_removes_freeze_from_frozen_string
|
|
32
|
+
source = "\"hello world\".freeze\n"
|
|
33
|
+
actions = code_actions_for(source, line: 0)
|
|
34
|
+
action = find_action(actions, "Remove freeze")
|
|
35
|
+
refute_nil action
|
|
36
|
+
|
|
37
|
+
edit = single_edit(action)
|
|
38
|
+
assert_equal '"hello world"', edit.new_text
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def test_does_not_offer_wrap_when_already_frozen
|
|
42
|
+
source = "\"hello\".freeze\n"
|
|
43
|
+
actions = code_actions_for(source, line: 0)
|
|
44
|
+
assert_nil find_action(actions, "Wrap in freeze")
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def test_does_not_raise_on_empty_source
|
|
48
|
+
assert_silent { code_actions_for("", line: 0) }
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
@@ -47,13 +47,13 @@ module RubyLsp
|
|
|
47
47
|
# ---------------------------------------------------------------------------
|
|
48
48
|
|
|
49
49
|
def test_does_not_offer_action_for_already_double_quoted_string
|
|
50
|
-
source =
|
|
50
|
+
source = "\"hello world\"\n"
|
|
51
51
|
actions = code_actions_for(source, line: 0)
|
|
52
52
|
assert_nil find_action(actions, "Convert to interpolated string")
|
|
53
53
|
end
|
|
54
54
|
|
|
55
55
|
def test_does_not_offer_action_for_interpolated_string
|
|
56
|
-
source =
|
|
56
|
+
source = "\"hello #{name}\"\n"
|
|
57
57
|
actions = code_actions_for(source, line: 0)
|
|
58
58
|
assert_nil find_action(actions, "Convert to interpolated string")
|
|
59
59
|
end
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "minitest/autorun"
|
|
4
|
+
require "ruby_lsp/test_helper"
|
|
5
|
+
|
|
6
|
+
module RubyLsp
|
|
7
|
+
module Refactor
|
|
8
|
+
class SuperListenerTest < Minitest::Test
|
|
9
|
+
include RubyLsp::Refactor::TestHelper
|
|
10
|
+
|
|
11
|
+
def find_action(actions, title_pattern)
|
|
12
|
+
actions.find { |a| a.title.match?(title_pattern) }
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def single_edit(action)
|
|
16
|
+
edits = action.edit.changes.values.flatten
|
|
17
|
+
assert_equal 1, edits.size
|
|
18
|
+
edits.first
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def test_converts_bare_super_to_explicit
|
|
22
|
+
source = <<~RUBY
|
|
23
|
+
def initialize(name, age)
|
|
24
|
+
super
|
|
25
|
+
end
|
|
26
|
+
RUBY
|
|
27
|
+
|
|
28
|
+
actions = code_actions_for(source, line: 1)
|
|
29
|
+
action = find_action(actions, /explicit super/)
|
|
30
|
+
refute_nil action
|
|
31
|
+
|
|
32
|
+
edit = single_edit(action)
|
|
33
|
+
assert_equal "super(name, age)", edit.new_text.strip
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def test_title_includes_param_names
|
|
37
|
+
source = <<~RUBY
|
|
38
|
+
def initialize(name, age)
|
|
39
|
+
super
|
|
40
|
+
end
|
|
41
|
+
RUBY
|
|
42
|
+
|
|
43
|
+
actions = code_actions_for(source, line: 1)
|
|
44
|
+
action = find_action(actions, /explicit super/)
|
|
45
|
+
refute_nil action
|
|
46
|
+
assert_match(/name, age/, action.title)
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def test_does_not_offer_when_no_params
|
|
50
|
+
source = <<~RUBY
|
|
51
|
+
def initialize
|
|
52
|
+
super
|
|
53
|
+
end
|
|
54
|
+
RUBY
|
|
55
|
+
|
|
56
|
+
actions = code_actions_for(source, line: 1)
|
|
57
|
+
assert_nil find_action(actions, /explicit super/)
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def test_does_not_raise_on_empty_source
|
|
61
|
+
assert_silent { code_actions_for("", line: 0) }
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ruby-lsp-refactor
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Aboobacker MK
|
|
@@ -10,39 +10,39 @@ cert_chain: []
|
|
|
10
10
|
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
12
|
- !ruby/object:Gem::Dependency
|
|
13
|
-
name:
|
|
13
|
+
name: prism
|
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
|
15
15
|
requirements:
|
|
16
16
|
- - ">="
|
|
17
17
|
- !ruby/object:Gem::Version
|
|
18
|
-
version: '0.
|
|
19
|
-
- - "<"
|
|
20
|
-
- !ruby/object:Gem::Version
|
|
21
|
-
version: '2'
|
|
18
|
+
version: '0.29'
|
|
22
19
|
type: :runtime
|
|
23
20
|
prerelease: false
|
|
24
21
|
version_requirements: !ruby/object:Gem::Requirement
|
|
25
22
|
requirements:
|
|
26
23
|
- - ">="
|
|
27
24
|
- !ruby/object:Gem::Version
|
|
28
|
-
version: '0.
|
|
29
|
-
- - "<"
|
|
30
|
-
- !ruby/object:Gem::Version
|
|
31
|
-
version: '2'
|
|
25
|
+
version: '0.29'
|
|
32
26
|
- !ruby/object:Gem::Dependency
|
|
33
|
-
name:
|
|
27
|
+
name: ruby-lsp
|
|
34
28
|
requirement: !ruby/object:Gem::Requirement
|
|
35
29
|
requirements:
|
|
36
30
|
- - ">="
|
|
37
31
|
- !ruby/object:Gem::Version
|
|
38
|
-
version: '0.
|
|
32
|
+
version: '0.17'
|
|
33
|
+
- - "<"
|
|
34
|
+
- !ruby/object:Gem::Version
|
|
35
|
+
version: '2'
|
|
39
36
|
type: :runtime
|
|
40
37
|
prerelease: false
|
|
41
38
|
version_requirements: !ruby/object:Gem::Requirement
|
|
42
39
|
requirements:
|
|
43
40
|
- - ">="
|
|
44
41
|
- !ruby/object:Gem::Version
|
|
45
|
-
version: '0.
|
|
42
|
+
version: '0.17'
|
|
43
|
+
- - "<"
|
|
44
|
+
- !ruby/object:Gem::Version
|
|
45
|
+
version: '2'
|
|
46
46
|
- !ruby/object:Gem::Dependency
|
|
47
47
|
name: minitest
|
|
48
48
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -94,6 +94,7 @@ executables: []
|
|
|
94
94
|
extensions: []
|
|
95
95
|
extra_rdoc_files: []
|
|
96
96
|
files:
|
|
97
|
+
- ".rubocop_todo.yml"
|
|
97
98
|
- CHANGELOG.md
|
|
98
99
|
- LICENSE.txt
|
|
99
100
|
- README.md
|
|
@@ -101,20 +102,42 @@ files:
|
|
|
101
102
|
- lib/ruby/lsp/refactor.rb
|
|
102
103
|
- lib/ruby/lsp/refactor/version.rb
|
|
103
104
|
- lib/ruby_lsp/ruby_lsp_refactor/addon.rb
|
|
105
|
+
- lib/ruby_lsp/ruby_lsp_refactor/listeners/accessor_listener.rb
|
|
104
106
|
- lib/ruby_lsp/ruby_lsp_refactor/listeners/array_listener.rb
|
|
107
|
+
- lib/ruby_lsp/ruby_lsp_refactor/listeners/block_style_listener.rb
|
|
105
108
|
- lib/ruby_lsp/ruby_lsp_refactor/listeners/conditional_listener.rb
|
|
109
|
+
- lib/ruby_lsp/ruby_lsp_refactor/listeners/constant_listener.rb
|
|
110
|
+
- lib/ruby_lsp/ruby_lsp_refactor/listeners/enumerable_listener.rb
|
|
106
111
|
- lib/ruby_lsp/ruby_lsp_refactor/listeners/hash_listener.rb
|
|
112
|
+
- lib/ruby_lsp/ruby_lsp_refactor/listeners/logical_operator_listener.rb
|
|
107
113
|
- lib/ruby_lsp/ruby_lsp_refactor/listeners/method_listener.rb
|
|
114
|
+
- lib/ruby_lsp/ruby_lsp_refactor/listeners/raise_listener.rb
|
|
115
|
+
- lib/ruby_lsp/ruby_lsp_refactor/listeners/rescue_listener.rb
|
|
116
|
+
- lib/ruby_lsp/ruby_lsp_refactor/listeners/rspec_let_listener.rb
|
|
117
|
+
- lib/ruby_lsp/ruby_lsp_refactor/listeners/string_array_listener.rb
|
|
118
|
+
- lib/ruby_lsp/ruby_lsp_refactor/listeners/string_freeze_listener.rb
|
|
108
119
|
- lib/ruby_lsp/ruby_lsp_refactor/listeners/string_listener.rb
|
|
120
|
+
- lib/ruby_lsp/ruby_lsp_refactor/listeners/super_listener.rb
|
|
109
121
|
- lib/ruby_lsp/ruby_lsp_refactor/listeners/variable_listener.rb
|
|
110
122
|
- lib/ruby_lsp/ruby_lsp_refactor/support/node_helpers.rb
|
|
111
123
|
- lib/ruby_lsp/test_helper.rb
|
|
112
124
|
- sig/ruby/lsp/refactor.rbs
|
|
125
|
+
- test/ruby_lsp_refactor/accessor_listener_test.rb
|
|
113
126
|
- test/ruby_lsp_refactor/array_listener_test.rb
|
|
127
|
+
- test/ruby_lsp_refactor/block_style_listener_test.rb
|
|
114
128
|
- test/ruby_lsp_refactor/conditional_listener_test.rb
|
|
129
|
+
- test/ruby_lsp_refactor/constant_listener_test.rb
|
|
130
|
+
- test/ruby_lsp_refactor/enumerable_listener_test.rb
|
|
115
131
|
- test/ruby_lsp_refactor/hash_listener_test.rb
|
|
132
|
+
- test/ruby_lsp_refactor/logical_operator_listener_test.rb
|
|
116
133
|
- test/ruby_lsp_refactor/method_listener_test.rb
|
|
134
|
+
- test/ruby_lsp_refactor/raise_listener_test.rb
|
|
135
|
+
- test/ruby_lsp_refactor/rescue_listener_test.rb
|
|
136
|
+
- test/ruby_lsp_refactor/rspec_let_listener_test.rb
|
|
137
|
+
- test/ruby_lsp_refactor/string_array_listener_test.rb
|
|
138
|
+
- test/ruby_lsp_refactor/string_freeze_listener_test.rb
|
|
117
139
|
- test/ruby_lsp_refactor/string_listener_test.rb
|
|
140
|
+
- test/ruby_lsp_refactor/super_listener_test.rb
|
|
118
141
|
- test/ruby_lsp_refactor/variable_listener_test.rb
|
|
119
142
|
homepage: https://github.com/tachyons/ruby-lsp-refactor
|
|
120
143
|
licenses:
|