solargraph 0.39.7 → 0.39.8

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: 86abdabe74326a279a6dc6c3f02ff09dc469e1e92cfd5f89ac3a3363ce47e146
4
- data.tar.gz: 1772fe6f16f7531758d5c5853201b86c334eec8ef3f049ae764f6aa3d2d4c118
3
+ metadata.gz: 17711680892b43f0ee8848707305dfdb801e7fc15f65e3426fab759dc0309c20
4
+ data.tar.gz: 6e8a9089d203ef9a405da33e449f3c4291d57d741e0bde5d615ecc629276a60a
5
5
  SHA512:
6
- metadata.gz: 6256341e8373235c53af95ab62fc61b02c2a3b755391786d6d28ae8b2373a141f8b4b875789760adfbdf333dfd020bff15d791c4d423cd90f5b96b6e8d9e2750
7
- data.tar.gz: da4580767cecf3c62ad1e949a3ee0a97ac3a07785e52cacc5d53977f6ac6db8db4507c912136455646be196aa915920632e776aec98ddeb1d686868539707290
6
+ metadata.gz: 33685a93c52c6417d88f07a76dd4af8c77bf6446d551615e3a745462c622a7808b200638d0af8dbe269cd41c92cac6ba234bb86c29bf7f385ff9d39dd1155ff7
7
+ data.tar.gz: a53bfd06eb1d3e56564ca03b434ba48169e2f56e7712d7eda0f26f67a3830741a70729df280cc80414d69e6586034cbdb7eea11bf31ee87a83a1eabe3b04da05
@@ -1,5 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ Encoding.default_external = 'UTF-8'
4
+
5
+ require 'solargraph/compat'
3
6
  require 'solargraph/version'
4
7
 
5
8
  # The top-level namespace for the Solargraph code mapping, documentation,
@@ -26,7 +26,6 @@ module Solargraph
26
26
  def initialize pins: []
27
27
  @source_map_hash = {}
28
28
  @cache = Cache.new
29
- @mutex = Mutex.new
30
29
  @method_alias_stack = []
31
30
  index pins
32
31
  end
@@ -34,13 +33,11 @@ module Solargraph
34
33
  # @param pins [Array<Pin::Base>]
35
34
  # @return [self]
36
35
  def index pins
37
- @mutex.synchronize {
38
- @source_map_hash.clear
39
- @cache.clear
40
- @store = Store.new(pins + YardMap.new.pins)
41
- @unresolved_requires = []
42
- workspace_filenames.clear
43
- }
36
+ @source_map_hash.clear
37
+ @cache.clear
38
+ @store = Store.new(pins + YardMap.new.pins)
39
+ @unresolved_requires = []
40
+ workspace_filenames.clear
44
41
  self
45
42
  end
46
43
 
@@ -123,14 +120,14 @@ module Solargraph
123
120
  reqs.merge br.keys
124
121
  yard_map.change(reqs.to_a, br, bundle.workspace.gemnames)
125
122
  new_store = Store.new(pins + yard_map.pins)
126
- @mutex.synchronize {
127
- @cache.clear
128
- @source_map_hash = new_map_hash
129
- @store = new_store
130
- @unresolved_requires = yard_map.unresolved_requires
131
- workspace_filenames.clear
132
- workspace_filenames.concat bundle.workspace.filenames
133
- }
123
+ @cache.clear
124
+ @source_map_hash = new_map_hash
125
+ @store = new_store
126
+ @unresolved_requires = yard_map.unresolved_requires
127
+ workspace_filenames.clear
128
+ workspace_filenames.concat bundle.workspace.filenames
129
+ @rebindable_method_names = nil
130
+ store.block_pins.each { |blk| blk.rebind(self) }
134
131
  self
135
132
  end
136
133
 
@@ -179,6 +176,16 @@ module Solargraph
179
176
  store.pins
180
177
  end
181
178
 
179
+ def rebindable_method_names
180
+ @rebindable_method_names ||= begin
181
+ result = yard_map.rebindable_method_names
182
+ source_maps.each do |map|
183
+ result.merge map.rebindable_method_names
184
+ end
185
+ result
186
+ end
187
+ end
188
+
182
189
  # An array of pins based on Ruby keywords (`if`, `end`, etc.).
183
190
  #
184
191
  # @return [Array<Solargraph::Pin::Keyword>]
@@ -280,8 +287,7 @@ module Solargraph
280
287
 
281
288
  # @return [Array<Solargraph::Pin::GlobalVariable>]
282
289
  def get_global_variable_pins
283
- # @todo Slow version
284
- pins.select{ |p| p.is_a?(Pin::GlobalVariable) }
290
+ store.pins_by_class(Pin::GlobalVariable)
285
291
  end
286
292
 
287
293
  # Get an array of methods available in a particular context.
@@ -535,17 +541,17 @@ module Solargraph
535
541
  #
536
542
  # @return [Hash{String => SourceMap}]
537
543
  def source_map_hash
538
- @mutex.synchronize { @source_map_hash }
544
+ @source_map_hash
539
545
  end
540
546
 
541
547
  # @return [ApiMap::Store]
542
548
  def store
543
- @mutex.synchronize { @store }
549
+ @store
544
550
  end
545
551
 
546
552
  # @return [Solargraph::ApiMap::Cache]
547
553
  def cache
548
- @mutex.synchronize { @cache }
554
+ @cache
549
555
  end
550
556
 
551
557
  # @param fqns [String] A fully qualified namespace
@@ -10,6 +10,7 @@ module Solargraph
10
10
  @receiver_definitions = {}
11
11
  end
12
12
 
13
+ # @return [Array<Pin::BaseMethod>]
13
14
  def get_methods fqns, scope, visibility, deep
14
15
  @methods[[fqns, scope, visibility.sort, deep]]
15
16
  end
@@ -18,6 +19,7 @@ module Solargraph
18
19
  @methods[[fqns, scope, visibility.sort, deep]] = value
19
20
  end
20
21
 
22
+ # @return [Array<Pin::Base>]
21
23
  def get_constants namespace, context
22
24
  @constants[[namespace, context]]
23
25
  end
@@ -26,6 +28,7 @@ module Solargraph
26
28
  @constants[[namespace, context]] = value
27
29
  end
28
30
 
31
+ # @return [String]
29
32
  def get_qualified_namespace name, context
30
33
  @qualified_namespaces[[name, context]]
31
34
  end
@@ -38,6 +41,7 @@ module Solargraph
38
41
  @receiver_definitions.key? path
39
42
  end
40
43
 
44
+ # @return [Pin::BaseMethod]
41
45
  def get_receiver_definition path
42
46
  @receiver_definitions[path]
43
47
  end
@@ -99,12 +99,12 @@ module Solargraph
99
99
 
100
100
  # @return [Array<Solargraph::Pin::Base>]
101
101
  def namespace_pins
102
- @namespace_pins ||= []
102
+ pins_by_class(Solargraph::Pin::Namespace)
103
103
  end
104
104
 
105
- # @return [Array<Solargraph::Pin::Base>]
105
+ # @return [Array<Solargraph::Pin::BaseMethod>]
106
106
  def method_pins
107
- @method_pins ||= []
107
+ pins_by_class(Solargraph::Pin::BaseMethod)
108
108
  end
109
109
 
110
110
  # @param fqns [String]
@@ -133,7 +133,7 @@ module Solargraph
133
133
 
134
134
  # @return [Array<Pin::Block>]
135
135
  def block_pins
136
- @block_pins ||= []
136
+ pins_by_class(Pin::Block)
137
137
  end
138
138
 
139
139
  def inspect
@@ -141,6 +141,12 @@ module Solargraph
141
141
  to_s
142
142
  end
143
143
 
144
+ # @param klass [Class]
145
+ # @return [Array<Solargraph::Pin::Base>]
146
+ def pins_by_class klass
147
+ @pin_select_cache[klass] ||= @pin_class_hash.select { |key, _| key <= klass }.values.flatten
148
+ end
149
+
144
150
  private
145
151
 
146
152
  # @param fqns [String]
@@ -167,7 +173,7 @@ module Solargraph
167
173
 
168
174
  # @return [Array<Solargraph::Pin::Symbol>]
169
175
  def symbols
170
- @symbols ||= []
176
+ pins_by_class(Pin::Symbol)
171
177
  end
172
178
 
173
179
  def superclass_references
@@ -198,7 +204,7 @@ module Solargraph
198
204
  end
199
205
 
200
206
  def all_instance_variables
201
- @all_instance_variables ||= []
207
+ pins_by_class(Pin::InstanceVariable)
202
208
  end
203
209
 
204
210
  def path_pin_hash
@@ -207,48 +213,29 @@ module Solargraph
207
213
 
208
214
  # @return [void]
209
215
  def index
210
- namespace_map.clear
211
- namespaces.clear
212
- namespace_pins.clear
213
- method_pins.clear
214
- symbols.clear
215
- block_pins.clear
216
- all_instance_variables.clear
217
- path_pin_hash.clear
218
- namespace_map[''] = []
219
- override_pins = []
220
- pins.each do |pin|
221
- namespace_map[pin.namespace] ||= []
222
- namespace_map[pin.namespace].push pin
223
- namespaces.add pin.path if pin.is_a?(Pin::Namespace) && !pin.path.empty?
224
- namespace_pins.push pin if pin.is_a?(Pin::Namespace)
225
- method_pins.push pin if pin.is_a?(Pin::BaseMethod)
226
- symbols.push pin if pin.is_a?(Pin::Symbol)
227
- if pin.is_a?(Pin::Reference::Include)
228
- include_references[pin.namespace] ||= []
229
- include_references[pin.namespace].push pin.name
230
- elsif pin.is_a?(Pin::Reference::Prepend)
231
- prepend_references[pin.namespace] ||= []
232
- prepend_references[pin.namespace].push pin.name
233
- elsif pin.is_a?(Pin::Reference::Extend)
234
- extend_references[pin.namespace] ||= []
235
- extend_references[pin.namespace].push pin.name
236
- elsif pin.is_a?(Pin::Reference::Superclass)
237
- superclass_references[pin.namespace] ||= []
238
- superclass_references[pin.namespace].push pin.name
239
- elsif pin.is_a?(Pin::Block)
240
- block_pins.push pin
241
- elsif pin.is_a?(Pin::InstanceVariable)
242
- all_instance_variables.push pin
243
- elsif pin.is_a?(Pin::Reference::Override)
244
- override_pins.push pin
245
- end
246
- if pin.path
247
- path_pin_hash[pin.path] ||= []
248
- path_pin_hash[pin.path].push pin
249
- end
216
+ set = pins.to_set
217
+ @pin_class_hash = set.classify(&:class).transform_values(&:to_a)
218
+ @pin_select_cache = {}
219
+ @namespace_map = set.classify(&:namespace).transform_values(&:to_a)
220
+ @path_pin_hash = set.classify(&:path).transform_values(&:to_a)
221
+ @namespaces = @path_pin_hash.keys.compact
222
+ pins_by_class(Pin::Reference::Include).each do |pin|
223
+ include_references[pin.namespace] ||= []
224
+ include_references[pin.namespace].push pin.name
225
+ end
226
+ pins_by_class(Pin::Reference::Prepend).each do |pin|
227
+ prepend_references[pin.namespace] ||= []
228
+ prepend_references[pin.namespace].push pin.name
229
+ end
230
+ pins_by_class(Pin::Reference::Extend).each do |pin|
231
+ extend_references[pin.namespace] ||= []
232
+ extend_references[pin.namespace].push pin.name
233
+ end
234
+ pins_by_class(Pin::Reference::Superclass).each do |pin|
235
+ superclass_references[pin.namespace] ||= []
236
+ superclass_references[pin.namespace].push pin.name
250
237
  end
251
- override_pins.each do |ovr|
238
+ pins_by_class(Pin::Reference::Override).each do |ovr|
252
239
  pin = get_path_pins(ovr.name).first
253
240
  next if pin.nil?
254
241
  (ovr.tags.map(&:tag_name) + ovr.delete).uniq.each do |tag|
@@ -261,6 +248,7 @@ module Solargraph
261
248
  # @todo This is probably not the best place for these overrides
262
249
  superclass_references['Integer'] = ['Numeric']
263
250
  superclass_references['Float'] = ['Numeric']
251
+ superclass_references['File'] = ['IO']
264
252
  end
265
253
  end
266
254
  end
@@ -0,0 +1,9 @@
1
+ unless Hash.method_defined?(:transform_values)
2
+ class Hash
3
+ def transform_values &block
4
+ each_pair do |k, v|
5
+ self[k] = block.call(v)
6
+ end
7
+ end
8
+ end
9
+ end
@@ -36,6 +36,8 @@ module Solargraph
36
36
  process_prepend
37
37
  elsif node.children[1] == :require
38
38
  process_require
39
+ elsif node.children[1] == :autoload
40
+ process_autoload
39
41
  elsif node.children[1] == :private_constant
40
42
  process_private_constant
41
43
  elsif node.children[1] == :alias_method && node.children[2] && node.children[2] && node.children[2].type == :sym && node.children[3] && node.children[3].type == :sym
@@ -138,6 +140,14 @@ module Solargraph
138
140
  end
139
141
  end
140
142
 
143
+ # @return [void]
144
+ def process_autoload
145
+ if node.children[3].is_a?(AST::Node) && node.children[3].type == :str
146
+ path = node.children[3].children[0].to_s
147
+ pins.push Pin::Reference::Require.new(get_node_location(node), path)
148
+ end
149
+ end
150
+
141
151
  # @return [void]
142
152
  def process_module_function
143
153
  if node.children[2].nil?
@@ -28,6 +28,8 @@ module Solargraph
28
28
  process_module_function
29
29
  elsif node.children[0] == :require
30
30
  process_require
31
+ elsif node.children[0] == :autoload
32
+ process_autoload
31
33
  elsif node.children[0] == :alias_method
32
34
  process_alias_method
33
35
  elsif node.children[0] == :private_class_method
@@ -143,6 +145,15 @@ module Solargraph
143
145
  end
144
146
  end
145
147
 
148
+ # @return [void]
149
+ def process_autoload
150
+ return unless Parser.is_ast_node?(node.children[1]) && Parser.is_ast_node?(node.children[1].children[1])
151
+ arg = node.children[1].children[1]
152
+ if arg.type == :STR
153
+ pins.push Pin::Reference::Require.new(get_node_location(arg), arg.children[0])
154
+ end
155
+ end
156
+
146
157
  # @return [void]
147
158
  def process_module_function
148
159
  if node.type == :VCALL
@@ -23,7 +23,7 @@ module Solargraph
23
23
 
24
24
  # @param location [Solargraph::Location]
25
25
  # @param kind [Integer]
26
- # @param closure [String]
26
+ # @param closure [Solargraph::Pin::Closure]
27
27
  # @param name [String]
28
28
  # @param comments [String]
29
29
  def initialize location: nil, closure: nil, name: '', comments: ''
@@ -38,7 +38,7 @@ module Solargraph
38
38
  @comments ||= ''
39
39
  end
40
40
 
41
- # @return [String]
41
+ # @return [String, nil]
42
42
  def filename
43
43
  return nil if location.nil?
44
44
  location.filename
@@ -14,17 +14,14 @@ module Solargraph
14
14
  @parameters = args
15
15
  end
16
16
 
17
- def rebind context
18
- @rebound = true
19
- @binder = context unless context.undefined?
20
- end
21
-
22
- def rebound?
23
- @rebound ||= false
17
+ # @param api_map [ApiMap]
18
+ # @return [void]
19
+ def rebind api_map
20
+ @binder ||= binder_or_nil(api_map)
24
21
  end
25
22
 
26
23
  def binder
27
- @binder || context
24
+ @binder || closure.binder
28
25
  end
29
26
 
30
27
  # @return [Array<String>]
@@ -37,11 +34,28 @@ module Solargraph
37
34
  @parameter_names ||= parameters.map(&:name)
38
35
  end
39
36
 
40
- def nearly? other
41
- return false unless super
42
- # @todo Trying to not to block merges too much
43
- # receiver == other.receiver and parameters == other.parameters
44
- true
37
+ private
38
+
39
+ # @param api_map [ApiMap]
40
+ # @return [ComplexType, nil]
41
+ def binder_or_nil api_map
42
+ return nil unless receiver
43
+ word = receiver.children.find { |c| c.is_a?(::Symbol) }.to_s
44
+ return nil unless api_map.rebindable_method_names.include?(word)
45
+ chain = Parser.chain(receiver, location.filename)
46
+ locals = api_map.source_map(location.filename).locals_at(location)
47
+ if ['instance_eval', 'instance_exec', 'class_eval', 'class_exec', 'module_eval', 'module_exec'].include?(chain.links.last.word)
48
+ return chain.base.infer(api_map, self, locals)
49
+ else
50
+ receiver_pin = chain.define(api_map, self, locals).first
51
+ if receiver_pin && receiver_pin.docstring
52
+ ys = receiver_pin.docstring.tag(:yieldself)
53
+ if ys && ys.types && !ys.types.empty?
54
+ return ComplexType.try_parse(*ys.types).qualify(api_map, receiver_pin.context.namespace)
55
+ end
56
+ end
57
+ end
58
+ nil
45
59
  end
46
60
  end
47
61
  end
@@ -57,7 +57,6 @@ module Solargraph
57
57
  # @param locals [Array<Pin::Base>]
58
58
  # @return [Array<Pin::Base>]
59
59
  def define api_map, name_pin, locals
60
- rebind_block name_pin, api_map, locals
61
60
  return [] if undefined?
62
61
  working_pin = name_pin
63
62
  links[0..-2].each do |link|
@@ -79,7 +78,6 @@ module Solargraph
79
78
  # @param locals [Array<Pin::Base>]
80
79
  # @return [ComplexType]
81
80
  def infer api_map, name_pin, locals
82
- rebind_block name_pin, api_map, locals
83
81
  pins = define(api_map, name_pin, locals)
84
82
  infer_first_defined(pins, links.last.last_context, api_map)
85
83
  end
@@ -138,35 +136,6 @@ module Solargraph
138
136
  return type if context.nil? || context.return_type.undefined?
139
137
  type.self_to(context.return_type.namespace)
140
138
  end
141
-
142
- def skippable_block_receivers api_map
143
- @@skippable_block_receivers ||= (
144
- api_map.get_methods('Array', deep: false).map(&:name) +
145
- api_map.get_methods('Enumerable', deep: false).map(&:name) +
146
- api_map.get_methods('Hash', deep: false).map(&:name) +
147
- ['new']
148
- ).to_set
149
- end
150
-
151
- def rebind_block pin, api_map, locals
152
- return unless pin.is_a?(Pin::Block) && pin.receiver && !pin.rebound?
153
- # This first rebind just sets the block pin's rebound state
154
- pin.rebind ComplexType::UNDEFINED
155
- chain = Parser.chain(pin.receiver, pin.location.filename)
156
- return if skippable_block_receivers(api_map).include?(chain.links.last.word)
157
- if ['instance_eval', 'instance_exec', 'class_eval', 'class_exec', 'module_eval', 'module_exec'].include?(chain.links.last.word)
158
- type = chain.base.infer(api_map, pin, locals)
159
- pin.rebind type
160
- else
161
- receiver_pin = chain.define(api_map, pin, locals).first
162
- return if receiver_pin.nil? || receiver_pin.docstring.nil?
163
- ys = receiver_pin.docstring.tag(:yieldself)
164
- unless ys.nil? || ys.types.nil? || ys.types.empty?
165
- ysct = ComplexType.try_parse(*ys.types).qualify(api_map, receiver_pin.context.namespace)
166
- pin.rebind ysct
167
- end
168
- end
169
- end
170
139
  end
171
140
  end
172
141
  end
@@ -17,7 +17,6 @@ module Solargraph
17
17
  # @param position [Position]
18
18
  # @return [Source::Chain]
19
19
  def chain source, position
20
- # raise "Not a source" unless source.is_a?(Source)
21
20
  new(source, position).chain
22
21
  end
23
22
  end
@@ -32,6 +31,8 @@ module Solargraph
32
31
 
33
32
  # @return [Source::Chain]
34
33
  def chain
34
+ # Special handling for files that end with an integer and a period
35
+ return Chain.new([Chain::Literal.new('Integer'), Chain::UNDEFINED_CALL]) if phrase =~ /^[0-9]+\.$/
35
36
  return Chain.new([Chain::Literal.new('Symbol')]) if phrase.start_with?(':') && !phrase.start_with?('::')
36
37
  begin
37
38
  return Chain.new([]) if phrase.end_with?('..')
@@ -3,6 +3,7 @@
3
3
  require 'jaro_winkler'
4
4
  require 'yard'
5
5
  require 'yard-solargraph'
6
+ require 'set'
6
7
 
7
8
  module Solargraph
8
9
  # An index of pins and other ApiMap-related data for a Source.
@@ -30,6 +31,19 @@ module Solargraph
30
31
  @pins = pins
31
32
  @locals = locals
32
33
  environ.merge Convention.for(source)
34
+ @pin_class_hash = pins.to_set.classify(&:class).transform_values(&:to_a)
35
+ @pin_select_cache = {}
36
+ end
37
+
38
+ def pins_by_class klass
39
+ @pin_select_cache[klass] ||= @pin_class_hash.select { |key, _| key <= klass }.values.flatten
40
+ end
41
+
42
+ def rebindable_method_names
43
+ @rebindable_method_names ||= pins_by_class(Pin::Method)
44
+ .select { |pin| pin.comments && pin.comments.include?('@yieldself') }
45
+ .map(&:name)
46
+ .to_set
33
47
  end
34
48
 
35
49
  # @return [String]
@@ -44,7 +58,7 @@ module Solargraph
44
58
 
45
59
  # @return [Array<Pin::Reference::Require>]
46
60
  def requires
47
- @requires ||= pins.select{ |p| p.is_a?(Pin::Reference::Require) }
61
+ pins_by_class(Pin::Reference::Require)
48
62
  end
49
63
 
50
64
  # @return [Environ]
@@ -20,6 +20,14 @@ module Solargraph
20
20
  Override.method_return('Pathname#cleanpath', 'Pathname'),
21
21
  Override.method_return('Pathname#children', 'Array<Pathname>'),
22
22
  Override.method_return('Pathname#entries', 'Array<Pathname>')
23
+ ],
24
+
25
+ 'set' => [
26
+ Override.method_return('Enumerable#to_set', 'Set'),
27
+ Override.method_return('Set#add', 'self'),
28
+ Override.method_return('Set#add?', 'self, nil'),
29
+ Override.method_return('Set#classify', 'Hash'),
30
+ Override.from_comment('Set#each', '@yieldparam_single_parameter')
23
31
  ]
24
32
  }
25
33
 
@@ -74,7 +74,7 @@ module Solargraph
74
74
  def method_tag_problems
75
75
  result = []
76
76
  # @param pin [Pin::BaseMethod]
77
- source_map.pins.select { |pin| pin.is_a?(Pin::BaseMethod) }.each do |pin|
77
+ source_map.pins_by_class(Pin::BaseMethod).each do |pin|
78
78
  result.concat method_return_type_problems_for(pin)
79
79
  result.concat method_param_type_problems_for(pin)
80
80
  end
@@ -184,8 +184,7 @@ module Solargraph
184
184
 
185
185
  # @return [Array<Pin::BaseVariable>]
186
186
  def all_variables
187
- source_map.pins.select { |pin| pin.is_a?(Pin::BaseVariable) } +
188
- source_map.locals.select { |pin| pin.is_a?(Pin::LocalVariable) }
187
+ source_map.pins_by_class(Pin::BaseVariable) + source_map.locals.select { |pin| pin.is_a?(Pin::LocalVariable) }
189
188
  end
190
189
 
191
190
  def const_problems
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Solargraph
4
- VERSION = '0.39.7'
4
+ VERSION = '0.39.8'
5
5
  end
@@ -3,6 +3,7 @@
3
3
  require 'yard'
4
4
  require 'yard-solargraph'
5
5
  require 'rubygems/package'
6
+ require 'set'
6
7
 
7
8
  module Solargraph
8
9
  # The YardMap provides access to YARD documentation for the Ruby core, the
@@ -56,6 +57,7 @@ module Solargraph
56
57
  @source_gems = []
57
58
  process_requires
58
59
  yardocs.uniq!
60
+ @pin_select_cache = {}
59
61
  end
60
62
 
61
63
  # @return [Array<Solargraph::Pin::Base>]
@@ -80,10 +82,22 @@ module Solargraph
80
82
  @gemset = new_gemset
81
83
  @source_gems = source_gems
82
84
  process_requires
85
+ @rebindable_method_names = nil
86
+ @pin_class_hash = nil
87
+ @pin_select_cache = {}
83
88
  true
84
89
  end
85
90
  end
86
91
 
92
+ # @return [Set<String>]
93
+ def rebindable_method_names
94
+ @rebindable_method_names ||= pins_by_class(Pin::Method)
95
+ .select { |pin| pin.comments && pin.comments.include?('@yieldself') }
96
+ .map(&:name)
97
+ .concat(['instance_eval', 'instance_exec', 'class_eval', 'class_exec', 'module_eval', 'module_exec'])
98
+ .to_set
99
+ end
100
+
87
101
  # @return [Array<String>]
88
102
  def yardocs
89
103
  @yardocs ||= []
@@ -144,6 +158,14 @@ module Solargraph
144
158
  @cache ||= YardMap::Cache.new
145
159
  end
146
160
 
161
+ def pin_class_hash
162
+ @pin_class_hash ||= pins.to_set.classify(&:class).transform_values(&:to_a)
163
+ end
164
+
165
+ def pins_by_class klass
166
+ @pin_select_cache[klass] ||= pin_class_hash.select { |key, _| key <= klass }.values.flatten
167
+ end
168
+
147
169
  # @param ns [YARD::CodeObjects::NamespaceObject]
148
170
  # @return [Array<YARD::CodeObjects::Base>]
149
171
  def recurse_namespace_object ns
@@ -27,7 +27,7 @@ Gem::Specification.new do |s|
27
27
  s.add_runtime_dependency 'maruku', '~> 0.7', '>= 0.7.3'
28
28
  s.add_runtime_dependency 'nokogiri', '~> 1.9', '>= 1.9.1'
29
29
  s.add_runtime_dependency 'parser', '~> 2.3'
30
- s.add_runtime_dependency 'reverse_markdown', '~> 1.0', '>= 1.0.5'
30
+ s.add_runtime_dependency 'reverse_markdown', '>= 1.0.5', '< 3'
31
31
  s.add_runtime_dependency 'rubocop', '~> 0.52'
32
32
  s.add_runtime_dependency 'thor', '~> 1.0'
33
33
  s.add_runtime_dependency 'tilt', '~> 2.0'
Binary file
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.39.7
4
+ version: 0.39.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fred Snyder
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-05-04 00:00:00.000000000 Z
11
+ date: 2020-05-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: backport
@@ -138,22 +138,22 @@ dependencies:
138
138
  name: reverse_markdown
139
139
  requirement: !ruby/object:Gem::Requirement
140
140
  requirements:
141
- - - "~>"
142
- - !ruby/object:Gem::Version
143
- version: '1.0'
144
141
  - - ">="
145
142
  - !ruby/object:Gem::Version
146
143
  version: 1.0.5
144
+ - - "<"
145
+ - !ruby/object:Gem::Version
146
+ version: '3'
147
147
  type: :runtime
148
148
  prerelease: false
149
149
  version_requirements: !ruby/object:Gem::Requirement
150
150
  requirements:
151
- - - "~>"
152
- - !ruby/object:Gem::Version
153
- version: '1.0'
154
151
  - - ">="
155
152
  - !ruby/object:Gem::Version
156
153
  version: 1.0.5
154
+ - - "<"
155
+ - !ruby/object:Gem::Version
156
+ version: '3'
157
157
  - !ruby/object:Gem::Dependency
158
158
  name: rubocop
159
159
  requirement: !ruby/object:Gem::Requirement
@@ -317,6 +317,7 @@ files:
317
317
  - lib/solargraph/api_map/source_to_yard.rb
318
318
  - lib/solargraph/api_map/store.rb
319
319
  - lib/solargraph/bundle.rb
320
+ - lib/solargraph/compat.rb
320
321
  - lib/solargraph/complex_type.rb
321
322
  - lib/solargraph/complex_type/type_methods.rb
322
323
  - lib/solargraph/complex_type/unique_type.rb