solargraph 0.32.5 → 0.33.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (125) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/README.md +2 -11
  4. data/lib/solargraph.rb +1 -2
  5. data/lib/solargraph/api_map.rb +93 -63
  6. data/lib/solargraph/api_map/cache.rb +16 -1
  7. data/lib/solargraph/api_map/source_to_yard.rb +16 -7
  8. data/lib/solargraph/api_map/store.rb +55 -12
  9. data/lib/solargraph/complex_type.rb +58 -14
  10. data/lib/solargraph/complex_type/type_methods.rb +2 -2
  11. data/lib/solargraph/complex_type/unique_type.rb +33 -4
  12. data/lib/solargraph/core_fills.rb +40 -12
  13. data/lib/solargraph/diagnostics.rb +4 -3
  14. data/lib/solargraph/diagnostics/base.rb +6 -0
  15. data/lib/solargraph/diagnostics/require_not_found.rb +17 -10
  16. data/lib/solargraph/diagnostics/rubocop_helpers.rb +2 -0
  17. data/lib/solargraph/diagnostics/type_check.rb +51 -0
  18. data/lib/solargraph/diagnostics/update_errors.rb +1 -0
  19. data/lib/solargraph/language_server/host.rb +55 -25
  20. data/lib/solargraph/language_server/host/diagnoser.rb +1 -2
  21. data/lib/solargraph/language_server/host/dispatch.rb +4 -8
  22. data/lib/solargraph/language_server/host/sources.rb +1 -1
  23. data/lib/solargraph/language_server/message.rb +1 -0
  24. data/lib/solargraph/language_server/message/completion_item/resolve.rb +4 -2
  25. data/lib/solargraph/language_server/message/initialize.rb +9 -0
  26. data/lib/solargraph/language_server/message/initialized.rb +1 -0
  27. data/lib/solargraph/language_server/message/text_document.rb +1 -0
  28. data/lib/solargraph/language_server/message/text_document/code_action.rb +15 -0
  29. data/lib/solargraph/language_server/message/text_document/completion.rb +1 -1
  30. data/lib/solargraph/language_server/message/text_document/definition.rb +25 -5
  31. data/lib/solargraph/language_server/message/text_document/hover.rb +1 -1
  32. data/lib/solargraph/language_server/message/text_document/signature_help.rb +4 -0
  33. data/lib/solargraph/language_server/message/workspace/did_change_watched_files.rb +8 -4
  34. data/lib/solargraph/language_server/transport/adapter.rb +12 -15
  35. data/lib/solargraph/library.rb +23 -6
  36. data/lib/solargraph/location.rb +4 -0
  37. data/lib/solargraph/pin.rb +7 -3
  38. data/lib/solargraph/pin/attribute.rb +14 -13
  39. data/lib/solargraph/pin/base.rb +56 -43
  40. data/lib/solargraph/pin/base_method.rb +41 -18
  41. data/lib/solargraph/pin/base_variable.rb +17 -15
  42. data/lib/solargraph/pin/block.rb +22 -4
  43. data/lib/solargraph/pin/closure.rb +28 -0
  44. data/lib/solargraph/pin/common.rb +59 -0
  45. data/lib/solargraph/pin/constant.rb +4 -4
  46. data/lib/solargraph/pin/conversions.rb +8 -8
  47. data/lib/solargraph/pin/duck_method.rb +3 -3
  48. data/lib/solargraph/pin/instance_variable.rb +30 -0
  49. data/lib/solargraph/pin/keyword.rb +1 -1
  50. data/lib/solargraph/pin/local_variable.rb +3 -3
  51. data/lib/solargraph/pin/localized.rb +9 -5
  52. data/lib/solargraph/pin/method.rb +26 -40
  53. data/lib/solargraph/pin/method_alias.rb +9 -6
  54. data/lib/solargraph/pin/namespace.rb +33 -10
  55. data/lib/solargraph/pin/parameter.rb +150 -0
  56. data/lib/solargraph/pin/proxy_type.rb +8 -8
  57. data/lib/solargraph/pin/reference.rb +1 -12
  58. data/lib/solargraph/pin/reference/override.rb +18 -0
  59. data/lib/solargraph/pin/reference/require.rb +2 -1
  60. data/lib/solargraph/pin/singleton.rb +9 -0
  61. data/lib/solargraph/pin/symbol.rb +9 -4
  62. data/lib/solargraph/pin/yard_pin/constant.rb +12 -3
  63. data/lib/solargraph/pin/yard_pin/method.rb +18 -6
  64. data/lib/solargraph/pin/yard_pin/namespace.rb +13 -1
  65. data/lib/solargraph/position.rb +1 -1
  66. data/lib/solargraph/range.rb +4 -0
  67. data/lib/solargraph/shell.rb +83 -4
  68. data/lib/solargraph/source.rb +32 -12
  69. data/lib/solargraph/source/chain.rb +48 -28
  70. data/lib/solargraph/source/chain/call.rb +37 -38
  71. data/lib/solargraph/source/chain/constant.rb +1 -1
  72. data/lib/solargraph/source/chain/head.rb +2 -8
  73. data/lib/solargraph/source/chain/instance_variable.rb +1 -1
  74. data/lib/solargraph/source/chain/link.rb +2 -0
  75. data/lib/solargraph/source/cursor.rb +59 -24
  76. data/lib/solargraph/source/node_chainer.rb +0 -2
  77. data/lib/solargraph/source/node_methods.rb +12 -6
  78. data/lib/solargraph/source/source_chainer.rb +38 -44
  79. data/lib/solargraph/source_map.rb +11 -18
  80. data/lib/solargraph/source_map/clip.rb +13 -15
  81. data/lib/solargraph/source_map/mapper.rb +37 -26
  82. data/lib/solargraph/source_map/node_processor.rb +13 -8
  83. data/lib/solargraph/source_map/node_processor/alias_node.rb +8 -8
  84. data/lib/solargraph/source_map/node_processor/args_node.rb +10 -16
  85. data/lib/solargraph/source_map/node_processor/base.rb +47 -4
  86. data/lib/solargraph/source_map/node_processor/block_node.rb +9 -4
  87. data/lib/solargraph/source_map/node_processor/casgn_node.rb +7 -2
  88. data/lib/solargraph/source_map/node_processor/cvasgn_node.rb +8 -3
  89. data/lib/solargraph/source_map/node_processor/def_node.rb +45 -38
  90. data/lib/solargraph/source_map/node_processor/defs_node.rb +16 -6
  91. data/lib/solargraph/source_map/node_processor/gvasgn_node.rb +8 -1
  92. data/lib/solargraph/source_map/node_processor/ivasgn_node.rb +20 -6
  93. data/lib/solargraph/source_map/node_processor/lvasgn_node.rb +10 -4
  94. data/lib/solargraph/source_map/node_processor/namespace_node.rb +18 -12
  95. data/lib/solargraph/source_map/node_processor/orasgn_node.rb +1 -1
  96. data/lib/solargraph/source_map/node_processor/resbody_node.rb +30 -0
  97. data/lib/solargraph/source_map/node_processor/sclass_node.rb +7 -1
  98. data/lib/solargraph/source_map/node_processor/send_node.rb +102 -52
  99. data/lib/solargraph/source_map/node_processor/sym_node.rb +4 -1
  100. data/lib/solargraph/source_map/region.rb +9 -8
  101. data/lib/solargraph/type_checker.rb +282 -0
  102. data/lib/solargraph/type_checker/param_def.rb +47 -0
  103. data/lib/solargraph/type_checker/problem.rb +25 -0
  104. data/lib/solargraph/version.rb +1 -1
  105. data/lib/solargraph/views/environment.erb +1 -1
  106. data/lib/solargraph/workspace.rb +2 -2
  107. data/lib/solargraph/workspace/config.rb +0 -8
  108. data/lib/solargraph/yard_map.rb +25 -69
  109. data/lib/solargraph/yard_map/core_docs.rb +8 -3
  110. data/lib/solargraph/yard_map/core_gen.rb +1 -3
  111. data/lib/solargraph/yard_map/mapper.rb +85 -0
  112. data/lib/yard-solargraph.rb +2 -0
  113. metadata +14 -14
  114. data/lib/solargraph/diagnostics/type_not_defined.rb +0 -108
  115. data/lib/solargraph/live_map.rb +0 -126
  116. data/lib/solargraph/live_map/cache.rb +0 -38
  117. data/lib/solargraph/pin/block_parameter.rb +0 -103
  118. data/lib/solargraph/pin/method_parameter.rb +0 -40
  119. data/lib/solargraph/pin/plugin/method.rb +0 -25
  120. data/lib/solargraph/plugin.rb +0 -8
  121. data/lib/solargraph/plugin/base.rb +0 -41
  122. data/lib/solargraph/plugin/canceler.rb +0 -11
  123. data/lib/solargraph/plugin/process.rb +0 -172
  124. data/lib/solargraph/plugin/runtime.rb +0 -134
  125. data/lib/yard-coregen.rb +0 -16
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8c99435136ad89666edbb8b132cd5715509cf0c7c365f1a0d3613db1579a718b
4
- data.tar.gz: afc550f621504729249a88461a719d28440a5dc8dcc226a1bb99f87d6ae65b8d
3
+ metadata.gz: 158c70ae0a463e58b036390de759450ff08ef9021338fac799b572c2ca31c705
4
+ data.tar.gz: 5ff363662d8bca00cd0e66dc34845532d9d19e9812d5a04c6f9c8c18319ee609
5
5
  SHA512:
6
- metadata.gz: a1396aec7a3ca2fb02a71d06a1c994f89c361c38cecdea08fde2d6cba02d73a824e1feca0d1ad886c59158fb52c4022d82e1e410847dbad85784e299e23c3b95
7
- data.tar.gz: a6f1252139db4157a3a2fdb2a4322da06de9e16912cbd37c8450d51a921341071223fc10f24cf0e2d3798ba08e73c41dade0ccad20a704360ee2851640fc1e81
6
+ metadata.gz: dddd44984f04c8307e590cd96344dad5bf25e5765ca0a03d8de03028820ca7e58abc248d5dd9430ee9e6841de491f5a46a68a63f6b4db8b0508347fa2b3fd7b2
7
+ data.tar.gz: 9e394ad6f0558f8c194dd8efb667c58a3bc512ff65f98b11342e07270ed96f854a50904740b01bd23d0a4c31d4f944a82a8369a65802b1857425ea881a4d0058
data/.gitignore CHANGED
@@ -7,3 +7,4 @@ Gemfile.lock
7
7
  doc
8
8
  coverage
9
9
  /tmp/
10
+ guides
data/README.md CHANGED
@@ -59,6 +59,8 @@ The gem includes an executable that provides access to the library's features. F
59
59
  The language server protocol is the recommended way for integrating Solargraph into editors and IDEs. Clients can connect using either stdio or TCP.
60
60
  See [LANGUAGE_SERVER.md](LANGUAGE_SERVER.md) for more information.
61
61
 
62
+ ## Updating Core Documentation
63
+
62
64
  The Solargraph gem ships with documentation for Ruby 2.2.2. As of gem version 0.15.0, there's an option to download additional documentation for other Ruby versions from the command line.
63
65
 
64
66
  $ solargraph list-cores # List the installed documentation versions
@@ -78,17 +80,6 @@ Run `bundle install` and use `bundle exec yard gems` to generate the documentati
78
80
 
79
81
  In order to access the gems in your project, you'll need to start the language server with Bundler. In VS Code, there's a `solargraph.useBundler` option. Other clients will vary, but the command you probably want to run is `bundle exec solargraph socket` or `bundle exec solargraph stdio`.
80
82
 
81
- ## Runtime Suggestions (EXPERIMENTAL)
82
-
83
- As of gem version 0.15.0, Solargraph includes experimental support for plugins.
84
-
85
- The Runtime plugin enhances code completion by querying namespaces for method names in a subprocess. If it finds any undocumented or "magic" methods, they get added to the suggestions.
86
-
87
- This feature is currently disabled by default. If you'd like to try it, you can enable it by setting the `plugins` section in your project's .solargraph.yml file:
88
-
89
- plugins:
90
- - runtime
91
-
92
83
  ## Contributing to Solargraph
93
84
 
94
85
  ### Bug Reports and Feature Requests
@@ -23,9 +23,7 @@ module Solargraph
23
23
  autoload :ApiMap, 'solargraph/api_map'
24
24
  autoload :YardMap, 'solargraph/yard_map'
25
25
  autoload :Pin, 'solargraph/pin'
26
- autoload :LiveMap, 'solargraph/live_map'
27
26
  autoload :ServerMethods, 'solargraph/server_methods'
28
- autoload :Plugin, 'solargraph/plugin'
29
27
  autoload :CoreFills, 'solargraph/core_fills'
30
28
  autoload :LanguageServer, 'solargraph/language_server'
31
29
  autoload :Workspace, 'solargraph/workspace'
@@ -35,6 +33,7 @@ module Solargraph
35
33
  autoload :ComplexType, 'solargraph/complex_type'
36
34
  autoload :Bundle, 'solargraph/bundle'
37
35
  autoload :Logging, 'solargraph/logging'
36
+ autoload :TypeChecker, 'solargraph/type_checker'
38
37
 
39
38
  dir = File.dirname(__FILE__)
40
39
  YARDOC_PATH = File.realpath(File.join(dir, '..', 'yardoc'))
@@ -13,21 +13,15 @@ module Solargraph
13
13
 
14
14
  include SourceToYard
15
15
 
16
- # Get a LiveMap associated with the current workspace.
17
- #
18
- # @return [Solargraph::LiveMap]
19
- attr_reader :live_map
20
-
21
16
  # @return [Array<String>]
22
17
  attr_reader :unresolved_requires
23
18
 
24
19
  # @param pins [Array<Solargraph::Pin::Base>]
25
20
  def initialize pins: []
26
- # @todo Extensions don't work yet
27
- # require_extensions
28
21
  @source_map_hash = {}
29
22
  @cache = Cache.new
30
23
  @mutex = Mutex.new
24
+ @method_alias_stack = []
31
25
  index pins
32
26
  end
33
27
 
@@ -40,7 +34,6 @@ module Solargraph
40
34
  @store = Store.new(pins + YardMap.new.pins)
41
35
  @unresolved_requires = []
42
36
  }
43
- # resolve_method_aliases
44
37
  self
45
38
  end
46
39
 
@@ -97,12 +90,14 @@ module Solargraph
97
90
  reqs.concat map.requires.map(&:name)
98
91
  end
99
92
  reqs.concat bundle.workspace.config.required
93
+ local_path_hash.clear
100
94
  unless bundle.workspace.require_paths.empty?
101
95
  reqs.delete_if do |r|
102
96
  result = false
103
97
  bundle.workspace.require_paths.each do |l|
104
98
  pn = Pathname.new(bundle.workspace.directory).join(l, "#{r}.rb")
105
99
  if new_map_hash.keys.include?(pn.to_s)
100
+ local_path_hash[r] = pn.to_s
106
101
  result = true
107
102
  break
108
103
  end
@@ -118,10 +113,13 @@ module Solargraph
118
113
  @store = new_store
119
114
  @unresolved_requires = yard_map.unresolved_requires
120
115
  }
121
- # resolve_method_aliases
122
116
  self
123
117
  end
124
118
 
119
+ def local_path_hash
120
+ @local_paths ||= {}
121
+ end
122
+
125
123
  # @param filename [String]
126
124
  # @param position [Position, Array(Integer, Integer)]
127
125
  # @return [Source::Cursor]
@@ -218,9 +216,7 @@ module Solargraph
218
216
  # @param context [String] The context to search
219
217
  # @return [String]
220
218
  def qualify namespace, context = ''
221
- # @todo The return for self might work better elsewhere
222
- return nil if namespace.nil?
223
- return qualify(context) if namespace == 'self'
219
+ return namespace if ['self', nil].include?(namespace)
224
220
  cached = cache.get_qualified_namespace(namespace, context)
225
221
  return cached.clone unless cached.nil?
226
222
  result = if namespace.start_with?('::')
@@ -240,11 +236,13 @@ module Solargraph
240
236
  # @return [Array<Solargraph::Pin::InstanceVariable>]
241
237
  def get_instance_variable_pins(namespace, scope = :instance)
242
238
  result = []
239
+ used = [namespace]
243
240
  result.concat store.get_instance_variables(namespace, scope)
244
- sc = qualify(store.get_superclass(namespace), namespace)
245
- until sc.nil?
241
+ sc = qualify_lower(store.get_superclass(namespace), namespace)
242
+ until sc.nil? || used.include?(sc)
243
+ used.push sc
246
244
  result.concat store.get_instance_variables(sc, scope)
247
- sc = qualify(store.get_superclass(sc), sc)
245
+ sc = qualify_lower(store.get_superclass(sc), sc)
248
246
  end
249
247
  result
250
248
  end
@@ -274,7 +272,7 @@ module Solargraph
274
272
  # @param scope [Symbol] :class or :instance
275
273
  # @param visibility [Array<Symbol>] :public, :protected, and/or :private
276
274
  # @param deep [Boolean] True to include superclasses, mixins, etc.
277
- # @return [Array<Solargraph::Pin::Base>]
275
+ # @return [Array<Solargraph::Pin::BaseMethod>]
278
276
  def get_methods fqns, scope: :instance, visibility: [:public], deep: true
279
277
  cached = cache.get_methods(fqns, scope, visibility, deep)
280
278
  return cached.clone unless cached.nil?
@@ -292,12 +290,7 @@ module Solargraph
292
290
  else
293
291
  result.concat inner_get_methods(fqns, scope, visibility, deep, skip)
294
292
  end
295
- # live = live_map.get_methods(fqns, '', scope.to_s, visibility.include?(:private))
296
- # unless live.empty?
297
- # exist = result.map(&:name)
298
- # result.concat live.reject{|p| exist.include?(p.name)}
299
- # end
300
- resolved = resolve_method_aliases(result)
293
+ resolved = resolve_method_aliases(result, visibility)
301
294
  cache.set_methods(fqns, scope, visibility, deep, resolved)
302
295
  resolved
303
296
  end
@@ -327,7 +320,7 @@ module Solargraph
327
320
  result = []
328
321
  if type.duck_type?
329
322
  type.select(&:duck_type?).each do |t|
330
- result.push Pin::DuckMethod.new(nil, t.tag[1..-1])
323
+ result.push Pin::DuckMethod.new(name: t.tag[1..-1])
331
324
  end
332
325
  result.concat get_methods('Object')
333
326
  else
@@ -354,7 +347,7 @@ module Solargraph
354
347
  # @param fqns [String]
355
348
  # @param name [String]
356
349
  # @param scope [Symbol] :instance or :class
357
- # @return [Array<Solargraph::Pin::Base>]
350
+ # @return [Array<Solargraph::Pin::BaseMethod>]
358
351
  def get_method_stack fqns, name, scope: :instance
359
352
  get_methods(fqns, scope: scope, visibility: [:private, :protected, :public]).select{|p| p.name == name}
360
353
  end
@@ -369,10 +362,6 @@ module Solargraph
369
362
  return [] if path.nil?
370
363
  result = []
371
364
  result.concat store.get_path_pins(path)
372
- # if result.empty?
373
- # lp = live_map.get_path_pin(path)
374
- # result.push lp unless lp.nil?
375
- # end
376
365
  resolve_method_aliases(result)
377
366
  end
378
367
 
@@ -452,6 +441,11 @@ module Solargraph
452
441
  source_map_hash[filename].document_symbols
453
442
  end
454
443
 
444
+ # @return [Array<SourceMap>]
445
+ def source_maps
446
+ source_map_hash.values
447
+ end
448
+
455
449
  # Get a source map by filename.
456
450
  #
457
451
  # @param filename [String]
@@ -461,6 +455,42 @@ module Solargraph
461
455
  source_map_hash[filename]
462
456
  end
463
457
 
458
+ # True if the specified file was included in a bundle, i.e., it's either
459
+ # included in a workspace or open in a library.
460
+ #
461
+ # @param filename [String]
462
+ def bundled? filename
463
+ source_map_hash.keys.include?(filename)
464
+ end
465
+
466
+ # @param location [Location]
467
+ def require_reference_at location
468
+ map = source_map(location.filename)
469
+ pin = map.requires.select { |pin| pin.location.range.contain?(location.range.start) }.first
470
+ return nil if pin.nil?
471
+ if local_path_hash.key?(pin.name)
472
+ return Location.new(local_path_hash[pin.name], Solargraph::Range.from_to(0, 0, 0, 0))
473
+ end
474
+ yard_map.require_reference(pin.name)
475
+ rescue FileNotFoundError
476
+ nil
477
+ end
478
+
479
+ # Check if a class is a superclass of another class.
480
+ #
481
+ # @param sup [String] The superclass
482
+ # @param sub [String] The subclass
483
+ # @return [Boolean]
484
+ def super_and_sub?(sup, sub)
485
+ fqsup = qualify(sup)
486
+ cls = qualify(store.get_superclass(sub), sub)
487
+ until cls.nil?
488
+ return true if cls == fqsup
489
+ cls = qualify(store.get_superclass(cls), cls)
490
+ end
491
+ false
492
+ end
493
+
464
494
  private
465
495
 
466
496
  # @return [YardMap]
@@ -544,27 +574,21 @@ module Solargraph
544
574
  fqis = qualify(is, fqns)
545
575
  result.concat inner_get_constants(fqis, [:public], skip) unless fqis.nil?
546
576
  end
547
- # result.concat live_map.get_constants(fqns)
548
577
  result
549
578
  end
550
579
 
551
- # Require extensions for the experimental plugin architecture. Any
552
- # installed gem with a name that starts with "solargraph-" is considered
553
- # an extension.
554
- #
555
- # @return [void]
556
- def require_extensions
557
- Gem::Specification.all_names.select{|n| n.match(/^solargraph\-[a-z0-9_\-]*?\-ext\-[0-9\.]*$/)}.each do |n|
558
- Solargraph::Logging.logger.info "Loading extension #{n}"
559
- require n.match(/^(solargraph\-[a-z0-9_\-]*?\-ext)\-[0-9\.]*$/)[1]
560
- end
561
- end
562
-
563
580
  # @return [Hash]
564
581
  def path_macros
565
582
  @path_macros ||= {}
566
583
  end
567
584
 
585
+ # @param namespace [String]
586
+ # @param context [String]
587
+ # @return [String]
588
+ def qualify_lower namespace, context
589
+ qualify namespace, context.split('::')[0..-2].join('::')
590
+ end
591
+
568
592
  # @param name [String]
569
593
  # @param root [String]
570
594
  # @param skip [Array<String>]
@@ -599,7 +623,6 @@ module Solargraph
599
623
  end
600
624
  return name if store.namespace_exists?(name)
601
625
  end
602
- # live_map.get_fqns(name, root)
603
626
  end
604
627
 
605
628
  # Get the namespace's type (Class or Module).
@@ -608,6 +631,7 @@ module Solargraph
608
631
  # @return [Symbol] :class, :module, or nil
609
632
  def get_namespace_type fqns
610
633
  return nil if fqns.nil?
634
+ # @type [Pin::Namespace, nil]
611
635
  pin = store.get_path_pins(fqns).select{|p| p.is_a?(Pin::Namespace)}.first
612
636
  return nil if pin.nil?
613
637
  pin.type
@@ -630,30 +654,36 @@ module Solargraph
630
654
  result + nil_pins
631
655
  end
632
656
 
633
- # Check if a class is a superclass of another class.
634
- #
635
- # @param sup [String] The superclass
636
- # @param sub [String] The subclass
637
- # @return [Boolean]
638
- def super_and_sub?(sup, sub)
639
- fqsup = qualify(sup)
640
- cls = qualify(store.get_superclass(sub), sub)
641
- until cls.nil?
642
- return true if cls == fqsup
643
- cls = qualify(store.get_superclass(cls), cls)
644
- end
645
- false
646
- end
647
-
648
657
  # @param pins [Array<Pin::Base>]
658
+ # @param visibility [Array<Symbol>]
649
659
  # @return [Array<Pin::Base>]
650
- def resolve_method_aliases pins
651
- pins.map do |pin|
652
- next pin unless pin.kind == Pin::METHOD_ALIAS
653
- origin = get_method_stack(pin.namespace, pin.original, scope: pin.scope).select{|pin| pin.is_a?(Pin::BaseMethod)}.first
654
- next pin if origin.nil?
655
- Pin::Method.new(pin.location, pin.namespace, pin.name, origin.comments, origin.scope, origin.visibility, origin.parameters)
660
+ def resolve_method_aliases pins, visibility = [:public, :private, :protected]
661
+ result = []
662
+ pins.each do |pin|
663
+ resolved = resolve_method_alias(pin)
664
+ next unless visibility.include?(resolved.visibility)
665
+ result.push resolved
656
666
  end
667
+ result
668
+ end
669
+
670
+ # @param pin [Pin::MethodAlias, Pin::Base]
671
+ # @return [Pin::BaseMethod]
672
+ def resolve_method_alias pin
673
+ return pin if !pin.is_a?(Pin::MethodAlias) || @method_alias_stack.include?(pin.path)
674
+ @method_alias_stack.push pin.path
675
+ origin = get_method_stack(pin.full_context.namespace, pin.original, scope: pin.scope).first
676
+ @method_alias_stack.pop
677
+ return pin if origin.nil?
678
+ Pin::Method.new(
679
+ location: pin.location,
680
+ closure: pin.closure,
681
+ name: pin.name,
682
+ comments: origin.comments,
683
+ scope: origin.scope,
684
+ visibility: origin.visibility,
685
+ args: origin.parameters
686
+ )
657
687
  end
658
688
  end
659
689
  end
@@ -5,6 +5,7 @@ module Solargraph
5
5
  @methods = {}
6
6
  @constants = {}
7
7
  @qualified_namespaces = {}
8
+ @receiver_definitions = {}
8
9
  end
9
10
 
10
11
  def get_methods fqns, scope, visibility, deep
@@ -31,18 +32,32 @@ module Solargraph
31
32
  @qualified_namespaces[[name, context]] = value
32
33
  end
33
34
 
35
+ def receiver_defined? path
36
+ @receiver_definitions.key? path
37
+ end
38
+
39
+ def get_receiver_definition path
40
+ @receiver_definitions[path]
41
+ end
42
+
43
+ def set_receiver_definition path, pin
44
+ @receiver_definitions[path] = pin
45
+ end
46
+
34
47
  # @return [void]
35
48
  def clear
36
49
  @methods.clear
37
50
  @constants.clear
38
51
  @qualified_namespaces.clear
52
+ @receiver_definitions.clear
39
53
  end
40
54
 
41
55
  # @return [Boolean]
42
56
  def empty?
43
57
  @methods.empty? &&
44
58
  @constants.empty? &&
45
- @qualified_namespaces.empty?
59
+ @qualified_namespaces.empty? &&
60
+ @receiver_definitions.empty?
46
61
  end
47
62
  end
48
63
  end
@@ -15,31 +15,40 @@ module Solargraph
15
15
  code_object_map.keys
16
16
  end
17
17
 
18
- # @param store [Array<Store>] ApiMap pin store
18
+ # @param store [ApiMap::Store] ApiMap pin store
19
19
  # @return [void]
20
20
  def rake_yard store
21
21
  code_object_map.clear
22
22
  store.namespace_pins.each do |pin|
23
23
  next if pin.path.nil? or pin.path.empty?
24
+ if pin.code_object
25
+ code_object_map[pin.path] ||= pin.code_object
26
+ next
27
+ end
24
28
  if pin.type == :class
25
29
  code_object_map[pin.path] ||= YARD::CodeObjects::ClassObject.new(root_code_object, pin.path)
26
30
  else
27
31
  code_object_map[pin.path] ||= YARD::CodeObjects::ModuleObject.new(root_code_object, pin.path)
28
32
  end
29
33
  code_object_map[pin.path].docstring = pin.docstring
30
- code_object_map[pin.path].files.push pin.location.filename unless pin.location.nil?
31
- end
32
- store.namespace_pins.each do |pin|
33
- # pin.include_references.each do |ref|
34
+ code_object_map[pin.path].files.push pin.location.filename unless pin.location.nil? || code_object_map[pin.path].files.include?(pin.location.filename)
34
35
  store.get_includes(pin.path).each do |ref|
35
36
  code_object_map[pin.path].instance_mixins.push code_object_map[ref] unless code_object_map[ref].nil? or code_object_map[pin.path].nil?
36
37
  end
38
+ store.get_extends(pin.path).each do |ref|
39
+ code_object_map[pin.path].instance_mixins.push code_object_map[ref] unless code_object_map[ref].nil? or code_object_map[pin.path].nil?
40
+ code_object_map[pin.path].class_mixins.push code_object_map[ref] unless code_object_map[ref].nil? or code_object_map[pin.path].nil?
41
+ end
37
42
  end
38
43
  store.method_pins.each do |pin|
44
+ if pin.code_object
45
+ code_object_map[pin.path] ||= pin.code_object
46
+ next
47
+ end
39
48
  code_object_map[pin.path] ||= YARD::CodeObjects::MethodObject.new(code_object_at(pin.namespace), pin.name, pin.scope)
40
49
  code_object_map[pin.path].docstring = pin.docstring
41
50
  code_object_map[pin.path].visibility = pin.visibility || :public
42
- code_object_map[pin.path].files.push pin.location.filename unless pin.location.nil?
51
+ code_object_map[pin.path].files.push pin.location.filename unless pin.location.nil? || code_object_map[pin.path].files.include?(pin.location.filename)
43
52
  code_object_map[pin.path].parameters = pin.parameters.map do |p|
44
53
  n = p.match(/^[a-z0-9_]*:?/i)[0]
45
54
  v = nil
@@ -53,7 +62,7 @@ module Solargraph
53
62
 
54
63
  private
55
64
 
56
- # @return [Hash]
65
+ # @return [Hash{String => YARD::CodeObjects::Base}]
57
66
  def code_object_map
58
67
  @code_object_map ||= {}
59
68
  end