solargraph 0.54.2 → 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.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +18 -0
  3. data/lib/solargraph/api_map/cache.rb +10 -1
  4. data/lib/solargraph/api_map/index.rb +167 -0
  5. data/lib/solargraph/api_map/store.rb +68 -121
  6. data/lib/solargraph/api_map.rb +20 -13
  7. data/lib/solargraph/bench.rb +17 -1
  8. data/lib/solargraph/complex_type/unique_type.rb +21 -1
  9. data/lib/solargraph/complex_type.rb +13 -12
  10. data/lib/solargraph/convention.rb +1 -0
  11. data/lib/solargraph/doc_map.rb +1 -0
  12. data/lib/solargraph/equality.rb +33 -0
  13. data/lib/solargraph/language_server/host/message_worker.rb +3 -0
  14. data/lib/solargraph/language_server/host.rb +2 -1
  15. data/lib/solargraph/language_server/message/base.rb +1 -1
  16. data/lib/solargraph/language_server/message/initialize.rb +3 -1
  17. data/lib/solargraph/language_server/message/text_document/formatting.rb +4 -0
  18. data/lib/solargraph/library.rb +7 -7
  19. data/lib/solargraph/location.rb +7 -0
  20. data/lib/solargraph/parser/node_methods.rb +1 -1
  21. data/lib/solargraph/parser/node_processor.rb +1 -0
  22. data/lib/solargraph/parser/parser_gem/class_methods.rb +2 -6
  23. data/lib/solargraph/parser/parser_gem/node_chainer.rb +7 -13
  24. data/lib/solargraph/parser/parser_gem/node_methods.rb +2 -2
  25. data/lib/solargraph/parser/parser_gem/node_processors/lvasgn_node.rb +2 -2
  26. data/lib/solargraph/pin/base.rb +27 -16
  27. data/lib/solargraph/pin/base_variable.rb +3 -2
  28. data/lib/solargraph/pin/callable.rb +3 -3
  29. data/lib/solargraph/pin/method.rb +6 -0
  30. data/lib/solargraph/pin/namespace.rb +1 -1
  31. data/lib/solargraph/pin/parameter.rb +2 -1
  32. data/lib/solargraph/position.rb +7 -0
  33. data/lib/solargraph/range.rb +7 -0
  34. data/lib/solargraph/rbs_map/conversions.rb +1 -1
  35. data/lib/solargraph/rbs_map.rb +1 -0
  36. data/lib/solargraph/shell.rb +2 -0
  37. data/lib/solargraph/source/chain/array.rb +1 -1
  38. data/lib/solargraph/source/chain/call.rb +9 -4
  39. data/lib/solargraph/source/chain/hash.rb +5 -0
  40. data/lib/solargraph/source/chain/if.rb +5 -0
  41. data/lib/solargraph/source/chain/link.rb +17 -5
  42. data/lib/solargraph/source/chain/literal.rb +5 -0
  43. data/lib/solargraph/source/chain.rb +33 -19
  44. data/lib/solargraph/source/cursor.rb +0 -11
  45. data/lib/solargraph/source.rb +2 -1
  46. data/lib/solargraph/source_map/clip.rb +1 -1
  47. data/lib/solargraph/type_checker.rb +8 -8
  48. data/lib/solargraph/version.rb +1 -1
  49. data/lib/solargraph/workspace/config.rb +7 -3
  50. data/lib/solargraph/workspace.rb +1 -1
  51. data/lib/solargraph/yard_map/mapper/to_constant.rb +1 -0
  52. data/lib/solargraph/yard_map/mapper/to_namespace.rb +1 -0
  53. data/lib/solargraph/yard_map/mapper.rb +1 -0
  54. data/lib/solargraph/yardoc.rb +1 -1
  55. data/lib/solargraph.rb +1 -0
  56. data/solargraph.gemspec +1 -1
  57. metadata +11 -3
@@ -7,6 +7,7 @@ module Solargraph
7
7
  GENERIC_TAG_NAME = 'generic'.freeze
8
8
  # @!parse
9
9
  # include TypeMethods
10
+ include Equality
10
11
 
11
12
  autoload :TypeMethods, 'solargraph/complex_type/type_methods'
12
13
  autoload :UniqueType, 'solargraph/complex_type/unique_type'
@@ -18,17 +19,9 @@ module Solargraph
18
19
  @items = types.flat_map(&:items).uniq(&:to_s)
19
20
  end
20
21
 
21
- def eql?(other)
22
- self.class == other.class &&
23
- @items == other.items
24
- end
25
-
26
- def ==(other)
27
- self.eql?(other)
28
- end
29
-
30
- def hash
31
- [self.class, @items].hash
22
+ # @sg-ignore Fix "Not enough arguments to Module#protected"
23
+ protected def equality_fields
24
+ [self.class, items]
32
25
  end
33
26
 
34
27
  # @param api_map [ApiMap]
@@ -154,14 +147,22 @@ module Solargraph
154
147
  map(&:tag).join(', ')
155
148
  end
156
149
 
150
+ def desc
151
+ rooted_tags
152
+ end
153
+
157
154
  def rooted_tags
158
155
  map(&:rooted_tag).join(', ')
159
156
  end
160
157
 
158
+ # @yieldparam [UniqueType]
161
159
  def all? &block
162
160
  @items.all? &block
163
161
  end
164
162
 
163
+ # @yieldparam [UniqueType]
164
+ # @yieldreturn [Boolean]
165
+ # @return [Boolean]
165
166
  def any? &block
166
167
  @items.compact.any? &block
167
168
  end
@@ -263,7 +264,7 @@ module Solargraph
263
264
  # Consumers should not need to use this parameter; it should only be
264
265
  # used internally.
265
266
  #
266
- # @param *strings [Array<String>] The type definitions to parse
267
+ # @param strings [Array<String>] The type definitions to parse
267
268
  # @return [ComplexType]
268
269
  # # @overload parse(*strings, partial: false)
269
270
  # # @todo Need ability to use a literal true as a type below
@@ -11,6 +11,7 @@ module Solargraph
11
11
  autoload :Gemspec, 'solargraph/convention/gemspec'
12
12
  autoload :Rakefile, 'solargraph/convention/rakefile'
13
13
 
14
+ # @type [Set<Convention::Base>]
14
15
  @@conventions = Set.new
15
16
 
16
17
  # @param convention [Class<Convention::Base>]
@@ -112,6 +112,7 @@ module Solargraph
112
112
  true
113
113
  end
114
114
 
115
+ # @param gemspec [Gem::Specification]
115
116
  def update_from_collection gemspec, gempins
116
117
  return gempins unless @rbs_path && File.directory?(@rbs_path)
117
118
  return gempins if RbsMap.new(gemspec.name, gemspec.version).resolved?
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Solargraph
4
+ # @abstract This mixin relies on these -
5
+ # methods:
6
+ # equality_fields()
7
+ module Equality
8
+ # @!method equality_fields
9
+ # @return [Array]
10
+
11
+ # @param other [Object]
12
+ # @return [Boolean]
13
+ def eql?(other)
14
+ self.class.eql?(other.class) &&
15
+ equality_fields.eql?(other.equality_fields)
16
+ end
17
+
18
+ # @param other [Object]
19
+ # @return [Boolean]
20
+ def ==(other)
21
+ self.eql?(other)
22
+ end
23
+
24
+ def hash
25
+ equality_fields.hash
26
+ end
27
+
28
+ def freeze
29
+ equality_fields.each(&:freeze)
30
+ super
31
+ end
32
+ end
33
+ end
@@ -94,6 +94,9 @@ module Solargraph
94
94
  # True if the message requires a previous update to have executed in
95
95
  # order to work correctly.
96
96
  #
97
+ # @param msg [Hash{String => Object}]
98
+ # @todo need boolish type from RBS
99
+ # @return [Object]
97
100
  def version_dependent? msg
98
101
  msg['textDocument'] && msg['position']
99
102
  end
@@ -471,6 +471,7 @@ module Solargraph
471
471
  def locate_pins params
472
472
  return [] unless params['data'] && params['data']['uri']
473
473
  library = library_for(params['data']['uri'])
474
+ # @type [Array<Pin::Base>]
474
475
  result = []
475
476
  if params['data']['location']
476
477
  location = Location.new(
@@ -570,7 +571,7 @@ module Solargraph
570
571
  # @param column [Integer]
571
572
  # @param strip [Boolean] Strip special characters from variable names
572
573
  # @param only [Boolean] If true, search current file only
573
- # @return [Array<Solargraph::Range>]
574
+ # @return [Array<Solargraph::Location>]
574
575
  def references_from uri, line, column, strip: true, only: false
575
576
  library = library_for(uri)
576
577
  library.references_from(uri_to_file(uri), line, column, strip: strip, only: only)
@@ -16,7 +16,7 @@ module Solargraph
16
16
  # @return [String]
17
17
  attr_reader :method
18
18
 
19
- # @return [Hash{String => Array, Hash, String, Integer}]
19
+ # @return [Hash{String => Array<undefined>, Hash{String => undefined}, String, Integer}]
20
20
  attr_reader :params
21
21
 
22
22
  # @return [Hash, Array, nil]
@@ -174,7 +174,9 @@ module Solargraph
174
174
 
175
175
  # @param section [String]
176
176
  # @param capability [String]
177
- # @return [Boolean]
177
+ # @todo Need support for RBS' boolish "type", which doesn't
178
+ # enforce strict true/false-ness
179
+ # @sg-ignore
178
180
  def dynamic_registration_for? section, capability
179
181
  result = (params['capabilities'] &&
180
182
  params['capabilities'][section] &&
@@ -33,6 +33,7 @@ module Solargraph
33
33
 
34
34
  private
35
35
 
36
+ # @param corrections [String]
36
37
  def log_corrections(corrections)
37
38
  corrections = corrections&.strip
38
39
  return if corrections&.empty?
@@ -51,6 +52,7 @@ module Solargraph
51
52
  conf['rubocop'] || {}
52
53
  end
53
54
 
55
+ # @param config [Hash{String => String}]
54
56
  def cli_args file_uri, config
55
57
  file = UriHelpers.uri_to_file(file_uri)
56
58
  args = [
@@ -68,6 +70,7 @@ module Solargraph
68
70
  args + [file]
69
71
  end
70
72
 
73
+ # @param config [Hash{String => String}]
71
74
  def formatter_class(config)
72
75
  if self.class.const_defined?('BlankRubocopFormatter')
73
76
  # @sg-ignore
@@ -79,6 +82,7 @@ module Solargraph
79
82
  end
80
83
  end
81
84
 
85
+ # @param value [Array, String]
82
86
  def cop_list(value)
83
87
  value = value.join(',') if value.respond_to?(:join)
84
88
  return nil if value == '' || !value.is_a?(String)
@@ -132,6 +132,7 @@ module Solargraph
132
132
  result = false
133
133
  filenames.each do |filename|
134
134
  detach filename
135
+ source_map_hash.delete(filename)
135
136
  result ||= workspace.remove(filename)
136
137
  end
137
138
  result
@@ -192,11 +193,7 @@ module Solargraph
192
193
  else
193
194
  mutex.synchronize do
194
195
  clip = api_map.clip(cursor)
195
- if cursor.assign?
196
- [Pin::ProxyType.new(name: cursor.word, return_type: clip.infer)]
197
- else
198
- clip.define.map { |pin| pin.realize(api_map) }
199
- end
196
+ clip.define.map { |pin| pin.realize(api_map) }
200
197
  end
201
198
  end
202
199
  rescue FileNotFoundError => e
@@ -240,7 +237,7 @@ module Solargraph
240
237
  # @param column [Integer]
241
238
  # @param strip [Boolean] Strip special characters from variable names
242
239
  # @param only [Boolean] Search for references in the current file only
243
- # @return [Array<Solargraph::Range>]
240
+ # @return [Array<Solargraph::Location>]
244
241
  # @todo Take a Location instead of filename/line/column
245
242
  def references_from filename, line, column, strip: false, only: false
246
243
  sync_catalog
@@ -398,6 +395,8 @@ module Solargraph
398
395
  return [] unless open?(filename)
399
396
  result = []
400
397
  source = read(filename)
398
+
399
+ # @type [Hash{Class<Solargraph::Diagnostics::Base> => Array<String>}]
401
400
  repargs = {}
402
401
  workspace.config.reporters.each do |line|
403
402
  if line == 'all!'
@@ -431,7 +430,8 @@ module Solargraph
431
430
  Bench.new(
432
431
  source_maps: source_map_hash.values,
433
432
  workspace: workspace,
434
- external_requires: external_requires
433
+ external_requires: external_requires,
434
+ live_map: @current ? source_map_hash[@current.filename] : nil
435
435
  )
436
436
  end
437
437
 
@@ -5,6 +5,8 @@ module Solargraph
5
5
  # and Range.
6
6
  #
7
7
  class Location
8
+ include Equality
9
+
8
10
  # @return [String]
9
11
  attr_reader :filename
10
12
 
@@ -18,6 +20,11 @@ module Solargraph
18
20
  @range = range
19
21
  end
20
22
 
23
+ # @sg-ignore Fix "Not enough arguments to Module#protected"
24
+ protected def equality_fields
25
+ [filename, range]
26
+ end
27
+
21
28
  # @param location [self]
22
29
  def contain? location
23
30
  range.contain?(location.range.start) && range.contain?(location.range.ending) && filename == location.filename
@@ -74,7 +74,7 @@ module Solargraph
74
74
 
75
75
  # @abstract
76
76
  # @param node [Parser::AST::Node]
77
- # @return [Hash{Parser::AST::Node => Chain}]
77
+ # @return [Hash{Parser::AST::Node => Source::Chain}]
78
78
  def convert_hash node
79
79
  raise NotImplementedError
80
80
  end
@@ -9,6 +9,7 @@ module Solargraph
9
9
  autoload :Base, 'solargraph/parser/node_processor/base'
10
10
 
11
11
  class << self
12
+ # @type [Hash<Symbol, Class<NodeProcessor::Base>>]
12
13
  @@processors ||= {}
13
14
 
14
15
  # Register a processor for a node type.
@@ -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
 
@@ -89,21 +89,15 @@ module Solargraph
89
89
  elsif n.type == :const
90
90
  const = unpack_name(n)
91
91
  result.push Chain::Constant.new(const)
92
- elsif [:lvasgn, :ivasgn, :gvasgn, :cvasgn].include?(n.type)
93
- result.concat generate_links(n.children[1])
94
- elsif n.type == :lvar
92
+ elsif [:lvar, :lvasgn].include?(n.type)
95
93
  result.push Chain::Call.new(n.children[0].to_s)
96
- elsif n.type == :ivar
97
- result.push Chain::InstanceVariable.new(n.children[0].to_s)
98
- elsif n.type == :cvar
99
- result.push Chain::ClassVariable.new(n.children[0].to_s)
100
- elsif n.type == :gvar
101
- result.push Chain::GlobalVariable.new(n.children[0].to_s)
94
+ elsif [:ivar, :ivasgn].include?(n.type)
95
+ result.push Chain::InstanceVariable.new(n.children[0].to_s)
96
+ elsif [:cvar, :cvasgn].include?(n.type)
97
+ result.push Chain::ClassVariable.new(n.children[0].to_s)
98
+ elsif [:gvar, :gvasgn].include?(n.type)
99
+ result.push Chain::GlobalVariable.new(n.children[0].to_s)
102
100
  elsif n.type == :or_asgn
103
- # @todo: Need a new Link class here that evaluates the
104
- # existing variable type with the RHS, and generates a
105
- # union type of the LHS alone if never nil, or minus nil +
106
- # RHS if it is nilable.
107
101
  result.concat generate_links n.children[1]
108
102
  elsif [:class, :module, :def, :defs].include?(n.type)
109
103
  # @todo Undefined or what?
@@ -12,7 +12,7 @@ require 'ast'
12
12
  # class Node
13
13
  # # New children
14
14
  #
15
- # # @return [Array<AST::Node>]
15
+ # # @return [Array<self>]
16
16
  # attr_reader :children
17
17
  # end
18
18
  # end
@@ -462,7 +462,7 @@ module Solargraph
462
462
  result
463
463
  end
464
464
 
465
- # @param nodes [Enumerable<Parser::AST::Node, BaseObject>]
465
+ # @param nodes [Enumerable<Parser::AST::Node, BasicObject>]
466
466
  # @return [Array<Parser::AST::Node, nil>]
467
467
  def reduce_to_value_nodes nodes
468
468
  result = []
@@ -8,8 +8,8 @@ module Solargraph
8
8
  include ParserGem::NodeMethods
9
9
 
10
10
  def process
11
- # variable not visible until next statement
12
- presence = Range.new(get_node_end_position(node), region.closure.location.range.ending)
11
+ here = get_node_start_position(node)
12
+ presence = Range.new(here, region.closure.location.range.ending)
13
13
  loc = get_node_location(node)
14
14
  locals.push Solargraph::Pin::LocalVariable.new(
15
15
  location: loc,
@@ -78,7 +78,7 @@ module Solargraph
78
78
  !return_type || return_type.all_rooted?
79
79
  end
80
80
 
81
- # @param generics_to_erase [Enumerable<String>]
81
+ # @param generics_to_erase [::Array<String>]
82
82
  # @return [self]
83
83
  def erase_generics(generics_to_erase)
84
84
  return self if generics_to_erase.empty?
@@ -102,7 +102,7 @@ module Solargraph
102
102
  end
103
103
 
104
104
  def to_s
105
- to_rbs
105
+ desc
106
106
  end
107
107
 
108
108
  # @return [Boolean]
@@ -115,14 +115,6 @@ module Solargraph
115
115
  location || type_location
116
116
  end
117
117
 
118
- # Pin equality is determined using the #nearly? method and also
119
- # requiring both pins to have the same location.
120
- #
121
- def == other
122
- return false unless nearly? other
123
- comments == other.comments and location == other.location
124
- end
125
-
126
118
  # True if the specified pin is a near match to this one. A near match
127
119
  # indicates that the pins contain mostly the same data. Any differences
128
120
  # between them should not have an impact on the API surface.
@@ -139,6 +131,14 @@ module Solargraph
139
131
  )
140
132
  end
141
133
 
134
+ # Pin equality is determined using the #nearly? method and also
135
+ # requiring both pins to have the same location.
136
+ #
137
+ def == other
138
+ return false unless nearly? other
139
+ comments == other.comments && location == other.location
140
+ end
141
+
142
142
  # The pin's return type.
143
143
  #
144
144
  # @return [ComplexType]
@@ -265,9 +265,10 @@ module Solargraph
265
265
  result
266
266
  end
267
267
 
268
+ # @deprecated
268
269
  # @return [String]
269
270
  def identity
270
- @identity ||= "#{closure.path}|#{name}"
271
+ @identity ||= "#{closure&.path}|#{name}"
271
272
  end
272
273
 
273
274
  # @return [String, nil]
@@ -275,19 +276,29 @@ module Solargraph
275
276
  return_type.to_rbs
276
277
  end
277
278
 
278
- # @return [String, nil]
279
- def desc
279
+ # @return [String]
280
+ def type_desc
281
+ rbs = to_rbs
282
+ # RBS doesn't have a way to represent a Class<x> type
283
+ rbs = return_type.rooted_tags if return_type.name == 'Class'
280
284
  if path
281
- if to_rbs
282
- path + ' ' + to_rbs
285
+ if rbs
286
+ path + ' ' + rbs
283
287
  else
284
288
  path
285
289
  end
286
290
  else
287
- to_rbs
291
+ rbs
288
292
  end
289
293
  end
290
294
 
295
+ # @return [String]
296
+ def desc
297
+ closure_info = closure&.desc
298
+ binder_info = binder&.desc
299
+ "[#{type_desc}, closure=#{closure_info}, binder=#{binder}"
300
+ end
301
+
291
302
  def inspect
292
303
  "#<#{self.class} `#{self.desc}` at #{self.location.inspect}>"
293
304
  end
@@ -93,6 +93,7 @@ module Solargraph
93
93
  assignment == other.assignment
94
94
  end
95
95
 
96
+ # @param pin [self]
96
97
  def try_merge! pin
97
98
  return false unless super
98
99
  @assignment = pin.assignment
@@ -100,8 +101,8 @@ module Solargraph
100
101
  true
101
102
  end
102
103
 
103
- def desc
104
- "#{to_rbs} = #{assignment&.type.inspect}"
104
+ def type_desc
105
+ "#{super} = #{assignment&.type.inspect}"
105
106
  end
106
107
 
107
108
  private
@@ -3,7 +3,7 @@
3
3
  module Solargraph
4
4
  module Pin
5
5
  class Callable < Closure
6
- # @return [self]
6
+ # @return [Signature]
7
7
  attr_reader :block
8
8
 
9
9
  attr_reader :parameters
@@ -57,7 +57,7 @@ module Solargraph
57
57
  callable
58
58
  end
59
59
 
60
- # @param generics_to_resolve [Enumerable<String>]
60
+ # @param generics_to_resolve [::Array<String>]
61
61
  # @param arg_types [Array<ComplexType>, nil]
62
62
  # @param return_type_context [ComplexType, nil]
63
63
  # @param yield_arg_types [Array<ComplexType>, nil]
@@ -113,7 +113,7 @@ module Solargraph
113
113
  end
114
114
 
115
115
  # @param arguments [::Array<Chain>]
116
- # @param signature [Pin::Signature]
116
+ # @param with_block [Boolean]
117
117
  # @return [Boolean]
118
118
  def arity_matches? arguments, with_block
119
119
  argcount = arguments.length
@@ -31,6 +31,10 @@ module Solargraph
31
31
  @anon_splat = anon_splat
32
32
  end
33
33
 
34
+ def == other
35
+ super && other.node == node
36
+ end
37
+
34
38
  def transform_types(&transform)
35
39
  # @todo 'super' alone should work here I think, but doesn't typecheck at level typed
36
40
  m = super(&transform)
@@ -262,6 +266,7 @@ module Solargraph
262
266
  @attribute
263
267
  end
264
268
 
269
+ # @parm other [Method]
265
270
  def nearly? other
266
271
  super &&
267
272
  parameters == other.parameters &&
@@ -273,6 +278,7 @@ module Solargraph
273
278
  attribute? ? infer_from_iv(api_map) : infer_from_return_nodes(api_map)
274
279
  end
275
280
 
281
+ # @param pin [Pin::Method]
276
282
  def try_merge! pin
277
283
  return false unless super
278
284
  @node = pin.node
@@ -48,7 +48,7 @@ module Solargraph
48
48
  if name.nil? || name.empty?
49
49
  '(top-level)'
50
50
  else
51
- to_rbs
51
+ return_type.rooted_tags
52
52
  end
53
53
  end
54
54
 
@@ -3,7 +3,7 @@
3
3
  module Solargraph
4
4
  module Pin
5
5
  class Parameter < LocalVariable
6
- # @return [Symbol]
6
+ # @return [::Symbol]
7
7
  attr_reader :decl
8
8
 
9
9
  # @return [String]
@@ -121,6 +121,7 @@ module Solargraph
121
121
  tag.text
122
122
  end
123
123
 
124
+ # @param pin [Pin::Parameter]
124
125
  def try_merge! pin
125
126
  return false unless super && closure == pin.closure
126
127
  true
@@ -4,6 +4,8 @@ module Solargraph
4
4
  # The zero-based line and column numbers of a position in a string.
5
5
  #
6
6
  class Position
7
+ include Equality
8
+
7
9
  # @return [Integer]
8
10
  attr_reader :line
9
11
 
@@ -19,6 +21,11 @@ module Solargraph
19
21
  @character = character
20
22
  end
21
23
 
24
+ # @sg-ignore Fix "Not enough arguments to Module#protected"
25
+ protected def equality_fields
26
+ [line, character]
27
+ end
28
+
22
29
  # Get a hash of the position. This representation is suitable for use in
23
30
  # the language server protocol.
24
31
  #
@@ -4,6 +4,8 @@ module Solargraph
4
4
  # A pair of Positions that compose a section of text in code.
5
5
  #
6
6
  class Range
7
+ include Equality
8
+
7
9
  # @return [Position]
8
10
  attr_reader :start
9
11
 
@@ -17,6 +19,11 @@ module Solargraph
17
19
  @ending = ending
18
20
  end
19
21
 
22
+ # @sg-ignore Fix "Not enough arguments to Module#protected"
23
+ protected def equality_fields
24
+ [start, ending]
25
+ end
26
+
20
27
  # Get a hash of the range. This representation is suitable for use in
21
28
  # the language server protocol.
22
29
  #
@@ -321,7 +321,7 @@ module Solargraph
321
321
  # @return [void]
322
322
  def method_def_to_sigs decl, pin
323
323
  decl.overloads.map do |overload|
324
- generics = overload.method_type.type_params.map(&:to_s)
324
+ generics = overload.method_type.type_params.map(&:name).map(&:to_s)
325
325
  signature_parameters, signature_return_type = parts_of_function(overload.method_type, pin)
326
326
  block = if overload.method_type.block
327
327
  block_parameters, block_return_type = parts_of_function(overload.method_type.block, pin)
@@ -64,6 +64,7 @@ module Solargraph
64
64
  @@rbs_maps_hash[library] ||= RbsMap.new(library)
65
65
  end
66
66
 
67
+ # @param gemspec [Gem::Specification]
67
68
  def self.from_gemspec(gemspec)
68
69
  RbsMap.new(gemspec.name, gemspec.version)
69
70
  end
@@ -111,6 +111,7 @@ module Solargraph
111
111
  also be specified to clear cached system documentation.
112
112
  Documentation will be regenerated as needed.
113
113
  )
114
+ # @param gems [Array<String>]
114
115
  # @return [void]
115
116
  def uncache *gems
116
117
  raise ArgumentError, 'No gems specified.' if gems.empty?
@@ -133,6 +134,7 @@ module Solargraph
133
134
 
134
135
  desc 'gems [GEM[=VERSION]]', 'Cache documentation for installed gems'
135
136
  option :rebuild, type: :boolean, desc: 'Rebuild existing documentation', default: false
137
+ # @param names [Array<String>]
136
138
  # @return [void]
137
139
  def gems *names
138
140
  if names.empty?
@@ -14,7 +14,7 @@ module Solargraph
14
14
 
15
15
  # @param api_map [ApiMap]
16
16
  # @param name_pin [Pin::Base]
17
- # @param locals [Enumerable<Pin::LocalVariable>]
17
+ # @param locals [::Array<Pin::Parameter, Pin::LocalVariable>]
18
18
  def resolve api_map, name_pin, locals
19
19
  child_types = @children.map do |child|
20
20
  child.infer(api_map, name_pin, locals)