ruby-lsp 0.26.9 → 0.26.11

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: 7b12b079fa54de3410e0d0ab2db9bf2241c6413c3c61d3ead21d4bbcc9b4e7d6
4
- data.tar.gz: dede13048ef29f79079271c7d20d505160f8fe24d495863e08be96c95207c6bf
3
+ metadata.gz: 8c49f507d132aa56e83a1bc78b2c9d51380720d1741f2fa842b5cc703a120f85
4
+ data.tar.gz: aaef95ca8aa9882039e4779ccff619944e7197b27d9235df17a1cd9f360eda8d
5
5
  SHA512:
6
- metadata.gz: 922edf8dadc38fa037d2c157c8e0b9bbbd3c759931ac6cda3070b615a3039597028672e8632507e80689f6a8f6cc793e7a1006a49bba28d72489f541e75f2fc3
7
- data.tar.gz: 046d2d369c16a743f71750a9a6dfed945d8e21b43bb58ad357ce1098fd731dc4e7060ffebcc96e1b78a43a3b2571ac9e31d94dc6c25c380478cb54a979c0f461
6
+ metadata.gz: d74e43b92f8205947c3ab0fd33c7c72ad173bbad910f8c223501695870dda4765cd6fde8f9a59e7fe286f109a393ec72f9d51103f74f8839bccdd6cc9cf06dd2
7
+ data.tar.gz: db06722c4dda7d57abbaebcb35be5aa60e3e246e29e28095a6da9851b7a0c99e0a3156657b2fc7c1298977539296ba8b636e2b15320fc258f2fbecd2822182e4
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.26.9
1
+ 0.26.11
@@ -56,25 +56,15 @@ module RubyLsp
56
56
  addon_files = Gem.find_files("ruby_lsp/**/addon.rb")
57
57
 
58
58
  if include_project_addons
59
- project_addons = Dir.glob("#{global_state.workspace_path}/**/ruby_lsp/**/addon.rb")
60
- bundle_path = Bundler.bundle_path.to_s
61
- gems_dir = Bundler.bundle_path.join("gems")
62
-
63
- # Create an array of rejection glob patterns to ignore add-ons already discovered through Gem.find_files if
64
- # they are also copied inside the workspace for whatever reason. We received reports of projects having gems
65
- # installed in vendor/bundle despite BUNDLE_PATH pointing elsewhere. Without this mechanism, we will
66
- # double-require the same add-on, potentially for different versions of the same gem, which leads to incorrect
67
- # behavior
68
- reject_glob_patterns = addon_files.map do |path|
69
- relative_gem_path = Pathname.new(path).relative_path_from(gems_dir)
70
- first_part, *parts = relative_gem_path.to_s.split(File::SEPARATOR)
71
- first_part&.gsub!(/-([0-9.]+)$/, "*")
72
- "**/#{first_part}/#{parts.join("/")}"
59
+ bundle_path = begin
60
+ Bundler.bundle_path.to_s
61
+ rescue Bundler::GemfileNotFound
62
+ nil
73
63
  end
74
64
 
65
+ project_addons = Dir.glob("#{global_state.workspace_path}/**/ruby_lsp/**/addon.rb")
75
66
  project_addons.reject! do |path|
76
- path.start_with?(bundle_path) ||
77
- reject_glob_patterns.any? { |pattern| File.fnmatch?(pattern, path, File::Constants::FNM_PATHNAME) }
67
+ (bundle_path && path.start_with?(bundle_path)) || gem_installation_path?(path)
78
68
  end
79
69
 
80
70
  addon_files.concat(project_addons)
@@ -162,6 +152,23 @@ module RubyLsp
162
152
  "Add-on is not compatible with this version of the Ruby LSP. Skipping its activation"
163
153
  end
164
154
  end
155
+
156
+ private
157
+
158
+ # Checks if a path appears to be inside a versioned gem installation directory (e.g., `rubocop-1.73.0/lib/...`) by
159
+ # looking for a directory segment matching `name-version` before the `lib` component
160
+ #
161
+ #: (String path) -> bool
162
+ def gem_installation_path?(path)
163
+ parts = path.split(%r{[/\\]})
164
+ lib_index = parts.rindex("lib")
165
+ return false unless lib_index
166
+
167
+ prefix = parts[0...lib_index] #: Array[String]?
168
+ return false unless prefix
169
+
170
+ prefix.any? { |part| part.match?(/-\d+(\.\d+)+$/) }
171
+ end
165
172
  end
166
173
 
167
174
  #: -> void
@@ -74,6 +74,8 @@ module RubyLsp
74
74
  )
75
75
  end
76
76
  end
77
+ rescue URI::Error
78
+ # A client can send a document URI with a scheme Ruby's URI parser rejects, so we don't want to fail
77
79
  rescue Store::NonExistingDocumentError
78
80
  # If we receive a request for a file that no longer exists, we don't want to fail
79
81
  end
@@ -21,6 +21,8 @@ module RubyLsp
21
21
 
22
22
  Gem::Specification.stubs.each do |stub|
23
23
  spec = stub.to_spec
24
+ next unless spec
25
+
24
26
  lookup[spec.name] = {}
25
27
  lookup[spec.name][spec.version.to_s] = {}
26
28
 
@@ -31,6 +33,8 @@ module RubyLsp
31
33
 
32
34
  Gem::Specification.default_stubs.each do |stub|
33
35
  spec = stub.to_spec
36
+ next unless spec
37
+
34
38
  lookup[spec.name] = {}
35
39
  lookup[spec.name][spec.version.to_s] = {}
36
40
  prefix_matchers = Regexp.union(spec.require_paths.map do |rp|
@@ -120,6 +120,10 @@ module RubyLsp
120
120
 
121
121
  return unless END_REGEXES.any? { |regex| regex.match?(@previous_line) }
122
122
 
123
+ # Endless method definitions (e.g., `def foo = 42`) are complete statements
124
+ # and should not have `end` added
125
+ return if @previous_line.match?(/\bdef\s+[\w.]+[!?=]?(\([^)]*\))?\s*=[^=~>]/)
126
+
123
127
  indents = " " * @indentation
124
128
  current_line = @lines[@position[:line]]
125
129
  next_line = @lines[@position[:line] + 1]
@@ -3,7 +3,11 @@
3
3
 
4
4
  module RubyLsp
5
5
  class Server < BaseServer
6
- NON_REPORTABLE_SETUP_ERRORS = [Bundler::GemNotFound, Bundler::GitError].freeze #: Array[singleton(StandardError)]
6
+ NON_REPORTABLE_SETUP_ERRORS = [
7
+ Bundler::GemNotFound,
8
+ Bundler::GitError,
9
+ Bundler::Dsl::DSLError,
10
+ ].freeze #: Array[singleton(StandardError)]
7
11
 
8
12
  # Only for testing
9
13
  #: GlobalState
@@ -120,6 +124,16 @@ module RubyLsp
120
124
  @global_state.synchronize { @cancelled_requests << message[:params][:id] }
121
125
  when nil
122
126
  process_response(message) if message[:result]
127
+ else
128
+ id = message[:id]
129
+
130
+ if id
131
+ send_message(Error.new(
132
+ id: id,
133
+ code: Constant::ErrorCodes::METHOD_NOT_FOUND,
134
+ message: "Method not found: #{message[:method]}",
135
+ ))
136
+ end
123
137
  end
124
138
  rescue DelegateRequestError
125
139
  send_message(Error.new(id: message[:id], code: DelegateRequestError::CODE, message: "DELEGATE_REQUEST"))
@@ -191,7 +191,11 @@ module RubyLsp
191
191
  end
192
192
 
193
193
  if @rails_app && !@dependencies["ruby-lsp-rails"]
194
- parts << 'gem "ruby-lsp-rails", require: false, group: :development'
194
+ parts << if @beta
195
+ 'gem "ruby-lsp-rails", ">= 0.a", require: false, group: :development'
196
+ else
197
+ 'gem "ruby-lsp-rails", require: false, group: :development'
198
+ end
195
199
  end
196
200
 
197
201
  content = parts.join("\n")
@@ -445,7 +449,7 @@ module RubyLsp
445
449
  requirement = Gem::Requirement.new(@bundler_version.to_s)
446
450
  return if Gem::Specification.any? { |s| s.name == "bundler" && requirement =~ s.version }
447
451
 
448
- Gem.install("bundler", @bundler_version.to_s)
452
+ Gem.install("bundler", @bundler_version.to_s, env_shebang: true)
449
453
  end
450
454
 
451
455
  #: -> bool
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.9
4
+ version: 0.26.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shopify
@@ -203,7 +203,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
203
203
  - !ruby/object:Gem::Version
204
204
  version: '0'
205
205
  requirements: []
206
- rubygems_version: 4.0.3
206
+ rubygems_version: 4.0.10
207
207
  specification_version: 4
208
208
  summary: An opinionated language server for Ruby
209
209
  test_files: []