ruby-lsp-mongoid 0.1.2 → 0.1.3

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: 459274f7c2be280ff2e284869fcd8dc7e424dcce61799d881a27f7bc250edf75
4
- data.tar.gz: 07ee1f8583968c5b01bc395df23e3b598967e9ae389b10100d4681eb5c592f9d
3
+ metadata.gz: 8fbccb41fea414098880ead42297015e17b7f8e375efd0a389fcf6ffc9f50ac8
4
+ data.tar.gz: f3e1eb7a9271a97b00f314f88e755a5aabfde5f9fb700d031e0709eb20bae9c2
5
5
  SHA512:
6
- metadata.gz: c946f9ee440c08d5620f074272c1f34376624b4cfb7251bf26d4e7342a76792bd625d86b78eda2015da57eccdaf4b38be838e97e82a39ead6e8d73c8fe890750
7
- data.tar.gz: 2343c3b4a06ecd64abf51015cac50ce6f45380148a796777860474e025e446526892a2f2a486235a0f5e38906258b9c2b6b07044d12500b38468ad2cfc8adcde
6
+ metadata.gz: f28b770bf135a4e1c1eddeeb3368ad05793054f535dd2ae8f08c07a6d2bbab75b2732227950cdb784e89d98ccf8747581eceff8fd347956eeda247aac21213a8
7
+ data.tar.gz: 17c8daf234ffb9ee7d3587437ae6439dd098018b4521dfc11ccb8315a20c2662e204f6385b66a065f2cf6e12f4184cdf2f433eb72fc23bc69f68a8722bc7905e
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ### Fixed
4
+
5
+ - Fix "can't add a new key into hash during iteration" error caused by concurrent hash modification when background signature update thread iterates while ruby-lsp modifies the index
6
+ - Fix compatibility with ruby-lsp 0.26.5+ by using `@listener.add_method` instead of directly calling `Entry::Method.new`
7
+
3
8
  ## [0.1.2] - 2025-12-15
4
9
 
5
10
  ### Added
@@ -89,7 +89,10 @@ module RubyLsp
89
89
 
90
90
  # Find all classes that have this method registered by our addon
91
91
  # We look for methods that were registered with empty signatures
92
- index.instance_variable_get(:@entries).each do |_name, entries|
92
+ # Use dup to avoid "can't add a new key into hash during iteration" error
93
+ # when ruby-lsp modifies the index concurrently
94
+ entries_snapshot = index.instance_variable_get(:@entries).dup
95
+ entries_snapshot.each do |_name, entries|
93
96
  entries.each do |entry|
94
97
  next unless entry.is_a?(RubyIndexer::Entry::Method)
95
98
  next unless entry.name == method_name
@@ -107,7 +110,9 @@ module RubyLsp
107
110
  def update_singleton_method_signatures_for_mongoid_models(index, method_name, new_signatures)
108
111
  updated = 0
109
112
 
110
- index.instance_variable_get(:@entries).each do |_name, entries|
113
+ # Use dup to avoid "can't add a new key into hash during iteration" error
114
+ entries_snapshot = index.instance_variable_get(:@entries).dup
115
+ entries_snapshot.each do |_name, entries|
111
116
  entries.each do |entry|
112
117
  next unless entry.is_a?(RubyIndexer::Entry::Method)
113
118
  next unless entry.name == method_name
@@ -254,22 +254,14 @@ module RubyLsp
254
254
 
255
255
  def add_singleton_method_with_signatures(name, node_location, owner, signatures)
256
256
  index = @listener.instance_variable_get(:@index)
257
- code_units_cache = @listener.instance_variable_get(:@code_units_cache)
258
- uri = @listener.instance_variable_get(:@uri)
257
+ owner_stack = @listener.instance_variable_get(:@owner_stack)
259
258
 
260
- location = RubyIndexer::Location.from_prism_location(node_location, code_units_cache)
261
259
  singleton = index.existing_or_new_singleton_class(owner.name)
260
+ owner_stack << singleton
262
261
 
263
- index.add(RubyIndexer::Entry::Method.new(
264
- name,
265
- uri,
266
- location,
267
- location,
268
- "",
269
- signatures,
270
- :public,
271
- singleton,
272
- ))
262
+ @listener.add_method(name, node_location, signatures)
263
+
264
+ owner_stack.pop
273
265
  end
274
266
 
275
267
  def extract_lambda_node(call_node)
@@ -2,6 +2,6 @@
2
2
 
3
3
  module RubyLsp
4
4
  module Mongoid
5
- VERSION = "0.1.2"
5
+ VERSION = "0.1.3"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-lsp-mongoid
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shia