solargraph 0.59.0 → 0.59.2
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 +6 -0
- data/.github/workflows/plugins.yml +9 -1
- data/.github/workflows/typecheck.yml +3 -1
- data/CHANGELOG.md +12 -0
- data/lib/solargraph/api_map/store.rb +1 -2
- data/lib/solargraph/api_map.rb +4 -6
- data/lib/solargraph/complex_type/type_methods.rb +1 -0
- data/lib/solargraph/complex_type/unique_type.rb +14 -15
- data/lib/solargraph/complex_type.rb +2 -1
- data/lib/solargraph/convention/active_support_concern.rb +111 -111
- data/lib/solargraph/convention/base.rb +50 -50
- data/lib/solargraph/diagnostics.rb +55 -55
- data/lib/solargraph/environ.rb +52 -52
- data/lib/solargraph/gem_pins.rb +0 -11
- data/lib/solargraph/language_server/host.rb +6 -7
- data/lib/solargraph/language_server/message/extended/environment.rb +25 -25
- data/lib/solargraph/language_server/message/initialized.rb +28 -28
- data/lib/solargraph/language_server/message/text_document.rb +28 -28
- data/lib/solargraph/language_server/progress.rb +143 -143
- data/lib/solargraph/language_server/transport/adapter.rb +68 -68
- data/lib/solargraph/language_server.rb +20 -20
- data/lib/solargraph/parser/parser_gem/node_chainer.rb +1 -0
- data/lib/solargraph/parser/parser_gem/node_methods.rb +91 -4
- data/lib/solargraph/parser/parser_gem/node_processors/alias_node.rb +24 -24
- data/lib/solargraph/parser/parser_gem/node_processors/casgn_node.rb +36 -36
- data/lib/solargraph/parser/parser_gem/node_processors/cvasgn_node.rb +24 -24
- data/lib/solargraph/parser/parser_gem/node_processors/gvasgn_node.rb +24 -24
- data/lib/solargraph/parser/parser_gem/node_processors/namespace_node.rb +40 -40
- data/lib/solargraph/parser/parser_gem/node_processors/sym_node.rb +20 -20
- data/lib/solargraph/pin/base.rb +3 -3
- data/lib/solargraph/pin/method.rb +2 -0
- data/lib/solargraph/pin/parameter.rb +3 -1
- data/lib/solargraph/pin/reference/require.rb +14 -14
- data/lib/solargraph/pin/search.rb +5 -5
- data/lib/solargraph/pin/singleton.rb +11 -11
- data/lib/solargraph/rbs_map/conversions.rb +15 -8
- data/lib/solargraph/shell.rb +1 -1
- data/lib/solargraph/source/chain/array.rb +1 -12
- data/lib/solargraph/source/chain/block_symbol.rb +13 -13
- data/lib/solargraph/source/chain/block_variable.rb +13 -13
- data/lib/solargraph/source/chain/head.rb +19 -19
- data/lib/solargraph/source/chain/literal.rb +18 -14
- data/lib/solargraph/source/cursor.rb +11 -2
- data/lib/solargraph/source/source_chainer.rb +4 -4
- data/lib/solargraph/source_map/clip.rb +6 -1
- data/lib/solargraph/type_checker.rb +4 -4
- data/lib/solargraph/version.rb +1 -1
- data/lib/solargraph/yard_map/cache.rb +25 -25
- data/lib/solargraph/yard_map/mapper/to_constant.rb +28 -28
- data/lib/solargraph/yard_map/mapper/to_method.rb +1 -1
- data/lib/solargraph.rb +2 -2
- metadata +1 -2
- data/rbs/fills/tuple/tuple.rbs +0 -177
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Solargraph
|
|
4
|
-
module Parser
|
|
5
|
-
module ParserGem
|
|
6
|
-
module NodeProcessors
|
|
7
|
-
class CasgnNode < Parser::NodeProcessor::Base
|
|
8
|
-
include ParserGem::NodeMethods
|
|
9
|
-
|
|
10
|
-
def process
|
|
11
|
-
pins.push Solargraph::Pin::Constant.new(
|
|
12
|
-
location: get_node_location(node),
|
|
13
|
-
closure: region.closure,
|
|
14
|
-
name: const_name,
|
|
15
|
-
comments: comments_for(node),
|
|
16
|
-
assignment: node.children[2],
|
|
17
|
-
source: :parser
|
|
18
|
-
)
|
|
19
|
-
process_children
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
private
|
|
23
|
-
|
|
24
|
-
# @return [String]
|
|
25
|
-
def const_name
|
|
26
|
-
if node.children[0]
|
|
27
|
-
Parser::NodeMethods.unpack_name(node.children[0]) + "::#{node.children[1]}"
|
|
28
|
-
else
|
|
29
|
-
node.children[1].to_s
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
end
|
|
34
|
-
end
|
|
35
|
-
end
|
|
36
|
-
end
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Solargraph
|
|
4
|
+
module Parser
|
|
5
|
+
module ParserGem
|
|
6
|
+
module NodeProcessors
|
|
7
|
+
class CasgnNode < Parser::NodeProcessor::Base
|
|
8
|
+
include ParserGem::NodeMethods
|
|
9
|
+
|
|
10
|
+
def process
|
|
11
|
+
pins.push Solargraph::Pin::Constant.new(
|
|
12
|
+
location: get_node_location(node),
|
|
13
|
+
closure: region.closure,
|
|
14
|
+
name: const_name,
|
|
15
|
+
comments: comments_for(node),
|
|
16
|
+
assignment: node.children[2],
|
|
17
|
+
source: :parser
|
|
18
|
+
)
|
|
19
|
+
process_children
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
private
|
|
23
|
+
|
|
24
|
+
# @return [String]
|
|
25
|
+
def const_name
|
|
26
|
+
if node.children[0]
|
|
27
|
+
Parser::NodeMethods.unpack_name(node.children[0]) + "::#{node.children[1]}"
|
|
28
|
+
else
|
|
29
|
+
node.children[1].to_s
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Solargraph
|
|
4
|
-
module Parser
|
|
5
|
-
module ParserGem
|
|
6
|
-
module NodeProcessors
|
|
7
|
-
class CvasgnNode < Parser::NodeProcessor::Base
|
|
8
|
-
def process
|
|
9
|
-
loc = get_node_location(node)
|
|
10
|
-
pins.push Solargraph::Pin::ClassVariable.new(
|
|
11
|
-
location: loc,
|
|
12
|
-
closure: region.closure,
|
|
13
|
-
name: node.children[0].to_s,
|
|
14
|
-
comments: comments_for(node),
|
|
15
|
-
assignment: node.children[1],
|
|
16
|
-
source: :parser
|
|
17
|
-
)
|
|
18
|
-
process_children
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
end
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Solargraph
|
|
4
|
+
module Parser
|
|
5
|
+
module ParserGem
|
|
6
|
+
module NodeProcessors
|
|
7
|
+
class CvasgnNode < Parser::NodeProcessor::Base
|
|
8
|
+
def process
|
|
9
|
+
loc = get_node_location(node)
|
|
10
|
+
pins.push Solargraph::Pin::ClassVariable.new(
|
|
11
|
+
location: loc,
|
|
12
|
+
closure: region.closure,
|
|
13
|
+
name: node.children[0].to_s,
|
|
14
|
+
comments: comments_for(node),
|
|
15
|
+
assignment: node.children[1],
|
|
16
|
+
source: :parser
|
|
17
|
+
)
|
|
18
|
+
process_children
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Solargraph
|
|
4
|
-
module Parser
|
|
5
|
-
module ParserGem
|
|
6
|
-
module NodeProcessors
|
|
7
|
-
class GvasgnNode < Parser::NodeProcessor::Base
|
|
8
|
-
def process
|
|
9
|
-
loc = get_node_location(node)
|
|
10
|
-
pins.push Solargraph::Pin::GlobalVariable.new(
|
|
11
|
-
location: loc,
|
|
12
|
-
closure: region.closure,
|
|
13
|
-
name: node.children[0].to_s,
|
|
14
|
-
comments: comments_for(node),
|
|
15
|
-
assignment: node.children[1],
|
|
16
|
-
source: :parser
|
|
17
|
-
)
|
|
18
|
-
process_children
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
end
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Solargraph
|
|
4
|
+
module Parser
|
|
5
|
+
module ParserGem
|
|
6
|
+
module NodeProcessors
|
|
7
|
+
class GvasgnNode < Parser::NodeProcessor::Base
|
|
8
|
+
def process
|
|
9
|
+
loc = get_node_location(node)
|
|
10
|
+
pins.push Solargraph::Pin::GlobalVariable.new(
|
|
11
|
+
location: loc,
|
|
12
|
+
closure: region.closure,
|
|
13
|
+
name: node.children[0].to_s,
|
|
14
|
+
comments: comments_for(node),
|
|
15
|
+
assignment: node.children[1],
|
|
16
|
+
source: :parser
|
|
17
|
+
)
|
|
18
|
+
process_children
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -1,40 +1,40 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Solargraph
|
|
4
|
-
module Parser
|
|
5
|
-
module ParserGem
|
|
6
|
-
module NodeProcessors
|
|
7
|
-
class NamespaceNode < Parser::NodeProcessor::Base
|
|
8
|
-
include ParserGem::NodeMethods
|
|
9
|
-
|
|
10
|
-
def process
|
|
11
|
-
superclass_name = nil
|
|
12
|
-
superclass_name = unpack_name(node.children[1]) if node.type == :class && node.children[1]&.type == :const
|
|
13
|
-
|
|
14
|
-
loc = get_node_location(node)
|
|
15
|
-
nspin = Solargraph::Pin::Namespace.new(
|
|
16
|
-
type: node.type,
|
|
17
|
-
location: loc,
|
|
18
|
-
closure: region.closure,
|
|
19
|
-
name: unpack_name(node.children[0]),
|
|
20
|
-
comments: comments_for(node),
|
|
21
|
-
visibility: :public,
|
|
22
|
-
gates: region.closure.gates.freeze,
|
|
23
|
-
source: :parser
|
|
24
|
-
)
|
|
25
|
-
pins.push nspin
|
|
26
|
-
unless superclass_name.nil?
|
|
27
|
-
pins.push Pin::Reference::Superclass.new(
|
|
28
|
-
location: loc,
|
|
29
|
-
closure: pins.last,
|
|
30
|
-
name: superclass_name,
|
|
31
|
-
source: :parser
|
|
32
|
-
)
|
|
33
|
-
end
|
|
34
|
-
process_children region.update(closure: nspin, visibility: :public)
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
end
|
|
38
|
-
end
|
|
39
|
-
end
|
|
40
|
-
end
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Solargraph
|
|
4
|
+
module Parser
|
|
5
|
+
module ParserGem
|
|
6
|
+
module NodeProcessors
|
|
7
|
+
class NamespaceNode < Parser::NodeProcessor::Base
|
|
8
|
+
include ParserGem::NodeMethods
|
|
9
|
+
|
|
10
|
+
def process
|
|
11
|
+
superclass_name = nil
|
|
12
|
+
superclass_name = unpack_name(node.children[1]) if node.type == :class && node.children[1]&.type == :const
|
|
13
|
+
|
|
14
|
+
loc = get_node_location(node)
|
|
15
|
+
nspin = Solargraph::Pin::Namespace.new(
|
|
16
|
+
type: node.type,
|
|
17
|
+
location: loc,
|
|
18
|
+
closure: region.closure,
|
|
19
|
+
name: unpack_name(node.children[0]),
|
|
20
|
+
comments: comments_for(node),
|
|
21
|
+
visibility: :public,
|
|
22
|
+
gates: region.closure.gates.freeze,
|
|
23
|
+
source: :parser
|
|
24
|
+
)
|
|
25
|
+
pins.push nspin
|
|
26
|
+
unless superclass_name.nil?
|
|
27
|
+
pins.push Pin::Reference::Superclass.new(
|
|
28
|
+
location: loc,
|
|
29
|
+
closure: pins.last,
|
|
30
|
+
name: superclass_name,
|
|
31
|
+
source: :parser
|
|
32
|
+
)
|
|
33
|
+
end
|
|
34
|
+
process_children region.update(closure: nspin, visibility: :public)
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Solargraph
|
|
4
|
-
module Parser
|
|
5
|
-
module ParserGem
|
|
6
|
-
module NodeProcessors
|
|
7
|
-
class SymNode < Parser::NodeProcessor::Base
|
|
8
|
-
# @return [void]
|
|
9
|
-
def process
|
|
10
|
-
pins.push Solargraph::Pin::Symbol.new(
|
|
11
|
-
get_node_location(node),
|
|
12
|
-
":#{node.children[0]}",
|
|
13
|
-
source: :parser
|
|
14
|
-
)
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
end
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Solargraph
|
|
4
|
+
module Parser
|
|
5
|
+
module ParserGem
|
|
6
|
+
module NodeProcessors
|
|
7
|
+
class SymNode < Parser::NodeProcessor::Base
|
|
8
|
+
# @return [void]
|
|
9
|
+
def process
|
|
10
|
+
pins.push Solargraph::Pin::Symbol.new(
|
|
11
|
+
get_node_location(node),
|
|
12
|
+
":#{node.children[0]}",
|
|
13
|
+
source: :parser
|
|
14
|
+
)
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
data/lib/solargraph/pin/base.rb
CHANGED
|
@@ -293,7 +293,7 @@ module Solargraph
|
|
|
293
293
|
# @param attr [::Symbol]
|
|
294
294
|
# @return [void]
|
|
295
295
|
# @todo strong typechecking should complain when there are no block-related tags
|
|
296
|
-
def assert_same_array_content
|
|
296
|
+
def assert_same_array_content(other, attr, &)
|
|
297
297
|
arr1 = send(attr)
|
|
298
298
|
raise "Expected #{attr} on #{self} to be an Enumerable, got #{arr1.class}" unless arr1.is_a?(::Enumerable)
|
|
299
299
|
# @type arr1 [::Enumerable]
|
|
@@ -302,9 +302,9 @@ module Solargraph
|
|
|
302
302
|
# @type arr2 [::Enumerable]
|
|
303
303
|
|
|
304
304
|
# @type [undefined]
|
|
305
|
-
values1 = arr1.map(&
|
|
305
|
+
values1 = arr1.map(&)
|
|
306
306
|
# @type [undefined]
|
|
307
|
-
values2 = arr2.map(&
|
|
307
|
+
values2 = arr2.map(&)
|
|
308
308
|
# @sg-ignore
|
|
309
309
|
return arr1 if values1 == values2
|
|
310
310
|
Solargraph.assert_or_log(:"combine_with_#{attr}",
|
|
@@ -508,6 +508,7 @@ module Solargraph
|
|
|
508
508
|
# @todo Stubbing this method while we debug an infinite loop bug in Ruby 3.x
|
|
509
509
|
return same_type_arity_signatures
|
|
510
510
|
|
|
511
|
+
# rubocop:disable Lint/UnreachableCode
|
|
511
512
|
# This is an O(n^2) operation, so bail out if n is not small
|
|
512
513
|
return same_type_arity_signatures if same_type_arity_signatures.length > 10
|
|
513
514
|
|
|
@@ -534,6 +535,7 @@ module Solargraph
|
|
|
534
535
|
end
|
|
535
536
|
end
|
|
536
537
|
end
|
|
538
|
+
# rubocop:enable Lint/UnreachableCode
|
|
537
539
|
end
|
|
538
540
|
|
|
539
541
|
# @param name [String]
|
|
@@ -31,7 +31,9 @@ module Solargraph
|
|
|
31
31
|
end
|
|
32
32
|
|
|
33
33
|
def combine_with other, attrs = {}
|
|
34
|
-
# Parameters can be combined with local variables
|
|
34
|
+
# Parameters can only be combined with local variables in the same closure
|
|
35
|
+
return self unless other.closure == closure
|
|
36
|
+
|
|
35
37
|
new_attrs = if other.is_a?(Parameter)
|
|
36
38
|
{
|
|
37
39
|
decl: assert_same(other, :decl),
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Solargraph
|
|
4
|
-
module Pin
|
|
5
|
-
class Reference
|
|
6
|
-
class Require < Reference
|
|
7
|
-
def initialize location, name, **splat
|
|
8
|
-
# super(location, '', name)
|
|
9
|
-
super(location: location, name: name, closure: Pin::ROOT_PIN, **splat)
|
|
10
|
-
end
|
|
11
|
-
end
|
|
12
|
-
end
|
|
13
|
-
end
|
|
14
|
-
end
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Solargraph
|
|
4
|
+
module Pin
|
|
5
|
+
class Reference
|
|
6
|
+
class Require < Reference
|
|
7
|
+
def initialize location, name, **splat
|
|
8
|
+
# super(location, '', name)
|
|
9
|
+
super(location: location, name: name, closure: Pin::ROOT_PIN, **splat)
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -41,11 +41,11 @@ module Solargraph
|
|
|
41
41
|
match = [fuzzy_string_match(pin.path, @query), fuzzy_string_match(pin.name, @query)].max
|
|
42
42
|
Result.new(match, pin) if match > 0.7
|
|
43
43
|
end
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
44
|
+
.compact
|
|
45
|
+
# @param a [self]
|
|
46
|
+
# @param b [self]
|
|
47
|
+
# @sg-ignore https://github.com/castwide/solargraph/pull/1050
|
|
48
|
+
.sort { |a, b| b.match <=> a.match }
|
|
49
49
|
.map(&:pin)
|
|
50
50
|
end
|
|
51
51
|
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Solargraph
|
|
4
|
-
module Pin
|
|
5
|
-
class Singleton < Closure
|
|
6
|
-
def initialize name: '', location: nil, closure: nil, **splat
|
|
7
|
-
super
|
|
8
|
-
end
|
|
9
|
-
end
|
|
10
|
-
end
|
|
11
|
-
end
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Solargraph
|
|
4
|
+
module Pin
|
|
5
|
+
class Singleton < Closure
|
|
6
|
+
def initialize name: '', location: nil, closure: nil, **splat
|
|
7
|
+
super
|
|
8
|
+
end
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
end
|
|
@@ -481,7 +481,7 @@ module Solargraph
|
|
|
481
481
|
visibility = VISIBILITY_OVERRIDE[override_key]
|
|
482
482
|
simple_override_key = [closure.path, scope]
|
|
483
483
|
visibility ||= VISIBILITY_OVERRIDE[simple_override_key]
|
|
484
|
-
if closure.path == 'Kernel' && Kernel.
|
|
484
|
+
if closure.path == 'Kernel' && Kernel.private_method_defined?(decl.name, false)
|
|
485
485
|
visibility ||= :private
|
|
486
486
|
end
|
|
487
487
|
if decl.kind == :singleton_instance
|
|
@@ -552,16 +552,19 @@ module Solargraph
|
|
|
552
552
|
# @param pin [Pin::Method]
|
|
553
553
|
# @return [void]
|
|
554
554
|
def method_def_to_sigs decl, pin
|
|
555
|
+
# rubocop:disable Style/SafeNavigationChainLength
|
|
556
|
+
implicit_nil = decl.overloads.first&.annotations&.map(&:string)&.include?('implicitly-returns-nil') || false
|
|
557
|
+
# rubocop:enable Style/SafeNavigationChainLength
|
|
555
558
|
# @param overload [RBS::AST::Members::MethodDefinition::Overload]
|
|
556
559
|
decl.overloads.map do |overload|
|
|
557
560
|
# @sg-ignore Wrong argument type for Solargraph::RbsMap::Conversions#location_decl_to_pin_location:
|
|
558
561
|
# location expected RBS::Location, nil, received RBS::Location<:type, :type_params>, RBS::AST::Members::Attribute::loc, nil
|
|
559
562
|
type_location = location_decl_to_pin_location(overload.method_type.location)
|
|
560
563
|
generics = type_parameter_names(overload.method_type)
|
|
561
|
-
signature_parameters, signature_return_type = parts_of_function(overload.method_type, pin)
|
|
564
|
+
signature_parameters, signature_return_type = parts_of_function(overload.method_type, pin, implicit_nil)
|
|
562
565
|
rbs_block = overload.method_type.block
|
|
563
566
|
block = if rbs_block
|
|
564
|
-
block_parameters, block_return_type = parts_of_function(rbs_block, pin)
|
|
567
|
+
block_parameters, block_return_type = parts_of_function(rbs_block, pin, implicit_nil)
|
|
565
568
|
Pin::Signature.new(generics: generics, parameters: block_parameters,
|
|
566
569
|
return_type: block_return_type, source: :rbs,
|
|
567
570
|
type_location: type_location, closure: pin)
|
|
@@ -588,14 +591,15 @@ module Solargraph
|
|
|
588
591
|
|
|
589
592
|
# @param type [RBS::MethodType, RBS::Types::Block]
|
|
590
593
|
# @param pin [Pin::Method]
|
|
594
|
+
# @param implicit_nil [Boolean]
|
|
591
595
|
# @return [Array(Array<Pin::Parameter>, ComplexType)]
|
|
592
|
-
def parts_of_function type, pin
|
|
596
|
+
def parts_of_function type, pin, implicit_nil
|
|
593
597
|
type_location = pin.type_location
|
|
594
598
|
if defined?(RBS::Types::UntypedFunction) && type.type.is_a?(RBS::Types::UntypedFunction)
|
|
595
599
|
return [
|
|
596
600
|
[Solargraph::Pin::Parameter.new(decl: :restarg, name: 'arg', closure: pin, source: :rbs,
|
|
597
601
|
type_location: type_location)],
|
|
598
|
-
method_type_to_type(type)
|
|
602
|
+
method_type_to_type(type, implicit_nil)
|
|
599
603
|
]
|
|
600
604
|
end
|
|
601
605
|
|
|
@@ -659,7 +663,7 @@ module Solargraph
|
|
|
659
663
|
source: :rbs, type_location: type_location)
|
|
660
664
|
end
|
|
661
665
|
|
|
662
|
-
return_type = method_type_to_type(type)
|
|
666
|
+
return_type = method_type_to_type(type, implicit_nil)
|
|
663
667
|
[parameters, return_type]
|
|
664
668
|
end
|
|
665
669
|
|
|
@@ -842,9 +846,12 @@ module Solargraph
|
|
|
842
846
|
end
|
|
843
847
|
|
|
844
848
|
# @param type [RBS::MethodType, RBS::Types::Block]
|
|
849
|
+
# @param implicit_nil [Boolean]
|
|
845
850
|
# @return [ComplexType, ComplexType::UniqueType]
|
|
846
|
-
def method_type_to_type type
|
|
847
|
-
other_type_to_type type.type.return_type
|
|
851
|
+
def method_type_to_type type, implicit_nil
|
|
852
|
+
tag = other_type_to_type type.type.return_type
|
|
853
|
+
return ComplexType.parse("#{tag}, nil") if tag && implicit_nil
|
|
854
|
+
tag
|
|
848
855
|
end
|
|
849
856
|
|
|
850
857
|
# @param type [RBS::Types::Bases::Base,Object] RBS type object.
|
data/lib/solargraph/shell.rb
CHANGED
|
@@ -188,7 +188,7 @@ module Solargraph
|
|
|
188
188
|
names.each do |name|
|
|
189
189
|
if name == 'core'
|
|
190
190
|
# @sg-ignore cache_core and core? are dynamically defined
|
|
191
|
-
PinCache.cache_core(out: $stdout) if !PinCache.core? || options[:rebuild]
|
|
191
|
+
PinCache.cache_core(out: $stdout) # if !PinCache.core? || options[:rebuild]
|
|
192
192
|
next
|
|
193
193
|
end
|
|
194
194
|
|
|
@@ -19,18 +19,7 @@ module Solargraph
|
|
|
19
19
|
# @param name_pin [Pin::Base]
|
|
20
20
|
# @param locals [::Array<Pin::Parameter, Pin::LocalVariable>]
|
|
21
21
|
def resolve api_map, name_pin, locals
|
|
22
|
-
|
|
23
|
-
child.infer(api_map, name_pin, locals).simplify_literals
|
|
24
|
-
end
|
|
25
|
-
type = if child_types.empty? || child_types.any?(&:undefined?)
|
|
26
|
-
ComplexType::UniqueType.new('Array', rooted: true)
|
|
27
|
-
elsif child_types.uniq.length == 1 && child_types.first.defined?
|
|
28
|
-
ComplexType::UniqueType.new('Array', [], child_types.uniq, rooted: true, parameters_type: :list)
|
|
29
|
-
elsif child_types.empty?
|
|
30
|
-
ComplexType::UniqueType.new('Array', rooted: true, parameters_type: :list)
|
|
31
|
-
else
|
|
32
|
-
ComplexType::UniqueType.new('Array', [], child_types, rooted: true, parameters_type: :fixed)
|
|
33
|
-
end
|
|
22
|
+
type = ComplexType::UniqueType.new('Array', rooted: true)
|
|
34
23
|
[Pin::ProxyType.anonymous(type, source: :chain)]
|
|
35
24
|
end
|
|
36
25
|
end
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Solargraph
|
|
4
|
-
class Source
|
|
5
|
-
class Chain
|
|
6
|
-
class BlockSymbol < Link
|
|
7
|
-
def resolve api_map, name_pin, locals
|
|
8
|
-
[Pin::ProxyType.anonymous(ComplexType.try_parse('::Proc'), source: :chain)]
|
|
9
|
-
end
|
|
10
|
-
end
|
|
11
|
-
end
|
|
12
|
-
end
|
|
13
|
-
end
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Solargraph
|
|
4
|
+
class Source
|
|
5
|
+
class Chain
|
|
6
|
+
class BlockSymbol < Link
|
|
7
|
+
def resolve api_map, name_pin, locals
|
|
8
|
+
[Pin::ProxyType.anonymous(ComplexType.try_parse('::Proc'), source: :chain)]
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Solargraph
|
|
4
|
-
class Source
|
|
5
|
-
class Chain
|
|
6
|
-
class BlockVariable < Link
|
|
7
|
-
def resolve api_map, name_pin, locals
|
|
8
|
-
[Pin::ProxyType.anonymous(ComplexType.try_parse('::Proc'), source: :chain)]
|
|
9
|
-
end
|
|
10
|
-
end
|
|
11
|
-
end
|
|
12
|
-
end
|
|
13
|
-
end
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Solargraph
|
|
4
|
+
class Source
|
|
5
|
+
class Chain
|
|
6
|
+
class BlockVariable < Link
|
|
7
|
+
def resolve api_map, name_pin, locals
|
|
8
|
+
[Pin::ProxyType.anonymous(ComplexType.try_parse('::Proc'), source: :chain)]
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Solargraph
|
|
4
|
-
class Source
|
|
5
|
-
class Chain
|
|
6
|
-
# Chain::Head is a link for ambiguous words, e.g.; `String` can refer to
|
|
7
|
-
# either a class (`String`) or a function (`Kernel#String`).
|
|
8
|
-
#
|
|
9
|
-
# @note Chain::Head is only intended to handle `self` and `super`.
|
|
10
|
-
class Head < Link
|
|
11
|
-
def resolve api_map, name_pin, locals
|
|
12
|
-
return [Pin::ProxyType.anonymous(name_pin.binder, source: :chain)] if word == 'self'
|
|
13
|
-
# return super_pins(api_map, name_pin) if word == 'super'
|
|
14
|
-
[]
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
end
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Solargraph
|
|
4
|
+
class Source
|
|
5
|
+
class Chain
|
|
6
|
+
# Chain::Head is a link for ambiguous words, e.g.; `String` can refer to
|
|
7
|
+
# either a class (`String`) or a function (`Kernel#String`).
|
|
8
|
+
#
|
|
9
|
+
# @note Chain::Head is only intended to handle `self` and `super`.
|
|
10
|
+
class Head < Link
|
|
11
|
+
def resolve api_map, name_pin, locals
|
|
12
|
+
return [Pin::ProxyType.anonymous(name_pin.binder, source: :chain)] if word == 'self'
|
|
13
|
+
# return super_pins(api_map, name_pin) if word == 'super'
|
|
14
|
+
[]
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -13,21 +13,25 @@ module Solargraph
|
|
|
13
13
|
def initialize type, node
|
|
14
14
|
super("<#{type}>")
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
16
|
+
# @todo We might be able to do some light inference from literals and
|
|
17
|
+
# tuples as long as literal values are intransitive.
|
|
18
|
+
|
|
19
|
+
# if node.is_a?(::Parser::AST::Node)
|
|
20
|
+
# # @sg-ignore flow sensitive typing needs to narrow down type with an if is_a? check
|
|
21
|
+
# if node.type == :true
|
|
22
|
+
# @value = true
|
|
23
|
+
# # @sg-ignore flow sensitive typing needs to narrow down type with an if is_a? check
|
|
24
|
+
# elsif node.type == :false
|
|
25
|
+
# @value = false
|
|
26
|
+
# # @sg-ignore flow sensitive typing needs to narrow down type with an if is_a? check
|
|
27
|
+
# elsif %i[int sym].include?(node.type)
|
|
28
|
+
# # @sg-ignore flow sensitive typing needs to narrow down type with an if is_a? check
|
|
29
|
+
# @value = node.children.first
|
|
30
|
+
# end
|
|
31
|
+
# end
|
|
29
32
|
@type = type
|
|
30
|
-
@literal_type = ComplexType.try_parse(@value.inspect)
|
|
33
|
+
# @literal_type = ComplexType.try_parse(@value.inspect)
|
|
34
|
+
@literal_type = ComplexType::UNDEFINED
|
|
31
35
|
@complex_type = ComplexType.try_parse(type)
|
|
32
36
|
end
|
|
33
37
|
|