solargraph 0.55.0 → 0.55.2
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 +8 -0
- data/lib/solargraph/api_map.rb +1 -1
- data/lib/solargraph/convention/struct_definition/struct_assignment_node.rb +11 -2
- data/lib/solargraph/doc_map.rb +57 -21
- data/lib/solargraph/parser/flow_sensitive_typing.rb +3 -1
- data/lib/solargraph/pin/delegated_method.rb +18 -1
- data/lib/solargraph/version.rb +1 -1
- data/lib/solargraph.rb +1 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8a2f6018173b0c7fb772fb29ddcfac606af3bdc3495793eb88c35573164ba64d
|
4
|
+
data.tar.gz: 622be262bbfda497e13caf68d769cd30d4de62ff1aa6ee04ec80f7627af1af43
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4c0f53c95bacfd15f7e1d90a160df31799777ebbfd6a5728dcef38cab0e9a88741b1ce4a392a5dd5ccbec0a395867b17c766b08fce4dadd9000c51bdb36edae3
|
7
|
+
data.tar.gz: '08298eef6f231bbf2379186b8d9a37885386774f164c16f45897d3d0c1347f44460b2eb997bbc5410b01a503b92bc141549724692a38414f9e4fc386177a22c6'
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
## 0.55.2 - June 21, 2025
|
2
|
+
- Require external bundle (#972)
|
3
|
+
|
4
|
+
## 0.55.1 - June 8, 2025
|
5
|
+
- Fix inline Struct definition (#962)
|
6
|
+
- Ensure DocMap requires bundler when loading gemspecs (#963)
|
7
|
+
- DelegatedMethod improvements (#953)
|
8
|
+
|
1
9
|
## 0.55.0 - June 3, 2025
|
2
10
|
- Flow-sensitive typing - automatically downcast from is_a? calls (#856)
|
3
11
|
- Tuple enabler: infer literal types and use them for signature selection (#836)
|
data/lib/solargraph/api_map.rb
CHANGED
@@ -94,7 +94,7 @@ module Solargraph
|
|
94
94
|
end
|
95
95
|
unresolved_requires = (bench.external_requires + implicit.requires + bench.workspace.config.required).to_a.compact.uniq
|
96
96
|
if @unresolved_requires != unresolved_requires || @doc_map&.uncached_gemspecs&.any?
|
97
|
-
@doc_map = DocMap.new(unresolved_requires, [], bench.workspace
|
97
|
+
@doc_map = DocMap.new(unresolved_requires, [], bench.workspace) # @todo Implement gem preferences
|
98
98
|
@unresolved_requires = unresolved_requires
|
99
99
|
end
|
100
100
|
@cache.clear if store.update(@@core_map.pins, @doc_map.pins, implicit.pins, iced_pins, live_pins)
|
@@ -25,7 +25,12 @@ module Solargraph
|
|
25
25
|
def valid?(node)
|
26
26
|
return false unless node&.type == :casgn
|
27
27
|
return false if node.children[2].nil?
|
28
|
-
|
28
|
+
|
29
|
+
struct_node = if node.children[2].type == :block
|
30
|
+
node.children[2].children[0]
|
31
|
+
else
|
32
|
+
node.children[2]
|
33
|
+
end
|
29
34
|
|
30
35
|
struct_definition_node?(struct_node)
|
31
36
|
end
|
@@ -43,7 +48,11 @@ module Solargraph
|
|
43
48
|
|
44
49
|
# @return [Parser::AST::Node]
|
45
50
|
def struct_node
|
46
|
-
node.children[2].
|
51
|
+
if node.children[2].type == :block
|
52
|
+
node.children[2].children[0]
|
53
|
+
else
|
54
|
+
node.children[2]
|
55
|
+
end
|
47
56
|
end
|
48
57
|
end
|
49
58
|
end
|
data/lib/solargraph/doc_map.rb
CHANGED
@@ -18,13 +18,16 @@ module Solargraph
|
|
18
18
|
# @return [Array<Gem::Specification>]
|
19
19
|
attr_reader :uncached_gemspecs
|
20
20
|
|
21
|
+
# @return [Workspace, nil]
|
22
|
+
attr_reader :workspace
|
23
|
+
|
21
24
|
# @param requires [Array<String>]
|
22
25
|
# @param preferences [Array<Gem::Specification>]
|
23
|
-
# @param
|
24
|
-
def initialize(requires, preferences,
|
26
|
+
# @param workspace [Workspace, nil]
|
27
|
+
def initialize(requires, preferences, workspace = nil)
|
25
28
|
@requires = requires.compact
|
26
29
|
@preferences = preferences.compact
|
27
|
-
@
|
30
|
+
@workspace = workspace
|
28
31
|
generate
|
29
32
|
end
|
30
33
|
|
@@ -118,10 +121,10 @@ module Solargraph
|
|
118
121
|
|
119
122
|
# @param gemspec [Gem::Specification]
|
120
123
|
def update_from_collection gemspec, gempins
|
121
|
-
return gempins unless
|
124
|
+
return gempins unless workspace&.rbs_collection_path && File.directory?(workspace&.rbs_collection_path)
|
122
125
|
return gempins if RbsMap.new(gemspec.name, gemspec.version).resolved?
|
123
126
|
|
124
|
-
rbs_map = RbsMap.new(gemspec.name, gemspec.version, directories: [
|
127
|
+
rbs_map = RbsMap.new(gemspec.name, gemspec.version, directories: [workspace&.rbs_collection_path])
|
125
128
|
return gempins unless rbs_map.resolved?
|
126
129
|
|
127
130
|
Solargraph.logger.info "Updating #{gemspec.name} #{gemspec.version} from collection"
|
@@ -132,22 +135,7 @@ module Solargraph
|
|
132
135
|
# @return [::Array<Gem::Specification>, nil]
|
133
136
|
def resolve_path_to_gemspecs path
|
134
137
|
return nil if path.empty?
|
135
|
-
|
136
|
-
if path == 'bundler/require'
|
137
|
-
# find only the gems bundler is now using
|
138
|
-
gemspecs = Bundler.definition.locked_gems.specs.flat_map do |lazy_spec|
|
139
|
-
logger.info "Handling #{lazy_spec.name}:#{lazy_spec.version} from #{path}"
|
140
|
-
[Gem::Specification.find_by_name(lazy_spec.name, lazy_spec.version)]
|
141
|
-
rescue Gem::MissingSpecError => e
|
142
|
-
logger.info("Could not find #{lazy_spec.name}:#{lazy_spec.version} with find_by_name, falling back to guess")
|
143
|
-
# can happen in local filesystem references
|
144
|
-
specs = resolve_path_to_gemspecs lazy_spec.name
|
145
|
-
logger.info "Gem #{lazy_spec.name} #{lazy_spec.version} from bundle not found: #{e}" if specs.nil?
|
146
|
-
next specs
|
147
|
-
end.compact
|
148
|
-
|
149
|
-
return gemspecs
|
150
|
-
end
|
138
|
+
return gemspecs_required_from_bundler if path == 'bundler/require'
|
151
139
|
|
152
140
|
gemspec = Gem::Specification.find_by_path(path)
|
153
141
|
if gemspec.nil?
|
@@ -208,5 +196,53 @@ module Solargraph
|
|
208
196
|
def only_runtime_dependencies gemspec
|
209
197
|
gemspec.dependencies - gemspec.development_dependencies
|
210
198
|
end
|
199
|
+
|
200
|
+
def gemspecs_required_from_bundler
|
201
|
+
if workspace&.directory && Bundler.definition&.lockfile&.to_s&.start_with?(workspace.directory)
|
202
|
+
# Find only the gems bundler is now using
|
203
|
+
Bundler.definition.locked_gems.specs.flat_map do |lazy_spec|
|
204
|
+
logger.info "Handling #{lazy_spec.name}:#{lazy_spec.version}"
|
205
|
+
[Gem::Specification.find_by_name(lazy_spec.name, lazy_spec.version)]
|
206
|
+
rescue Gem::MissingSpecError => e
|
207
|
+
logger.info("Could not find #{lazy_spec.name}:#{lazy_spec.version} with find_by_name, falling back to guess")
|
208
|
+
# can happen in local filesystem references
|
209
|
+
specs = resolve_path_to_gemspecs lazy_spec.name
|
210
|
+
logger.info "Gem #{lazy_spec.name} #{lazy_spec.version} from bundle not found: #{e}" if specs.nil?
|
211
|
+
next specs
|
212
|
+
end.compact
|
213
|
+
else
|
214
|
+
logger.info 'Fetching gemspecs required from Bundler (bundler/require)'
|
215
|
+
gemspecs_required_from_external_bundle
|
216
|
+
end
|
217
|
+
end
|
218
|
+
|
219
|
+
def gemspecs_required_from_external_bundle
|
220
|
+
logger.info 'Fetching gemspecs required from external bundle'
|
221
|
+
return [] unless workspace&.directory
|
222
|
+
|
223
|
+
Solargraph.with_clean_env do
|
224
|
+
cmd = [
|
225
|
+
'ruby', '-e',
|
226
|
+
"require 'bundler'; require 'json'; Dir.chdir('#{workspace&.directory}') { puts Bundler.definition.locked_gems.specs.map { |spec| [spec.name, spec.version] }.to_h.to_json }"
|
227
|
+
]
|
228
|
+
o, e, s = Open3.capture3(*cmd)
|
229
|
+
if s.success?
|
230
|
+
Solargraph.logger.debug "External bundle: #{o}"
|
231
|
+
hash = o && !o.empty? ? JSON.parse(o.split("\n").last) : {}
|
232
|
+
hash.map do |name, version|
|
233
|
+
Gem::Specification.find_by_name(name, version)
|
234
|
+
rescue Gem::MissingSpecError => e
|
235
|
+
logger.info("Could not find #{name}:#{version} with find_by_name, falling back to guess")
|
236
|
+
# can happen in local filesystem references
|
237
|
+
specs = resolve_path_to_gemspecs name
|
238
|
+
logger.info "Gem #{name} #{version} from bundle not found: #{e}" if specs.nil?
|
239
|
+
next specs
|
240
|
+
end.compact
|
241
|
+
else
|
242
|
+
Solargraph.logger.warn e
|
243
|
+
raise BundleNotFoundError, "Failed to load gems from bundle at #{workspace&.directory}"
|
244
|
+
end
|
245
|
+
end
|
246
|
+
end
|
211
247
|
end
|
212
248
|
end
|
@@ -152,7 +152,9 @@ module Solargraph
|
|
152
152
|
# @param isa_node [Parser::AST::Node]
|
153
153
|
# @return [Array(String, String)]
|
154
154
|
def parse_isa(isa_node)
|
155
|
-
|
155
|
+
# @todo A nil guard might be good enough here, but we might want to
|
156
|
+
# see if the callers are checking for nils instead.
|
157
|
+
return unless isa_node&.type == :send && isa_node.children[1] == :is_a?
|
156
158
|
# Check if conditional node follows this pattern:
|
157
159
|
# s(:send,
|
158
160
|
# s(:send, nil, :foo), :is_a?,
|
@@ -24,7 +24,24 @@ module Solargraph
|
|
24
24
|
@receiver_method_name = receiver_method_name
|
25
25
|
end
|
26
26
|
|
27
|
-
|
27
|
+
def inner_desc
|
28
|
+
"#{name} => #{@receiver_chain}##{@receiver_method_name}"
|
29
|
+
end
|
30
|
+
|
31
|
+
def location
|
32
|
+
return super if super
|
33
|
+
|
34
|
+
@resolved_method&.send(:location)
|
35
|
+
end
|
36
|
+
|
37
|
+
|
38
|
+
def type_location
|
39
|
+
return super if super
|
40
|
+
|
41
|
+
@resolved_method&.send(:type_location)
|
42
|
+
end
|
43
|
+
|
44
|
+
%i[comments parameters return_type signatures].each do |method|
|
28
45
|
define_method(method) do
|
29
46
|
@resolved_method ? @resolved_method.send(method) : super()
|
30
47
|
end
|
data/lib/solargraph/version.rb
CHANGED
data/lib/solargraph.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: solargraph
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.55.
|
4
|
+
version: 0.55.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Fred Snyder
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-06-
|
11
|
+
date: 2025-06-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: backport
|