ruby-lsp-mongoid 0.1.0 → 0.1.1
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 +4 -4
- data/CHANGELOG.md +5 -0
- data/TODO.md +1 -0
- data/lib/ruby_lsp/ruby_lsp_mongoid/indexing_enhancement.rb +29 -2
- data/lib/ruby_lsp_mongoid/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 25deaba20b973e9a4ceae841a71e0ae0d46b7ba6272fc5c48a9a56900d5240f3
|
|
4
|
+
data.tar.gz: 1075b753283b79bdf2cb9a0e36fdc16659d7b79e7f419b7a039531b8d1b92ecf
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7717dc958cb9f9c06fe1e097b8d8771ec0e52cfcf68ab502165ddc21e24dca5cf56cb07fff2c5d5790345fe56f08b479a843b2001b0ac21b7c89a9f0ef920e48
|
|
7
|
+
data.tar.gz: da98dc048563431553f88902e5068ce03757dc9056f43c47388651f978a98909e1fbf5664f367c9e3d2fe81c8fbe5a024ea710e9606b95ca7804c57e49af1610
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
## [Unreleased]
|
|
2
2
|
|
|
3
|
+
### Added
|
|
4
|
+
|
|
5
|
+
- Auto-index `_id` and `id` accessor methods for all Mongoid models that use any DSL (field, associations, scope)
|
|
6
|
+
- Each class using Mongoid DSL now automatically gets `_id`, `_id=`, `id`, and `id=` methods indexed at the first DSL location
|
|
7
|
+
|
|
3
8
|
## [0.1.0] - 2025-12-02
|
|
4
9
|
|
|
5
10
|
- Initial release
|
data/TODO.md
CHANGED
|
@@ -3,6 +3,11 @@
|
|
|
3
3
|
module RubyLsp
|
|
4
4
|
module Mongoid
|
|
5
5
|
class IndexingEnhancement < RubyIndexer::Enhancement
|
|
6
|
+
def initialize(listener)
|
|
7
|
+
super
|
|
8
|
+
@id_indexed_owners = Set.new
|
|
9
|
+
end
|
|
10
|
+
|
|
6
11
|
def on_call_node_enter(call_node)
|
|
7
12
|
owner = @listener.current_owner
|
|
8
13
|
return unless owner
|
|
@@ -32,6 +37,8 @@ module RubyLsp
|
|
|
32
37
|
loc = call_node.location
|
|
33
38
|
comment = build_field_options_comment(call_node)
|
|
34
39
|
|
|
40
|
+
ensure_id_field_indexed(loc)
|
|
41
|
+
|
|
35
42
|
add_accessor_methods(name, loc, comments: comment)
|
|
36
43
|
|
|
37
44
|
# Handle as: option for field alias
|
|
@@ -43,7 +50,10 @@ module RubyLsp
|
|
|
43
50
|
name = extract_name(call_node)
|
|
44
51
|
return unless name
|
|
45
52
|
|
|
46
|
-
|
|
53
|
+
loc = call_node.location
|
|
54
|
+
ensure_id_field_indexed(loc)
|
|
55
|
+
|
|
56
|
+
add_accessor_methods(name, loc)
|
|
47
57
|
end
|
|
48
58
|
|
|
49
59
|
def handle_many_association(call_node)
|
|
@@ -51,6 +61,7 @@ module RubyLsp
|
|
|
51
61
|
return unless name
|
|
52
62
|
|
|
53
63
|
loc = call_node.location
|
|
64
|
+
ensure_id_field_indexed(loc)
|
|
54
65
|
|
|
55
66
|
add_accessor_methods(name, loc)
|
|
56
67
|
|
|
@@ -63,6 +74,7 @@ module RubyLsp
|
|
|
63
74
|
return unless name
|
|
64
75
|
|
|
65
76
|
loc = call_node.location
|
|
77
|
+
ensure_id_field_indexed(loc)
|
|
66
78
|
|
|
67
79
|
add_accessor_methods(name, loc)
|
|
68
80
|
add_builder_methods(name, loc)
|
|
@@ -75,7 +87,10 @@ module RubyLsp
|
|
|
75
87
|
owner = @listener.current_owner
|
|
76
88
|
return unless owner
|
|
77
89
|
|
|
78
|
-
|
|
90
|
+
loc = call_node.location
|
|
91
|
+
ensure_id_field_indexed(loc)
|
|
92
|
+
|
|
93
|
+
add_singleton_method(name.to_s, loc, owner)
|
|
79
94
|
end
|
|
80
95
|
|
|
81
96
|
def extract_name(call_node)
|
|
@@ -198,6 +213,18 @@ module RubyLsp
|
|
|
198
213
|
name_str
|
|
199
214
|
end
|
|
200
215
|
end
|
|
216
|
+
|
|
217
|
+
def ensure_id_field_indexed(location)
|
|
218
|
+
owner = @listener.current_owner
|
|
219
|
+
return unless owner
|
|
220
|
+
return if @id_indexed_owners.include?(owner.name)
|
|
221
|
+
|
|
222
|
+
@id_indexed_owners.add(owner.name)
|
|
223
|
+
|
|
224
|
+
# Add _id and id (alias) accessor methods
|
|
225
|
+
add_accessor_methods("_id", location)
|
|
226
|
+
add_accessor_methods("id", location)
|
|
227
|
+
end
|
|
201
228
|
end
|
|
202
229
|
end
|
|
203
230
|
end
|