ruby-lsp 0.27.0.beta1 → 0.27.0.beta3

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.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/VERSION +1 -1
  3. data/exe/ruby-lsp +0 -46
  4. data/exe/ruby-lsp-check +0 -15
  5. data/lib/ruby_lsp/addon.rb +19 -19
  6. data/lib/ruby_lsp/global_state.rb +1 -6
  7. data/lib/ruby_lsp/internal.rb +3 -2
  8. data/lib/ruby_lsp/listeners/code_lens.rb +1 -1
  9. data/lib/ruby_lsp/listeners/completion.rb +246 -382
  10. data/lib/ruby_lsp/listeners/definition.rb +7 -10
  11. data/lib/ruby_lsp/listeners/document_link.rb +4 -0
  12. data/lib/ruby_lsp/listeners/hover.rb +234 -82
  13. data/lib/ruby_lsp/listeners/signature_help.rb +11 -12
  14. data/lib/ruby_lsp/listeners/spec_style.rb +6 -1
  15. data/lib/ruby_lsp/listeners/test_discovery.rb +38 -15
  16. data/lib/ruby_lsp/listeners/test_style.rb +21 -9
  17. data/lib/ruby_lsp/node_context.rb +31 -8
  18. data/lib/ruby_lsp/requests/completion_resolve.rb +55 -39
  19. data/lib/ruby_lsp/requests/discover_tests.rb +5 -41
  20. data/lib/ruby_lsp/requests/hover.rb +2 -5
  21. data/lib/ruby_lsp/requests/prepare_type_hierarchy.rb +66 -22
  22. data/lib/ruby_lsp/requests/references.rb +180 -66
  23. data/lib/ruby_lsp/requests/rename.rb +1 -1
  24. data/lib/ruby_lsp/requests/request.rb +3 -33
  25. data/lib/ruby_lsp/requests/support/common.rb +82 -68
  26. data/lib/ruby_lsp/requests/type_hierarchy_supertypes.rb +82 -46
  27. data/lib/ruby_lsp/ruby_document.rb +0 -73
  28. data/lib/ruby_lsp/rubydex/declaration.rb +174 -0
  29. data/lib/ruby_lsp/rubydex/definition.rb +73 -0
  30. data/lib/ruby_lsp/rubydex/reference.rb +6 -1
  31. data/lib/ruby_lsp/rubydex/signature.rb +107 -0
  32. data/lib/ruby_lsp/scripts/compose_bundle.rb +1 -1
  33. data/lib/ruby_lsp/server.rb +56 -171
  34. data/lib/ruby_lsp/test_helper.rb +0 -1
  35. data/lib/ruby_lsp/test_reporters/lsp_reporter.rb +1 -1
  36. data/lib/ruby_lsp/type_inferrer.rb +89 -11
  37. metadata +12 -18
  38. data/lib/ruby_indexer/lib/ruby_indexer/configuration.rb +0 -276
  39. data/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb +0 -1101
  40. data/lib/ruby_indexer/lib/ruby_indexer/enhancement.rb +0 -44
  41. data/lib/ruby_indexer/lib/ruby_indexer/entry.rb +0 -605
  42. data/lib/ruby_indexer/lib/ruby_indexer/index.rb +0 -1077
  43. data/lib/ruby_indexer/lib/ruby_indexer/location.rb +0 -37
  44. data/lib/ruby_indexer/lib/ruby_indexer/prefix_tree.rb +0 -149
  45. data/lib/ruby_indexer/lib/ruby_indexer/rbs_indexer.rb +0 -294
  46. data/lib/ruby_indexer/lib/ruby_indexer/reference_finder.rb +0 -335
  47. data/lib/ruby_indexer/lib/ruby_indexer/visibility_scope.rb +0 -32
  48. data/lib/ruby_indexer/ruby_indexer.rb +0 -20
  49. data/lib/ruby_lsp/static_docs.rb +0 -20
  50. data/static_docs/break.md +0 -103
  51. data/static_docs/yield.md +0 -81
  52. /data/lib/{ruby_indexer/lib/ruby_indexer → ruby_lsp}/uri.rb +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4e5c88483f280d13f2691e131a16e35df07df898e8f380071d077479cd24133e
4
- data.tar.gz: 7630ce8844fcb532ca63c77e299b692471b145530a623dcbc78ecbb50ce08596
3
+ metadata.gz: b3bc7e833f5619665b205e3346555594540a1150cf4a66514ed1fe6900fc8d0e
4
+ data.tar.gz: c7cf77eed53ba29b680221474abffd5356f723dd4bb2bd586b8158c5b3794dba
5
5
  SHA512:
6
- metadata.gz: 7757882e6e441d49705a389bad6b0b617b7f9a26fb1e5f34ebd3fc93eeb8921b31a703253cff79ed123ae411333fc7d91f0555ae162cafee1d10adfb13b76cf4
7
- data.tar.gz: c215743ab00113e4dd3186732faabd462fef6a3be425f1c76bb65b045846effd7db0673478244218f1087e3fa9ca96f8668c86970def65bf2e5fbb4ea0728a8d
6
+ metadata.gz: 3b265bbdf75bd46df7acc181a9d77aced50b403b5efa21dc7c22eeda92b5b0319b5d1ac21a279d2c436c5126026c3f643760974c57d26bbbcc32ca69fba5b9bc
7
+ data.tar.gz: ee7b8e028a2a38e301ec14c33c2a7c6f292e89f1c850a935b26dce19bc4a10f15915a07c2dea8f8e32839acd3018f7613e698a06d6e908b3334d38cccddd47de
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.27.0.beta1
1
+ 0.27.0.beta3
data/exe/ruby-lsp CHANGED
@@ -17,14 +17,6 @@ parser = OptionParser.new do |opts|
17
17
  options[:debug] = true
18
18
  end
19
19
 
20
- opts.on("--time-index", "Measure the time it takes to index the project") do
21
- options[:time_index] = true
22
- end
23
-
24
- opts.on("--doctor", "Run troubleshooting steps") do
25
- options[:doctor] = true
26
- end
27
-
28
20
  opts.on("--use-launcher", "[EXPERIMENTAL] Use launcher mechanism to handle missing dependencies gracefully") do
29
21
  options[:launcher] = true
30
22
  end
@@ -110,44 +102,6 @@ if options[:debug]
110
102
  end
111
103
  end
112
104
 
113
- if options[:time_index]
114
- index = RubyIndexer::Index.new
115
-
116
- time_start = Process.clock_gettime(Process::CLOCK_MONOTONIC)
117
- index.index_all
118
- elapsed_time = Process.clock_gettime(Process::CLOCK_MONOTONIC) - time_start
119
-
120
- entries = index.instance_variable_get(:@entries)
121
- entries_by_entry_type = entries.values.flatten.group_by(&:class)
122
-
123
- puts <<~MSG
124
- Ruby LSP v#{RubyLsp::VERSION}: Indexing took #{elapsed_time.round(5)} seconds and generated:
125
- - #{entries_by_entry_type.sort_by { |k, _| k.to_s }.map { |k, v| "#{k.name.split("::").last}: #{v.size}" }.join("\n- ")}
126
- MSG
127
- return
128
- end
129
-
130
- if options[:doctor]
131
- index = RubyIndexer::Index.new
132
-
133
- if File.exist?(".index.yml")
134
- begin
135
- config = YAML.parse_file(".index.yml").to_ruby
136
- rescue => e
137
- abort("Error parsing config: #{e.message}")
138
- end
139
- index.configuration.apply_config(config)
140
- end
141
-
142
- puts "Globbing for indexable files"
143
-
144
- index.configuration.indexable_uris.each do |uri|
145
- puts "indexing: #{uri}"
146
- index.index_file(uri)
147
- end
148
- return
149
- end
150
-
151
105
  server = RubyLsp::Server.new
152
106
 
153
107
  # Ensure all output goes out stderr by default to allow puts/p/pp to work
data/exe/ruby-lsp-check CHANGED
@@ -36,21 +36,6 @@ ensure
36
36
  end
37
37
  puts "\n"
38
38
 
39
- # Indexing
40
- puts "Verifying that indexing executes successfully. This may take a while..."
41
-
42
- index = RubyIndexer::Index.new
43
- uris = index.configuration.indexable_uris
44
-
45
- uris.each_with_index do |uri, i|
46
- index.index_file(uri)
47
- rescue => e
48
- errors[uri.full_path] = e
49
- ensure
50
- print("\033[M\033[0KIndexed #{i + 1}/#{uris.length}") unless ENV["CI"]
51
- end
52
- puts "\n"
53
-
54
39
  if errors.empty?
55
40
  puts "All operations completed successfully!"
56
41
  exit
@@ -56,26 +56,9 @@ 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
59
  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("/")}"
73
- end
74
-
75
- 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) }
78
- end
60
+ project_addons = Dir.glob("#{global_state.workspace_path}/**/ruby_lsp/**/addon.rb")
61
+ project_addons.reject! { |path| path.start_with?(bundle_path) || gem_installation_path?(path) }
79
62
 
80
63
  addon_files.concat(project_addons)
81
64
  end
@@ -162,6 +145,23 @@ module RubyLsp
162
145
  "Add-on is not compatible with this version of the Ruby LSP. Skipping its activation"
163
146
  end
164
147
  end
148
+
149
+ private
150
+
151
+ # Checks if a path appears to be inside a versioned gem installation directory (e.g., `rubocop-1.73.0/lib/...`) by
152
+ # looking for a directory segment matching `name-version` before the `lib` component
153
+ #
154
+ #: (String path) -> bool
155
+ def gem_installation_path?(path)
156
+ parts = path.split(%r{[/\\]})
157
+ lib_index = parts.rindex("lib")
158
+ return false unless lib_index
159
+
160
+ prefix = parts[0...lib_index] #: Array[String]?
161
+ return false unless prefix
162
+
163
+ prefix.any? { |part| part.match?(/-\d+(\.\d+)+$/) }
164
+ end
165
165
  end
166
166
 
167
167
  #: -> void
@@ -27,9 +27,6 @@ module RubyLsp
27
27
  #: bool
28
28
  attr_reader :has_type_checker
29
29
 
30
- #: RubyIndexer::Index
31
- attr_reader :index
32
-
33
30
  #: Rubydex::Graph
34
31
  attr_reader :graph
35
32
 
@@ -60,7 +57,6 @@ module RubyLsp
60
57
  @linters = [] #: Array[String]
61
58
  @test_library = "minitest" #: String
62
59
  @has_type_checker = true #: bool
63
- @index = RubyIndexer::Index.new #: RubyIndexer::Index
64
60
  @graph = Rubydex::Graph.new #: Rubydex::Graph
65
61
  @supported_formatters = {} #: Hash[String, Requests::Support::Formatter]
66
62
  @type_inferrer = TypeInferrer.new(@graph) #: TypeInferrer
@@ -204,9 +200,8 @@ module RubyLsp
204
200
  Encoding::UTF_16LE
205
201
  else
206
202
  @graph.encoding = "utf32"
207
- Encoding::UTF_32
203
+ Encoding::UTF_32LE
208
204
  end
209
- @index.configuration.encoding = @encoding
210
205
 
211
206
  @client_capabilities.apply_client_capabilities(options[:capabilities]) if options[:capabilities]
212
207
 
@@ -32,14 +32,15 @@ require "shellwords"
32
32
  require "set"
33
33
 
34
34
  # Rubydex LSP additions
35
+ require "ruby_lsp/rubydex/declaration"
35
36
  require "ruby_lsp/rubydex/definition"
36
37
  require "ruby_lsp/rubydex/reference"
38
+ require "ruby_lsp/rubydex/signature"
37
39
 
38
40
  require "ruby-lsp"
39
41
  require "ruby_lsp/base_server"
40
- require "ruby_indexer/ruby_indexer"
42
+ require "ruby_lsp/uri"
41
43
  require "ruby_lsp/utils"
42
- require "ruby_lsp/static_docs"
43
44
  require "ruby_lsp/scope"
44
45
  require "ruby_lsp/client_capabilities"
45
46
  require "ruby_lsp/global_state"
@@ -279,7 +279,7 @@ module RubyLsp
279
279
  when Prism::StringNode
280
280
  first_argument.content
281
281
  when Prism::ConstantReadNode, Prism::ConstantPathNode
282
- RubyIndexer::Index.constant_name(first_argument)
282
+ constant_name(first_argument)
283
283
  end
284
284
 
285
285
  return unless name