solargraph 0.56.2 → 0.58.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 +127 -0
- data/.github/workflows/plugins.yml +183 -7
- data/.github/workflows/rspec.yml +55 -5
- data/.github/workflows/typecheck.yml +6 -3
- data/.gitignore +5 -0
- data/.overcommit.yml +72 -0
- data/.rspec +1 -0
- data/.rubocop.yml +66 -0
- data/.rubocop_todo.yml +1279 -0
- data/.yardopts +1 -0
- data/CHANGELOG.md +69 -0
- data/README.md +8 -4
- data/Rakefile +125 -13
- data/bin/solargraph +8 -5
- data/lib/solargraph/api_map/cache.rb +3 -2
- data/lib/solargraph/api_map/constants.rb +279 -0
- data/lib/solargraph/api_map/index.rb +49 -31
- data/lib/solargraph/api_map/source_to_yard.rb +13 -4
- data/lib/solargraph/api_map/store.rb +144 -26
- data/lib/solargraph/api_map.rb +217 -245
- data/lib/solargraph/bench.rb +1 -0
- data/lib/solargraph/complex_type/type_methods.rb +6 -0
- data/lib/solargraph/complex_type/unique_type.rb +19 -12
- data/lib/solargraph/complex_type.rb +24 -3
- 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 +4 -2
- 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 +5 -3
- data/lib/solargraph/doc_map.rb +44 -13
- data/lib/solargraph/environ.rb +9 -2
- data/lib/solargraph/equality.rb +1 -0
- data/lib/solargraph/gem_pins.rb +21 -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 +12 -5
- 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 +19 -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 +4 -1
- data/lib/solargraph/library.rb +11 -18
- data/lib/solargraph/location.rb +3 -0
- data/lib/solargraph/logging.rb +11 -2
- data/lib/solargraph/page.rb +3 -0
- data/lib/solargraph/parser/comment_ripper.rb +8 -1
- data/lib/solargraph/parser/flow_sensitive_typing.rb +33 -5
- 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 +3 -13
- 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 +5 -16
- data/lib/solargraph/parser/parser_gem/node_processors/and_node.rb +1 -0
- 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/opasgn_node.rb +64 -8
- data/lib/solargraph/parser/parser_gem/node_processors/sclass_node.rb +12 -3
- data/lib/solargraph/parser/parser_gem/node_processors/send_node.rb +36 -16
- data/lib/solargraph/parser/region.rb +3 -0
- data/lib/solargraph/parser/snippet.rb +2 -0
- data/lib/solargraph/pin/base.rb +77 -14
- data/lib/solargraph/pin/base_variable.rb +6 -5
- data/lib/solargraph/pin/block.rb +3 -2
- data/lib/solargraph/pin/callable.rb +14 -1
- data/lib/solargraph/pin/closure.rb +5 -7
- data/lib/solargraph/pin/common.rb +6 -2
- data/lib/solargraph/pin/constant.rb +2 -0
- data/lib/solargraph/pin/local_variable.rb +1 -2
- data/lib/solargraph/pin/method.rb +28 -9
- data/lib/solargraph/pin/method_alias.rb +3 -0
- data/lib/solargraph/pin/parameter.rb +24 -10
- data/lib/solargraph/pin/proxy_type.rb +5 -1
- data/lib/solargraph/pin/reference/override.rb +15 -1
- data/lib/solargraph/pin/reference/superclass.rb +5 -0
- data/lib/solargraph/pin/reference.rb +17 -0
- data/lib/solargraph/pin/search.rb +6 -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 +3 -0
- data/lib/solargraph/range.rb +5 -0
- data/lib/solargraph/rbs_map/conversions.rb +29 -6
- data/lib/solargraph/rbs_map/core_fills.rb +18 -0
- data/lib/solargraph/rbs_map/core_map.rb +14 -7
- data/lib/solargraph/rbs_map.rb +14 -1
- data/lib/solargraph/shell.rb +85 -1
- data/lib/solargraph/source/chain/call.rb +7 -3
- data/lib/solargraph/source/chain/constant.rb +3 -66
- data/lib/solargraph/source/chain/if.rb +1 -1
- data/lib/solargraph/source/chain/link.rb +11 -2
- data/lib/solargraph/source/chain/or.rb +1 -1
- data/lib/solargraph/source/chain.rb +11 -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 +6 -3
- data/lib/solargraph/source_map/clip.rb +18 -26
- data/lib/solargraph/source_map/data.rb +4 -0
- data/lib/solargraph/source_map/mapper.rb +2 -2
- data/lib/solargraph/source_map.rb +28 -16
- data/lib/solargraph/type_checker/param_def.rb +2 -0
- data/lib/solargraph/type_checker/rules.rb +30 -8
- data/lib/solargraph/type_checker.rb +301 -186
- data/lib/solargraph/version.rb +1 -1
- data/lib/solargraph/workspace/config.rb +21 -5
- data/lib/solargraph/workspace/require_paths.rb +97 -0
- data/lib/solargraph/workspace.rb +30 -67
- data/lib/solargraph/yard_map/mapper/to_method.rb +4 -3
- data/lib/solargraph/yard_map/mapper/to_namespace.rb +1 -0
- data/lib/solargraph/yard_map/to_method.rb +2 -1
- data/lib/solargraph/yardoc.rb +39 -3
- data/lib/solargraph.rb +2 -0
- data/rbs/fills/bundler/0/bundler.rbs +4271 -0
- data/rbs/fills/open3/0/open3.rbs +172 -0
- data/rbs/fills/rubygems/0/basic_specification.rbs +326 -0
- data/rbs/fills/rubygems/0/errors.rbs +364 -0
- data/rbs/fills/rubygems/0/spec_fetcher.rbs +107 -0
- data/rbs/fills/rubygems/0/specification.rbs +1753 -0
- data/rbs/fills/{tuple.rbs → tuple/tuple.rbs} +2 -3
- data/rbs_collection.yaml +4 -4
- data/sig/shims/ast/0/node.rbs +5 -0
- data/sig/shims/ast/2.4/.rbs_meta.yaml +9 -0
- data/sig/shims/ast/2.4/ast.rbs +73 -0
- data/sig/shims/parser/3.2.0.1/builders/default.rbs +195 -0
- data/sig/shims/parser/3.2.0.1/manifest.yaml +7 -0
- data/sig/shims/parser/3.2.0.1/parser.rbs +201 -0
- data/sig/shims/parser/3.2.0.1/polyfill.rbs +4 -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 +26 -5
- metadata +181 -13
- data/lib/.rubocop.yml +0 -22
- data/lib/solargraph/parser/node_methods.rb +0 -97
|
@@ -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
|
@@ -15,7 +15,7 @@ module Solargraph
|
|
|
15
15
|
|
|
16
16
|
include EncodingFixes
|
|
17
17
|
|
|
18
|
-
# @return [String]
|
|
18
|
+
# @return [String, nil]
|
|
19
19
|
attr_reader :filename
|
|
20
20
|
|
|
21
21
|
# @return [String]
|
|
@@ -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
|
|
@@ -11,15 +11,14 @@ module Solargraph
|
|
|
11
11
|
def initialize api_map, cursor
|
|
12
12
|
@api_map = api_map
|
|
13
13
|
@cursor = cursor
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
@in_block = nil
|
|
14
|
+
closure_pin = closure
|
|
15
|
+
closure_pin.rebind(api_map) if closure_pin.is_a?(Pin::Block) && !Solargraph::Range.from_node(closure_pin.receiver).contain?(cursor.range.start)
|
|
17
16
|
end
|
|
18
17
|
|
|
19
18
|
# @return [Array<Pin::Base>] Relevant pins for infering the type of the Cursor's position
|
|
20
19
|
def define
|
|
21
20
|
return [] if cursor.comment? || cursor.chain.literal?
|
|
22
|
-
result = cursor.chain.define(api_map,
|
|
21
|
+
result = cursor.chain.define(api_map, closure, locals)
|
|
23
22
|
result.concat file_global_methods
|
|
24
23
|
result.concat((source_map.pins + source_map.locals).select{ |p| p.name == cursor.word && p.location.range.contain?(cursor.position) }) if result.empty?
|
|
25
24
|
result
|
|
@@ -51,43 +50,36 @@ module Solargraph
|
|
|
51
50
|
|
|
52
51
|
# @return [ComplexType]
|
|
53
52
|
def infer
|
|
54
|
-
result = cursor.chain.infer(api_map,
|
|
53
|
+
result = cursor.chain.infer(api_map, closure, locals)
|
|
55
54
|
if result.tag == 'Class'
|
|
56
55
|
# HACK: Exception to return BasicObject from Class#new
|
|
57
|
-
dfn = cursor.chain.define(api_map,
|
|
56
|
+
dfn = cursor.chain.define(api_map, closure, locals).first
|
|
58
57
|
return ComplexType.try_parse('::BasicObject') if dfn && dfn.path == 'Class#new'
|
|
59
58
|
end
|
|
60
|
-
|
|
61
|
-
|
|
59
|
+
# should receive result with selfs resolved from infer()
|
|
60
|
+
Solargraph.assert_or_log(:clip_infer_self, 'Received selfy inference') if result.selfy?
|
|
61
|
+
result
|
|
62
62
|
end
|
|
63
63
|
|
|
64
64
|
# Get an array of all the locals that are visible from the cursors's
|
|
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
|
|
72
72
|
|
|
73
73
|
# @return [::Array<String>]
|
|
74
74
|
def gates
|
|
75
|
-
|
|
76
|
-
end
|
|
77
|
-
|
|
78
|
-
def in_block?
|
|
79
|
-
return @in_block unless @in_block.nil?
|
|
80
|
-
@in_block = begin
|
|
81
|
-
tree = cursor.source.tree_at(cursor.position.line, cursor.position.column)
|
|
82
|
-
Parser.is_ast_node?(tree[1]) && [:block, :ITER].include?(tree[1].type)
|
|
83
|
-
end
|
|
75
|
+
closure.gates
|
|
84
76
|
end
|
|
85
77
|
|
|
86
78
|
# @param phrase [String]
|
|
87
79
|
# @return [Array<Solargraph::Pin::Base>]
|
|
88
80
|
def translate phrase
|
|
89
81
|
chain = Parser.chain(Parser.parse(phrase))
|
|
90
|
-
chain.define(api_map,
|
|
82
|
+
chain.define(api_map, closure, locals)
|
|
91
83
|
end
|
|
92
84
|
|
|
93
85
|
private
|
|
@@ -109,8 +101,8 @@ module Solargraph
|
|
|
109
101
|
end
|
|
110
102
|
|
|
111
103
|
# @return [Solargraph::Pin::Closure]
|
|
112
|
-
def
|
|
113
|
-
@
|
|
104
|
+
def closure
|
|
105
|
+
@closure ||= source_map.locate_closure_pin(cursor.node_position.line, cursor.node_position.character)
|
|
114
106
|
end
|
|
115
107
|
|
|
116
108
|
# The context at the current position.
|
|
@@ -201,20 +193,20 @@ module Solargraph
|
|
|
201
193
|
result.concat api_map.get_constants(type.namespace, cursor.start_of_constant? ? '' : context_pin.full_context.namespace, *gates)
|
|
202
194
|
end
|
|
203
195
|
else
|
|
204
|
-
type = cursor.chain.base.infer(api_map,
|
|
205
|
-
result.concat api_map.get_complex_type_methods(type,
|
|
196
|
+
type = cursor.chain.base.infer(api_map, closure, locals)
|
|
197
|
+
result.concat api_map.get_complex_type_methods(type, closure.binder.namespace, cursor.chain.links.length == 1)
|
|
206
198
|
if cursor.chain.links.length == 1
|
|
207
199
|
if cursor.word.start_with?('@@')
|
|
208
200
|
return package_completions(api_map.get_class_variable_pins(context_pin.full_context.namespace))
|
|
209
201
|
elsif cursor.word.start_with?('@')
|
|
210
|
-
return package_completions(api_map.get_instance_variable_pins(
|
|
202
|
+
return package_completions(api_map.get_instance_variable_pins(closure.binder.namespace, closure.binder.scope))
|
|
211
203
|
elsif cursor.word.start_with?('$')
|
|
212
204
|
return package_completions(api_map.get_global_variable_pins)
|
|
213
205
|
end
|
|
214
206
|
result.concat locals
|
|
215
|
-
result.concat file_global_methods unless
|
|
207
|
+
result.concat file_global_methods unless closure.binder.namespace.empty?
|
|
216
208
|
result.concat api_map.get_constants(context_pin.context.namespace, *gates)
|
|
217
|
-
result.concat api_map.get_methods(
|
|
209
|
+
result.concat api_map.get_methods(closure.binder.namespace, scope: closure.binder.scope, visibility: [:public, :private, :protected])
|
|
218
210
|
result.concat api_map.get_methods('Kernel')
|
|
219
211
|
result.concat api_map.keyword_pins.to_a
|
|
220
212
|
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
|
|
|
@@ -163,7 +163,7 @@ module Solargraph
|
|
|
163
163
|
end
|
|
164
164
|
end
|
|
165
165
|
when 'visibility'
|
|
166
|
-
|
|
166
|
+
|
|
167
167
|
kind = directive.tag.text&.to_sym
|
|
168
168
|
return unless [:private, :protected, :public].include?(kind)
|
|
169
169
|
|
|
@@ -182,7 +182,7 @@ module Solargraph
|
|
|
182
182
|
pin.instance_variable_set(:@visibility, kind)
|
|
183
183
|
end
|
|
184
184
|
end
|
|
185
|
-
|
|
185
|
+
|
|
186
186
|
when 'parse'
|
|
187
187
|
begin
|
|
188
188
|
ns = closure_at(source_position)
|
|
@@ -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,20 @@ 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
|
|
44
|
+
# @type [Hash{Class<Pin::Base> => Array<Pin::Base>}]
|
|
35
45
|
@pin_select_cache = {}
|
|
36
46
|
end
|
|
37
47
|
|
|
38
|
-
# @
|
|
39
|
-
# @
|
|
48
|
+
# @generic T
|
|
49
|
+
# @param klass [Class<generic<T>>]
|
|
50
|
+
#
|
|
51
|
+
# @return [Array<generic<T>>]
|
|
40
52
|
def pins_by_class klass
|
|
41
53
|
@pin_select_cache[klass] ||= pin_class_hash.select { |key, _| key <= klass }.values.flatten
|
|
42
54
|
end
|
|
@@ -67,8 +79,8 @@ module Solargraph
|
|
|
67
79
|
end
|
|
68
80
|
|
|
69
81
|
# @return [Environ]
|
|
70
|
-
def
|
|
71
|
-
@
|
|
82
|
+
def conventions_environ
|
|
83
|
+
@conventions_environ ||= Environ.new
|
|
72
84
|
end
|
|
73
85
|
|
|
74
86
|
# all pins except Solargraph::Pin::Reference::Reference
|
|
@@ -114,10 +126,13 @@ module Solargraph
|
|
|
114
126
|
# @param line [Integer]
|
|
115
127
|
# @param character [Integer]
|
|
116
128
|
# @return [Pin::Namespace,Pin::Method,Pin::Block]
|
|
117
|
-
def
|
|
118
|
-
_locate_pin line, character, Pin::
|
|
129
|
+
def locate_closure_pin line, character
|
|
130
|
+
_locate_pin line, character, Pin::Closure
|
|
119
131
|
end
|
|
120
132
|
|
|
133
|
+
# @deprecated Please use locate_closure_pin instead
|
|
134
|
+
alias locate_block_pin locate_closure_pin
|
|
135
|
+
|
|
121
136
|
# @param name [String]
|
|
122
137
|
# @return [Array<Location>]
|
|
123
138
|
def references name
|
|
@@ -158,10 +173,15 @@ module Solargraph
|
|
|
158
173
|
|
|
159
174
|
private
|
|
160
175
|
|
|
176
|
+
# @return [Array<Pin::Base>]
|
|
177
|
+
attr_writer :convention_pins
|
|
178
|
+
|
|
179
|
+
# @return [Hash{Class<Pin::Base> => Array<Pin::Base>}]
|
|
161
180
|
def pin_class_hash
|
|
162
181
|
@pin_class_hash ||= pins.to_set.classify(&:class).transform_values(&:to_a)
|
|
163
182
|
end
|
|
164
183
|
|
|
184
|
+
# @return [Data]
|
|
165
185
|
def data
|
|
166
186
|
@data ||= Data.new(source)
|
|
167
187
|
end
|
|
@@ -171,14 +191,6 @@ module Solargraph
|
|
|
171
191
|
@convention_pins || []
|
|
172
192
|
end
|
|
173
193
|
|
|
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
194
|
# @param line [Integer]
|
|
183
195
|
# @param character [Integer]
|
|
184
196
|
# @param klasses [Array<Class>]
|
|
@@ -20,7 +20,8 @@ module Solargraph
|
|
|
20
20
|
attr_reader :rank
|
|
21
21
|
|
|
22
22
|
# @param level [Symbol]
|
|
23
|
-
|
|
23
|
+
# @param overrides [Hash{Symbol => Symbol}]
|
|
24
|
+
def initialize level, overrides
|
|
24
25
|
@rank = if LEVELS.key?(level)
|
|
25
26
|
LEVELS[level]
|
|
26
27
|
else
|
|
@@ -28,34 +29,55 @@ module Solargraph
|
|
|
28
29
|
0
|
|
29
30
|
end
|
|
30
31
|
@level = LEVELS[LEVELS.values.index(@rank)]
|
|
32
|
+
@overrides = overrides
|
|
31
33
|
end
|
|
32
34
|
|
|
33
35
|
def ignore_all_undefined?
|
|
34
|
-
|
|
36
|
+
!report_undefined?
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def report_undefined?
|
|
40
|
+
report?(:report_undefined, :strict)
|
|
35
41
|
end
|
|
36
42
|
|
|
37
43
|
def validate_consts?
|
|
38
|
-
|
|
44
|
+
report?(:validate_consts, :strict)
|
|
39
45
|
end
|
|
40
46
|
|
|
41
47
|
def validate_calls?
|
|
42
|
-
|
|
48
|
+
report?(:validate_calls, :strict)
|
|
43
49
|
end
|
|
44
50
|
|
|
45
51
|
def require_type_tags?
|
|
46
|
-
|
|
52
|
+
report?(:validate_type_tags, :strong)
|
|
47
53
|
end
|
|
48
54
|
|
|
49
55
|
def must_tag_or_infer?
|
|
50
|
-
|
|
56
|
+
report?(:must_tag_or_infer, :strict)
|
|
51
57
|
end
|
|
52
58
|
|
|
53
59
|
def validate_tags?
|
|
54
|
-
|
|
60
|
+
report?(:validate_tags, :typed)
|
|
55
61
|
end
|
|
56
62
|
|
|
57
63
|
def require_all_return_types_match_inferred?
|
|
58
|
-
|
|
64
|
+
report?(:require_all_return_types_match_inferred, :alpha)
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
# We keep this at strong because if you added an @ sg-ignore to
|
|
68
|
+
# address a strong-level issue, then ran at a lower level, you'd
|
|
69
|
+
# get a false positive - we don't run stronger level checks than
|
|
70
|
+
# requested for performance reasons
|
|
71
|
+
def validate_sg_ignores?
|
|
72
|
+
report?(:validate_sg_ignores, :strong)
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
private
|
|
76
|
+
|
|
77
|
+
# @param type [Symbol]
|
|
78
|
+
# @param level [Symbol]
|
|
79
|
+
def report?(type, level)
|
|
80
|
+
rank >= LEVELS[@overrides.fetch(type, level)]
|
|
59
81
|
end
|
|
60
82
|
end
|
|
61
83
|
end
|