solargraph 0.56.2 → 0.57.0
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 +4 -4
- data/.github/workflows/linting.yml +125 -0
- data/.github/workflows/plugins.yml +148 -6
- data/.github/workflows/rspec.yml +39 -4
- data/.github/workflows/typecheck.yml +5 -2
- data/.gitignore +5 -0
- data/.overcommit.yml +72 -0
- data/.rspec +1 -0
- data/.rubocop.yml +66 -0
- data/.rubocop_todo.yml +2627 -0
- data/.yardopts +1 -0
- data/CHANGELOG.md +42 -0
- data/README.md +8 -4
- data/Rakefile +125 -13
- data/lib/solargraph/api_map/cache.rb +3 -2
- data/lib/solargraph/api_map/constants.rb +218 -0
- data/lib/solargraph/api_map/index.rb +20 -26
- data/lib/solargraph/api_map/source_to_yard.rb +10 -4
- data/lib/solargraph/api_map/store.rb +126 -18
- data/lib/solargraph/api_map.rb +212 -234
- data/lib/solargraph/bench.rb +1 -0
- data/lib/solargraph/complex_type/type_methods.rb +1 -0
- data/lib/solargraph/complex_type/unique_type.rb +7 -7
- data/lib/solargraph/complex_type.rb +5 -1
- data/lib/solargraph/convention/active_support_concern.rb +111 -0
- data/lib/solargraph/convention/base.rb +17 -0
- data/lib/solargraph/convention/data_definition/data_assignment_node.rb +1 -0
- data/lib/solargraph/convention/data_definition/data_definition_node.rb +3 -1
- data/lib/solargraph/convention/data_definition.rb +2 -1
- data/lib/solargraph/convention/gemspec.rb +1 -1
- data/lib/solargraph/convention/struct_definition/struct_assignment_node.rb +1 -0
- data/lib/solargraph/convention/struct_definition/struct_definition_node.rb +3 -1
- data/lib/solargraph/convention/struct_definition.rb +36 -13
- data/lib/solargraph/convention.rb +31 -2
- data/lib/solargraph/diagnostics/rubocop.rb +6 -1
- data/lib/solargraph/diagnostics/rubocop_helpers.rb +1 -1
- data/lib/solargraph/doc_map.rb +40 -12
- data/lib/solargraph/environ.rb +9 -2
- data/lib/solargraph/gem_pins.rb +17 -11
- data/lib/solargraph/language_server/host/dispatch.rb +2 -0
- data/lib/solargraph/language_server/host/message_worker.rb +3 -0
- data/lib/solargraph/language_server/host.rb +2 -1
- data/lib/solargraph/language_server/message/base.rb +2 -1
- data/lib/solargraph/language_server/message/extended/check_gem_version.rb +1 -1
- data/lib/solargraph/language_server/message/text_document/definition.rb +2 -0
- data/lib/solargraph/language_server/message/text_document/formatting.rb +16 -2
- data/lib/solargraph/language_server/message/text_document/type_definition.rb +1 -0
- data/lib/solargraph/language_server/message/workspace/did_change_workspace_folders.rb +2 -0
- data/lib/solargraph/language_server/progress.rb +8 -0
- data/lib/solargraph/language_server/request.rb +1 -0
- data/lib/solargraph/library.rb +8 -15
- data/lib/solargraph/location.rb +2 -0
- data/lib/solargraph/logging.rb +11 -2
- data/lib/solargraph/page.rb +4 -0
- data/lib/solargraph/parser/comment_ripper.rb +8 -1
- data/lib/solargraph/parser/flow_sensitive_typing.rb +32 -4
- data/lib/solargraph/parser/node_methods.rb +2 -2
- data/lib/solargraph/parser/node_processor/base.rb +1 -1
- data/lib/solargraph/parser/node_processor.rb +6 -2
- data/lib/solargraph/parser/parser_gem/class_methods.rb +1 -1
- data/lib/solargraph/parser/parser_gem/flawed_builder.rb +1 -0
- data/lib/solargraph/parser/parser_gem/node_chainer.rb +3 -1
- data/lib/solargraph/parser/parser_gem/node_methods.rb +4 -2
- data/lib/solargraph/parser/parser_gem/node_processors/block_node.rb +3 -2
- data/lib/solargraph/parser/parser_gem/node_processors/if_node.rb +2 -0
- data/lib/solargraph/parser/parser_gem/node_processors/masgn_node.rb +3 -0
- data/lib/solargraph/parser/parser_gem/node_processors/send_node.rb +35 -14
- data/lib/solargraph/parser/region.rb +3 -0
- data/lib/solargraph/parser/snippet.rb +2 -0
- data/lib/solargraph/pin/base.rb +50 -8
- data/lib/solargraph/pin/base_variable.rb +1 -2
- data/lib/solargraph/pin/callable.rb +9 -0
- data/lib/solargraph/pin/closure.rb +2 -0
- data/lib/solargraph/pin/common.rb +6 -2
- data/lib/solargraph/pin/constant.rb +2 -0
- data/lib/solargraph/pin/delegated_method.rb +1 -0
- data/lib/solargraph/pin/local_variable.rb +4 -1
- data/lib/solargraph/pin/method.rb +8 -5
- data/lib/solargraph/pin/method_alias.rb +3 -0
- data/lib/solargraph/pin/parameter.rb +18 -8
- data/lib/solargraph/pin/proxy_type.rb +1 -0
- data/lib/solargraph/pin/reference/override.rb +15 -1
- data/lib/solargraph/pin/reference/superclass.rb +5 -0
- data/lib/solargraph/pin/reference.rb +26 -0
- data/lib/solargraph/pin/search.rb +3 -1
- data/lib/solargraph/pin/signature.rb +2 -0
- data/lib/solargraph/pin/symbol.rb +5 -0
- data/lib/solargraph/pin_cache.rb +64 -4
- data/lib/solargraph/position.rb +2 -0
- data/lib/solargraph/range.rb +1 -0
- data/lib/solargraph/rbs_map/conversions.rb +7 -5
- data/lib/solargraph/rbs_map/core_map.rb +3 -0
- data/lib/solargraph/rbs_map.rb +15 -2
- data/lib/solargraph/shell.rb +3 -0
- data/lib/solargraph/source/chain/link.rb +10 -1
- data/lib/solargraph/source/chain.rb +9 -2
- data/lib/solargraph/source/change.rb +2 -2
- data/lib/solargraph/source/cursor.rb +2 -3
- data/lib/solargraph/source/source_chainer.rb +1 -1
- data/lib/solargraph/source.rb +5 -2
- data/lib/solargraph/source_map/clip.rb +1 -1
- data/lib/solargraph/source_map/data.rb +4 -0
- data/lib/solargraph/source_map/mapper.rb +4 -2
- data/lib/solargraph/source_map.rb +21 -14
- data/lib/solargraph/type_checker/param_def.rb +2 -0
- data/lib/solargraph/type_checker/rules.rb +8 -0
- data/lib/solargraph/type_checker.rb +173 -120
- data/lib/solargraph/version.rb +1 -1
- data/lib/solargraph/workspace/config.rb +0 -2
- data/lib/solargraph/workspace/require_paths.rb +98 -0
- data/lib/solargraph/workspace.rb +16 -48
- data/lib/solargraph/yard_map/mapper/to_method.rb +2 -2
- data/lib/solargraph/yardoc.rb +16 -3
- data/lib/solargraph.rb +2 -0
- data/rbs/fills/tuple.rbs +2 -3
- data/sig/shims/parser/3.2.0.1/builders/default.rbs +195 -0
- data/sig/shims/thor/1.2.0.1/.rbs_meta.yaml +9 -0
- data/sig/shims/thor/1.2.0.1/manifest.yaml +7 -0
- data/sig/shims/thor/1.2.0.1/thor.rbs +17 -0
- data/solargraph.gemspec +14 -4
- metadata +123 -9
- data/lib/.rubocop.yml +0 -22
@@ -17,7 +17,13 @@ module Solargraph
|
|
17
17
|
@word = word
|
18
18
|
end
|
19
19
|
|
20
|
-
# @sg-ignore
|
20
|
+
# @sg-ignore two problems - Declared return type
|
21
|
+
# ::Solargraph::Source::Chain::Array does not match inferred
|
22
|
+
# type ::Array(::Class<::Solargraph::Source::Chain::Link>,
|
23
|
+
# ::String) for
|
24
|
+
# Solargraph::Source::Chain::Link#equality_fields
|
25
|
+
# and
|
26
|
+
# Not enough arguments to Module#protected
|
21
27
|
protected def equality_fields
|
22
28
|
[self.class, word]
|
23
29
|
end
|
@@ -39,6 +45,7 @@ module Solargraph
|
|
39
45
|
end
|
40
46
|
|
41
47
|
# debugging description of contents; not for machine use
|
48
|
+
# @return [String]
|
42
49
|
def desc
|
43
50
|
word
|
44
51
|
end
|
@@ -74,6 +81,8 @@ module Solargraph
|
|
74
81
|
end
|
75
82
|
|
76
83
|
# debugging description of contents; not for machine use
|
84
|
+
#
|
85
|
+
# @return [String]
|
77
86
|
def desc
|
78
87
|
word
|
79
88
|
end
|
@@ -15,6 +15,7 @@ module Solargraph
|
|
15
15
|
#
|
16
16
|
class Chain
|
17
17
|
include Equality
|
18
|
+
include Logging
|
18
19
|
|
19
20
|
autoload :Link, 'solargraph/source/chain/link'
|
20
21
|
autoload :Call, 'solargraph/source/chain/call'
|
@@ -75,7 +76,9 @@ module Solargraph
|
|
75
76
|
|
76
77
|
# Determine potential Pins returned by this chain of words
|
77
78
|
#
|
78
|
-
# @param api_map [ApiMap]
|
79
|
+
# @param api_map [ApiMap]
|
80
|
+
#
|
81
|
+
# @param name_pin [Pin::Base] A pin
|
79
82
|
# representing the place in which expression is evaluated (e.g.,
|
80
83
|
# a Method pin, or a Module or Class pin if not run within a
|
81
84
|
# method - both in terms of the closure around the chain, as well
|
@@ -192,6 +195,7 @@ module Solargraph
|
|
192
195
|
|
193
196
|
include Logging
|
194
197
|
|
198
|
+
# @return [String]
|
195
199
|
def desc
|
196
200
|
links.map(&:desc).to_s
|
197
201
|
end
|
@@ -265,7 +269,10 @@ module Solargraph
|
|
265
269
|
else
|
266
270
|
ComplexType.new(types)
|
267
271
|
end
|
268
|
-
|
272
|
+
if context.nil? || context.return_type.undefined?
|
273
|
+
# up to downstream to resolve self type
|
274
|
+
return type
|
275
|
+
end
|
269
276
|
|
270
277
|
type.self_to_type(context.return_type)
|
271
278
|
end
|
@@ -28,7 +28,7 @@ module Solargraph
|
|
28
28
|
# syntax errors will be repaired.
|
29
29
|
# @return [String] The updated text.
|
30
30
|
def write text, nullable = false
|
31
|
-
if nullable and !range.nil? and new_text.match(/[
|
31
|
+
if nullable and !range.nil? and new_text.match(/[.\[{(@$:]$/)
|
32
32
|
[':', '@'].each do |dupable|
|
33
33
|
next unless new_text == dupable
|
34
34
|
offset = Position.to_offset(text, range.start)
|
@@ -59,7 +59,7 @@ module Solargraph
|
|
59
59
|
else
|
60
60
|
result = commit text, fixed
|
61
61
|
off = Position.to_offset(text, range.start)
|
62
|
-
match = result[0, off].match(/[
|
62
|
+
match = result[0, off].match(/[.:]+\z/)
|
63
63
|
if match
|
64
64
|
result = result[0, off].sub(/#{match[0]}\z/, ' ' * match[0].length) + result[off..-1]
|
65
65
|
end
|
@@ -35,7 +35,6 @@ module Solargraph
|
|
35
35
|
# The part of the word before the current position. Given the text
|
36
36
|
# `foo.bar`, the start_of_word at position(0, 6) is `ba`.
|
37
37
|
#
|
38
|
-
# @sg-ignore Improve resolution of String#match below
|
39
38
|
# @return [String]
|
40
39
|
def start_of_word
|
41
40
|
@start_of_word ||= begin
|
@@ -125,7 +124,7 @@ module Solargraph
|
|
125
124
|
def node_position
|
126
125
|
@node_position ||= begin
|
127
126
|
if start_of_word.empty?
|
128
|
-
match = source.code[0, offset].match(
|
127
|
+
match = source.code[0, offset].match(/\s*(\.|:+)\s*$/)
|
129
128
|
if match
|
130
129
|
Position.from_offset(source.code, offset - match[0].length)
|
131
130
|
else
|
@@ -160,7 +159,7 @@ module Solargraph
|
|
160
159
|
#
|
161
160
|
# @return [Regexp]
|
162
161
|
def end_word_pattern
|
163
|
-
/^([a-z0-9_]|[^\u0000-\u007F])*[
|
162
|
+
/^([a-z0-9_]|[^\u0000-\u007F])*[?!]?/i
|
164
163
|
end
|
165
164
|
end
|
166
165
|
end
|
data/lib/solargraph/source.rb
CHANGED
@@ -30,7 +30,7 @@ module Solargraph
|
|
30
30
|
@node
|
31
31
|
end
|
32
32
|
|
33
|
-
# @return [Hash{Integer =>
|
33
|
+
# @return [Hash{Integer => Solargraph::Parser::Snippet}]
|
34
34
|
def comments
|
35
35
|
finalize
|
36
36
|
@comments
|
@@ -235,6 +235,7 @@ module Solargraph
|
|
235
235
|
# @return [Hash{Integer => String}]
|
236
236
|
def associated_comments
|
237
237
|
@associated_comments ||= begin
|
238
|
+
# @type [Hash{Integer => String}]
|
238
239
|
result = {}
|
239
240
|
buffer = String.new('')
|
240
241
|
# @type [Integer, nil]
|
@@ -317,7 +318,7 @@ module Solargraph
|
|
317
318
|
@string_nodes ||= string_nodes_in(node)
|
318
319
|
end
|
319
320
|
|
320
|
-
# @return [Array<Range>]
|
321
|
+
# @return [Array<Solargraph::Range>]
|
321
322
|
def comment_ranges
|
322
323
|
@comment_ranges ||= comments.values.map(&:range)
|
323
324
|
end
|
@@ -386,6 +387,7 @@ module Solargraph
|
|
386
387
|
# @return [Integer]
|
387
388
|
attr_writer :version
|
388
389
|
|
390
|
+
# @return [void]
|
389
391
|
def finalize
|
390
392
|
return if @finalized && changes.empty?
|
391
393
|
|
@@ -440,6 +442,7 @@ module Solargraph
|
|
440
442
|
# @return [String]
|
441
443
|
attr_writer :repaired
|
442
444
|
|
445
|
+
# @return [String]
|
443
446
|
def repaired
|
444
447
|
finalize
|
445
448
|
@repaired
|
@@ -65,7 +65,7 @@ module Solargraph
|
|
65
65
|
# position. Locals can be local variables, method parameters, or block
|
66
66
|
# parameters. The array starts with the nearest local pin.
|
67
67
|
#
|
68
|
-
# @return [::Array<Solargraph::Pin::
|
68
|
+
# @return [::Array<Solargraph::Pin::LocalVariable>]
|
69
69
|
def locals
|
70
70
|
@locals ||= source_map.locals_at(location)
|
71
71
|
end
|
@@ -3,15 +3,18 @@
|
|
3
3
|
module Solargraph
|
4
4
|
class SourceMap
|
5
5
|
class Data
|
6
|
+
# @param source [Solargraph::Source]
|
6
7
|
def initialize source
|
7
8
|
@source = source
|
8
9
|
end
|
9
10
|
|
11
|
+
# @return [Array<Solargraph::Pin::Base>]
|
10
12
|
def pins
|
11
13
|
generate
|
12
14
|
@pins || []
|
13
15
|
end
|
14
16
|
|
17
|
+
# @return [Array<Solargraph::LocalVariable>]
|
15
18
|
def locals
|
16
19
|
generate
|
17
20
|
@locals || []
|
@@ -19,6 +22,7 @@ module Solargraph
|
|
19
22
|
|
20
23
|
private
|
21
24
|
|
25
|
+
# @return [void]
|
22
26
|
def generate
|
23
27
|
return if @generated
|
24
28
|
|
@@ -70,6 +70,7 @@ module Solargraph
|
|
70
70
|
# @param comment [String]
|
71
71
|
# @return [void]
|
72
72
|
def process_comment source_position, comment_position, comment
|
73
|
+
# @sg-ignore Wrong argument type for String#=~: object expected String::_MatchAgainst<String, undefined>, received Regexp
|
73
74
|
return unless comment.encode('UTF-8', invalid: :replace, replace: '?') =~ DIRECTIVE_REGEXP
|
74
75
|
cmnt = remove_inline_comment_hashes(comment)
|
75
76
|
parse = Solargraph::Source.parse_docstring(cmnt)
|
@@ -163,7 +164,7 @@ module Solargraph
|
|
163
164
|
end
|
164
165
|
end
|
165
166
|
when 'visibility'
|
166
|
-
|
167
|
+
|
167
168
|
kind = directive.tag.text&.to_sym
|
168
169
|
return unless [:private, :protected, :public].include?(kind)
|
169
170
|
|
@@ -182,7 +183,7 @@ module Solargraph
|
|
182
183
|
pin.instance_variable_set(:@visibility, kind)
|
183
184
|
end
|
184
185
|
end
|
185
|
-
|
186
|
+
|
186
187
|
when 'parse'
|
187
188
|
begin
|
188
189
|
ns = closure_at(source_position)
|
@@ -244,6 +245,7 @@ module Solargraph
|
|
244
245
|
|
245
246
|
# @return [void]
|
246
247
|
def process_comment_directives
|
248
|
+
# @sg-ignore Wrong argument type for String#=~: object expected String::_MatchAgainst<String, undefined>, received Regexp
|
247
249
|
return unless @code.encode('UTF-8', invalid: :replace, replace: '?') =~ DIRECTIVE_REGEXP
|
248
250
|
code_lines = @code.lines
|
249
251
|
@source.associated_comments.each do |line, comments|
|
@@ -21,6 +21,11 @@ module Solargraph
|
|
21
21
|
data.pins
|
22
22
|
end
|
23
23
|
|
24
|
+
# @return [Array<Pin::Base>]
|
25
|
+
def all_pins
|
26
|
+
pins + convention_pins
|
27
|
+
end
|
28
|
+
|
24
29
|
# @return [Array<Pin::LocalVariable>]
|
25
30
|
def locals
|
26
31
|
data.locals
|
@@ -30,13 +35,18 @@ module Solargraph
|
|
30
35
|
def initialize source
|
31
36
|
@source = source
|
32
37
|
|
33
|
-
|
34
|
-
|
38
|
+
conventions_environ.merge Convention.for_local(self) unless filename.nil?
|
39
|
+
# FIXME: unmemoizing the document_symbols in case it was called and memoized from any of conventions above
|
40
|
+
# this is to ensure that the convention_pins from all conventions are used in the document_symbols.
|
41
|
+
# solargraph-rails is known to use this method to get the document symbols. It should probably be removed.
|
42
|
+
@document_symbols = nil
|
43
|
+
self.convention_pins = conventions_environ.pins
|
35
44
|
@pin_select_cache = {}
|
36
45
|
end
|
37
46
|
|
38
|
-
# @
|
39
|
-
# @
|
47
|
+
# @generic T
|
48
|
+
# @param klass [Class<generic<T>>]
|
49
|
+
# @return [Array<generic<T>>]
|
40
50
|
def pins_by_class klass
|
41
51
|
@pin_select_cache[klass] ||= pin_class_hash.select { |key, _| key <= klass }.values.flatten
|
42
52
|
end
|
@@ -67,8 +77,8 @@ module Solargraph
|
|
67
77
|
end
|
68
78
|
|
69
79
|
# @return [Environ]
|
70
|
-
def
|
71
|
-
@
|
80
|
+
def conventions_environ
|
81
|
+
@conventions_environ ||= Environ.new
|
72
82
|
end
|
73
83
|
|
74
84
|
# all pins except Solargraph::Pin::Reference::Reference
|
@@ -158,10 +168,15 @@ module Solargraph
|
|
158
168
|
|
159
169
|
private
|
160
170
|
|
171
|
+
# @return [Hash{Class => Array<Pin::Base>}]
|
172
|
+
# @return [Array<Pin::Base>]
|
173
|
+
attr_writer :convention_pins
|
174
|
+
|
161
175
|
def pin_class_hash
|
162
176
|
@pin_class_hash ||= pins.to_set.classify(&:class).transform_values(&:to_a)
|
163
177
|
end
|
164
178
|
|
179
|
+
# @return [Data]
|
165
180
|
def data
|
166
181
|
@data ||= Data.new(source)
|
167
182
|
end
|
@@ -171,14 +186,6 @@ module Solargraph
|
|
171
186
|
@convention_pins || []
|
172
187
|
end
|
173
188
|
|
174
|
-
# @param pins [Array<Pin::Base>]
|
175
|
-
# @return [Array<Pin::Base>]
|
176
|
-
def convention_pins=(pins)
|
177
|
-
# unmemoizing the document_symbols in case it was called from any of conventions
|
178
|
-
@document_symbols = nil
|
179
|
-
@convention_pins = pins
|
180
|
-
end
|
181
|
-
|
182
189
|
# @param line [Integer]
|
183
190
|
# @param character [Integer]
|
184
191
|
# @param klasses [Array<Class>]
|
@@ -57,6 +57,14 @@ module Solargraph
|
|
57
57
|
def require_all_return_types_match_inferred?
|
58
58
|
rank >= LEVELS[:alpha]
|
59
59
|
end
|
60
|
+
|
61
|
+
# We keep this at strong because if you added an @ sg-ignore to
|
62
|
+
# address a strong-level issue, then ran at a lower level, you'd
|
63
|
+
# get a false positive - we don't run stronger level checks than
|
64
|
+
# requested for performance reasons
|
65
|
+
def validate_sg_ignores?
|
66
|
+
rank >= LEVELS[:strong]
|
67
|
+
end
|
60
68
|
end
|
61
69
|
end
|
62
70
|
end
|