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
@@ -6,7 +6,7 @@ module Solargraph
6
6
  # @return [Array<Solargraph::Pin::Base>]
7
7
  attr_reader :pins
8
8
 
9
- # @param pins [Array<Solargraph::Source>]
9
+ # @param pins [Array<Solargraph::Pin::Base>]
10
10
  def initialize pins = []
11
11
  @pins = pins
12
12
  index
@@ -26,16 +26,16 @@ module Solargraph
26
26
  # @param visibility [Array<Symbol>]
27
27
  # @return [Array<Solargraph::Pin::Base>]
28
28
  def get_methods fqns, scope: :instance, visibility: [:public]
29
- kinds = [Pin::METHOD, Pin::ATTRIBUTE]
30
- namespace_children(fqns).select{ |pin|
29
+ kinds = [Pin::METHOD, Pin::ATTRIBUTE, Pin::METHOD_ALIAS]
30
+ namespace_children(fqns).select do |pin|
31
31
  kinds.include?(pin.kind) && pin.scope == scope && visibility.include?(pin.visibility)
32
- }
32
+ end
33
33
  end
34
34
 
35
35
  # @param fqns [String]
36
36
  # @return [String]
37
37
  def get_superclass fqns
38
- return superclass_references[fqns].first if superclass_references.has_key?(fqns)
38
+ return superclass_references[fqns].first if superclass_references.key?(fqns)
39
39
  nil
40
40
  end
41
41
 
@@ -54,15 +54,17 @@ module Solargraph
54
54
  # @param path [String]
55
55
  # @return [Array<Solargraph::Pin::Base>]
56
56
  def get_path_pins path
57
- return [] if path.nil? # @todo Should be '' instead?
58
- pins.select { |pin| pin.path == path }
57
+ path_pin_hash[path] || []
59
58
  end
60
59
 
61
60
  # @param fqns [String]
62
61
  # @param scope [Symbol] :class or :instance
63
62
  # @return [Array<Solargraph::Pin::Base>]
64
63
  def get_instance_variables(fqns, scope = :instance)
65
- namespace_children(fqns).select{|pin| pin.kind == Pin::INSTANCE_VARIABLE and pin.context.scope == scope}
64
+ # namespace_children(fqns).select{|pin| pin.kind == Pin::INSTANCE_VARIABLE and pin.context.scope == scope}
65
+ all_instance_variables.select { |pin|
66
+ pin.binder.namespace == fqns && pin.binder.scope == scope
67
+ }
66
68
  end
67
69
 
68
70
  # @param fqns [String]
@@ -89,12 +91,14 @@ module Solargraph
89
91
 
90
92
  # @return [Array<Solargraph::Pin::Base>]
91
93
  def namespace_pins
92
- @namespace_pins ||= pins.select{|p| p.kind == Pin::NAMESPACE}
94
+ # @namespace_pins ||= pins.select{|p| p.kind == Pin::NAMESPACE}
95
+ @namespace_pins ||= []
93
96
  end
94
97
 
95
98
  # @return [Array<Solargraph::Pin::Base>]
96
99
  def method_pins
97
- @method_pins ||= pins.select{|p| p.kind == Pin::METHOD or p.kind == Pin::ATTRIBUTE}
100
+ # @method_pins ||= pins.select{|p| p.kind == Pin::METHOD or p.kind == Pin::ATTRIBUTE}
101
+ @method_pins ||= []
98
102
  end
99
103
 
100
104
  # @param fqns [String]
@@ -121,6 +125,11 @@ module Solargraph
121
125
  end
122
126
  end
123
127
 
128
+ # @return [Array<Pin::Block>]
129
+ def block_pins
130
+ @block_pins ||= []
131
+ end
132
+
124
133
  def inspect
125
134
  # Avoid insane dumps in specs
126
135
  to_s
@@ -171,16 +180,32 @@ module Solargraph
171
180
  @namespace_map ||= {}
172
181
  end
173
182
 
183
+ def all_instance_variables
184
+ @all_instance_variables ||= []
185
+ end
186
+
187
+ def path_pin_hash
188
+ @path_pin_hash ||= {}
189
+ end
190
+
174
191
  # @return [void]
175
192
  def index
176
193
  namespace_map.clear
177
194
  namespaces.clear
195
+ namespace_pins.clear
196
+ method_pins.clear
178
197
  symbols.clear
198
+ block_pins.clear
199
+ all_instance_variables.clear
200
+ path_pin_hash.clear
179
201
  namespace_map[''] = []
202
+ override_pins = []
180
203
  pins.each do |pin|
181
204
  namespace_map[pin.namespace] ||= []
182
205
  namespace_map[pin.namespace].push pin
183
206
  namespaces.add pin.path if pin.kind == Pin::NAMESPACE and !pin.path.empty?
207
+ namespace_pins.push pin if pin.kind == Pin::NAMESPACE
208
+ method_pins.push pin if pin.kind == Pin::METHOD || pin.kind == Pin::ATTRIBUTE
184
209
  symbols.push pin if pin.kind == Pin::SYMBOL
185
210
  if pin.kind == Pin::INCLUDE_REFERENCE
186
211
  include_references[pin.namespace] ||= []
@@ -191,10 +216,28 @@ module Solargraph
191
216
  elsif pin.kind == Pin::SUPERCLASS_REFERENCE
192
217
  superclass_references[pin.namespace] ||= []
193
218
  superclass_references[pin.namespace].push pin.name
219
+ elsif pin.is_a?(Pin::Block)
220
+ block_pins.push pin
221
+ elsif pin.is_a?(Pin::InstanceVariable)
222
+ all_instance_variables.push pin
223
+ elsif pin.is_a?(Pin::Reference::Override)
224
+ override_pins.push pin
225
+ end
226
+ if pin.path
227
+ path_pin_hash[pin.path] ||= []
228
+ path_pin_hash[pin.path].push pin
229
+ end
230
+ end
231
+ override_pins.concat CoreFills::OVERRIDES
232
+ override_pins.each do |ovr|
233
+ pin = get_path_pins(ovr.name).first
234
+ next if pin.nil?
235
+ pin.docstring.delete_tags(:overload)
236
+ pin.docstring.delete_tags(:return)
237
+ ovr.tags.each do |tag|
238
+ pin.docstring.add_tag(tag)
194
239
  end
195
240
  end
196
- @namespace_pins = nil
197
- @method_pins = nil
198
241
  end
199
242
  end
200
243
  end
@@ -1,35 +1,57 @@
1
1
  module Solargraph
2
2
  # A container for type data based on YARD type tags.
3
3
  #
4
- class ComplexType < Array
5
- # @todo Figure out how to add the basic type methods here without actually
6
- # including the module. One possibility:
7
- #
4
+ class ComplexType
8
5
  # @!parse
9
6
  # include TypeMethods
10
7
 
11
8
  autoload :TypeMethods, 'solargraph/complex_type/type_methods'
12
9
  autoload :UniqueType, 'solargraph/complex_type/unique_type'
13
10
 
14
- # @param types [Array<ComplexType>]
15
- def initialize types = [ComplexType::UNDEFINED]
16
- super()
17
- concat types
11
+ # @param types [Array<UniqueType>]
12
+ def initialize types = [UniqueType::UNDEFINED]
13
+ @items = types
18
14
  end
19
15
 
20
16
  # @param api_map [ApiMap]
21
17
  # @param context [String]
22
18
  # @return [ComplexType]
23
19
  def qualify api_map, context = ''
24
- types = map do |t|
20
+ types = @items.map do |t|
25
21
  t.qualify api_map, context
26
22
  end
27
23
  ComplexType.new(types)
28
24
  end
29
25
 
26
+ def first
27
+ @items.first
28
+ end
29
+
30
+ def map &block
31
+ @items.map &block
32
+ end
33
+
34
+ # @yieldparam [UniqueType]
35
+ # @return [Array]
36
+ def each &block
37
+ @items.each &block
38
+ end
39
+
40
+ def length
41
+ @items.length
42
+ end
43
+
44
+ def [](index)
45
+ @items[index]
46
+ end
47
+
48
+ def select &block
49
+ @items.select &block
50
+ end
51
+
30
52
  def method_missing name, *args, &block
31
- return if first.nil?
32
- return first.send(name, *args, &block) if respond_to_missing?(name)
53
+ return if @items.first.nil?
54
+ return @items.first.send(name, *args, &block) if respond_to_missing?(name)
33
55
  super
34
56
  end
35
57
 
@@ -41,6 +63,20 @@ module Solargraph
41
63
  map(&:tag).join(', ')
42
64
  end
43
65
 
66
+ def all? &block
67
+ @items.all? &block
68
+ end
69
+
70
+ def selfy?
71
+ @items.any?(&:selfy?)
72
+ end
73
+
74
+ def self_to dst
75
+ return self unless selfy?
76
+ result = @items.map { |i| i.self_to dst }
77
+ ComplexType.parse(*result.map(&:tag))
78
+ end
79
+
44
80
  class << self
45
81
  # Parse type strings into a ComplexType.
46
82
  #
@@ -81,7 +117,8 @@ module Solargraph
81
117
  subtype_string += char
82
118
  elsif base.end_with?('=')
83
119
  raise ComplexTypeError, "Invalid hash thing" unless key_types.nil?
84
- types.push ComplexType.new([UniqueType.new(base[0..-2].strip)])
120
+ # types.push ComplexType.new([UniqueType.new(base[0..-2].strip)])
121
+ types.push UniqueType.new(base[0..-2].strip)
85
122
  key_types = types
86
123
  types = []
87
124
  base = ''
@@ -108,7 +145,8 @@ module Solargraph
108
145
  raise ComplexTypeError, "Invalid close in type #{type_string}" if paren_stack < 0
109
146
  next
110
147
  elsif char == ',' && point_stack == 0 && curly_stack == 0 && paren_stack == 0
111
- types.push ComplexType.new([UniqueType.new(base.strip, subtype_string.strip)])
148
+ # types.push ComplexType.new([UniqueType.new(base.strip, subtype_string.strip)])
149
+ types.push UniqueType.new(base.strip, subtype_string.strip)
112
150
  base = ''
113
151
  subtype_string = ''
114
152
  next
@@ -122,7 +160,8 @@ module Solargraph
122
160
  base.strip!
123
161
  subtype_string.strip!
124
162
  raise ComplexTypeError, "Unclosed subtype in #{type_string}" if point_stack != 0 || curly_stack != 0 || paren_stack != 0
125
- types.push ComplexType.new([UniqueType.new(base, subtype_string)])
163
+ # types.push ComplexType.new([UniqueType.new(base, subtype_string)])
164
+ types.push UniqueType.new(base, subtype_string)
126
165
  end
127
166
  unless key_types.nil?
128
167
  raise ComplexTypeError, "Invalid use of key/value parameters" unless partial
@@ -134,6 +173,8 @@ module Solargraph
134
173
  result
135
174
  end
136
175
 
176
+ # @param strings [Array<String>]
177
+ # @return [ComplexType]
137
178
  def try_parse *strings
138
179
  parse *strings
139
180
  rescue ComplexTypeError => e
@@ -146,5 +187,8 @@ module Solargraph
146
187
  UNDEFINED = ComplexType.parse('undefined')
147
188
  SYMBOL = ComplexType.parse('Symbol')
148
189
  ROOT = ComplexType.parse('Class<>')
190
+ NIL = ComplexType.parse('nil')
191
+ SELF = ComplexType.parse('self')
192
+ BOOLEAN = ComplexType.parse('Boolean')
149
193
  end
150
194
  end
@@ -99,8 +99,8 @@ module Solargraph
99
99
  recon = (rooted? ? '' : context)
100
100
  fqns = api_map.qualify(name, recon)
101
101
  if fqns.nil?
102
- return ComplexType.parse('Boolean') if tag == 'Boolean'
103
- return ComplexType::UNDEFINED
102
+ return UniqueType::BOOLEAN if tag == 'Boolean'
103
+ return UniqueType::UNDEFINED
104
104
  end
105
105
  fqns = "::#{fqns}" # Ensure the resulting complex type is rooted
106
106
  ltypes = key_types.map do |t|
@@ -26,11 +26,15 @@ module Solargraph
26
26
  @key_types = []
27
27
  @subtypes = []
28
28
  return unless parameters?
29
- subs = ComplexType.parse(substring[1..-2], partial: true)
29
+ if @substring.start_with?('<(') && @substring.end_with?(')>')
30
+ subs = ComplexType.parse(substring[2..-3], partial: true)
31
+ else
32
+ subs = ComplexType.parse(substring[1..-2], partial: true)
33
+ end
30
34
  if hash_parameters?
31
- raise ComplexTypeError, "Bad hash type" unless !subs.is_a?(ComplexType) and subs.length == 2 and !subs[0].is_a?(ComplexType) and !subs[1].is_a?(ComplexType)
32
- @key_types.concat subs[0]
33
- @subtypes.concat subs[1]
35
+ raise ComplexTypeError, "Bad hash type" unless !subs.is_a?(ComplexType) and subs.length == 2 and !subs[0].is_a?(UniqueType) and !subs[1].is_a?(UniqueType)
36
+ @key_types.concat subs[0].map { |u| ComplexType.new([u]) }
37
+ @subtypes.concat subs[1].map { |u| ComplexType.new([u]) }
34
38
  else
35
39
  @subtypes.concat subs
36
40
  end
@@ -39,6 +43,31 @@ module Solargraph
39
43
  def to_s
40
44
  tag
41
45
  end
46
+
47
+ def self_to dst
48
+ return self unless selfy?
49
+ new_name = (@name == 'self' ? dst : @name)
50
+ new_key_types = @key_types.map { |t| t.self_to dst }
51
+ new_subtypes = @subtypes.map { |t| t.self_to dst }
52
+ if hash_parameters?
53
+ UniqueType.new(new_name, "{#{new_key_types.join(', ')} => #{new_subtypes.join(', ')}}")
54
+ elsif parameters?
55
+ if @substring.start_with?'<('
56
+ UniqueType.new(new_name, "<(#{new_subtypes.join(', ')})>")
57
+ else
58
+ UniqueType.new(new_name, "<#{new_subtypes.join(', ')}>")
59
+ end
60
+ else
61
+ UniqueType.new(new_name)
62
+ end
63
+ end
64
+
65
+ def selfy?
66
+ @name == 'self' || @key_types.any?(&:selfy?) || @subtypes.any?(&:selfy?)
67
+ end
68
+
69
+ UNDEFINED = UniqueType.new('undefined')
70
+ BOOLEAN = UniqueType.new('Boolean')
42
71
  end
43
72
  end
44
73
  end
@@ -8,30 +8,58 @@ module Solargraph
8
8
  'then', 'true', 'undef', 'unless', 'until', 'when', 'while', 'yield'
9
9
  ].freeze
10
10
 
11
- METHODS_RETURNING_SELF = %w[
12
- Array#select Array#reject Array#keep_if Array#delete_if
13
- Enumerable#select
14
- Object#clone Object#dup Object#freeze Object#taint Object#untaint Object#tap
15
- String#freeze
16
- ].freeze
17
-
18
11
  METHODS_RETURNING_SUBTYPES = %w[
19
12
  Array#[] Array#first Array#last
20
13
  ].freeze
21
14
 
15
+ METHODS_RETURNING_VALUE_TYPES = %w[
16
+ Hash#[]
17
+ ].freeze
18
+
22
19
  METHODS_WITH_YIELDPARAM_SELF = %w[
23
20
  Object#tap
24
21
  ].freeze
25
22
 
26
23
  METHODS_WITH_YIELDPARAM_SUBTYPES = %w[
27
- Array#each Array#map Array#any? Array#all? Array#index
24
+ Array#each Array#map Array#any? Array#all? Array#index Array#keep_if
25
+ Array#delete_if
28
26
  Enumerable#each_entry Enumerable#map Enumerable#any? Enumerable#all?
27
+ Enumerable#select Enumerable#reject
29
28
  Set#each
30
29
  ].freeze
31
30
 
32
- CUSTOM_RETURN_TYPES = {
33
- 'String#split' => 'Array<String>',
34
- 'String#lines' => 'Array<String>'
35
- }.freeze
31
+ class << self
32
+ private
33
+
34
+ def override path, *tags
35
+ Solargraph::Pin::Reference::Override.new(nil, path, [YARD::Tags::Tag.new('return', nil, tags)])
36
+ end
37
+ end
38
+
39
+ OVERRIDES = [
40
+ override('Array#select', 'self'),
41
+ override('Array#reject', 'self'),
42
+ override('Array#keep_if', 'self'),
43
+ override('Array#delete_if', 'self'),
44
+
45
+ override('Class#new', 'self'),
46
+ override('Class.new', 'Class<Object>'),
47
+ override('Class#allocate', 'self'),
48
+ override('Class.allocate', 'Class<Object>'),
49
+
50
+ override('Enumerable#select', 'self'),
51
+
52
+ override('Object#!', 'Boolean'),
53
+ override('Object#clone', 'self'),
54
+ override('Object#dup', 'self'),
55
+ override('Object#freeze', 'self'),
56
+ override('Object#taint', 'self'),
57
+ override('Object#untaint', 'self'),
58
+ override('Object#tap', 'self'),
59
+
60
+ override('String#freeze', 'self'),
61
+ override('String#split', 'Array<String>'),
62
+ override('String#lines', 'Array<String>')
63
+ ]
36
64
  end
37
65
  end
@@ -8,8 +8,8 @@ module Solargraph
8
8
  autoload :Rubocop, 'solargraph/diagnostics/rubocop'
9
9
  autoload :RubocopHelpers, 'solargraph/diagnostics/rubocop_helpers'
10
10
  autoload :RequireNotFound, 'solargraph/diagnostics/require_not_found'
11
- autoload :TypeNotDefined, 'solargraph/diagnostics/type_not_defined'
12
11
  autoload :UpdateErrors, 'solargraph/diagnostics/update_errors'
12
+ autoload :TypeCheck, 'solargraph/diagnostics/type_check'
13
13
 
14
14
  class << self
15
15
  # Add a reporter with a name to identify it in .solargraph.yml files.
@@ -25,7 +25,7 @@ module Solargraph
25
25
  #
26
26
  # @return [Array<String>]
27
27
  def reporters
28
- reporter_hash.keys
28
+ reporter_hash.keys - ['type_not_defined'] # @todo Hide type_not_defined for now
29
29
  end
30
30
 
31
31
  # Find a reporter by name.
@@ -46,7 +46,8 @@ module Solargraph
46
46
 
47
47
  register 'rubocop', Rubocop
48
48
  register 'require_not_found', RequireNotFound
49
- register 'type_not_defined', TypeNotDefined
49
+ register 'typecheck', TypeCheck
50
50
  register 'update_errors', UpdateErrors
51
+ register 'type_not_defined', TypeCheck # @todo Retained for backwards compatibility
51
52
  end
52
53
  end
@@ -3,6 +3,12 @@ module Solargraph
3
3
  # The base class for diagnostics reporters.
4
4
  #
5
5
  class Base
6
+ attr_reader :args
7
+
8
+ def initialize *args
9
+ @args = args
10
+ end
11
+
6
12
  # Perform a diagnosis on a Source within the context of an ApiMap.
7
13
  # The result is an array of hash objects that conform to the LSP's
8
14
  # Diagnostic specification.