ruby-lsp-cell 0.1.3 → 0.2.0
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.yml +4 -1
- data/CHANGELOG.md +5 -1
- data/README.md +2 -0
- data/example-ruby-lsp.gif +0 -0
- data/lib/ruby_lsp/cell/version.rb +1 -1
- data/lib/ruby_lsp/ruby-lsp-cell/addon.rb +21 -25
- data/lib/ruby_lsp/ruby-lsp-cell/code_lens.rb +26 -33
- data/tools/cell_fake.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: be16f412b1af125c90034244af33444ce8cb494d3cf442b59159cad19ba4f592
|
4
|
+
data.tar.gz: 80db8e5cbf2a28037dd5d44a50d822efc8a65783587573667818204db9cc6294
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fb9a1b6e99c6676aa57732da0c06fb98ba8176ee4252e00c07e3c7206c1e2bdfd2ed65d8a558130233dfb007eb49677cb77089bf366277b6cc75264d3327fa6b
|
7
|
+
data.tar.gz: 79b318cf629b1d2d9b9b7eae5607692c88cb902ff9978494b4c6781dd5fb854b40bcd9c616e53fb56bc66dd6ac80548be6c65290b9d694d0607779feccb2af92
|
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
## [0.2.0] - 2025-07-21
|
2
|
+
|
3
|
+
- Add compatibility with Ruby LSP 0.26.0
|
4
|
+
|
1
5
|
## [0.1.1] - 2025-06-09
|
2
6
|
- Add compatibility with Ruby LSP 0.24.1
|
3
7
|
|
@@ -6,4 +10,4 @@
|
|
6
10
|
- Start of the main project
|
7
11
|
|
8
12
|
## [0.0.1] - 2024-06-22
|
9
|
-
- Add compatibility with Ruby LSP 0.17.17
|
13
|
+
- Add compatibility with Ruby LSP 0.17.17
|
data/README.md
CHANGED
@@ -44,6 +44,8 @@ Or install it yourself as:
|
|
44
44
|
* **Top of the class** – lets you jump directly to the default template (`app/cells/user/show.erb` unless you changed `defaultViewFileName` in `.vscode/settings.json`).
|
45
45
|
* **Any instance method that calls `render`** – jumps to the template rendered by that method.
|
46
46
|
|
47
|
+

|
48
|
+
|
47
49
|
## Development
|
48
50
|
|
49
51
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `bundle exec rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
Binary file
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# typed:
|
1
|
+
# typed: true
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
4
|
require "ruby_lsp/addon"
|
@@ -7,27 +7,25 @@ require "ruby_lsp/internal"
|
|
7
7
|
require_relative "code_lens"
|
8
8
|
require_relative "../cell/version"
|
9
9
|
|
10
|
-
RubyLsp::Addon.depend_on_ruby_lsp!("~> 0.
|
10
|
+
RubyLsp::Addon.depend_on_ruby_lsp!("~> 0.26.0")
|
11
11
|
|
12
12
|
module RubyLsp
|
13
13
|
module Cell
|
14
|
-
#
|
15
14
|
# Addon for Ruby LSP Cell Context
|
16
15
|
#
|
17
16
|
class Addon < ::RubyLsp::Addon
|
18
|
-
|
19
|
-
|
20
|
-
sig { void }
|
17
|
+
#: -> void
|
21
18
|
def initialize
|
22
19
|
super
|
23
|
-
@global_state =
|
24
|
-
@message_queue =
|
25
|
-
@settings =
|
26
|
-
@enabled =
|
27
|
-
@default_view_filename =
|
20
|
+
@global_state = nil #: RubyLsp::GlobalState?
|
21
|
+
@message_queue = nil #: Thread::Queue?
|
22
|
+
@settings = nil #: Hash[Symbol, untyped]?
|
23
|
+
@enabled = nil #: bool?
|
24
|
+
@default_view_filename = nil #: String?
|
28
25
|
end
|
29
26
|
|
30
|
-
|
27
|
+
# @override
|
28
|
+
#: (RubyLsp::GlobalState global_state, Thread::Queue message_queue) -> void
|
31
29
|
def activate(global_state, message_queue)
|
32
30
|
return unless are_required_libraries_installed?
|
33
31
|
|
@@ -38,33 +36,31 @@ module RubyLsp
|
|
38
36
|
@default_view_filename = @settings.fetch(:defaultViewFileName, "show.erb")
|
39
37
|
end
|
40
38
|
|
41
|
-
|
39
|
+
# @override
|
40
|
+
#: -> void
|
42
41
|
def deactivate; end
|
43
42
|
|
44
|
-
|
43
|
+
# @override
|
44
|
+
#: -> String
|
45
45
|
def name
|
46
46
|
"Ruby LSP Cell"
|
47
47
|
end
|
48
48
|
|
49
|
-
|
50
|
-
|
51
|
-
response_builder: ResponseBuilders::CollectionResponseBuilder,
|
52
|
-
uri: URI::Generic,
|
53
|
-
dispatcher: Prism::Dispatcher,
|
54
|
-
).void
|
55
|
-
end
|
49
|
+
# @override
|
50
|
+
#: (RubyLsp::ResponseBuilders::CollectionResponseBuilder[untyped] response_builder, URI::Generic uri, Prism::Dispatcher dispatcher) -> void
|
56
51
|
def create_code_lens_listener(response_builder, uri, dispatcher)
|
57
52
|
CodeLens.new(
|
58
53
|
response_builder,
|
59
54
|
uri,
|
60
55
|
dispatcher,
|
61
|
-
|
62
|
-
enabled:
|
63
|
-
default_view_filename:
|
56
|
+
@global_state, #: as !nil
|
57
|
+
enabled: @enabled, #: as !nil
|
58
|
+
default_view_filename: @default_view_filename, #: as !nil
|
64
59
|
)
|
65
60
|
end
|
66
61
|
|
67
|
-
|
62
|
+
# @override
|
63
|
+
#: -> String
|
68
64
|
def version
|
69
65
|
RubyLsp::Cell::VERSION
|
70
66
|
end
|
@@ -1,38 +1,31 @@
|
|
1
|
-
# typed:
|
1
|
+
# typed: false
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
4
|
module RubyLsp
|
5
5
|
module Cell
|
6
6
|
class CodeLens
|
7
|
-
extend T::Sig
|
8
|
-
extend T::Generic
|
9
|
-
|
10
7
|
include ::RubyLsp::Requests::Support::Common
|
11
8
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
enabled: T::Boolean,
|
21
|
-
default_view_filename: String,
|
22
|
-
).void
|
23
|
-
end
|
9
|
+
#: (
|
10
|
+
#| RubyLsp::ResponseBuilders::CollectionResponseBuilder[untyped] response_builder,
|
11
|
+
#| URI::Generic uri,
|
12
|
+
#| Prism::Dispatcher dispatcher,
|
13
|
+
#| RubyLsp::GlobalState global_state,
|
14
|
+
#| enabled: bool,
|
15
|
+
#| default_view_filename: String
|
16
|
+
#| ) -> void
|
24
17
|
def initialize(response_builder, uri, dispatcher, global_state, enabled:, default_view_filename:)
|
25
18
|
return unless enabled
|
26
19
|
|
27
20
|
@response_builder = response_builder
|
28
21
|
@global_state = global_state
|
29
22
|
|
30
|
-
@path =
|
31
|
-
@class_name =
|
32
|
-
@pattern =
|
33
|
-
@default_view_filename =
|
34
|
-
@in_cell_class =
|
35
|
-
@nesting =
|
23
|
+
@path = uri.to_standardized_path #: String
|
24
|
+
@class_name = ""
|
25
|
+
@pattern = "_cell"
|
26
|
+
@default_view_filename = default_view_filename
|
27
|
+
@in_cell_class = false
|
28
|
+
@nesting = [] #: Array[String]
|
36
29
|
dispatcher.register(
|
37
30
|
self,
|
38
31
|
:on_module_node_enter,
|
@@ -43,17 +36,17 @@ module RubyLsp
|
|
43
36
|
)
|
44
37
|
end
|
45
38
|
|
46
|
-
|
39
|
+
#: (Prism::ModuleNode node) -> void
|
47
40
|
def on_module_node_enter(node)
|
48
41
|
@nesting.push(node.constant_path.slice)
|
49
42
|
end
|
50
43
|
|
51
|
-
|
44
|
+
#: (Prism::ModuleNode node) -> void
|
52
45
|
def on_module_node_leave(node)
|
53
46
|
@nesting.pop
|
54
47
|
end
|
55
48
|
|
56
|
-
|
49
|
+
#: (Prism::ClassNode node) -> void
|
57
50
|
def on_class_node_enter(node)
|
58
51
|
@nesting.push(node.constant_path.slice)
|
59
52
|
class_name = @nesting.join("::")
|
@@ -64,13 +57,13 @@ module RubyLsp
|
|
64
57
|
add_default_goto_code_lens(node)
|
65
58
|
end
|
66
59
|
|
67
|
-
|
60
|
+
#: (Prism::ClassNode node) -> void
|
68
61
|
def on_class_node_leave(node)
|
69
62
|
@nesting.pop
|
70
63
|
@in_cell_class = false
|
71
64
|
end
|
72
65
|
|
73
|
-
|
66
|
+
#: (Prism::DefNode node) -> void
|
74
67
|
def on_def_node_enter(node)
|
75
68
|
return unless @in_cell_class
|
76
69
|
return unless contains_render_call?(node.body)
|
@@ -80,7 +73,7 @@ module RubyLsp
|
|
80
73
|
|
81
74
|
private
|
82
75
|
|
83
|
-
|
76
|
+
#: (Prism::Node node) -> void
|
84
77
|
def add_default_goto_code_lens(node)
|
85
78
|
erb_filename = remove_last_pattern_in_string @default_view_filename, ".erb"
|
86
79
|
uri = compute_erb_view_path @default_view_filename
|
@@ -88,7 +81,7 @@ module RubyLsp
|
|
88
81
|
create_go_to_file_code_lens(node, erb_filename, uri)
|
89
82
|
end
|
90
83
|
|
91
|
-
|
84
|
+
#: (Prism::Node? node) -> bool
|
92
85
|
def contains_render_call?(node)
|
93
86
|
return false if node.nil?
|
94
87
|
|
@@ -99,18 +92,18 @@ module RubyLsp
|
|
99
92
|
node.child_nodes.any? { |child| contains_render_call?(child) }
|
100
93
|
end
|
101
94
|
|
102
|
-
|
95
|
+
#: (Prism::Node node, String name) -> void
|
103
96
|
def add_function_goto_code_lens(node, name)
|
104
97
|
uri = compute_erb_view_path("#{name}.erb")
|
105
98
|
create_go_to_file_code_lens(node, name, uri)
|
106
99
|
end
|
107
100
|
|
108
|
-
|
101
|
+
#: (String string, String pattern) -> String
|
109
102
|
def remove_last_pattern_in_string(string, pattern)
|
110
103
|
string.sub(/#{pattern}$/, "")
|
111
104
|
end
|
112
105
|
|
113
|
-
|
106
|
+
#: (String name) -> String
|
114
107
|
def compute_erb_view_path(name)
|
115
108
|
escaped_pattern = Regexp.escape(@pattern)
|
116
109
|
base_path = @path.sub(/#{escaped_pattern}\.rb$/, "")
|
@@ -120,7 +113,7 @@ module RubyLsp
|
|
120
113
|
uri
|
121
114
|
end
|
122
115
|
|
123
|
-
|
116
|
+
#: (Prism::Node node, String name, String uri) -> void
|
124
117
|
def create_go_to_file_code_lens(node, name, uri)
|
125
118
|
@response_builder << create_code_lens(
|
126
119
|
node,
|
data/tools/cell_fake.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-lsp-cell
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Edgar Guzmán
|
@@ -24,6 +24,7 @@ files:
|
|
24
24
|
- LICENSE.txt
|
25
25
|
- README.md
|
26
26
|
- Rakefile
|
27
|
+
- example-ruby-lsp.gif
|
27
28
|
- lib/ruby_lsp/cell.rb
|
28
29
|
- lib/ruby_lsp/cell/version.rb
|
29
30
|
- lib/ruby_lsp/ruby-lsp-cell/addon.rb
|