solargraph 0.54.4 → 0.54.5

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: 469236908941a1221785c7add8041544e118731b99e8a81b766856b96acbb307
4
- data.tar.gz: 6f2cf614a67abd04e53bb3a30a5ce2bc51b6b9cac16c474818e959c1e4c582ab
3
+ metadata.gz: 155e6f0e4fc44166c0d4b3c1ba6691ff1d1629d229adf8d37f6d3fe4b5fc0c77
4
+ data.tar.gz: c33c4dab114c6a70b3c0dfbee6a5ccdc379cf284af3d34dae8a30473dbcdc517
5
5
  SHA512:
6
- metadata.gz: 22777792098e88c264a08e8a9785df73e00b1ed20fbfb4efe0988f9cb8aa5deec93ae520961672f2848ac7b2bf02fefccbb83a14e0c9092c2e18bd861d938f0b
7
- data.tar.gz: f154c4badced68ac0ab43bfe43c380009787c424f909801da183fdaf63e9a818daf62eb7ddb904172b9f91957d634758732460aab317235bf163c9d26921f452
6
+ metadata.gz: 267350435fa9592fc49dc2c5b05f9f9157b576025ea4ed9abe3ebc58e4344d7412805ace58920585105fbb81eaa2bad246416c5456ce66656f22c8639054002d
7
+ data.tar.gz: 7a3860337657dc869e7a96f8b95509867ece49db13e89523e09c1567490b427ed41f5fc57c87e5d8477bfe3857cbe97512bd811598adbb53f4a2f617e724c44c
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## 0.54.5 - May 17, 2025
2
+ - Repair unknown encoding errors (#936, #935)
3
+ - Index arbitrary pinsets (#937)
4
+ - Separate YARD cache from doc map cache (#938)
5
+
1
6
  ## 0.54.4 - May 14, 2025
2
7
  - Delete files from Library hash (#932)
3
8
  - Clip#define returns variable pins (#934, #933)
@@ -4,7 +4,7 @@ module Solargraph
4
4
  class ApiMap
5
5
  class Index
6
6
  # @param pins [Array<Pin::Base>]
7
- def initialize pins
7
+ def initialize pins = []
8
8
  catalog pins
9
9
  end
10
10
 
@@ -1,18 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
-
4
3
  module Solargraph
5
4
  class ApiMap
6
5
  # Queryable collection of Pins representing a Workspace, gems and the Ruby
7
6
  # core.
8
7
  #
9
8
  class Store
10
- # @param static [Enumerable<Pin::Base>]
11
- # @param dynamic [Enumerable<Pin::Base>]
12
- def initialize static = [], dynamic = []
13
- @static_index = Index.new(static)
14
- @dynamic = dynamic
15
- @index = @static_index.merge(dynamic)
9
+ # @param pinsets [Array<Enumerable<Pin::Base>>]
10
+ def initialize *pinsets
11
+ catalog pinsets
16
12
  end
17
13
 
18
14
  # @return [Array<Solargraph::Pin::Base>]
@@ -20,19 +16,27 @@ module Solargraph
20
16
  index.pins
21
17
  end
22
18
 
23
- # @param static [Enumerable<Pin::Base>]
24
- # @param dynamic [Enumerable<Pin::Base>]
25
- def update! static = [], dynamic = []
19
+ # @param pinsets [Array<Enumerable<Pin::Base>>]
20
+ # @return [Boolean] True if the index was updated
21
+ def update *pinsets
22
+ return catalog(pinsets) if pinsets.length != @pinsets.length
23
+
24
+ changed = pinsets.find_index.with_index { |pinset, idx| @pinsets[idx] != pinset }
25
+ return false unless changed
26
+
26
27
  # @todo Fix this map
27
28
  @fqns_pins_map = nil
28
- if @static_index.pins == static
29
- return self if @dynamic == dynamic
30
- else
31
- @static_index = Index.new(static)
29
+ return catalog(pinsets) if changed == 0
30
+
31
+ pinsets[changed..].each_with_index do |pins, idx|
32
+ @pinsets[changed + idx] = pins
33
+ @indexes[changed + idx] = if pins.empty?
34
+ @indexes[changed + idx - 1]
35
+ else
36
+ @indexes[changed + idx - 1].merge(pins)
37
+ end
32
38
  end
33
- @dynamic = dynamic
34
- @index = @static_index.merge(dynamic)
35
- self
39
+ true
36
40
  end
37
41
 
38
42
  def to_s
@@ -190,7 +194,22 @@ module Solargraph
190
194
 
191
195
  private
192
196
 
193
- attr_reader :index
197
+ def index
198
+ @indexes.last
199
+ end
200
+
201
+ def catalog pinsets
202
+ @pinsets = pinsets
203
+ @indexes = []
204
+ pinsets.each do |pins|
205
+ if @indexes.last && pins.empty?
206
+ @indexes.push @indexes.last
207
+ else
208
+ @indexes.push(@indexes.last&.merge(pins) || Solargraph::ApiMap::Index.new(pins))
209
+ end
210
+ end
211
+ true
212
+ end
194
213
 
195
214
  # @return [Hash{::Array(String, String) => ::Array<Pin::Namespace>}]
196
215
  def fqns_pins_map
@@ -66,7 +66,7 @@ module Solargraph
66
66
  @source_map_hash = {}
67
67
  implicit.clear
68
68
  cache.clear
69
- store.update! @@core_map.pins, pins
69
+ store.update @@core_map.pins, pins
70
70
  self
71
71
  end
72
72
 
@@ -85,11 +85,9 @@ module Solargraph
85
85
  # @param bench [Bench]
86
86
  # @return [self]
87
87
  def catalog bench
88
- old_api_hash = @source_map_hash&.values&.map(&:api_hash)
89
- need_to_uncache = (old_api_hash != bench.source_maps.map(&:api_hash))
90
- # @todo Work around #to_h problem in current Ruby head (3.5)
91
- @source_map_hash = bench.source_maps.map { |s| [s.filename, s] }.to_h
92
- pins = bench.source_maps.flat_map(&:pins).flatten
88
+ @source_map_hash = bench.source_map_hash
89
+ iced_pins = bench.icebox.flat_map(&:pins)
90
+ live_pins = bench.live_map&.pins || []
93
91
  implicit.clear
94
92
  source_map_hash.each_value do |map|
95
93
  implicit.merge map.environ
@@ -98,11 +96,8 @@ module Solargraph
98
96
  if @unresolved_requires != unresolved_requires || @doc_map&.uncached_gemspecs&.any?
99
97
  @doc_map = DocMap.new(unresolved_requires, [], bench.workspace.rbs_collection_path) # @todo Implement gem preferences
100
98
  @unresolved_requires = unresolved_requires
101
- need_to_uncache = true
102
99
  end
103
- store.update! @@core_map.pins + @doc_map.pins, implicit.pins + pins
104
- @cache.clear if need_to_uncache
105
-
100
+ @cache.clear if store.update(@@core_map.pins, @doc_map.pins, implicit.pins, iced_pins, live_pins)
106
101
  @missing_docs = [] # @todo Implement missing docs
107
102
  self
108
103
  end
@@ -111,7 +106,7 @@ module Solargraph
111
106
  # that this overload of 'protected' will typecheck @sg-ignore
112
107
  # @sg-ignore
113
108
  protected def equality_fields
114
- [self.class, @source_map_hash, implicit, @doc_map, @unresolved_requires, @missing_docs]
109
+ [self.class, @source_map_hash, implicit, @doc_map, @unresolved_requires]
115
110
  end
116
111
 
117
112
  # @return [::Array<Gem::Specification>]
@@ -11,18 +11,34 @@ module Solargraph
11
11
  # @return [Workspace]
12
12
  attr_reader :workspace
13
13
 
14
+ # @return [SourceMap]
15
+ attr_reader :live_map
16
+
14
17
  # @return [Set<String>]
15
18
  attr_reader :external_requires
16
19
 
17
20
  # @param source_maps [Array<SourceMap>, Set<SourceMap>]
18
21
  # @param workspace [Workspace]
22
+ # @param live_map [SourceMap, nil]
19
23
  # @param external_requires [Array<String>, Set<String>]
20
- def initialize source_maps: [], workspace: Workspace.new, external_requires: []
24
+ def initialize source_maps: [], workspace: Workspace.new, live_map: nil, external_requires: []
21
25
  @source_maps = source_maps.to_set
22
26
  @workspace = workspace
27
+ @live_map = live_map
23
28
  @external_requires = external_requires.reject { |path| workspace.would_require?(path) }
24
29
  .compact
25
30
  .to_set
26
31
  end
32
+
33
+ # @return [Hash{String => SourceMap}]
34
+ def source_map_hash
35
+ # @todo Work around #to_h bug in current Ruby head (3.5) with #map#to_h
36
+ @source_map_hash ||= source_maps.map { |s| [s.filename, s] }
37
+ .to_h
38
+ end
39
+
40
+ def icebox
41
+ @icebox ||= (source_maps - [live_map])
42
+ end
27
43
  end
28
44
  end
@@ -430,7 +430,8 @@ module Solargraph
430
430
  Bench.new(
431
431
  source_maps: source_map_hash.values,
432
432
  workspace: workspace,
433
- external_requires: external_requires
433
+ external_requires: external_requires,
434
+ live_map: @current ? source_map_hash[@current.filename] : nil
434
435
  )
435
436
  end
436
437
 
@@ -11,13 +11,9 @@ module Solargraph
11
11
  # @param filename [String, nil]
12
12
  # @return [Array(Parser::AST::Node, Hash{Integer => String})]
13
13
  def parse_with_comments code, filename = nil
14
- buffer = ::Parser::Source::Buffer.new(filename, 0)
15
- buffer.source = code
16
- node = parser.parse(buffer)
14
+ node = parse(code, filename)
17
15
  comments = CommentRipper.new(code, filename, 0).parse
18
16
  [node, comments]
19
- rescue ::Parser::SyntaxError => e
20
- raise Parser::SyntaxError, e.message
21
17
  end
22
18
 
23
19
  # @param code [String]
@@ -28,7 +24,7 @@ module Solargraph
28
24
  buffer = ::Parser::Source::Buffer.new(filename, line)
29
25
  buffer.source = code
30
26
  parser.parse(buffer)
31
- rescue ::Parser::SyntaxError => e
27
+ rescue ::Parser::SyntaxError, ::Parser::UnknownEncodingInMagicComment => e
32
28
  raise Parser::SyntaxError, e.message
33
29
  end
34
30
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Solargraph
4
- VERSION = '0.54.4'
4
+ VERSION = '0.54.5'
5
5
  end
@@ -35,7 +35,7 @@ module Solargraph
35
35
  # @param gemspec [Gem::Specification]
36
36
  # @return [String]
37
37
  def path_for(gemspec)
38
- File.join(Solargraph::Cache.work_dir, 'gems', "#{gemspec.name}-#{gemspec.version}.yardoc")
38
+ File.join(Solargraph::Cache.base_dir, "yard-#{YARD::VERSION}", "#{gemspec.name}-#{gemspec.version}.yardoc")
39
39
  end
40
40
 
41
41
  # Load a gem's yardoc and return its code objects.
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.54.4
4
+ version: 0.54.5
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-05-14 00:00:00.000000000 Z
11
+ date: 2025-05-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: backport
@@ -643,7 +643,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
643
643
  - !ruby/object:Gem::Version
644
644
  version: '0'
645
645
  requirements: []
646
- rubygems_version: 3.3.7
646
+ rubygems_version: 3.5.22
647
647
  signing_key:
648
648
  specification_version: 4
649
649
  summary: A Ruby language server