ruby-lsp 0.26.5 → 0.26.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1c0285974bdf15d052431c1401f320645f57d8bd186ce9899dafc53f11da269a
4
- data.tar.gz: d17e63e0b0db476033d2dfcaec8e40b4131f97cde55c7ade2cd2977ead23dc15
3
+ metadata.gz: ce859aba34e036ede0a47740d7a1beb65ed4680d58bf95fa17ac85e7c74e8560
4
+ data.tar.gz: 49e26820d59a101fb64bbef651741225f4670b892ce7f6317eb7566389e62f8c
5
5
  SHA512:
6
- metadata.gz: 26f63dc15bacf617c683dbb7b55fbf1eee1d2f8051b207a27cead0479b475c16d9cb31fbee3fc180f3c054cfd6754c2e5427ec1fa7d4330a17ff3a0ccd9c5f92
7
- data.tar.gz: 1717199121bee0e9e72dc7bac4ba1779cbed7d4480f7f58bf046b9a3ac8c752c34fe4584eadcf45f98437bbdfb5a3ebcad36cf6951318cf4c63ae6fb84e5b41e
6
+ metadata.gz: 7a5dc4ad02c3e8fc462a08fc059e84039b2d63b39e066a46aedfa724837161941a92a8fd198f645818de819a7140e8abe576bc3a770fe355cab4f689ef9d568e
7
+ data.tar.gz: 2e7fa7e3d5e409c91fc4e3a05d1c15ea4b3bbabf41e2edd4078acb80e9817e1436b50a0a6656f1c46e7e6eb6d4f19f8b499cb89dc8aa761e7984bbad94cb5263
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.26.5
1
+ 0.26.6
@@ -227,7 +227,7 @@ module RubyIndexer
227
227
  others.uniq!
228
228
  others.map!(&:name)
229
229
 
230
- excluded.each do |dependency|
230
+ transitive_excluded = excluded.each_with_object([]) do |dependency, acc|
231
231
  next unless dependency.runtime?
232
232
 
233
233
  spec = dependency.to_spec
@@ -236,7 +236,7 @@ module RubyIndexer
236
236
  spec.dependencies.each do |transitive_dependency|
237
237
  next if others.include?(transitive_dependency.name)
238
238
 
239
- excluded << transitive_dependency
239
+ acc << transitive_dependency
240
240
  end
241
241
  rescue Gem::MissingSpecError
242
242
  # If a gem is scoped only to some specific platform, then its dependencies may not be installed either, but they
@@ -244,6 +244,7 @@ module RubyIndexer
244
244
  # just ignore if they're missing
245
245
  end
246
246
 
247
+ excluded.concat(transitive_excluded)
247
248
  excluded.uniq!
248
249
  excluded.map(&:name)
249
250
  rescue Bundler::GemfileNotFound
@@ -31,6 +31,10 @@ module RubyLsp
31
31
 
32
32
  FOUR_HOURS = 4 * 60 * 60 #: Integer
33
33
 
34
+ # Gems that should be kept up to date in the composed bundle. When updating, any of these gems that are not
35
+ # already in the user's Gemfile will be updated together.
36
+ GEMS_TO_UPDATE = ["ruby-lsp", "debug", "prism", "rbs"].freeze #: Array[String]
37
+
34
38
  #: (String project_path, **untyped options) -> void
35
39
  def initialize(project_path, **options)
36
40
  @project_path = project_path
@@ -331,7 +335,7 @@ module RubyLsp
331
335
  def update(env)
332
336
  # Try to auto upgrade the gems we depend on, unless they are in the Gemfile as that would result in undesired
333
337
  # source control changes
334
- gems = ["ruby-lsp", "debug", "prism"].reject { |dep| @dependencies[dep] }
338
+ gems = GEMS_TO_UPDATE.reject { |dep| @dependencies[dep] }
335
339
  gems << "ruby-lsp-rails" if @rails_app && !@dependencies["ruby-lsp-rails"]
336
340
 
337
341
  Bundler::CLI::Update.new({ conservative: true }, gems).run
@@ -343,14 +347,14 @@ module RubyLsp
343
347
 
344
348
  #: (Hash[String, String] env) -> Hash[String, String]
345
349
  def run_bundle_install_through_command(env)
346
- # If `ruby-lsp` and `debug` (and potentially `ruby-lsp-rails`) are already in the Gemfile, then we shouldn't try
347
- # to upgrade them or else we'll produce undesired source control changes. If the composed bundle was just created
348
- # and any of `ruby-lsp`, `ruby-lsp-rails` or `debug` weren't a part of the Gemfile, then we need to run `bundle
349
- # install` for the first time to generate the Gemfile.lock with them included or else Bundler will complain that
350
- # they're missing. We can only update if the custom `.ruby-lsp/Gemfile.lock` already exists and includes all gems
350
+ # If the gems in GEMS_TO_UPDATE (and potentially `ruby-lsp-rails`) are already in the Gemfile, then we shouldn't
351
+ # try to upgrade them or else we'll produce undesired source control changes. If the composed bundle was just
352
+ # created and any of those gems weren't a part of the Gemfile, then we need to run `bundle install` for the first
353
+ # time to generate the Gemfile.lock with them included or else Bundler will complain that they're missing. We can
354
+ # only update if the custom `.ruby-lsp/Gemfile.lock` already exists and includes all gems
351
355
 
352
356
  # When not updating, we run `(bundle check || bundle install)`
353
- # When updating, we run `((bundle check && bundle update ruby-lsp debug) || bundle install)`
357
+ # When updating, we run `((bundle check && bundle update <GEMS_TO_UPDATE>) || bundle install)`
354
358
  bundler_path = File.join(Gem.default_bindir, "bundle")
355
359
  base_command = (!Gem.win_platform? && File.exist?(bundler_path) ? "#{Gem.ruby} #{bundler_path}" : "bundle").dup
356
360
 
@@ -361,12 +365,11 @@ module RubyLsp
361
365
  command = +"(#{base_command} check"
362
366
 
363
367
  if should_bundle_update?
364
- # If any of `ruby-lsp`, `ruby-lsp-rails` or `debug` are not in the Gemfile, try to update them to the latest
365
- # version
368
+ # If any of the gems in GEMS_TO_UPDATE (or `ruby-lsp-rails` for Rails apps) are not in the Gemfile, try to
369
+ # update them to the latest version
366
370
  command.prepend("(")
367
371
  command << " && #{base_command} update "
368
- command << "ruby-lsp " unless @dependencies["ruby-lsp"]
369
- command << "debug " unless @dependencies["debug"]
372
+ GEMS_TO_UPDATE.each { |gem| command << "#{gem} " unless @dependencies[gem] }
370
373
  command << "ruby-lsp-rails " if @rails_app && !@dependencies["ruby-lsp-rails"]
371
374
  command.delete_suffix!(" ")
372
375
  command << ")"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-lsp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.26.5
4
+ version: 0.26.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shopify
@@ -96,20 +96,6 @@ files:
96
96
  - lib/ruby_indexer/lib/ruby_indexer/uri.rb
97
97
  - lib/ruby_indexer/lib/ruby_indexer/visibility_scope.rb
98
98
  - lib/ruby_indexer/ruby_indexer.rb
99
- - lib/ruby_indexer/test/class_variables_test.rb
100
- - lib/ruby_indexer/test/classes_and_modules_test.rb
101
- - lib/ruby_indexer/test/configuration_test.rb
102
- - lib/ruby_indexer/test/constant_test.rb
103
- - lib/ruby_indexer/test/enhancements_test.rb
104
- - lib/ruby_indexer/test/global_variable_test.rb
105
- - lib/ruby_indexer/test/index_test.rb
106
- - lib/ruby_indexer/test/instance_variables_test.rb
107
- - lib/ruby_indexer/test/method_test.rb
108
- - lib/ruby_indexer/test/prefix_tree_test.rb
109
- - lib/ruby_indexer/test/rbs_indexer_test.rb
110
- - lib/ruby_indexer/test/reference_finder_test.rb
111
- - lib/ruby_indexer/test/test_case.rb
112
- - lib/ruby_indexer/test/uri_test.rb
113
99
  - lib/ruby_lsp/addon.rb
114
100
  - lib/ruby_lsp/base_server.rb
115
101
  - lib/ruby_lsp/client_capabilities.rb
@@ -1,140 +0,0 @@
1
- # typed: true
2
- # frozen_string_literal: true
3
-
4
- require_relative "test_case"
5
-
6
- module RubyIndexer
7
- class ClassVariableTest < TestCase
8
- def test_class_variable_and_write
9
- index(<<~RUBY)
10
- class Foo
11
- @@bar &&= 1
12
- end
13
- RUBY
14
-
15
- assert_entry("@@bar", Entry::ClassVariable, "/fake/path/foo.rb:1-2:1-7")
16
-
17
- entry = @index["@@bar"]&.first #: as Entry::ClassVariable
18
- owner = entry.owner #: as !nil
19
- assert_instance_of(Entry::Class, owner)
20
- assert_equal("Foo", owner.name)
21
- end
22
-
23
- def test_class_variable_operator_write
24
- index(<<~RUBY)
25
- class Foo
26
- @@bar += 1
27
- end
28
- RUBY
29
-
30
- assert_entry("@@bar", Entry::ClassVariable, "/fake/path/foo.rb:1-2:1-7")
31
- end
32
-
33
- def test_class_variable_or_write
34
- index(<<~RUBY)
35
- class Foo
36
- @@bar ||= 1
37
- end
38
- RUBY
39
-
40
- assert_entry("@@bar", Entry::ClassVariable, "/fake/path/foo.rb:1-2:1-7")
41
- end
42
-
43
- def test_class_variable_target_node
44
- index(<<~RUBY)
45
- class Foo
46
- @@foo, @@bar = 1
47
- end
48
- RUBY
49
-
50
- assert_entry("@@foo", Entry::ClassVariable, "/fake/path/foo.rb:1-2:1-7")
51
- assert_entry("@@bar", Entry::ClassVariable, "/fake/path/foo.rb:1-9:1-14")
52
-
53
- entry = @index["@@foo"]&.first #: as Entry::ClassVariable
54
- owner = entry.owner #: as !nil
55
- assert_instance_of(Entry::Class, owner)
56
- assert_equal("Foo", owner.name)
57
-
58
- entry = @index["@@bar"]&.first #: as Entry::ClassVariable
59
- owner = entry.owner #: as !nil
60
- assert_instance_of(Entry::Class, owner)
61
- assert_equal("Foo", owner.name)
62
- end
63
-
64
- def test_class_variable_write
65
- index(<<~RUBY)
66
- class Foo
67
- @@bar = 1
68
- end
69
- RUBY
70
-
71
- assert_entry("@@bar", Entry::ClassVariable, "/fake/path/foo.rb:1-2:1-7")
72
- end
73
-
74
- def test_empty_name_class_variable
75
- index(<<~RUBY)
76
- module Foo
77
- @@ = 1
78
- end
79
- RUBY
80
-
81
- refute_entry("@@")
82
- end
83
-
84
- def test_top_level_class_variable
85
- index(<<~RUBY)
86
- @@foo = 123
87
- RUBY
88
-
89
- entry = @index["@@foo"]&.first #: as Entry::ClassVariable
90
- assert_nil(entry.owner)
91
- end
92
-
93
- def test_class_variable_inside_self_method
94
- index(<<~RUBY)
95
- class Foo
96
- def self.bar
97
- @@bar = 123
98
- end
99
- end
100
- RUBY
101
-
102
- entry = @index["@@bar"]&.first #: as Entry::ClassVariable
103
- owner = entry.owner #: as !nil
104
- assert_instance_of(Entry::Class, owner)
105
- assert_equal("Foo", owner.name)
106
- end
107
-
108
- def test_class_variable_inside_singleton_class
109
- index(<<~RUBY)
110
- class Foo
111
- class << self
112
- @@bar = 123
113
- end
114
- end
115
- RUBY
116
-
117
- entry = @index["@@bar"]&.first #: as Entry::ClassVariable
118
- owner = entry.owner #: as !nil
119
- assert_instance_of(Entry::Class, owner)
120
- assert_equal("Foo", owner.name)
121
- end
122
-
123
- def test_class_variable_in_singleton_class_method
124
- index(<<~RUBY)
125
- class Foo
126
- class << self
127
- def self.bar
128
- @@bar = 123
129
- end
130
- end
131
- end
132
- RUBY
133
-
134
- entry = @index["@@bar"]&.first #: as Entry::ClassVariable
135
- owner = entry.owner #: as !nil
136
- assert_instance_of(Entry::Class, owner)
137
- assert_equal("Foo", owner.name)
138
- end
139
- end
140
- end