ruby-lsp-rails 0.2.7 → 0.2.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d9abe40b8b01b5f0e7e81a3831b3da7fa57902d64f17cb0ce3a950d043d895ab
4
- data.tar.gz: 02b60ff2b040617a25fea20d715066a17092459532f56dc08a4350997e1369bc
3
+ metadata.gz: 54789b1f5da58f025ec88cfcff5cf95f800ae68af9dc409d31a4cdf6307e8286
4
+ data.tar.gz: c03bd0623133606a7ba2290198939fb7de0071bdcc2e52bea30efdb3ed1fc7e2
5
5
  SHA512:
6
- metadata.gz: e76db2c3f6ea300e1b7a935b958a60b18a322e5039f518a0ccbc4efe2dbe7c69f65401987c0969d9fff479e3526831600a24788f477cbd19d3a2d528dc63a293
7
- data.tar.gz: 1556932fe8c67752607b15e2520c2f71c0c88c2e1a005c78c1c72b31e49a2efac9e38a9da499bb91478ea8f8386661a269c18ab300809823d80c519cf517afa1
6
+ metadata.gz: 7426ceebeabe03877d10b49fcb05b88c435d968fdcfd300d898768289aff80dfac7936c604d43f46de58eaa1649c5047ae9f7f0edbdb708e86b260cb52827591
7
+ data.tar.gz: 52c94c5e2c2fe0c37e1fd3e807805ad2b80d5749903366a4dc41ff73885b150f8db03dd2a2154a9364e63b0eb36bf065cf0795eb5a19b801c201e8d5e93d40df
data/README.md CHANGED
@@ -48,8 +48,9 @@ See the [documentation](https://shopify.github.io/ruby-lsp-rails) for more in-de
48
48
  1. Open a test which inherits from `ActiveSupport::TestCase` or one of its descendants, such as `ActionDispatch::IntegrationTest`.
49
49
  2. Click on the "Run", "Run in Terminal" or "Debug" code lens which appears above the test class, or an individual test.
50
50
 
51
- Note: When using the Test Explorer view, if your code contains a statement to pause execution (e.g. `debugger`) it will
52
- cause the test runner to hang.
51
+ > [!NOTE]
52
+ > When using the Test Explorer view, if your code contains a statement to pause execution (e.g. `debugger`) it will
53
+ > cause the test runner to hang.
53
54
 
54
55
  ## How It Works
55
56
 
@@ -60,8 +61,7 @@ This gem consists of two components that enable enhanced Rails functionality in
60
61
 
61
62
  This is why the Rails server needs to be running for some features to work.
62
63
 
63
- > **Note**
64
- >
64
+ > [!NOTE]
65
65
  > There is no need to restart the Ruby LSP every time the Rails server is booted.
66
66
  > If the server is shut down, the extra features will temporarily disappear and reappear once the server is running again.
67
67
 
@@ -17,8 +17,8 @@ module RubyLsp
17
17
  @client ||= T.let(RailsClient.new, T.nilable(RailsClient))
18
18
  end
19
19
 
20
- sig { override.void }
21
- def activate
20
+ sig { override.params(message_queue: Thread::Queue).void }
21
+ def activate(message_queue)
22
22
  client.check_if_server_is_running!
23
23
  end
24
24
 
@@ -30,11 +30,10 @@ module RubyLsp
30
30
  override.params(
31
31
  uri: URI::Generic,
32
32
  dispatcher: Prism::Dispatcher,
33
- message_queue: Thread::Queue,
34
33
  ).returns(T.nilable(Listener[T::Array[Interface::CodeLens]]))
35
34
  end
36
- def create_code_lens_listener(uri, dispatcher, message_queue)
37
- CodeLens.new(uri, dispatcher, message_queue)
35
+ def create_code_lens_listener(uri, dispatcher)
36
+ CodeLens.new(uri, dispatcher)
38
37
  end
39
38
 
40
39
  sig do
@@ -42,11 +41,10 @@ module RubyLsp
42
41
  nesting: T::Array[String],
43
42
  index: RubyIndexer::Index,
44
43
  dispatcher: Prism::Dispatcher,
45
- message_queue: Thread::Queue,
46
44
  ).returns(T.nilable(Listener[T.nilable(Interface::Hover)]))
47
45
  end
48
- def create_hover_listener(nesting, index, dispatcher, message_queue)
49
- Hover.new(client, nesting, index, dispatcher, message_queue)
46
+ def create_hover_listener(nesting, index, dispatcher)
47
+ Hover.new(client, nesting, index, dispatcher)
50
48
  end
51
49
 
52
50
  sig { override.returns(String) }
@@ -42,13 +42,16 @@ module RubyLsp
42
42
  sig { override.returns(ResponseType) }
43
43
  attr_reader :_response
44
44
 
45
- sig { params(uri: URI::Generic, dispatcher: Prism::Dispatcher, message_queue: Thread::Queue).void }
46
- def initialize(uri, dispatcher, message_queue)
45
+ sig { params(uri: URI::Generic, dispatcher: Prism::Dispatcher).void }
46
+ def initialize(uri, dispatcher)
47
47
  @_response = T.let([], ResponseType)
48
48
  @path = T.let(uri.to_standardized_path, T.nilable(String))
49
- dispatcher.register(self, :on_call_node_enter, :on_class_node_enter, :on_def_node_enter)
49
+ @group_id = T.let(1, Integer)
50
+ @group_id_stack = T.let([], T::Array[Integer])
50
51
 
51
- super(dispatcher, message_queue)
52
+ dispatcher.register(self, :on_call_node_enter, :on_class_node_enter, :on_def_node_enter, :on_class_node_leave)
53
+
54
+ super(dispatcher)
52
55
  end
53
56
 
54
57
  sig { params(node: Prism::CallNode).void }
@@ -62,13 +65,11 @@ module RubyLsp
62
65
  first_argument = arguments.first
63
66
 
64
67
  content = case first_argument
65
- when Prism::StringConcatNode
66
- left = first_argument.left
67
- right = first_argument.right
68
- # We only support two lines of concatenation on test names
69
- if left.is_a?(Prism::StringNode) &&
70
- right.is_a?(Prism::StringNode)
71
- left.content + right.content
68
+ when Prism::InterpolatedStringNode
69
+ parts = first_argument.parts
70
+
71
+ if parts.all? { |part| part.is_a?(Prism::StringNode) }
72
+ T.cast(parts, T::Array[Prism::StringNode]).map(&:content).join
72
73
  end
73
74
  when Prism::StringNode
74
75
  first_argument.content
@@ -99,6 +100,14 @@ module RubyLsp
99
100
  command = "#{BASE_COMMAND} #{@path}"
100
101
  add_test_code_lens(node, name: class_name, command: command, kind: :group)
101
102
  end
103
+
104
+ @group_id_stack.push(@group_id)
105
+ @group_id += 1
106
+ end
107
+
108
+ sig { params(node: Prism::ClassNode).void }
109
+ def on_class_node_leave(node)
110
+ @group_id_stack.pop
102
111
  end
103
112
 
104
113
  private
@@ -119,12 +128,15 @@ module RubyLsp
119
128
  },
120
129
  ]
121
130
 
131
+ grouping_data = { group_id: @group_id_stack.last, kind: kind }
132
+ grouping_data[:id] = @group_id if kind == :group
133
+
122
134
  @_response << create_code_lens(
123
135
  node,
124
136
  title: "Run",
125
137
  command_name: "rubyLsp.runTest",
126
138
  arguments: arguments,
127
- data: { type: "test", kind: kind },
139
+ data: { type: "test", **grouping_data },
128
140
  )
129
141
 
130
142
  @_response << create_code_lens(
@@ -132,7 +144,7 @@ module RubyLsp
132
144
  title: "Run In Terminal",
133
145
  command_name: "rubyLsp.runTestInTerminal",
134
146
  arguments: arguments,
135
- data: { type: "test_in_terminal", kind: kind },
147
+ data: { type: "test_in_terminal", **grouping_data },
136
148
  )
137
149
 
138
150
  @_response << create_code_lens(
@@ -140,7 +152,7 @@ module RubyLsp
140
152
  title: "Debug",
141
153
  command_name: "rubyLsp.debugTest",
142
154
  arguments: arguments,
143
- data: { type: "debug", kind: kind },
155
+ data: { type: "debug", **grouping_data },
144
156
  )
145
157
  end
146
158
  end
@@ -31,11 +31,10 @@ module RubyLsp
31
31
  nesting: T::Array[String],
32
32
  index: RubyIndexer::Index,
33
33
  dispatcher: Prism::Dispatcher,
34
- message_queue: Thread::Queue,
35
34
  ).void
36
35
  end
37
- def initialize(client, nesting, index, dispatcher, message_queue)
38
- super(dispatcher, message_queue)
36
+ def initialize(client, nesting, index, dispatcher)
37
+ super(dispatcher)
39
38
 
40
39
  @_response = T.let(nil, ResponseType)
41
40
  @client = client
@@ -12,15 +12,13 @@ module RubyLsp
12
12
 
13
13
  initializer "ruby_lsp_rails.setup" do |_app|
14
14
  config.after_initialize do |app|
15
- unless config.ruby_lsp_rails.server == false
15
+ # If we start the app with `bin/rails console` then `Rails::Server` is not defined.
16
+ if defined?(::Rails::Server) && config.ruby_lsp_rails.server
16
17
  app.routes.prepend do
17
18
  T.bind(self, ActionDispatch::Routing::Mapper)
18
19
  mount(RackApp.new => RackApp::BASE_PATH)
19
20
  end
20
- end
21
21
 
22
- # If we start the app with `bin/rails console` then `Rails::Server` is not defined.
23
- if defined?(::Rails::Server)
24
22
  ssl_enable, host, port = ::Rails::Server::Options.new.parse!(ARGV).values_at(:SSLEnable, :Host, :Port)
25
23
  app_uri = "#{ssl_enable ? "https" : "http"}://#{host}:#{port}"
26
24
  app_uri_path = ::Rails.root.join("tmp", "app_uri.txt")
@@ -3,6 +3,6 @@
3
3
 
4
4
  module RubyLsp
5
5
  module Rails
6
- VERSION = "0.2.7"
6
+ VERSION = "0.2.9"
7
7
  end
8
8
  end
metadata CHANGED
@@ -1,17 +1,45 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-lsp-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.7
4
+ version: 0.2.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shopify
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-10-19 00:00:00.000000000 Z
11
+ date: 2024-01-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: rails
14
+ name: actionpack
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '6.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '6.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: activerecord
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '6.0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '6.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: railties
15
43
  requirement: !ruby/object:Gem::Requirement
16
44
  requirements:
17
45
  - - ">="
@@ -30,20 +58,20 @@ dependencies:
30
58
  requirements:
31
59
  - - ">="
32
60
  - !ruby/object:Gem::Version
33
- version: 0.12.0
61
+ version: 0.13.0
34
62
  - - "<"
35
63
  - !ruby/object:Gem::Version
36
- version: 0.13.0
64
+ version: 0.14.0
37
65
  type: :runtime
38
66
  prerelease: false
39
67
  version_requirements: !ruby/object:Gem::Requirement
40
68
  requirements:
41
69
  - - ">="
42
70
  - !ruby/object:Gem::Version
43
- version: 0.12.0
71
+ version: 0.13.0
44
72
  - - "<"
45
73
  - !ruby/object:Gem::Version
46
- version: 0.13.0
74
+ version: 0.14.0
47
75
  - !ruby/object:Gem::Dependency
48
76
  name: sorbet-runtime
49
77
  requirement: !ruby/object:Gem::Requirement
@@ -101,7 +129,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
101
129
  - !ruby/object:Gem::Version
102
130
  version: '0'
103
131
  requirements: []
104
- rubygems_version: 3.4.21
132
+ rubygems_version: 3.5.4
105
133
  signing_key:
106
134
  specification_version: 4
107
135
  summary: A Ruby LSP addon for Rails