solargraph 0.39.14 → 0.40.1

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 (69) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +4 -8
  3. data/CHANGELOG.md +988 -0
  4. data/Rakefile +12 -1
  5. data/SPONSORS.md +1 -0
  6. data/lib/solargraph.rb +2 -4
  7. data/lib/solargraph/api_map.rb +75 -74
  8. data/lib/solargraph/api_map/cache.rb +2 -2
  9. data/lib/solargraph/api_map/store.rb +4 -8
  10. data/lib/solargraph/{bundle.rb → bench.rb} +6 -2
  11. data/lib/solargraph/compat.rb +14 -0
  12. data/lib/solargraph/complex_type.rb +2 -2
  13. data/lib/solargraph/convention.rb +13 -4
  14. data/lib/solargraph/convention/base.rb +16 -8
  15. data/lib/solargraph/convention/gemfile.rb +2 -5
  16. data/lib/solargraph/convention/gemspec.rb +3 -6
  17. data/lib/solargraph/convention/rspec.rb +3 -6
  18. data/lib/solargraph/documentor.rb +2 -0
  19. data/lib/solargraph/environ.rb +11 -6
  20. data/lib/solargraph/language_server/message/extended/check_gem_version.rb +6 -1
  21. data/lib/solargraph/language_server/message/text_document/definition.rb +1 -1
  22. data/lib/solargraph/language_server/message/text_document/formatting.rb +17 -19
  23. data/lib/solargraph/library.rb +8 -10
  24. data/lib/solargraph/parser/legacy/node_chainer.rb +7 -7
  25. data/lib/solargraph/parser/legacy/node_methods.rb +5 -0
  26. data/lib/solargraph/parser/legacy/node_processors/ivasgn_node.rb +1 -1
  27. data/lib/solargraph/parser/legacy/node_processors/send_node.rb +36 -23
  28. data/lib/solargraph/parser/node_processor/base.rb +3 -0
  29. data/lib/solargraph/parser/rubyvm/node_chainer.rb +9 -9
  30. data/lib/solargraph/parser/rubyvm/node_methods.rb +11 -1
  31. data/lib/solargraph/parser/rubyvm/node_processors/args_node.rb +1 -1
  32. data/lib/solargraph/parser/rubyvm/node_processors/ivasgn_node.rb +1 -1
  33. data/lib/solargraph/parser/rubyvm/node_processors/send_node.rb +40 -29
  34. data/lib/solargraph/pin.rb +0 -3
  35. data/lib/solargraph/pin/common.rb +1 -1
  36. data/lib/solargraph/pin/conversions.rb +3 -4
  37. data/lib/solargraph/pin/documenting.rb +3 -9
  38. data/lib/solargraph/pin/method.rb +141 -7
  39. data/lib/solargraph/pin/method_alias.rb +1 -1
  40. data/lib/solargraph/position.rb +2 -14
  41. data/lib/solargraph/shell.rb +1 -1
  42. data/lib/solargraph/source.rb +10 -6
  43. data/lib/solargraph/source/chain.rb +18 -5
  44. data/lib/solargraph/source_map.rb +4 -1
  45. data/lib/solargraph/source_map/clip.rb +3 -2
  46. data/lib/solargraph/source_map/mapper.rb +10 -6
  47. data/lib/solargraph/type_checker.rb +35 -39
  48. data/lib/solargraph/type_checker/param_def.rb +1 -1
  49. data/lib/solargraph/version.rb +1 -1
  50. data/lib/solargraph/yard_map.rb +40 -47
  51. data/lib/solargraph/yard_map/core_fills.rb +185 -0
  52. data/lib/solargraph/yard_map/helpers.rb +16 -0
  53. data/lib/solargraph/yard_map/mapper.rb +14 -8
  54. data/lib/solargraph/{pin/yard_pin/constant.rb → yard_map/mapper/to_constant.rb} +6 -6
  55. data/lib/solargraph/yard_map/mapper/to_method.rb +78 -0
  56. data/lib/solargraph/{pin/yard_pin/namespace.rb → yard_map/mapper/to_namespace.rb} +6 -6
  57. data/lib/solargraph/yard_map/rdoc_to_yard.rb +1 -1
  58. data/lib/solargraph/yard_map/stdlib_fills.rb +43 -0
  59. data/lib/solargraph/yard_map/to_method.rb +79 -0
  60. data/solargraph.gemspec +4 -4
  61. metadata +20 -34
  62. data/lib/solargraph/core_fills.rb +0 -160
  63. data/lib/solargraph/pin/attribute.rb +0 -49
  64. data/lib/solargraph/pin/base_method.rb +0 -141
  65. data/lib/solargraph/pin/yard_pin.rb +0 -12
  66. data/lib/solargraph/pin/yard_pin/method.rb +0 -80
  67. data/lib/solargraph/pin/yard_pin/yard_mixin.rb +0 -20
  68. data/lib/solargraph/stdlib_fills.rb +0 -40
  69. data/travis-bundler.rb +0 -11
@@ -19,7 +19,7 @@ module Solargraph
19
19
  if region.visibility == :module_function
20
20
  here = get_node_start_position(node)
21
21
  named_path = named_path_pin(here)
22
- if named_path.is_a?(Pin::BaseMethod)
22
+ if named_path.is_a?(Pin::Method)
23
23
  pins.push Solargraph::Pin::InstanceVariable.new(
24
24
  location: loc,
25
25
  closure: Pin::Namespace.new(type: :module, closure: region.closure.closure, name: region.closure.name),
@@ -10,20 +10,7 @@ module Solargraph
10
10
  def process
11
11
  if node.children[0].nil?
12
12
  if [:private, :public, :protected].include?(node.children[1])
13
- if (node.children.length > 2)
14
- node.children[2..-1].each do |child|
15
- next unless child.is_a?(AST::Node) && (child.type == :sym || child.type == :str)
16
- name = child.children[0].to_s
17
- matches = pins.select{ |pin| pin.is_a?(Pin::BaseMethod) && pin.name == name && pin.namespace == region.closure.full_context.namespace && pin.context.scope == (region.scope || :instance)}
18
- matches.each do |pin|
19
- # @todo Smelly instance variable access
20
- pin.instance_variable_set(:@visibility, node.children[1])
21
- end
22
- end
23
- else
24
- # @todo Smelly instance variable access
25
- region.instance_variable_set(:@visibility, node.children[1])
26
- end
13
+ process_visibility
27
14
  elsif node.children[1] == :module_function
28
15
  process_module_function
29
16
  elsif [:attr_reader, :attr_writer, :attr_accessor].include?(node.children[1])
@@ -54,6 +41,27 @@ module Solargraph
54
41
 
55
42
  private
56
43
 
44
+ # @return [void]
45
+ def process_visibility
46
+ if (node.children.length > 2)
47
+ node.children[2..-1].each do |child|
48
+ if child.is_a?(AST::Node) && (child.type == :sym || child.type == :str)
49
+ name = child.children[0].to_s
50
+ matches = pins.select{ |pin| pin.is_a?(Pin::Method) && pin.name == name && pin.namespace == region.closure.full_context.namespace && pin.context.scope == (region.scope || :instance)}
51
+ matches.each do |pin|
52
+ # @todo Smelly instance variable access
53
+ pin.instance_variable_set(:@visibility, node.children[1])
54
+ end
55
+ else
56
+ process_children region.update(visibility: node.children[1])
57
+ end
58
+ end
59
+ else
60
+ # @todo Smelly instance variable access
61
+ region.instance_variable_set(:@visibility, node.children[1])
62
+ end
63
+ end
64
+
57
65
  # @return [void]
58
66
  def process_attribute
59
67
  node.children[2..-1].each do |a|
@@ -61,26 +69,30 @@ module Solargraph
61
69
  clos = region.closure
62
70
  cmnt = comments_for(node)
63
71
  if node.children[1] == :attr_reader || node.children[1] == :attr_accessor
64
- pins.push Solargraph::Pin::Attribute.new(
72
+ pins.push Solargraph::Pin::Method.new(
65
73
  location: loc,
66
74
  closure: clos,
67
75
  name: a.children[0].to_s,
68
76
  comments: cmnt,
69
- access: :reader,
70
77
  scope: region.scope || :instance,
71
- visibility: region.visibility
78
+ visibility: region.visibility,
79
+ attribute: true
72
80
  )
73
81
  end
74
82
  if node.children[1] == :attr_writer || node.children[1] == :attr_accessor
75
- pins.push Solargraph::Pin::Attribute.new(
83
+ pins.push Solargraph::Pin::Method.new(
76
84
  location: loc,
77
85
  closure: clos,
78
86
  name: "#{a.children[0]}=",
79
87
  comments: cmnt,
80
- access: :writer,
81
88
  scope: region.scope || :instance,
82
- visibility: region.visibility
89
+ visibility: region.visibility,
90
+ attribute: true
83
91
  )
92
+ pins.last.parameters.push Pin::Parameter.new(name: 'value', decl: :arg, closure: pins.last)
93
+ if pins.last.return_type.defined?
94
+ pins.last.docstring.add_tag YARD::Tags::Tag.new(:param, '', pins.last.return_type.to_s.split(', '), 'value')
95
+ end
84
96
  end
85
97
  end
86
98
  end
@@ -90,7 +102,8 @@ module Solargraph
90
102
  if node.children[2].is_a?(AST::Node) && node.children[2].type == :const
91
103
  cp = region.closure
92
104
  node.children[2..-1].each do |i|
93
- pins.push Pin::Reference::Include.new(
105
+ type = region.scope == :class ? Pin::Reference::Extend : Pin::Reference::Include
106
+ pins.push type.new(
94
107
  location: get_node_location(i),
95
108
  closure: cp,
96
109
  name: unpack_name(i)
@@ -156,7 +169,7 @@ module Solargraph
156
169
  elsif node.children[2].type == :sym || node.children[2].type == :str
157
170
  node.children[2..-1].each do |x|
158
171
  cn = x.children[0].to_s
159
- ref = pins.select{|p| [Solargraph::Pin::Method, Solargraph::Pin::Attribute].include?(p.class) && p.namespace == region.closure.full_context.namespace && p.name == cn}.first
172
+ ref = pins.select{ |p| p.is_a?(Pin::Method) && p.namespace == region.closure.full_context.namespace && p.name == cn }.first
160
173
  unless ref.nil?
161
174
  pins.delete ref
162
175
  mm = Solargraph::Pin::Method.new(
@@ -228,7 +241,7 @@ module Solargraph
228
241
  # @return [Boolean]
229
242
  def process_private_class_method
230
243
  if node.children[2].type == :sym || node.children[2].type == :str
231
- ref = pins.select{|p| [Solargraph::Pin::Method, Solargraph::Pin::Attribute].include?(p.class) && p.namespace == region.closure.full_context.namespace && p.name == node.children[2].children[0].to_s}.first
244
+ ref = pins.select { |p| p.is_a?(Pin::Method) && p.namespace == region.closure.full_context.namespace && p.name == node.children[2].children[0].to_s }.first
232
245
  # HACK: Smelly instance variable access
233
246
  ref.instance_variable_set(:@visibility, :private) unless ref.nil?
234
247
  false
@@ -27,6 +27,7 @@ module Solargraph
27
27
  @region = region
28
28
  @pins = pins
29
29
  @locals = locals
30
+ @processed_children = false
30
31
  end
31
32
 
32
33
  # Subclasses should override this method to generate new pins.
@@ -41,6 +42,8 @@ module Solargraph
41
42
  # @param subregion [Region]
42
43
  # @return [void]
43
44
  def process_children subregion = region
45
+ return if @processed_children
46
+ @processed_children = true
44
47
  node.children.each do |child|
45
48
  next unless Parser.is_ast_node?(child)
46
49
  NodeProcessor.process(child, subregion, pins, locals)
@@ -15,7 +15,7 @@ module Solargraph
15
15
  def initialize node, filename = nil, in_block = false
16
16
  @node = node
17
17
  @filename = filename
18
- @in_block = in_block
18
+ @in_block = in_block ? 1 : 0
19
19
  end
20
20
 
21
21
  # @return [Source::Chain]
@@ -52,27 +52,27 @@ module Solargraph
52
52
  return generate_links(n.children[0]) if n.type == :SPLAT
53
53
  result = []
54
54
  if n.type == :ITER
55
- @in_block = true
55
+ @in_block += 1
56
56
  result.concat generate_links(n.children[0])
57
- @in_block = false
57
+ @in_block -= 1
58
58
  elsif n.type == :CALL || n.type == :OPCALL
59
59
  n.children[0..-3].each do |c|
60
60
  result.concat generate_links(c)
61
61
  end
62
- result.push Chain::Call.new(n.children[-2].to_s, node_to_argchains(n.children.last), @in_block || block_passed?(n))
62
+ result.push Chain::Call.new(n.children[-2].to_s, node_to_argchains(n.children.last), @in_block > 0 || block_passed?(n))
63
63
  elsif n.type == :ATTRASGN
64
64
  result.concat generate_links(n.children[0])
65
- result.push Chain::Call.new(n.children[1].to_s, node_to_argchains(n.children[2]), @in_block || block_passed?(n))
65
+ result.push Chain::Call.new(n.children[1].to_s, node_to_argchains(n.children[2]), @in_block > 0 || block_passed?(n))
66
66
  elsif n.type == :VCALL
67
- result.push Chain::Call.new(n.children[0].to_s, [], @in_block || block_passed?(n))
67
+ result.push Chain::Call.new(n.children[0].to_s, [], @in_block > 0 || block_passed?(n))
68
68
  elsif n.type == :FCALL
69
- result.push Chain::Call.new(n.children[0].to_s, node_to_argchains(n.children[1]), @in_block || block_passed?(n))
69
+ result.push Chain::Call.new(n.children[0].to_s, node_to_argchains(n.children[1]), @in_block > 0 || block_passed?(n))
70
70
  elsif n.type == :SELF
71
71
  result.push Chain::Head.new('self')
72
72
  elsif n.type == :ZSUPER
73
- result.push Chain::ZSuper.new('super', @in_block || block_passed?(n))
73
+ result.push Chain::ZSuper.new('super', @in_block > 0 || block_passed?(n))
74
74
  elsif n.type == :SUPER
75
- result.push Chain::Call.new('super', node_to_argchains(n.children.last), @in_block || block_passed?(n))
75
+ result.push Chain::Call.new('super', node_to_argchains(n.children.last), @in_block > 0 || block_passed?(n))
76
76
  elsif [:COLON2, :COLON3, :CONST].include?(n.type)
77
77
  const = unpack_name(n)
78
78
  result.push Chain::Constant.new(const)
@@ -90,7 +90,9 @@ module Solargraph
90
90
  end
91
91
 
92
92
  def convert_hash node
93
- return {} unless node?(node) && node.type == :HASH && node?(node.children[0])
93
+ return {} unless node?(node) && node.type == :HASH
94
+ return convert_hash(node.children[0].children[1]) if splatted_hash?(node)
95
+ return {} unless node?(node.children[0])
94
96
  result = {}
95
97
  index = 0
96
98
  until index > node.children[0].children.length - 2
@@ -103,6 +105,14 @@ module Solargraph
103
105
  result
104
106
  end
105
107
 
108
+ def splatted_hash? node
109
+ node?(node.children[0]) &&
110
+ [:ARRAY, :LIST].include?(node.children[0].type) &&
111
+ node.children[0].children[0].nil? &&
112
+ node?(node.children[0].children[1]) &&
113
+ node.children[0].children[1].type == :HASH
114
+ end
115
+
106
116
  def node? node
107
117
  node.is_a?(RubyVM::AbstractSyntaxTree::Node)
108
118
  end
@@ -6,7 +6,7 @@ module Solargraph
6
6
  module NodeProcessors
7
7
  class ArgsNode < Parser::NodeProcessor::Base
8
8
  def process
9
- if region.closure.is_a?(Pin::BaseMethod) || region.closure.is_a?(Pin::Block)
9
+ if region.closure.is_a?(Pin::Method) || region.closure.is_a?(Pin::Block)
10
10
  if region.lvars[0].nil?
11
11
  node.children[0].times do |i|
12
12
  locals.push Solargraph::Pin::Parameter.new(
@@ -19,7 +19,7 @@ module Solargraph
19
19
  if region.visibility == :module_function
20
20
  rng = Range.from_node(node)
21
21
  named_path = named_path_pin(rng.start)
22
- if named_path.is_a?(Pin::BaseMethod)
22
+ if named_path.is_a?(Pin::Method)
23
23
  pins.push Solargraph::Pin::InstanceVariable.new(
24
24
  location: loc,
25
25
  closure: Pin::Namespace.new(type: :module, closure: region.closure.closure, name: region.closure.name),
@@ -9,21 +9,7 @@ module Solargraph
9
9
 
10
10
  def process
11
11
  if [:private, :public, :protected].include?(node.children[0])
12
- if node.type == :FCALL && Parser.is_ast_node?(node.children.last)
13
- node.children.last.children[0..-2].each do |child|
14
- # next unless child.is_a?(AST::Node) && (child.type == :sym || child.type == :str)
15
- next unless child.type == :LIT || child.type == :STR
16
- name = child.children[0].to_s
17
- matches = pins.select{ |pin| pin.is_a?(Pin::BaseMethod) && pin.name == name && pin.namespace == region.closure.full_context.namespace && pin.context.scope == (region.scope || :instance)}
18
- matches.each do |pin|
19
- # @todo Smelly instance variable access
20
- pin.instance_variable_set(:@visibility, node.children[0])
21
- end
22
- end
23
- else
24
- # @todo Smelly instance variable access
25
- region.instance_variable_set(:@visibility, node.children[0])
26
- end
12
+ process_visibility
27
13
  elsif node.children[0] == :module_function
28
14
  process_module_function
29
15
  elsif node.children[0] == :require
@@ -33,8 +19,7 @@ module Solargraph
33
19
  elsif node.children[0] == :alias_method
34
20
  process_alias_method
35
21
  elsif node.children[0] == :private_class_method
36
- # Processing a private class can potentially handle children on its own
37
- return if process_private_class_method
22
+ process_private_class_method
38
23
  elsif [:attr_reader, :attr_writer, :attr_accessor].include?(node.children[0])
39
24
  process_attribute
40
25
  elsif node.children[0] == :include
@@ -53,6 +38,28 @@ module Solargraph
53
38
 
54
39
  private
55
40
 
41
+ # @return [void]
42
+ def process_visibility
43
+ if node.type == :FCALL && Parser.is_ast_node?(node.children.last)
44
+ node.children.last.children[0..-2].each do |child|
45
+ # next unless child.is_a?(AST::Node) && (child.type == :sym || child.type == :str)
46
+ if child.type == :LIT || child.type == :STR
47
+ name = child.children[0].to_s
48
+ matches = pins.select{ |pin| pin.is_a?(Pin::Method) && pin.name == name && pin.namespace == region.closure.full_context.namespace && pin.context.scope == (region.scope || :instance)}
49
+ matches.each do |pin|
50
+ # @todo Smelly instance variable access
51
+ pin.instance_variable_set(:@visibility, node.children[0])
52
+ end
53
+ else
54
+ process_children region.update(visibility: node.children[0])
55
+ end
56
+ end
57
+ else
58
+ # @todo Smelly instance variable access
59
+ region.instance_variable_set(:@visibility, node.children[0])
60
+ end
61
+ end
62
+
56
63
  # @return [void]
57
64
  def process_attribute
58
65
  return unless Parser.is_ast_node?(node.children[1])
@@ -62,26 +69,30 @@ module Solargraph
62
69
  clos = region.closure
63
70
  cmnt = comments_for(node)
64
71
  if node.children[0] == :attr_reader || node.children[0] == :attr_accessor
65
- pins.push Solargraph::Pin::Attribute.new(
72
+ pins.push Solargraph::Pin::Method.new(
66
73
  location: loc,
67
74
  closure: clos,
68
75
  name: a.children[0].to_s,
69
76
  comments: cmnt,
70
- access: :reader,
71
77
  scope: region.scope || :instance,
72
- visibility: region.visibility
78
+ visibility: region.visibility,
79
+ attribute: true
73
80
  )
74
81
  end
75
82
  if node.children[0] == :attr_writer || node.children[0] == :attr_accessor
76
- pins.push Solargraph::Pin::Attribute.new(
83
+ pins.push Solargraph::Pin::Method.new(
77
84
  location: loc,
78
85
  closure: clos,
79
86
  name: "#{a.children[0]}=",
80
87
  comments: cmnt,
81
- access: :writer,
82
88
  scope: region.scope || :instance,
83
- visibility: region.visibility
89
+ visibility: region.visibility,
90
+ attribute: true
84
91
  )
92
+ pins.last.parameters.push Pin::Parameter.new(name: 'value', decl: :arg, closure: pins.last)
93
+ if pins.last.return_type.defined?
94
+ pins.last.docstring.add_tag YARD::Tags::Tag.new(:param, '', pins.last.return_type.to_s.split(', '), 'value')
95
+ end
85
96
  end
86
97
  end
87
98
  end
@@ -91,7 +102,8 @@ module Solargraph
91
102
  return unless Parser.is_ast_node?(node.children.last)
92
103
  node.children.last.children[0..-2].each do |i|
93
104
  next unless [:COLON2, :COLON3, :CONST].include?(i.type)
94
- pins.push Pin::Reference::Include.new(
105
+ type = region.scope == :class ? Pin::Reference::Extend : Pin::Reference::Include
106
+ pins.push type.new(
95
107
  location: get_node_location(i),
96
108
  closure: region.closure,
97
109
  name: unpack_name(i)
@@ -165,7 +177,7 @@ module Solargraph
165
177
  node.children.last.children[0..-2].each do |x|
166
178
  next unless [:LIT, :STR].include?(x.type)
167
179
  cn = x.children[0].to_s
168
- ref = pins.select{|p| [Solargraph::Pin::Method, Solargraph::Pin::Attribute].include?(p.class) && p.namespace == region.closure.full_context.namespace && p.name == cn}.first
180
+ ref = pins.select { |p| p.is_a?(Pin::Method) && p.namespace == region.closure.full_context.namespace && p.name == cn }.first
169
181
  unless ref.nil?
170
182
  pins.delete ref
171
183
  mm = Solargraph::Pin::Method.new(
@@ -214,6 +226,7 @@ module Solargraph
214
226
 
215
227
  # @return [void]
216
228
  def process_private_constant
229
+ # @todo Bare `private_constant` causes an error
217
230
  node.children.last.children[0..-2].each do |child|
218
231
  if [:LIT, :STR].include?(child.type)
219
232
  cn = child.children[0].to_s
@@ -241,20 +254,18 @@ module Solargraph
241
254
  )
242
255
  end
243
256
 
244
- # @return [Boolean]
257
+ # @return [void]
245
258
  def process_private_class_method
246
259
  return false unless Parser.is_ast_node?(node.children.last)
247
260
  if node.children.last.children.first.type == :DEFN
248
261
  process_children region.update(scope: :class, visibility: :private)
249
- true
250
262
  else
251
263
  node.children.last.children[0..-2].each do |child|
252
264
  if child.type == :LIT && child.children.first.is_a?(::Symbol)
253
265
  sym_name = child.children.first.to_s
254
- ref = pins.select{|p| [Solargraph::Pin::Method, Solargraph::Pin::Attribute].include?(p.class) && p.namespace == region.closure.full_context.namespace && p.name == sym_name}.first
266
+ ref = pins.select { |p| p.is_a?(Pin::Method) && p.namespace == region.closure.full_context.namespace && p.name == sym_name }.first
255
267
  # HACK: Smelly instance variable access
256
268
  ref.instance_variable_set(:@visibility, :private) unless ref.nil?
257
- false
258
269
  end
259
270
  end
260
271
  end
@@ -9,10 +9,8 @@ module Solargraph
9
9
  autoload :Common, 'solargraph/pin/common'
10
10
  autoload :Conversions, 'solargraph/pin/conversions'
11
11
  autoload :Base, 'solargraph/pin/base'
12
- autoload :BaseMethod, 'solargraph/pin/base_method'
13
12
  autoload :Method, 'solargraph/pin/method'
14
13
  autoload :MethodAlias, 'solargraph/pin/method_alias'
15
- autoload :Attribute, 'solargraph/pin/attribute'
16
14
  autoload :BaseVariable, 'solargraph/pin/base_variable'
17
15
  autoload :InstanceVariable, 'solargraph/pin/instance_variable'
18
16
  autoload :ClassVariable, 'solargraph/pin/class_variable'
@@ -30,7 +28,6 @@ module Solargraph
30
28
  autoload :Localized, 'solargraph/pin/localized'
31
29
  autoload :ProxyType, 'solargraph/pin/proxy_type'
32
30
  autoload :DuckMethod, 'solargraph/pin/duck_method'
33
- autoload :YardPin, 'solargraph/pin/yard_pin'
34
31
  autoload :Singleton, 'solargraph/pin/singleton'
35
32
  autoload :KeywordParam, 'solargraph/pin/keyword_param'
36
33
 
@@ -54,7 +54,7 @@ module Solargraph
54
54
  until here.nil?
55
55
  if here.is_a?(Pin::Namespace)
56
56
  return here.return_type
57
- elsif here.is_a?(Pin::BaseMethod)
57
+ elsif here.is_a?(Pin::Method)
58
58
  if here.scope == :instance
59
59
  return ComplexType.try_parse(here.context.namespace)
60
60
  else
@@ -23,16 +23,15 @@ module Solargraph
23
23
 
24
24
  # @return [Hash]
25
25
  def resolve_completion_item
26
- if @resolve_completion_item.nil?
26
+ @resolve_completion_item ||= begin
27
27
  extra = {}
28
28
  alldoc = ''
29
29
  # alldoc += link_documentation unless link_documentation.nil?
30
30
  # alldoc += "\n\n" unless alldoc.empty?
31
31
  alldoc += documentation unless documentation.nil?
32
32
  extra[:documentation] = alldoc unless alldoc.empty?
33
- @resolve_completion_item = completion_item.merge(extra)
33
+ completion_item.merge(extra)
34
34
  end
35
- @resolve_completion_item
36
35
  end
37
36
 
38
37
  # @return [Hash]
@@ -48,7 +47,7 @@ module Solargraph
48
47
  # This property is not cached in an instance variable because it can
49
48
  # change when pins get proxied.
50
49
  detail = String.new
51
- detail += "(#{parameters.map(&:full).join(', ')}) " unless !is_a?(Pin::BaseMethod) || parameters.empty?
50
+ detail += "(#{parameters.map(&:full).join(', ')}) " unless !is_a?(Pin::Method) || parameters.empty?
52
51
  detail += "=#{probed? ? '~' : (proxied? ? '^' : '>')} #{return_type.to_s}" unless return_type.undefined?
53
52
  detail.strip!
54
53
  return nil if detail.empty?
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'maruku'
3
+ require 'kramdown'
4
+ require 'kramdown-parser-gfm'
4
5
  require 'yard'
5
6
  require 'reverse_markdown'
6
7
  require 'solargraph/converters/dl'
@@ -8,9 +9,6 @@ require 'solargraph/converters/dt'
8
9
  require 'solargraph/converters/dd'
9
10
  require 'solargraph/converters/misc'
10
11
 
11
- # HACK: Setting :html_parser through `Maruku.new` does not work
12
- MaRuKu::Globals[:html_parser] = 'nokogiri'
13
-
14
12
  module Solargraph
15
13
  module Pin
16
14
  # A module to add the Pin::Base#documentation method.
@@ -41,11 +39,7 @@ module Solargraph
41
39
 
42
40
  def to_s
43
41
  return "\n```ruby\n#{@plaintext}#{@plaintext.end_with?("\n") ? '' : "\n"}```\n\n" if code?
44
- ReverseMarkdown.convert unescape_brackets(Maruku.new(escape_brackets(@plaintext), on_error: :raise).to_html)
45
- rescue MaRuKu::Exception
46
- # Maruku exceptions usually indicate that the documentation is in
47
- # RDoc syntax.
48
- ReverseMarkdown.convert YARD::Templates::Helpers::Markup::RDocMarkup.new(@plaintext).to_html
42
+ ReverseMarkdown.convert unescape_brackets(Kramdown::Document.new(escape_brackets(@plaintext), input: 'GFM').to_html)
49
43
  end
50
44
 
51
45
  private