solargraph 0.55.1 → 0.55.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 +4 -4
- data/CHANGELOG.md +6 -0
- data/lib/solargraph/api_map.rb +1 -1
- data/lib/solargraph/doc_map.rb +57 -28
- data/lib/solargraph/parser/flow_sensitive_typing.rb +3 -3
- 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: b92431804c7f970e2e2584375047eedef4155a24ac07e37dd0cfd5b9f3a4b562
|
4
|
+
data.tar.gz: e60ed915ee5ff35d91e66d0d15287d8a58f7c295080041d601c833092767bde9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e4d6a6fd86d4942dac41fbfe67d7860ed1bdc9534414c26adae8bba3b6cf2a402691a0de5adaf89fcf49fbb8d11fba81230d683ec4b7aed01c5b0a73671dd3fa
|
7
|
+
data.tar.gz: 1b12d4bfbdb9bcca0e87585fc985252ec6d343929b16f9317f12223f8e6d2d413ebb6a9674911eb09189c817703c35fbe5acb3c364666cb1f05dadd188279940
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
## 0.55.3 - June 25, 2025
|
2
|
+
- Nil guards in flow-sensitive typing (patch release) #980
|
3
|
+
|
4
|
+
## 0.55.2 - June 21, 2025
|
5
|
+
- Require external bundle (#972)
|
6
|
+
|
1
7
|
## 0.55.1 - June 8, 2025
|
2
8
|
- Fix inline Struct definition (#962)
|
3
9
|
- Ensure DocMap requires bundler when loading gemspecs (#963)
|
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)
|
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,29 +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
|
-
# @todo Quick fix for cases when Solargraph is running without Bundler.
|
138
|
-
# The next goal is to enable loading of external bundles, i.e.,
|
139
|
-
# finding gems that are defined in the workspace's bundle when
|
140
|
-
# Solargraph is running in a different environment.
|
141
|
-
# See https://github.com/castwide/vscode-solargraph/issues/279
|
142
|
-
require 'bundler'
|
143
|
-
|
144
|
-
# find only the gems bundler is now using
|
145
|
-
gemspecs = Bundler.definition.locked_gems.specs.flat_map do |lazy_spec|
|
146
|
-
logger.info "Handling #{lazy_spec.name}:#{lazy_spec.version} from #{path}"
|
147
|
-
[Gem::Specification.find_by_name(lazy_spec.name, lazy_spec.version)]
|
148
|
-
rescue Gem::MissingSpecError => e
|
149
|
-
logger.info("Could not find #{lazy_spec.name}:#{lazy_spec.version} with find_by_name, falling back to guess")
|
150
|
-
# can happen in local filesystem references
|
151
|
-
specs = resolve_path_to_gemspecs lazy_spec.name
|
152
|
-
logger.info "Gem #{lazy_spec.name} #{lazy_spec.version} from bundle not found: #{e}" if specs.nil?
|
153
|
-
next specs
|
154
|
-
end.compact
|
155
|
-
|
156
|
-
return gemspecs
|
157
|
-
end
|
138
|
+
return gemspecs_required_from_bundler if path == 'bundler/require'
|
158
139
|
|
159
140
|
gemspec = Gem::Specification.find_by_path(path)
|
160
141
|
if gemspec.nil?
|
@@ -215,5 +196,53 @@ module Solargraph
|
|
215
196
|
def only_runtime_dependencies gemspec
|
216
197
|
gemspec.dependencies - gemspec.development_dependencies
|
217
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
|
218
247
|
end
|
219
248
|
end
|
@@ -152,7 +152,7 @@ module Solargraph
|
|
152
152
|
# @param isa_node [Parser::AST::Node]
|
153
153
|
# @return [Array(String, String)]
|
154
154
|
def parse_isa(isa_node)
|
155
|
-
return unless isa_node
|
155
|
+
return unless isa_node&.type == :send && isa_node.children[1] == :is_a?
|
156
156
|
# Check if conditional node follows this pattern:
|
157
157
|
# s(:send,
|
158
158
|
# s(:send, nil, :foo), :is_a?,
|
@@ -164,12 +164,12 @@ module Solargraph
|
|
164
164
|
# check if isa_receiver looks like this:
|
165
165
|
# s(:send, nil, :foo)
|
166
166
|
# and set variable_name to :foo
|
167
|
-
if isa_receiver
|
167
|
+
if isa_receiver&.type == :send && isa_receiver.children[0].nil? && isa_receiver.children[1].is_a?(Symbol)
|
168
168
|
variable_name = isa_receiver.children[1].to_s
|
169
169
|
end
|
170
170
|
# or like this:
|
171
171
|
# (lvar :repr)
|
172
|
-
variable_name = isa_receiver.children[0].to_s if isa_receiver
|
172
|
+
variable_name = isa_receiver.children[0].to_s if isa_receiver&.type == :lvar
|
173
173
|
return unless variable_name
|
174
174
|
|
175
175
|
[isa_type_name, variable_name]
|
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.3
|
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-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: backport
|