solargraph 0.58.1 → 0.59.0.dev.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.
- checksums.yaml +4 -4
- data/.envrc +3 -0
- data/.github/workflows/linting.yml +4 -5
- data/.github/workflows/plugins.yml +40 -36
- data/.github/workflows/rspec.yml +45 -13
- data/.github/workflows/typecheck.yml +2 -2
- data/.rubocop_todo.yml +27 -49
- data/README.md +3 -3
- data/Rakefile +1 -0
- data/lib/solargraph/api_map/cache.rb +110 -110
- data/lib/solargraph/api_map/constants.rb +289 -279
- data/lib/solargraph/api_map/index.rb +204 -193
- data/lib/solargraph/api_map/source_to_yard.rb +109 -97
- data/lib/solargraph/api_map/store.rb +387 -384
- data/lib/solargraph/api_map.rb +1000 -945
- data/lib/solargraph/complex_type/conformance.rb +176 -0
- data/lib/solargraph/complex_type/type_methods.rb +242 -228
- data/lib/solargraph/complex_type/unique_type.rb +632 -482
- data/lib/solargraph/complex_type.rb +549 -444
- data/lib/solargraph/convention/data_definition/data_definition_node.rb +93 -91
- data/lib/solargraph/convention/data_definition.rb +108 -105
- data/lib/solargraph/convention/struct_definition/struct_assignment_node.rb +62 -61
- data/lib/solargraph/convention/struct_definition/struct_definition_node.rb +103 -102
- data/lib/solargraph/convention/struct_definition.rb +168 -164
- data/lib/solargraph/diagnostics/require_not_found.rb +54 -53
- data/lib/solargraph/diagnostics/rubocop.rb +119 -118
- data/lib/solargraph/diagnostics/rubocop_helpers.rb +70 -68
- data/lib/solargraph/diagnostics/type_check.rb +56 -55
- data/lib/solargraph/doc_map.rb +200 -439
- data/lib/solargraph/equality.rb +34 -34
- data/lib/solargraph/gem_pins.rb +97 -98
- data/lib/solargraph/language_server/host/dispatch.rb +131 -130
- data/lib/solargraph/language_server/host/message_worker.rb +113 -112
- data/lib/solargraph/language_server/host/sources.rb +100 -99
- data/lib/solargraph/language_server/host.rb +883 -878
- data/lib/solargraph/language_server/message/extended/check_gem_version.rb +109 -114
- data/lib/solargraph/language_server/message/extended/document.rb +24 -23
- data/lib/solargraph/language_server/message/text_document/completion.rb +58 -56
- data/lib/solargraph/language_server/message/text_document/definition.rb +42 -40
- data/lib/solargraph/language_server/message/text_document/document_symbol.rb +28 -26
- data/lib/solargraph/language_server/message/text_document/formatting.rb +150 -148
- data/lib/solargraph/language_server/message/text_document/hover.rb +60 -58
- data/lib/solargraph/language_server/message/text_document/signature_help.rb +25 -24
- data/lib/solargraph/language_server/message/text_document/type_definition.rb +27 -25
- data/lib/solargraph/language_server/message/workspace/workspace_symbol.rb +25 -23
- data/lib/solargraph/library.rb +729 -683
- data/lib/solargraph/location.rb +87 -82
- data/lib/solargraph/logging.rb +57 -37
- data/lib/solargraph/parser/comment_ripper.rb +76 -69
- data/lib/solargraph/parser/flow_sensitive_typing.rb +483 -255
- data/lib/solargraph/parser/node_processor/base.rb +122 -92
- data/lib/solargraph/parser/node_processor.rb +63 -62
- data/lib/solargraph/parser/parser_gem/class_methods.rb +167 -149
- data/lib/solargraph/parser/parser_gem/node_chainer.rb +191 -166
- data/lib/solargraph/parser/parser_gem/node_methods.rb +506 -486
- data/lib/solargraph/parser/parser_gem/node_processors/and_node.rb +22 -22
- data/lib/solargraph/parser/parser_gem/node_processors/args_node.rb +61 -59
- data/lib/solargraph/parser/parser_gem/node_processors/begin_node.rb +24 -15
- data/lib/solargraph/parser/parser_gem/node_processors/block_node.rb +46 -46
- data/lib/solargraph/parser/parser_gem/node_processors/def_node.rb +60 -53
- data/lib/solargraph/parser/parser_gem/node_processors/if_node.rb +53 -23
- data/lib/solargraph/parser/parser_gem/node_processors/ivasgn_node.rb +41 -40
- data/lib/solargraph/parser/parser_gem/node_processors/lvasgn_node.rb +30 -29
- data/lib/solargraph/parser/parser_gem/node_processors/masgn_node.rb +61 -59
- data/lib/solargraph/parser/parser_gem/node_processors/opasgn_node.rb +98 -98
- data/lib/solargraph/parser/parser_gem/node_processors/or_node.rb +22 -0
- data/lib/solargraph/parser/parser_gem/node_processors/orasgn_node.rb +17 -17
- data/lib/solargraph/parser/parser_gem/node_processors/resbody_node.rb +39 -38
- data/lib/solargraph/parser/parser_gem/node_processors/sclass_node.rb +53 -52
- data/lib/solargraph/parser/parser_gem/node_processors/send_node.rb +296 -291
- data/lib/solargraph/parser/parser_gem/node_processors/when_node.rb +23 -0
- data/lib/solargraph/parser/parser_gem/node_processors/while_node.rb +33 -29
- data/lib/solargraph/parser/parser_gem/node_processors.rb +74 -70
- data/lib/solargraph/parser/region.rb +75 -69
- data/lib/solargraph/parser/snippet.rb +17 -17
- data/lib/solargraph/pin/base.rb +761 -729
- data/lib/solargraph/pin/base_variable.rb +418 -126
- data/lib/solargraph/pin/block.rb +126 -104
- data/lib/solargraph/pin/breakable.rb +13 -9
- data/lib/solargraph/pin/callable.rb +278 -231
- data/lib/solargraph/pin/closure.rb +68 -72
- data/lib/solargraph/pin/common.rb +94 -79
- data/lib/solargraph/pin/compound_statement.rb +55 -0
- data/lib/solargraph/pin/conversions.rb +124 -123
- data/lib/solargraph/pin/delegated_method.rb +131 -120
- data/lib/solargraph/pin/documenting.rb +115 -114
- data/lib/solargraph/pin/instance_variable.rb +38 -34
- data/lib/solargraph/pin/keyword.rb +16 -20
- data/lib/solargraph/pin/local_variable.rb +31 -75
- data/lib/solargraph/pin/method.rb +720 -672
- data/lib/solargraph/pin/method_alias.rb +42 -34
- data/lib/solargraph/pin/namespace.rb +121 -115
- data/lib/solargraph/pin/parameter.rb +338 -275
- data/lib/solargraph/pin/proxy_type.rb +40 -39
- data/lib/solargraph/pin/reference/override.rb +47 -47
- data/lib/solargraph/pin/reference/superclass.rb +17 -15
- data/lib/solargraph/pin/reference.rb +41 -39
- data/lib/solargraph/pin/search.rb +62 -61
- data/lib/solargraph/pin/signature.rb +69 -61
- data/lib/solargraph/pin/symbol.rb +53 -53
- data/lib/solargraph/pin/until.rb +18 -18
- data/lib/solargraph/pin/while.rb +18 -18
- data/lib/solargraph/pin.rb +46 -44
- data/lib/solargraph/pin_cache.rb +665 -245
- data/lib/solargraph/position.rb +118 -119
- data/lib/solargraph/range.rb +112 -112
- data/lib/solargraph/rbs_map/conversions.rb +846 -823
- data/lib/solargraph/rbs_map/core_map.rb +65 -58
- data/lib/solargraph/rbs_map/stdlib_map.rb +72 -43
- data/lib/solargraph/rbs_map.rb +217 -163
- data/lib/solargraph/shell.rb +397 -352
- data/lib/solargraph/source/chain/call.rb +372 -337
- data/lib/solargraph/source/chain/constant.rb +28 -26
- data/lib/solargraph/source/chain/hash.rb +35 -34
- data/lib/solargraph/source/chain/if.rb +29 -28
- data/lib/solargraph/source/chain/instance_variable.rb +34 -13
- data/lib/solargraph/source/chain/literal.rb +53 -48
- data/lib/solargraph/source/chain/or.rb +31 -23
- data/lib/solargraph/source/chain.rb +294 -291
- data/lib/solargraph/source/change.rb +89 -82
- data/lib/solargraph/source/cursor.rb +172 -166
- data/lib/solargraph/source/source_chainer.rb +204 -194
- data/lib/solargraph/source/updater.rb +59 -55
- data/lib/solargraph/source.rb +524 -498
- data/lib/solargraph/source_map/clip.rb +237 -226
- data/lib/solargraph/source_map/data.rb +37 -34
- data/lib/solargraph/source_map/mapper.rb +282 -259
- data/lib/solargraph/source_map.rb +220 -212
- data/lib/solargraph/type_checker/problem.rb +34 -32
- data/lib/solargraph/type_checker/rules.rb +157 -84
- data/lib/solargraph/type_checker.rb +895 -814
- data/lib/solargraph/version.rb +1 -1
- data/lib/solargraph/workspace/config.rb +257 -255
- data/lib/solargraph/workspace/gemspecs.rb +367 -0
- data/lib/solargraph/workspace/require_paths.rb +98 -97
- data/lib/solargraph/workspace.rb +362 -220
- data/lib/solargraph/yard_map/helpers.rb +45 -44
- data/lib/solargraph/yard_map/mapper/to_method.rb +134 -130
- data/lib/solargraph/yard_map/mapper/to_namespace.rb +32 -31
- data/lib/solargraph/yard_map/mapper.rb +84 -79
- data/lib/solargraph/yardoc.rb +97 -87
- data/lib/solargraph.rb +126 -105
- data/rbs/fills/rubygems/0/dependency.rbs +193 -0
- data/rbs/fills/tuple/tuple.rbs +28 -0
- data/rbs/shims/ast/0/node.rbs +5 -0
- data/rbs/shims/diff-lcs/1.5/diff-lcs.rbs +11 -0
- data/rbs_collection.yaml +1 -1
- data/solargraph.gemspec +2 -1
- metadata +22 -17
- data/lib/solargraph/type_checker/checks.rb +0 -124
- data/lib/solargraph/type_checker/param_def.rb +0 -37
- data/lib/solargraph/yard_map/to_method.rb +0 -89
- data/sig/shims/ast/0/node.rbs +0 -5
- /data/{sig → rbs}/shims/ast/2.4/.rbs_meta.yaml +0 -0
- /data/{sig → rbs}/shims/ast/2.4/ast.rbs +0 -0
- /data/{sig → rbs}/shims/parser/3.2.0.1/builders/default.rbs +0 -0
- /data/{sig → rbs}/shims/parser/3.2.0.1/manifest.yaml +0 -0
- /data/{sig → rbs}/shims/parser/3.2.0.1/parser.rbs +0 -0
- /data/{sig → rbs}/shims/parser/3.2.0.1/polyfill.rbs +0 -0
- /data/{sig → rbs}/shims/thor/1.2.0.1/.rbs_meta.yaml +0 -0
- /data/{sig → rbs}/shims/thor/1.2.0.1/manifest.yaml +0 -0
- /data/{sig → rbs}/shims/thor/1.2.0.1/thor.rbs +0 -0
data/rbs_collection.yaml
CHANGED
data/solargraph.gemspec
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
# @sg-ignore Should better support meaning of '&' in RBS
|
|
1
2
|
$LOAD_PATH.unshift File.dirname(__FILE__) + '/lib'
|
|
2
3
|
require 'solargraph/version'
|
|
3
4
|
require 'date'
|
|
@@ -42,7 +43,7 @@ Gem::Specification.new do |s|
|
|
|
42
43
|
s.add_runtime_dependency 'open3', '~> 0.2.1'
|
|
43
44
|
s.add_runtime_dependency 'parser', '~> 3.0'
|
|
44
45
|
s.add_runtime_dependency 'prism', '~> 1.4'
|
|
45
|
-
s.add_runtime_dependency 'rbs', ['>= 3.6.1', '<= 4.0.0.dev.
|
|
46
|
+
s.add_runtime_dependency 'rbs', ['>= 3.6.1', '<= 4.0.0.dev.5']
|
|
46
47
|
s.add_runtime_dependency 'reverse_markdown', '~> 3.0'
|
|
47
48
|
s.add_runtime_dependency 'rubocop', '~> 1.76'
|
|
48
49
|
s.add_runtime_dependency 'thor', '~> 1.0'
|
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: solargraph
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.59.0.dev.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Fred Snyder
|
|
8
8
|
bindir: bin
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date: 2026-01-
|
|
10
|
+
date: 2026-01-13 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
12
|
- !ruby/object:Gem::Dependency
|
|
13
13
|
name: ast
|
|
@@ -220,7 +220,7 @@ dependencies:
|
|
|
220
220
|
version: 3.6.1
|
|
221
221
|
- - "<="
|
|
222
222
|
- !ruby/object:Gem::Version
|
|
223
|
-
version: 4.0.0.dev.
|
|
223
|
+
version: 4.0.0.dev.5
|
|
224
224
|
type: :runtime
|
|
225
225
|
prerelease: false
|
|
226
226
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -230,7 +230,7 @@ dependencies:
|
|
|
230
230
|
version: 3.6.1
|
|
231
231
|
- - "<="
|
|
232
232
|
- !ruby/object:Gem::Version
|
|
233
|
-
version: 4.0.0.dev.
|
|
233
|
+
version: 4.0.0.dev.5
|
|
234
234
|
- !ruby/object:Gem::Dependency
|
|
235
235
|
name: reverse_markdown
|
|
236
236
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -538,6 +538,7 @@ executables:
|
|
|
538
538
|
extensions: []
|
|
539
539
|
extra_rdoc_files: []
|
|
540
540
|
files:
|
|
541
|
+
- ".envrc"
|
|
541
542
|
- ".gitattributes"
|
|
542
543
|
- ".github/FUNDING.yml"
|
|
543
544
|
- ".github/workflows/linting.yml"
|
|
@@ -566,6 +567,7 @@ files:
|
|
|
566
567
|
- lib/solargraph/api_map/store.rb
|
|
567
568
|
- lib/solargraph/bench.rb
|
|
568
569
|
- lib/solargraph/complex_type.rb
|
|
570
|
+
- lib/solargraph/complex_type/conformance.rb
|
|
569
571
|
- lib/solargraph/complex_type/type_methods.rb
|
|
570
572
|
- lib/solargraph/complex_type/unique_type.rb
|
|
571
573
|
- lib/solargraph/convention.rb
|
|
@@ -688,12 +690,14 @@ files:
|
|
|
688
690
|
- lib/solargraph/parser/parser_gem/node_processors/masgn_node.rb
|
|
689
691
|
- lib/solargraph/parser/parser_gem/node_processors/namespace_node.rb
|
|
690
692
|
- lib/solargraph/parser/parser_gem/node_processors/opasgn_node.rb
|
|
693
|
+
- lib/solargraph/parser/parser_gem/node_processors/or_node.rb
|
|
691
694
|
- lib/solargraph/parser/parser_gem/node_processors/orasgn_node.rb
|
|
692
695
|
- lib/solargraph/parser/parser_gem/node_processors/resbody_node.rb
|
|
693
696
|
- lib/solargraph/parser/parser_gem/node_processors/sclass_node.rb
|
|
694
697
|
- lib/solargraph/parser/parser_gem/node_processors/send_node.rb
|
|
695
698
|
- lib/solargraph/parser/parser_gem/node_processors/sym_node.rb
|
|
696
699
|
- lib/solargraph/parser/parser_gem/node_processors/until_node.rb
|
|
700
|
+
- lib/solargraph/parser/parser_gem/node_processors/when_node.rb
|
|
697
701
|
- lib/solargraph/parser/parser_gem/node_processors/while_node.rb
|
|
698
702
|
- lib/solargraph/parser/region.rb
|
|
699
703
|
- lib/solargraph/parser/snippet.rb
|
|
@@ -706,6 +710,7 @@ files:
|
|
|
706
710
|
- lib/solargraph/pin/class_variable.rb
|
|
707
711
|
- lib/solargraph/pin/closure.rb
|
|
708
712
|
- lib/solargraph/pin/common.rb
|
|
713
|
+
- lib/solargraph/pin/compound_statement.rb
|
|
709
714
|
- lib/solargraph/pin/constant.rb
|
|
710
715
|
- lib/solargraph/pin/conversions.rb
|
|
711
716
|
- lib/solargraph/pin/delegated_method.rb
|
|
@@ -774,8 +779,6 @@ files:
|
|
|
774
779
|
- lib/solargraph/source_map/data.rb
|
|
775
780
|
- lib/solargraph/source_map/mapper.rb
|
|
776
781
|
- lib/solargraph/type_checker.rb
|
|
777
|
-
- lib/solargraph/type_checker/checks.rb
|
|
778
|
-
- lib/solargraph/type_checker/param_def.rb
|
|
779
782
|
- lib/solargraph/type_checker/problem.rb
|
|
780
783
|
- lib/solargraph/type_checker/rules.rb
|
|
781
784
|
- lib/solargraph/version.rb
|
|
@@ -788,6 +791,7 @@ files:
|
|
|
788
791
|
- lib/solargraph/views/search.erb
|
|
789
792
|
- lib/solargraph/workspace.rb
|
|
790
793
|
- lib/solargraph/workspace/config.rb
|
|
794
|
+
- lib/solargraph/workspace/gemspecs.rb
|
|
791
795
|
- lib/solargraph/workspace/require_paths.rb
|
|
792
796
|
- lib/solargraph/yard_map.rb
|
|
793
797
|
- lib/solargraph/yard_map/cache.rb
|
|
@@ -796,27 +800,28 @@ files:
|
|
|
796
800
|
- lib/solargraph/yard_map/mapper/to_constant.rb
|
|
797
801
|
- lib/solargraph/yard_map/mapper/to_method.rb
|
|
798
802
|
- lib/solargraph/yard_map/mapper/to_namespace.rb
|
|
799
|
-
- lib/solargraph/yard_map/to_method.rb
|
|
800
803
|
- lib/solargraph/yard_tags.rb
|
|
801
804
|
- lib/solargraph/yardoc.rb
|
|
802
805
|
- rbs/fills/bundler/0/bundler.rbs
|
|
803
806
|
- rbs/fills/open3/0/open3.rbs
|
|
804
807
|
- rbs/fills/rubygems/0/basic_specification.rbs
|
|
808
|
+
- rbs/fills/rubygems/0/dependency.rbs
|
|
805
809
|
- rbs/fills/rubygems/0/errors.rbs
|
|
806
810
|
- rbs/fills/rubygems/0/spec_fetcher.rbs
|
|
807
811
|
- rbs/fills/rubygems/0/specification.rbs
|
|
808
812
|
- rbs/fills/tuple/tuple.rbs
|
|
813
|
+
- rbs/shims/ast/0/node.rbs
|
|
814
|
+
- rbs/shims/ast/2.4/.rbs_meta.yaml
|
|
815
|
+
- rbs/shims/ast/2.4/ast.rbs
|
|
816
|
+
- rbs/shims/diff-lcs/1.5/diff-lcs.rbs
|
|
817
|
+
- rbs/shims/parser/3.2.0.1/builders/default.rbs
|
|
818
|
+
- rbs/shims/parser/3.2.0.1/manifest.yaml
|
|
819
|
+
- rbs/shims/parser/3.2.0.1/parser.rbs
|
|
820
|
+
- rbs/shims/parser/3.2.0.1/polyfill.rbs
|
|
821
|
+
- rbs/shims/thor/1.2.0.1/.rbs_meta.yaml
|
|
822
|
+
- rbs/shims/thor/1.2.0.1/manifest.yaml
|
|
823
|
+
- rbs/shims/thor/1.2.0.1/thor.rbs
|
|
809
824
|
- rbs_collection.yaml
|
|
810
|
-
- sig/shims/ast/0/node.rbs
|
|
811
|
-
- sig/shims/ast/2.4/.rbs_meta.yaml
|
|
812
|
-
- sig/shims/ast/2.4/ast.rbs
|
|
813
|
-
- sig/shims/parser/3.2.0.1/builders/default.rbs
|
|
814
|
-
- sig/shims/parser/3.2.0.1/manifest.yaml
|
|
815
|
-
- sig/shims/parser/3.2.0.1/parser.rbs
|
|
816
|
-
- sig/shims/parser/3.2.0.1/polyfill.rbs
|
|
817
|
-
- sig/shims/thor/1.2.0.1/.rbs_meta.yaml
|
|
818
|
-
- sig/shims/thor/1.2.0.1/manifest.yaml
|
|
819
|
-
- sig/shims/thor/1.2.0.1/thor.rbs
|
|
820
825
|
- solargraph.gemspec
|
|
821
826
|
homepage: https://solargraph.org
|
|
822
827
|
licenses:
|
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Solargraph
|
|
4
|
-
class TypeChecker
|
|
5
|
-
# Helper methods for performing type checks
|
|
6
|
-
#
|
|
7
|
-
module Checks
|
|
8
|
-
module_function
|
|
9
|
-
|
|
10
|
-
# Compare an expected type with an inferred type. Common usage is to
|
|
11
|
-
# check if the type declared in a method's @return tag matches the type
|
|
12
|
-
# inferred from static analysis of the code.
|
|
13
|
-
#
|
|
14
|
-
# @param api_map [ApiMap]
|
|
15
|
-
# @param expected [ComplexType]
|
|
16
|
-
# @param inferred [ComplexType]
|
|
17
|
-
# @return [Boolean]
|
|
18
|
-
def types_match? api_map, expected, inferred
|
|
19
|
-
return true if expected.to_s == inferred.to_s
|
|
20
|
-
matches = []
|
|
21
|
-
expected.each do |exp|
|
|
22
|
-
found = false
|
|
23
|
-
inferred.each do |inf|
|
|
24
|
-
# if api_map.super_and_sub?(fuzz(inf), fuzz(exp))
|
|
25
|
-
if either_way?(api_map, inf, exp)
|
|
26
|
-
found = true
|
|
27
|
-
matches.push inf
|
|
28
|
-
break
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
return false unless found
|
|
32
|
-
end
|
|
33
|
-
inferred.each do |inf|
|
|
34
|
-
next if matches.include?(inf)
|
|
35
|
-
found = false
|
|
36
|
-
expected.each do |exp|
|
|
37
|
-
# if api_map.super_and_sub?(fuzz(inf), fuzz(exp))
|
|
38
|
-
if either_way?(api_map, inf, exp)
|
|
39
|
-
found = true
|
|
40
|
-
break
|
|
41
|
-
end
|
|
42
|
-
end
|
|
43
|
-
return false unless found
|
|
44
|
-
end
|
|
45
|
-
true
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
# @param api_map [ApiMap]
|
|
49
|
-
# @param expected [ComplexType]
|
|
50
|
-
# @param inferred [ComplexType]
|
|
51
|
-
# @return [Boolean]
|
|
52
|
-
def any_types_match? api_map, expected, inferred
|
|
53
|
-
expected = expected.downcast_to_literal_if_possible
|
|
54
|
-
inferred = inferred.downcast_to_literal_if_possible
|
|
55
|
-
return duck_types_match?(api_map, expected, inferred) if expected.duck_type?
|
|
56
|
-
# walk through the union expected type and see if any members
|
|
57
|
-
# of the union match the inferred type
|
|
58
|
-
expected.each do |exp|
|
|
59
|
-
next if exp.duck_type?
|
|
60
|
-
# @todo: there should be a level of typechecking where all
|
|
61
|
-
# unique types in the inferred must match one of the
|
|
62
|
-
# expected unique types
|
|
63
|
-
inferred.each do |inf|
|
|
64
|
-
# return true if exp == inf || api_map.super_and_sub?(fuzz(inf), fuzz(exp))
|
|
65
|
-
return true if exp == inf || either_way?(api_map, inf, exp)
|
|
66
|
-
end
|
|
67
|
-
end
|
|
68
|
-
false
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
# @param api_map [ApiMap]
|
|
72
|
-
# @param inferred [ComplexType]
|
|
73
|
-
# @param expected [ComplexType]
|
|
74
|
-
# @return [Boolean]
|
|
75
|
-
def all_types_match? api_map, inferred, expected
|
|
76
|
-
expected = expected.downcast_to_literal_if_possible
|
|
77
|
-
inferred = inferred.downcast_to_literal_if_possible
|
|
78
|
-
return duck_types_match?(api_map, expected, inferred) if expected.duck_type?
|
|
79
|
-
inferred.each do |inf|
|
|
80
|
-
next if inf.duck_type?
|
|
81
|
-
return false unless expected.any? { |exp| exp == inf || either_way?(api_map, inf, exp) }
|
|
82
|
-
end
|
|
83
|
-
true
|
|
84
|
-
end
|
|
85
|
-
|
|
86
|
-
# @param api_map [ApiMap]
|
|
87
|
-
# @param expected [ComplexType]
|
|
88
|
-
# @param inferred [ComplexType]
|
|
89
|
-
# @return [Boolean]
|
|
90
|
-
def duck_types_match? api_map, expected, inferred
|
|
91
|
-
raise ArgumentError, 'Expected type must be duck type' unless expected.duck_type?
|
|
92
|
-
expected.each do |exp|
|
|
93
|
-
next unless exp.duck_type?
|
|
94
|
-
quack = exp.to_s[1..-1]
|
|
95
|
-
return false if api_map.get_method_stack(inferred.namespace, quack, scope: inferred.scope).empty?
|
|
96
|
-
end
|
|
97
|
-
true
|
|
98
|
-
end
|
|
99
|
-
|
|
100
|
-
# @param type [ComplexType::UniqueType]
|
|
101
|
-
# @return [String]
|
|
102
|
-
def fuzz type
|
|
103
|
-
if type.parameters?
|
|
104
|
-
type.name
|
|
105
|
-
else
|
|
106
|
-
type.tag
|
|
107
|
-
end
|
|
108
|
-
end
|
|
109
|
-
|
|
110
|
-
# @param api_map [ApiMap]
|
|
111
|
-
# @param cls1 [ComplexType::UniqueType]
|
|
112
|
-
# @param cls2 [ComplexType::UniqueType]
|
|
113
|
-
# @return [Boolean]
|
|
114
|
-
def either_way?(api_map, cls1, cls2)
|
|
115
|
-
# @todo there should be a level of typechecking which uses the
|
|
116
|
-
# full tag with parameters to determine compatibility
|
|
117
|
-
f1 = cls1.name
|
|
118
|
-
f2 = cls2.name
|
|
119
|
-
api_map.type_include?(f1, f2) || api_map.super_and_sub?(f1, f2) || api_map.super_and_sub?(f2, f1)
|
|
120
|
-
# api_map.type_include?(f1, f2) || api_map.super_and_sub?(f1, f2) || api_map.super_and_sub?(f2, f1)
|
|
121
|
-
end
|
|
122
|
-
end
|
|
123
|
-
end
|
|
124
|
-
end
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Solargraph
|
|
4
|
-
class TypeChecker
|
|
5
|
-
# Data about a method parameter definition. This is the information from
|
|
6
|
-
# the args list in the def call, not the `@param` tags.
|
|
7
|
-
#
|
|
8
|
-
class ParamDef
|
|
9
|
-
# @return [String]
|
|
10
|
-
attr_reader :name
|
|
11
|
-
|
|
12
|
-
# @return [Symbol]
|
|
13
|
-
attr_reader :type
|
|
14
|
-
|
|
15
|
-
# @param name [String]
|
|
16
|
-
# @param type [Symbol] The type of parameter, such as :req, :opt, :rest, etc.
|
|
17
|
-
def initialize name, type
|
|
18
|
-
@name = name
|
|
19
|
-
@type = type
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
class << self
|
|
23
|
-
# Get an array of ParamDefs from a method pin.
|
|
24
|
-
#
|
|
25
|
-
# @param pin [Solargraph::Pin::Method]
|
|
26
|
-
# @return [Array<ParamDef>]
|
|
27
|
-
def from pin
|
|
28
|
-
result = []
|
|
29
|
-
pin.parameters.each do |par|
|
|
30
|
-
result.push ParamDef.new(par.name, par.decl)
|
|
31
|
-
end
|
|
32
|
-
result
|
|
33
|
-
end
|
|
34
|
-
end
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
end
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Solargraph
|
|
4
|
-
class YardMap
|
|
5
|
-
class ToMethod
|
|
6
|
-
module InnerMethods
|
|
7
|
-
module_function
|
|
8
|
-
|
|
9
|
-
# @param code_object [YARD::CodeObjects::Base]
|
|
10
|
-
# @param location [Solargraph::Location]
|
|
11
|
-
# @param comments [String]
|
|
12
|
-
# @return [Array<Solargraph::Pin::Parameter>]
|
|
13
|
-
def get_parameters code_object, location, comments
|
|
14
|
-
return [] unless code_object.is_a?(YARD::CodeObjects::MethodObject)
|
|
15
|
-
# HACK: Skip `nil` and `self` parameters that are sometimes emitted
|
|
16
|
-
# for methods defined in C
|
|
17
|
-
# See https://github.com/castwide/solargraph/issues/345
|
|
18
|
-
# @sg-ignore https://github.com/castwide/solargraph/pull/1114
|
|
19
|
-
code_object.parameters.select { |a| a[0] && a[0] != 'self' }.map do |a|
|
|
20
|
-
Solargraph::Pin::Parameter.new(
|
|
21
|
-
location: location,
|
|
22
|
-
closure: self,
|
|
23
|
-
comments: comments,
|
|
24
|
-
name: arg_name(a),
|
|
25
|
-
presence: nil,
|
|
26
|
-
decl: arg_type(a),
|
|
27
|
-
asgn_code: a[1],
|
|
28
|
-
source: :yard_map
|
|
29
|
-
)
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
# @param a [Array<String>]
|
|
34
|
-
# @return [String]
|
|
35
|
-
def arg_name a
|
|
36
|
-
a[0].gsub(/[^a-z0-9_]/i, '')
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
# @param a [Array]
|
|
40
|
-
# @return [::Symbol]
|
|
41
|
-
def arg_type a
|
|
42
|
-
if a[0].start_with?('**')
|
|
43
|
-
:kwrestarg
|
|
44
|
-
elsif a[0].start_with?('*')
|
|
45
|
-
:restarg
|
|
46
|
-
elsif a[0].start_with?('&')
|
|
47
|
-
:blockarg
|
|
48
|
-
elsif a[0].end_with?(':')
|
|
49
|
-
a[1] ? :kwoptarg : :kwarg
|
|
50
|
-
elsif a[1]
|
|
51
|
-
:optarg
|
|
52
|
-
else
|
|
53
|
-
:arg
|
|
54
|
-
end
|
|
55
|
-
end
|
|
56
|
-
end
|
|
57
|
-
private_constant :InnerMethods
|
|
58
|
-
|
|
59
|
-
include Helpers
|
|
60
|
-
|
|
61
|
-
# @param code_object [YARD::CodeObjects::MethodObject]
|
|
62
|
-
# @param name [String, nil]
|
|
63
|
-
# @param scope [Symbol, nil]
|
|
64
|
-
# @param visibility [Symbol, nil]
|
|
65
|
-
# @param closure [Solargraph::Pin::Base, nil]
|
|
66
|
-
# @param spec [Solargraph::Pin::Base, nil]
|
|
67
|
-
# @return [Solargraph::Pin::Method]
|
|
68
|
-
def make code_object, name = nil, scope = nil, visibility = nil, closure = nil, spec = nil
|
|
69
|
-
closure ||= Solargraph::Pin::Namespace.new(
|
|
70
|
-
name: code_object.namespace.to_s,
|
|
71
|
-
gates: [code_object.namespace.to_s]
|
|
72
|
-
)
|
|
73
|
-
location = object_location(code_object, spec)
|
|
74
|
-
comments = code_object.docstring ? code_object.docstring.all.to_s : ''
|
|
75
|
-
Pin::Method.new(
|
|
76
|
-
location: location,
|
|
77
|
-
closure: closure,
|
|
78
|
-
name: name || code_object.name.to_s,
|
|
79
|
-
comments: comments,
|
|
80
|
-
scope: scope || code_object.scope,
|
|
81
|
-
visibility: visibility || code_object.visibility,
|
|
82
|
-
parameters: InnerMethods.get_parameters(code_object, location, comments),
|
|
83
|
-
explicit: code_object.is_explicit?,
|
|
84
|
-
source: :yard_map
|
|
85
|
-
)
|
|
86
|
-
end
|
|
87
|
-
end
|
|
88
|
-
end
|
|
89
|
-
end
|
data/sig/shims/ast/0/node.rbs
DELETED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|