solargraph 0.58.2 → 0.59.0.dev.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/.envrc +3 -0
- data/.github/workflows/linting.yml +4 -5
- data/.github/workflows/plugins.yml +41 -34
- data/.github/workflows/rspec.yml +44 -23
- data/.github/workflows/typecheck.yml +2 -2
- data/.rubocop.yml +32 -5
- data/.rubocop_todo.yml +50 -966
- data/Gemfile +3 -1
- data/README.md +3 -3
- data/Rakefile +26 -23
- data/bin/solargraph +2 -1
- data/lib/solargraph/api_map/cache.rb +3 -3
- data/lib/solargraph/api_map/constants.rb +13 -3
- data/lib/solargraph/api_map/index.rb +23 -18
- data/lib/solargraph/api_map/source_to_yard.rb +22 -9
- data/lib/solargraph/api_map/store.rb +33 -28
- data/lib/solargraph/api_map.rb +150 -82
- data/lib/solargraph/bench.rb +44 -45
- data/lib/solargraph/complex_type/conformance.rb +176 -0
- data/lib/solargraph/complex_type/type_methods.rb +28 -17
- data/lib/solargraph/complex_type/unique_type.rb +218 -57
- data/lib/solargraph/complex_type.rb +170 -57
- data/lib/solargraph/convention/data_definition/data_assignment_node.rb +61 -61
- data/lib/solargraph/convention/data_definition/data_definition_node.rb +7 -5
- data/lib/solargraph/convention/data_definition.rb +5 -2
- data/lib/solargraph/convention/gemfile.rb +15 -15
- data/lib/solargraph/convention/gemspec.rb +23 -23
- data/lib/solargraph/convention/rakefile.rb +17 -17
- data/lib/solargraph/convention/struct_definition/struct_assignment_node.rb +2 -1
- data/lib/solargraph/convention/struct_definition/struct_definition_node.rb +4 -3
- data/lib/solargraph/convention/struct_definition.rb +8 -4
- data/lib/solargraph/convention.rb +78 -78
- data/lib/solargraph/converters/dd.rb +19 -17
- data/lib/solargraph/converters/dl.rb +17 -15
- data/lib/solargraph/converters/dt.rb +17 -15
- data/lib/solargraph/converters/misc.rb +3 -1
- data/lib/solargraph/diagnostics/require_not_found.rb +1 -0
- data/lib/solargraph/diagnostics/rubocop.rb +11 -10
- data/lib/solargraph/diagnostics/rubocop_helpers.rb +5 -3
- data/lib/solargraph/diagnostics/type_check.rb +11 -10
- data/lib/solargraph/diagnostics/update_errors.rb +37 -41
- data/lib/solargraph/doc_map.rb +133 -373
- data/lib/solargraph/equality.rb +4 -4
- data/lib/solargraph/gem_pins.rb +21 -20
- data/lib/solargraph/language_server/error_codes.rb +20 -20
- data/lib/solargraph/language_server/host/diagnoser.rb +1 -1
- data/lib/solargraph/language_server/host/dispatch.rb +3 -3
- data/lib/solargraph/language_server/host/message_worker.rb +4 -3
- data/lib/solargraph/language_server/host/sources.rb +2 -1
- data/lib/solargraph/language_server/host.rb +30 -22
- data/lib/solargraph/language_server/message/base.rb +97 -97
- data/lib/solargraph/language_server/message/client/register_capability.rb +13 -15
- data/lib/solargraph/language_server/message/completion_item/resolve.rb +58 -60
- data/lib/solargraph/language_server/message/extended/check_gem_version.rb +12 -18
- data/lib/solargraph/language_server/message/extended/document.rb +1 -0
- data/lib/solargraph/language_server/message/extended/document_gems.rb +32 -32
- data/lib/solargraph/language_server/message/extended/download_core.rb +20 -19
- data/lib/solargraph/language_server/message/extended/search.rb +20 -20
- data/lib/solargraph/language_server/message/initialize.rb +197 -191
- data/lib/solargraph/language_server/message/text_document/completion.rb +10 -8
- data/lib/solargraph/language_server/message/text_document/definition.rb +41 -32
- data/lib/solargraph/language_server/message/text_document/document_highlight.rb +23 -16
- data/lib/solargraph/language_server/message/text_document/document_symbol.rb +29 -19
- data/lib/solargraph/language_server/message/text_document/formatting.rb +8 -6
- data/lib/solargraph/language_server/message/text_document/hover.rb +5 -5
- data/lib/solargraph/language_server/message/text_document/prepare_rename.rb +18 -11
- data/lib/solargraph/language_server/message/text_document/references.rb +23 -16
- data/lib/solargraph/language_server/message/text_document/rename.rb +26 -19
- data/lib/solargraph/language_server/message/text_document/signature_help.rb +3 -2
- data/lib/solargraph/language_server/message/text_document/type_definition.rb +25 -17
- data/lib/solargraph/language_server/message/workspace/did_change_configuration.rb +41 -35
- data/lib/solargraph/language_server/message/workspace/did_change_watched_files.rb +48 -40
- data/lib/solargraph/language_server/message/workspace/did_change_workspace_folders.rb +32 -26
- data/lib/solargraph/language_server/message/workspace/workspace_symbol.rb +27 -17
- data/lib/solargraph/language_server/message.rb +94 -94
- data/lib/solargraph/language_server/request.rb +29 -27
- data/lib/solargraph/language_server/transport/data_reader.rb +72 -74
- data/lib/solargraph/language_server/uri_helpers.rb +49 -49
- data/lib/solargraph/library.rb +85 -44
- data/lib/solargraph/location.rb +17 -14
- data/lib/solargraph/logging.rb +24 -4
- data/lib/solargraph/page.rb +92 -92
- data/lib/solargraph/parser/comment_ripper.rb +19 -4
- data/lib/solargraph/parser/flow_sensitive_typing.rb +326 -108
- data/lib/solargraph/parser/node_processor/base.rb +34 -4
- data/lib/solargraph/parser/node_processor.rb +8 -7
- data/lib/solargraph/parser/parser_gem/class_methods.rb +32 -14
- data/lib/solargraph/parser/parser_gem/flawed_builder.rb +19 -19
- data/lib/solargraph/parser/parser_gem/node_chainer.rb +50 -25
- data/lib/solargraph/parser/parser_gem/node_methods.rb +91 -70
- data/lib/solargraph/parser/parser_gem/node_processors/and_node.rb +4 -4
- data/lib/solargraph/parser/parser_gem/node_processors/args_node.rb +13 -11
- data/lib/solargraph/parser/parser_gem/node_processors/begin_node.rb +9 -0
- data/lib/solargraph/parser/parser_gem/node_processors/block_node.rb +12 -12
- data/lib/solargraph/parser/parser_gem/node_processors/def_node.rb +10 -3
- data/lib/solargraph/parser/parser_gem/node_processors/defs_node.rb +38 -37
- data/lib/solargraph/parser/parser_gem/node_processors/if_node.rb +36 -6
- data/lib/solargraph/parser/parser_gem/node_processors/ivasgn_node.rb +5 -3
- data/lib/solargraph/parser/parser_gem/node_processors/lvasgn_node.rb +1 -0
- data/lib/solargraph/parser/parser_gem/node_processors/masgn_node.rb +3 -1
- data/lib/solargraph/parser/parser_gem/node_processors/opasgn_node.rb +3 -3
- data/lib/solargraph/parser/parser_gem/node_processors/or_node.rb +22 -0
- data/lib/solargraph/parser/parser_gem/node_processors/orasgn_node.rb +1 -1
- data/lib/solargraph/parser/parser_gem/node_processors/resbody_node.rb +2 -1
- data/lib/solargraph/parser/parser_gem/node_processors/sclass_node.rb +4 -5
- data/lib/solargraph/parser/parser_gem/node_processors/send_node.rb +124 -113
- data/lib/solargraph/parser/parser_gem/node_processors/until_node.rb +29 -29
- data/lib/solargraph/parser/parser_gem/node_processors/when_node.rb +23 -0
- data/lib/solargraph/parser/parser_gem/node_processors/while_node.rb +6 -2
- data/lib/solargraph/parser/parser_gem/node_processors.rb +4 -0
- data/lib/solargraph/parser/parser_gem.rb +14 -12
- data/lib/solargraph/parser/region.rb +9 -3
- data/lib/solargraph/parser/snippet.rb +3 -1
- data/lib/solargraph/parser.rb +25 -23
- data/lib/solargraph/pin/base.rb +126 -80
- data/lib/solargraph/pin/base_variable.rb +273 -24
- data/lib/solargraph/pin/block.rb +29 -6
- data/lib/solargraph/pin/breakable.rb +7 -1
- data/lib/solargraph/pin/callable.rb +65 -21
- data/lib/solargraph/pin/closure.rb +7 -10
- data/lib/solargraph/pin/common.rb +24 -6
- data/lib/solargraph/pin/compound_statement.rb +55 -0
- data/lib/solargraph/pin/constant.rb +43 -45
- data/lib/solargraph/pin/conversions.rb +10 -4
- data/lib/solargraph/pin/delegated_method.rb +19 -8
- data/lib/solargraph/pin/documenting.rb +4 -2
- data/lib/solargraph/pin/instance_variable.rb +5 -1
- data/lib/solargraph/pin/keyword.rb +0 -4
- data/lib/solargraph/pin/local_variable.rb +15 -59
- data/lib/solargraph/pin/method.rb +153 -104
- data/lib/solargraph/pin/method_alias.rb +8 -0
- data/lib/solargraph/pin/namespace.rb +19 -12
- data/lib/solargraph/pin/parameter.rb +100 -36
- data/lib/solargraph/pin/proxy_type.rb +4 -1
- data/lib/solargraph/pin/reference/override.rb +1 -1
- data/lib/solargraph/pin/reference/superclass.rb +2 -0
- data/lib/solargraph/pin/reference.rb +19 -0
- data/lib/solargraph/pin/search.rb +3 -2
- data/lib/solargraph/pin/signature.rb +15 -12
- data/lib/solargraph/pin/symbol.rb +2 -1
- data/lib/solargraph/pin/until.rb +2 -4
- data/lib/solargraph/pin/while.rb +2 -4
- data/lib/solargraph/pin.rb +2 -0
- data/lib/solargraph/pin_cache.rb +490 -73
- data/lib/solargraph/position.rb +14 -10
- data/lib/solargraph/range.rb +16 -15
- data/lib/solargraph/rbs_map/conversions.rb +343 -214
- data/lib/solargraph/rbs_map/core_fills.rb +91 -84
- data/lib/solargraph/rbs_map/core_map.rb +24 -17
- data/lib/solargraph/rbs_map/stdlib_map.rb +33 -5
- data/lib/solargraph/rbs_map.rb +77 -32
- data/lib/solargraph/server_methods.rb +16 -16
- data/lib/solargraph/shell.rb +128 -73
- data/lib/solargraph/source/chain/array.rb +39 -37
- data/lib/solargraph/source/chain/call.rb +96 -56
- data/lib/solargraph/source/chain/class_variable.rb +13 -13
- data/lib/solargraph/source/chain/constant.rb +5 -1
- data/lib/solargraph/source/chain/global_variable.rb +13 -13
- data/lib/solargraph/source/chain/hash.rb +8 -5
- data/lib/solargraph/source/chain/if.rb +12 -10
- data/lib/solargraph/source/chain/instance_variable.rb +24 -1
- data/lib/solargraph/source/chain/link.rb +99 -109
- data/lib/solargraph/source/chain/literal.rb +9 -6
- data/lib/solargraph/source/chain/or.rb +10 -4
- data/lib/solargraph/source/chain/q_call.rb +13 -11
- data/lib/solargraph/source/chain/variable.rb +15 -13
- data/lib/solargraph/source/chain/z_super.rb +28 -30
- data/lib/solargraph/source/chain.rb +49 -38
- data/lib/solargraph/source/change.rb +12 -5
- data/lib/solargraph/source/cursor.rb +23 -17
- data/lib/solargraph/source/encoding_fixes.rb +6 -7
- data/lib/solargraph/source/source_chainer.rb +56 -32
- data/lib/solargraph/source/updater.rb +5 -1
- data/lib/solargraph/source.rb +59 -35
- data/lib/solargraph/source_map/clip.rb +48 -29
- data/lib/solargraph/source_map/data.rb +4 -1
- data/lib/solargraph/source_map/mapper.rb +71 -42
- data/lib/solargraph/source_map.rb +21 -9
- data/lib/solargraph/type_checker/problem.rb +3 -1
- data/lib/solargraph/type_checker/rules.rb +81 -8
- data/lib/solargraph/type_checker.rb +195 -120
- data/lib/solargraph/version.rb +1 -1
- data/lib/solargraph/workspace/config.rb +13 -10
- data/lib/solargraph/workspace/gemspecs.rb +367 -0
- data/lib/solargraph/workspace/require_paths.rb +1 -0
- data/lib/solargraph/workspace.rb +149 -30
- data/lib/solargraph/yard_map/helpers.rb +8 -3
- data/lib/solargraph/yard_map/mapper/to_method.rb +13 -7
- data/lib/solargraph/yard_map/mapper/to_namespace.rb +2 -1
- data/lib/solargraph/yard_map/mapper.rb +13 -8
- data/lib/solargraph/yard_tags.rb +20 -20
- data/lib/solargraph/yardoc.rb +33 -23
- data/lib/solargraph.rb +29 -8
- data/rbs/fills/rubygems/0/dependency.rbs +193 -0
- data/rbs/fills/tuple/tuple.rbs +28 -0
- data/rbs/shims/ast/0/node.rbs +1 -1
- data/rbs/shims/diff-lcs/1.5/diff-lcs.rbs +11 -0
- data/solargraph.gemspec +36 -34
- metadata +38 -33
- 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/Gemfile
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
source 'https://rubygems.org'
|
|
2
4
|
|
|
3
5
|
gemspec name: 'solargraph'
|
|
4
6
|
|
|
5
7
|
# Local gemfile for development tools, etc.
|
|
6
|
-
local_gemfile = File.expand_path(
|
|
8
|
+
local_gemfile = File.expand_path('.Gemfile', __dir__)
|
|
7
9
|
instance_eval File.read local_gemfile if File.exist? local_gemfile
|
data/README.md
CHANGED
|
@@ -51,6 +51,8 @@ Plug-ins and extensions are available for the following editors:
|
|
|
51
51
|
|
|
52
52
|
Solargraph's behavior can be controlled via optional [configuration](https://solargraph.org/guides/configuration) files. The highest priority file is a `.solargraph.yml` file at the root of the project. If not present, any global configuration at `~/.config/solargraph/config.yml` will apply. The path to the global configuration can be overridden with the `SOLARGRAPH_GLOBAL_CONFIG` environment variable.
|
|
53
53
|
|
|
54
|
+
Use `bundle exec solargraph config` to create a configuration file.
|
|
55
|
+
|
|
54
56
|
### Plugins
|
|
55
57
|
|
|
56
58
|
Solargraph supports [plugins](https://solargraph.org/guides/plugins) that implement their own Solargraph features, such as diagnostics reporters and conventions to provide LSP features and type-checking, e.g. for frameworks which use metaprogramming and/or DSLs.
|
|
@@ -132,9 +134,7 @@ See [https://solargraph.org/guides](https://solargraph.org/guides) for more tips
|
|
|
132
134
|
|
|
133
135
|
### Development
|
|
134
136
|
|
|
135
|
-
To see more logging when typechecking or running specs, set the
|
|
136
|
-
`SOLARGRAPH_LOG` environment variable to `debug` or `info`. `warn` is
|
|
137
|
-
the default value.
|
|
137
|
+
To see more logging when typechecking or running specs, set the `SOLARGRAPH_LOG` environment variable to `debug` or `info`. `warn` is the default value.
|
|
138
138
|
|
|
139
139
|
Code contributions are always appreciated. Feel free to fork the repo and submit pull requests. Check for open issues that could use help. Start new issues to discuss changes that have a major impact on the code or require large time commitments.
|
|
140
140
|
|
data/Rakefile
CHANGED
|
@@ -1,42 +1,44 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'rake'
|
|
2
4
|
require 'bundler/gem_tasks'
|
|
3
5
|
require 'fileutils'
|
|
4
6
|
require 'open3'
|
|
5
7
|
|
|
6
|
-
desc
|
|
8
|
+
desc 'Open a Pry session preloaded with this library'
|
|
7
9
|
task :console do
|
|
8
|
-
sh
|
|
10
|
+
sh 'pry -I lib -r solargraph.rb'
|
|
9
11
|
end
|
|
10
12
|
|
|
11
|
-
desc
|
|
13
|
+
desc 'Run the type checker'
|
|
12
14
|
task typecheck: [:typecheck_strong]
|
|
13
15
|
|
|
14
|
-
desc
|
|
16
|
+
desc 'Run the type checker at typed level - return code issues provable without annotations being correct'
|
|
15
17
|
task :typecheck_typed do
|
|
16
|
-
sh
|
|
18
|
+
sh 'SOLARGRAPH_ASSERTS=on bundle exec solargraph typecheck --level typed'
|
|
17
19
|
end
|
|
18
20
|
|
|
19
|
-
desc
|
|
21
|
+
desc 'Run the type checker at strict level - report issues using type annotations'
|
|
20
22
|
task :typecheck_strict do
|
|
21
|
-
sh
|
|
23
|
+
sh 'SOLARGRAPH_ASSERTS=on bundle exec solargraph typecheck --level strict'
|
|
22
24
|
end
|
|
23
25
|
|
|
24
|
-
desc
|
|
26
|
+
desc 'Run the type checker at strong level - enforce that type annotations exist'
|
|
25
27
|
task :typecheck_strong do
|
|
26
|
-
sh
|
|
28
|
+
sh 'SOLARGRAPH_ASSERTS=on bundle exec solargraph typecheck --level strong'
|
|
27
29
|
end
|
|
28
30
|
|
|
29
|
-
desc
|
|
31
|
+
desc 'Run the type checker at alpha level - run high-false-alarm checks'
|
|
30
32
|
task :typecheck_alpha do
|
|
31
|
-
sh
|
|
33
|
+
sh 'SOLARGRAPH_ASSERTS=on bundle exec solargraph typecheck --level alpha'
|
|
32
34
|
end
|
|
33
35
|
|
|
34
|
-
desc
|
|
36
|
+
desc 'Run RSpec tests, starting with the ones that failed last time'
|
|
35
37
|
task spec: %i[spec_failed undercover_no_fail full_spec] do
|
|
36
38
|
undercover
|
|
37
39
|
end
|
|
38
40
|
|
|
39
|
-
desc
|
|
41
|
+
desc 'Run all RSpec tests'
|
|
40
42
|
task :full_spec do
|
|
41
43
|
warn 'starting spec'
|
|
42
44
|
sh 'TEST_COVERAGE_COMMAND_NAME=full-new bundle exec rspec' # --profile'
|
|
@@ -63,19 +65,20 @@ def undercover
|
|
|
63
65
|
status
|
|
64
66
|
rescue StandardError => e
|
|
65
67
|
warn "hit error: #{e.message}"
|
|
68
|
+
# @sg-ignore Need to add nil check here
|
|
66
69
|
warn "Backtrace:\n#{e.backtrace.join("\n")}"
|
|
67
70
|
warn "output: #{output}"
|
|
68
|
-
puts
|
|
71
|
+
puts 'Flushing'
|
|
69
72
|
$stdout.flush
|
|
70
73
|
raise
|
|
71
74
|
end
|
|
72
75
|
|
|
73
|
-
desc
|
|
76
|
+
desc 'Check PR coverage'
|
|
74
77
|
task :undercover do
|
|
75
|
-
raise
|
|
78
|
+
raise 'Undercover failed' unless undercover.success?
|
|
76
79
|
end
|
|
77
80
|
|
|
78
|
-
desc
|
|
81
|
+
desc 'Branch-focused fast-feedback quality/spec/coverage checks'
|
|
79
82
|
task test: %i[overcommit spec typecheck] do
|
|
80
83
|
# do these in order
|
|
81
84
|
Rake::Task['typecheck_strict'].invoke
|
|
@@ -83,18 +86,18 @@ task test: %i[overcommit spec typecheck] do
|
|
|
83
86
|
Rake::Task['typecheck_alpha'].invoke
|
|
84
87
|
end
|
|
85
88
|
|
|
86
|
-
desc
|
|
89
|
+
desc 'Re-run failed specs. Add --fail-fast in your .rspec-local file if desired.'
|
|
87
90
|
task :spec_failed do
|
|
88
91
|
# allow user to check out any persistent failures while looking for
|
|
89
92
|
# more in the whole test suite
|
|
90
93
|
sh 'TEST_COVERAGE_COMMAND_NAME=next-failure bundle exec rspec --only-failures || true'
|
|
91
94
|
end
|
|
92
95
|
|
|
93
|
-
desc
|
|
96
|
+
desc 'Run undercover and show output without failing the task if it fails'
|
|
94
97
|
task :undercover_no_fail do
|
|
95
98
|
undercover
|
|
96
99
|
rescue StandardError
|
|
97
|
-
puts
|
|
100
|
+
puts 'Undercover failed, but continuing with other tasks.'
|
|
98
101
|
end
|
|
99
102
|
|
|
100
103
|
# @return [void]
|
|
@@ -103,7 +106,7 @@ def simplecov_collate
|
|
|
103
106
|
require 'simplecov-lcov'
|
|
104
107
|
require 'undercover/simplecov_formatter'
|
|
105
108
|
|
|
106
|
-
SimpleCov.collate(Dir[
|
|
109
|
+
SimpleCov.collate(Dir['coverage/{next-failure,full,ad-hoc}/.resultset.json']) do
|
|
107
110
|
cname = 'combined'
|
|
108
111
|
command_name cname
|
|
109
112
|
new_dir = File.join('coverage', cname)
|
|
@@ -118,7 +121,7 @@ def simplecov_collate
|
|
|
118
121
|
])
|
|
119
122
|
SimpleCov::Formatter::LcovFormatter.config.report_with_single_file = true
|
|
120
123
|
end
|
|
121
|
-
puts
|
|
124
|
+
puts 'Simplecov collated results into coverage/combined/.resultset.json'
|
|
122
125
|
rescue StandardError => e
|
|
123
126
|
puts "Simplecov collate failed: #{e.message}"
|
|
124
127
|
ensure
|
|
@@ -130,7 +133,7 @@ task :simplecov_collate do
|
|
|
130
133
|
simplecov_collate
|
|
131
134
|
end
|
|
132
135
|
|
|
133
|
-
desc
|
|
136
|
+
desc 'Show quality checks on this development branch so far, including any staged files'
|
|
134
137
|
task :overcommit do
|
|
135
138
|
# OVERCOMMIT_DEBUG=1 will show more detail
|
|
136
139
|
sh 'SOLARGRAPH_ASSERTS=on bundle exec overcommit --run --diff origin/master'
|
data/bin/solargraph
CHANGED
|
@@ -8,7 +8,7 @@ module Solargraph
|
|
|
8
8
|
@methods = {}
|
|
9
9
|
# @type [Hash{String, Array<String> => Array<Pin::Base>}]
|
|
10
10
|
@constants = {}
|
|
11
|
-
# @type [Hash{String => String}]
|
|
11
|
+
# @type [Hash{String => String, nil}]
|
|
12
12
|
@qualified_namespaces = {}
|
|
13
13
|
# @type [Hash{String => Pin::Method}]
|
|
14
14
|
@receiver_definitions = {}
|
|
@@ -61,14 +61,14 @@ module Solargraph
|
|
|
61
61
|
|
|
62
62
|
# @param name [String]
|
|
63
63
|
# @param context [String]
|
|
64
|
-
# @return [String]
|
|
64
|
+
# @return [String, nil]
|
|
65
65
|
def get_qualified_namespace name, context
|
|
66
66
|
@qualified_namespaces["#{name}|#{context}"]
|
|
67
67
|
end
|
|
68
68
|
|
|
69
69
|
# @param name [String]
|
|
70
70
|
# @param context [String]
|
|
71
|
-
# @param value [String]
|
|
71
|
+
# @param value [String, nil]
|
|
72
72
|
# @return [void]
|
|
73
73
|
def set_qualified_namespace name, context, value
|
|
74
74
|
@qualified_namespaces["#{name}|#{context}"] = value
|
|
@@ -27,9 +27,11 @@ module Solargraph
|
|
|
27
27
|
# @param name [String] Namespace which may relative and not be rooted.
|
|
28
28
|
# @param gates [Array<Array<String>, String>] Namespaces to search while resolving the name
|
|
29
29
|
#
|
|
30
|
+
# @sg-ignore flow sensitive typing needs to eliminate literal from union with return if foo == :bar
|
|
30
31
|
# @return [String, nil] fully qualified namespace (i.e., is
|
|
31
32
|
# absolute, but will not start with ::)
|
|
32
33
|
def resolve(name, *gates)
|
|
34
|
+
# @sg-ignore Need to add nil check here
|
|
33
35
|
return store.get_path_pins(name[2..]).first&.path if name.start_with?('::')
|
|
34
36
|
|
|
35
37
|
flat = gates.flatten
|
|
@@ -86,6 +88,7 @@ module Solargraph
|
|
|
86
88
|
return unless fqns
|
|
87
89
|
pin = store.get_path_pins(fqns).first
|
|
88
90
|
if pin.is_a?(Pin::Constant)
|
|
91
|
+
# @sg-ignore Need to add nil check here
|
|
89
92
|
const = Solargraph::Parser::NodeMethods.unpack_name(pin.assignment)
|
|
90
93
|
return unless const
|
|
91
94
|
fqns = resolve(const, *pin.gates)
|
|
@@ -105,6 +108,7 @@ module Solargraph
|
|
|
105
108
|
|
|
106
109
|
# @param name [String]
|
|
107
110
|
# @param gates [Array<String>]
|
|
111
|
+
# @sg-ignore flow sensitive typing should be able to handle redefinition
|
|
108
112
|
# @return [String, nil]
|
|
109
113
|
def resolve_and_cache name, gates
|
|
110
114
|
cached_resolve[[name, gates]] = :in_process
|
|
@@ -125,6 +129,7 @@ module Solargraph
|
|
|
125
129
|
if resolved
|
|
126
130
|
base = [resolved]
|
|
127
131
|
else
|
|
132
|
+
# @sg-ignore flow sensitive typing needs better handling of ||= on lvars
|
|
128
133
|
return resolve(name, first) unless first.empty?
|
|
129
134
|
end
|
|
130
135
|
end
|
|
@@ -138,7 +143,7 @@ module Solargraph
|
|
|
138
143
|
# @param name [String]
|
|
139
144
|
# @param gates [Array<String>]
|
|
140
145
|
# @param internal [Boolean] True if the name is not the last in the namespace
|
|
141
|
-
# @return [Array(
|
|
146
|
+
# @return [Array(String, Array<String>), Array(nil, Array<String>), String]
|
|
142
147
|
def complex_resolve name, gates, internal
|
|
143
148
|
resolved = nil
|
|
144
149
|
gates.each.with_index do |gate, idx|
|
|
@@ -165,6 +170,7 @@ module Solargraph
|
|
|
165
170
|
here = "#{gate}::#{name}".sub(/^::/, '').sub(/::$/, '')
|
|
166
171
|
pin = store.get_path_pins(here).first
|
|
167
172
|
if pin.is_a?(Pin::Constant) && internal
|
|
173
|
+
# @sg-ignore Need to add nil check here
|
|
168
174
|
const = Solargraph::Parser::NodeMethods.unpack_name(pin.assignment)
|
|
169
175
|
return unless const
|
|
170
176
|
resolve(const, pin.gates)
|
|
@@ -197,13 +203,14 @@ module Solargraph
|
|
|
197
203
|
# will start the search in the specified context until it finds a
|
|
198
204
|
# match for the namespace.
|
|
199
205
|
#
|
|
200
|
-
# @param namespace [String
|
|
206
|
+
# @param namespace [String] The namespace to
|
|
201
207
|
# match
|
|
202
208
|
# @param context_namespace [String] The context namespace in which the
|
|
203
209
|
# tag was referenced; start from here to resolve the name
|
|
204
210
|
# @return [String, nil] fully qualified namespace
|
|
205
211
|
def qualify_namespace namespace, context_namespace = ''
|
|
206
212
|
if namespace.start_with?('::')
|
|
213
|
+
# @sg-ignore Need to add nil check here
|
|
207
214
|
inner_qualify(namespace[2..], '', Set.new)
|
|
208
215
|
else
|
|
209
216
|
inner_qualify(namespace, context_namespace, Set.new)
|
|
@@ -249,7 +256,7 @@ module Solargraph
|
|
|
249
256
|
end
|
|
250
257
|
end
|
|
251
258
|
|
|
252
|
-
# @param fqns [String]
|
|
259
|
+
# @param fqns [String, nil]
|
|
253
260
|
# @param visibility [Array<Symbol>]
|
|
254
261
|
# @param skip [Set<String>]
|
|
255
262
|
# @return [Array<Solargraph::Pin::Namespace, Solargraph::Pin::Constant>]
|
|
@@ -259,17 +266,20 @@ module Solargraph
|
|
|
259
266
|
result = []
|
|
260
267
|
|
|
261
268
|
store.get_prepends(fqns).each do |pre|
|
|
269
|
+
# @sg-ignore Need to add nil check here
|
|
262
270
|
pre_fqns = resolve(pre.name, pre.closure.gates - skip.to_a)
|
|
263
271
|
result.concat inner_get_constants(pre_fqns, [:public], skip)
|
|
264
272
|
end
|
|
265
273
|
result.concat(store.get_constants(fqns, visibility).sort { |a, b| a.name <=> b.name })
|
|
266
274
|
store.get_includes(fqns).each do |pin|
|
|
275
|
+
# @sg-ignore Need to add nil check here
|
|
267
276
|
inc_fqns = resolve(pin.name, pin.closure.gates - skip.to_a)
|
|
268
277
|
result.concat inner_get_constants(inc_fqns, [:public], skip)
|
|
269
278
|
end
|
|
270
279
|
sc_ref = store.get_superclass(fqns)
|
|
271
280
|
if sc_ref
|
|
272
281
|
fqsc = dereference(sc_ref)
|
|
282
|
+
# @sg-ignore Need to add nil check here
|
|
273
283
|
result.concat inner_get_constants(fqsc, [:public], skip) unless %w[Object BasicObject].include?(fqsc)
|
|
274
284
|
end
|
|
275
285
|
result
|
|
@@ -40,13 +40,13 @@ module Solargraph
|
|
|
40
40
|
# @param klass [Class<generic<T>>]
|
|
41
41
|
# @return [Set<generic<T>>]
|
|
42
42
|
def pins_by_class klass
|
|
43
|
-
# @type [Set<
|
|
43
|
+
# @type [Set<generic<T>>]
|
|
44
44
|
s = Set.new
|
|
45
45
|
# @sg-ignore need to support destructured args in blocks
|
|
46
46
|
@pin_select_cache[klass] ||= pin_class_hash.each_with_object(s) { |(key, o), n| n.merge(o) if key <= klass }
|
|
47
47
|
end
|
|
48
48
|
|
|
49
|
-
# @return [Hash{String => Array<
|
|
49
|
+
# @return [Hash{String => Array<Pin::Reference::Include>}]
|
|
50
50
|
def include_references
|
|
51
51
|
# @param h [String]
|
|
52
52
|
# @param k [Array<String>]
|
|
@@ -60,21 +60,21 @@ module Solargraph
|
|
|
60
60
|
@include_reference_pins ||= Hash.new { |h, k| h[k] = [] }
|
|
61
61
|
end
|
|
62
62
|
|
|
63
|
-
# @return [Hash{String => Array<
|
|
63
|
+
# @return [Hash{String => Array<Pin::Reference::Extend>}]
|
|
64
64
|
def extend_references
|
|
65
65
|
# @param h [String]
|
|
66
66
|
# @param k [Array<String>]
|
|
67
67
|
@extend_references ||= Hash.new { |h, k| h[k] = [] }
|
|
68
68
|
end
|
|
69
69
|
|
|
70
|
-
# @return [Hash{String => Array<
|
|
70
|
+
# @return [Hash{String => Array<Pin::Reference::Prepend>}]
|
|
71
71
|
def prepend_references
|
|
72
72
|
# @param h [String]
|
|
73
73
|
# @param k [Array<String>]
|
|
74
74
|
@prepend_references ||= Hash.new { |h, k| h[k] = [] }
|
|
75
75
|
end
|
|
76
76
|
|
|
77
|
-
# @return [Hash{String => Array<
|
|
77
|
+
# @return [Hash{String => Array<Pin::Reference::Superclass>}]
|
|
78
78
|
def superclass_references
|
|
79
79
|
# @param h [String]
|
|
80
80
|
# @param k [Array<String>]
|
|
@@ -118,15 +118,15 @@ module Solargraph
|
|
|
118
118
|
# @param k [String]
|
|
119
119
|
# @param v [Set<Pin::Base>]
|
|
120
120
|
set.classify(&:class)
|
|
121
|
-
|
|
121
|
+
.map { |k, v| pin_class_hash[k].concat v.to_a }
|
|
122
122
|
# @param k [String]
|
|
123
123
|
# @param v [Set<Pin::Namespace>]
|
|
124
124
|
set.classify(&:namespace)
|
|
125
|
-
|
|
125
|
+
.map { |k, v| namespace_hash[k].concat v.to_a }
|
|
126
126
|
# @param k [String]
|
|
127
127
|
# @param v [Set<Pin::Base>]
|
|
128
128
|
set.classify(&:path)
|
|
129
|
-
|
|
129
|
+
.map { |k, v| path_pin_hash[k].concat v.to_a }
|
|
130
130
|
@namespaces = path_pin_hash.keys.compact.to_set
|
|
131
131
|
map_references Pin::Reference::Include, include_references
|
|
132
132
|
map_references Pin::Reference::Prepend, prepend_references
|
|
@@ -138,7 +138,7 @@ module Solargraph
|
|
|
138
138
|
|
|
139
139
|
# @generic T
|
|
140
140
|
# @param klass [Class<generic<T>>]
|
|
141
|
-
# @param hash [Hash{String => generic<T
|
|
141
|
+
# @param hash [Hash{String => Array<generic<T>>}]
|
|
142
142
|
#
|
|
143
143
|
# @return [void]
|
|
144
144
|
def map_references klass, hash
|
|
@@ -150,26 +150,32 @@ module Solargraph
|
|
|
150
150
|
|
|
151
151
|
# @return [void]
|
|
152
152
|
def map_overrides
|
|
153
|
+
# @todo should complain when type for 'ovr' is not provided
|
|
153
154
|
# @param ovr [Pin::Reference::Override]
|
|
154
155
|
pins_by_class(Pin::Reference::Override).each do |ovr|
|
|
155
156
|
logger.debug { "ApiMap::Index#map_overrides: Looking at override #{ovr} for #{ovr.name}" }
|
|
156
157
|
pins = path_pin_hash[ovr.name]
|
|
157
158
|
logger.debug { "ApiMap::Index#map_overrides: pins for path=#{ovr.name}: #{pins}" }
|
|
158
159
|
pins.each do |pin|
|
|
159
|
-
new_pin = if pin.path.end_with?('#initialize')
|
|
160
|
-
path_pin_hash[pin.path.sub(/#initialize/, '.new')].first
|
|
161
|
-
end
|
|
160
|
+
new_pin = (path_pin_hash[pin.path.sub('#initialize', '.new')].first if pin.path.end_with?('#initialize'))
|
|
162
161
|
(ovr.tags.map(&:tag_name) + ovr.delete).uniq.each do |tag|
|
|
162
|
+
# @sg-ignore Wrong argument type for
|
|
163
|
+
# YARD::Docstring#delete_tags: name expected String,
|
|
164
|
+
# received String, Symbol - delete_tags is ok with a
|
|
165
|
+
# _ToS, but we should fix anyway
|
|
163
166
|
pin.docstring.delete_tags tag
|
|
164
|
-
new_pin
|
|
167
|
+
new_pin&.docstring&.delete_tags tag
|
|
165
168
|
end
|
|
166
169
|
ovr.tags.each do |tag|
|
|
167
170
|
pin.docstring.add_tag(tag)
|
|
168
171
|
redefine_return_type pin, tag
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
172
|
+
pin.reset_generated!
|
|
173
|
+
|
|
174
|
+
next unless new_pin
|
|
175
|
+
|
|
176
|
+
new_pin.docstring.add_tag(tag)
|
|
177
|
+
redefine_return_type new_pin, tag
|
|
178
|
+
new_pin.reset_generated!
|
|
173
179
|
end
|
|
174
180
|
end
|
|
175
181
|
end
|
|
@@ -186,7 +192,6 @@ module Solargraph
|
|
|
186
192
|
pin.signatures.each do |sig|
|
|
187
193
|
sig.instance_variable_set(:@return_type, ComplexType.try_parse(tag.type))
|
|
188
194
|
end
|
|
189
|
-
pin.reset_generated!
|
|
190
195
|
end
|
|
191
196
|
end
|
|
192
197
|
end
|
|
@@ -3,16 +3,18 @@
|
|
|
3
3
|
module Solargraph
|
|
4
4
|
class ApiMap
|
|
5
5
|
module SourceToYard
|
|
6
|
-
|
|
7
6
|
# Get the YARD CodeObject at the specified path.
|
|
8
7
|
#
|
|
8
|
+
# @sg-ignore Declared return type generic<T>, nil does not match
|
|
9
|
+
# inferred type ::YARD::CodeObjects::Base, nil for
|
|
10
|
+
# Solargraph::ApiMap::SourceToYard#code_object_at
|
|
9
11
|
# @generic T
|
|
10
12
|
# @param path [String]
|
|
11
13
|
# @param klass [Class<generic<T>>]
|
|
12
14
|
# @return [generic<T>, nil]
|
|
13
15
|
def code_object_at path, klass = YARD::CodeObjects::Base
|
|
14
16
|
obj = code_object_map[path]
|
|
15
|
-
obj if obj
|
|
17
|
+
obj if obj.is_a?(klass)
|
|
16
18
|
end
|
|
17
19
|
|
|
18
20
|
# @return [Array<String>]
|
|
@@ -33,16 +35,20 @@ module Solargraph
|
|
|
33
35
|
end
|
|
34
36
|
if pin.type == :class
|
|
35
37
|
# @param obj [YARD::CodeObjects::RootObject]
|
|
36
|
-
code_object_map[pin.path] ||= YARD::CodeObjects::ClassObject.new(root_code_object, pin.path)
|
|
38
|
+
code_object_map[pin.path] ||= YARD::CodeObjects::ClassObject.new(root_code_object, pin.path) do |obj|
|
|
39
|
+
# @sg-ignore flow sensitive typing needs to handle attrs
|
|
37
40
|
next if pin.location.nil? || pin.location.filename.nil?
|
|
41
|
+
# @sg-ignore flow sensitive typing needs to handle attrs
|
|
38
42
|
obj.add_file(pin.location.filename, pin.location.range.start.line, !pin.comments.empty?)
|
|
39
|
-
|
|
43
|
+
end
|
|
40
44
|
else
|
|
41
45
|
# @param obj [YARD::CodeObjects::RootObject]
|
|
42
|
-
code_object_map[pin.path] ||= YARD::CodeObjects::ModuleObject.new(root_code_object, pin.path)
|
|
46
|
+
code_object_map[pin.path] ||= YARD::CodeObjects::ModuleObject.new(root_code_object, pin.path) do |obj|
|
|
47
|
+
# @sg-ignore flow sensitive typing needs to handle attrs
|
|
43
48
|
next if pin.location.nil? || pin.location.filename.nil?
|
|
49
|
+
# @sg-ignore flow sensitive typing needs to handle attrs
|
|
44
50
|
obj.add_file(pin.location.filename, pin.location.range.start.line, !pin.comments.empty?)
|
|
45
|
-
|
|
51
|
+
end
|
|
46
52
|
end
|
|
47
53
|
code_object_map[pin.path].docstring = pin.docstring
|
|
48
54
|
store.get_includes(pin.path).each do |ref|
|
|
@@ -57,7 +63,6 @@ module Solargraph
|
|
|
57
63
|
code_object = code_object_map[ref.type.to_s]
|
|
58
64
|
next unless code_object
|
|
59
65
|
extend_object.class_mixins.push code_object
|
|
60
|
-
# @todo add spec showing why this next line is necessary
|
|
61
66
|
extend_object.instance_mixins.push code_object
|
|
62
67
|
end
|
|
63
68
|
end
|
|
@@ -67,14 +72,22 @@ module Solargraph
|
|
|
67
72
|
next
|
|
68
73
|
end
|
|
69
74
|
|
|
75
|
+
# @sg-ignore Need to add nil check here
|
|
70
76
|
# @param obj [YARD::CodeObjects::RootObject]
|
|
71
|
-
code_object_map[pin.path] ||= YARD::CodeObjects::MethodObject.new(
|
|
77
|
+
code_object_map[pin.path] ||= YARD::CodeObjects::MethodObject.new(
|
|
78
|
+
code_object_at(pin.namespace, YARD::CodeObjects::NamespaceObject), pin.name, pin.scope
|
|
79
|
+
) do |obj|
|
|
80
|
+
# @sg-ignore flow sensitive typing needs to handle attrs
|
|
72
81
|
next if pin.location.nil? || pin.location.filename.nil?
|
|
82
|
+
# @sg-ignore flow sensitive typing needs to handle attrs
|
|
73
83
|
obj.add_file pin.location.filename, pin.location.range.start.line
|
|
74
|
-
|
|
84
|
+
end
|
|
75
85
|
method_object = code_object_at(pin.path, YARD::CodeObjects::MethodObject)
|
|
86
|
+
# @sg-ignore Need to add nil check here
|
|
76
87
|
method_object.docstring = pin.docstring
|
|
88
|
+
# @sg-ignore Need to add nil check here
|
|
77
89
|
method_object.visibility = pin.visibility || :public
|
|
90
|
+
# @sg-ignore Need to add nil check here
|
|
78
91
|
method_object.parameters = pin.parameters.map do |p|
|
|
79
92
|
[p.full_name, p.asgn_code]
|
|
80
93
|
end
|
|
@@ -32,15 +32,16 @@ module Solargraph
|
|
|
32
32
|
|
|
33
33
|
# @todo Fix this map
|
|
34
34
|
@fqns_pins_map = nil
|
|
35
|
-
return catalog(pinsets) if changed
|
|
35
|
+
return catalog(pinsets) if changed.zero?
|
|
36
36
|
|
|
37
|
+
# @sg-ignore Need to add nil check here
|
|
37
38
|
pinsets[changed..].each_with_index do |pins, idx|
|
|
38
39
|
@pinsets[changed + idx] = pins
|
|
39
40
|
@indexes[changed + idx] = if pins.empty?
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
41
|
+
@indexes[changed + idx - 1]
|
|
42
|
+
else
|
|
43
|
+
@indexes[changed + idx - 1].merge(pins)
|
|
44
|
+
end
|
|
44
45
|
end
|
|
45
46
|
constants.clear
|
|
46
47
|
cached_qualify_superclass.clear
|
|
@@ -59,10 +60,10 @@ module Solargraph
|
|
|
59
60
|
# @param visibility [Array<Symbol>]
|
|
60
61
|
# @return [Enumerable<Solargraph::Pin::Namespace, Solargraph::Pin::Constant>]
|
|
61
62
|
def get_constants fqns, visibility = [:public]
|
|
62
|
-
namespace_children(fqns).select
|
|
63
|
-
# @sg-ignore flow
|
|
63
|
+
namespace_children(fqns).select do |pin|
|
|
64
|
+
# @sg-ignore flow sensitive typing not smart enough to handle this case
|
|
64
65
|
!pin.name.empty? && (pin.is_a?(Pin::Namespace) || pin.is_a?(Pin::Constant)) && visibility.include?(pin.visibility)
|
|
65
|
-
|
|
66
|
+
end
|
|
66
67
|
end
|
|
67
68
|
|
|
68
69
|
# @param fqns [String]
|
|
@@ -71,17 +72,18 @@ module Solargraph
|
|
|
71
72
|
# @return [Enumerable<Solargraph::Pin::Method>]
|
|
72
73
|
def get_methods fqns, scope: :instance, visibility: [:public]
|
|
73
74
|
all_pins = namespace_children(fqns).select do |pin|
|
|
74
|
-
# @sg-ignore https://github.com/castwide/solargraph/pull/1114
|
|
75
75
|
pin.is_a?(Pin::Method) && pin.scope == scope && visibility.include?(pin.visibility)
|
|
76
76
|
end
|
|
77
77
|
GemPins.combine_method_pins_by_path(all_pins)
|
|
78
78
|
end
|
|
79
79
|
|
|
80
|
-
BOOLEAN_SUPERCLASS_PIN = Pin::Reference::Superclass.new(name: 'Boolean', closure: Pin::ROOT_PIN,
|
|
81
|
-
|
|
80
|
+
BOOLEAN_SUPERCLASS_PIN = Pin::Reference::Superclass.new(name: 'Boolean', closure: Pin::ROOT_PIN,
|
|
81
|
+
source: :solargraph)
|
|
82
|
+
OBJECT_SUPERCLASS_PIN = Pin::Reference::Superclass.new(name: 'Object', closure: Pin::ROOT_PIN,
|
|
83
|
+
source: :solargraph)
|
|
82
84
|
|
|
83
|
-
# @param fqns [String]
|
|
84
|
-
# @return [Pin::Reference::Superclass]
|
|
85
|
+
# @param fqns [String, nil]
|
|
86
|
+
# @return [Pin::Reference::Superclass, nil]
|
|
85
87
|
def get_superclass fqns
|
|
86
88
|
return nil if fqns.nil? || fqns.empty?
|
|
87
89
|
return BOOLEAN_SUPERCLASS_PIN if %w[TrueClass FalseClass].include?(fqns)
|
|
@@ -126,20 +128,20 @@ module Solargraph
|
|
|
126
128
|
index.path_pin_hash[path]
|
|
127
129
|
end
|
|
128
130
|
|
|
129
|
-
# @param fqns [String]
|
|
131
|
+
# @param fqns [String, nil]
|
|
130
132
|
# @param scope [Symbol] :class or :instance
|
|
131
133
|
# @return [Enumerable<Solargraph::Pin::Base>]
|
|
132
|
-
def get_instance_variables
|
|
133
|
-
all_instance_variables.select
|
|
134
|
+
def get_instance_variables fqns, scope = :instance
|
|
135
|
+
all_instance_variables.select do |pin|
|
|
134
136
|
pin.binder.namespace == fqns && pin.binder.scope == scope
|
|
135
|
-
|
|
137
|
+
end
|
|
136
138
|
end
|
|
137
139
|
|
|
138
140
|
# @param fqns [String]
|
|
139
141
|
#
|
|
140
142
|
# @return [Enumerable<Solargraph::Pin::ClassVariable>]
|
|
141
|
-
def get_class_variables
|
|
142
|
-
namespace_children(fqns).select { |pin| pin.is_a?(Pin::ClassVariable)}
|
|
143
|
+
def get_class_variables fqns
|
|
144
|
+
namespace_children(fqns).select { |pin| pin.is_a?(Pin::ClassVariable) }
|
|
143
145
|
end
|
|
144
146
|
|
|
145
147
|
# @return [Enumerable<Solargraph::Pin::Base>]
|
|
@@ -149,7 +151,7 @@ module Solargraph
|
|
|
149
151
|
|
|
150
152
|
# @param fqns [String]
|
|
151
153
|
# @return [Boolean]
|
|
152
|
-
def namespace_exists?
|
|
154
|
+
def namespace_exists? fqns
|
|
153
155
|
fqns_pins(fqns).any?
|
|
154
156
|
end
|
|
155
157
|
|
|
@@ -165,7 +167,7 @@ module Solargraph
|
|
|
165
167
|
|
|
166
168
|
# @param fqns [String]
|
|
167
169
|
# @return [Array<String>]
|
|
168
|
-
def domains
|
|
170
|
+
def domains fqns
|
|
169
171
|
result = []
|
|
170
172
|
fqns_pins(fqns).each do |nspin|
|
|
171
173
|
result.concat nspin.domains
|
|
@@ -178,7 +180,7 @@ module Solargraph
|
|
|
178
180
|
@named_macros ||= begin
|
|
179
181
|
result = {}
|
|
180
182
|
pins.each do |pin|
|
|
181
|
-
pin.macros.select{|m| m.tag.tag_name == 'macro' && !m.tag.text.empty? }.each do |macro|
|
|
183
|
+
pin.macros.select { |m| m.tag.tag_name == 'macro' && !m.tag.text.empty? }.each do |macro|
|
|
182
184
|
next if macro.tag.name.nil? || macro.tag.name.empty?
|
|
183
185
|
result[macro.tag.name] = macro
|
|
184
186
|
end
|
|
@@ -199,7 +201,7 @@ module Solargraph
|
|
|
199
201
|
index.pins_by_class klass
|
|
200
202
|
end
|
|
201
203
|
|
|
202
|
-
# @param fqns [String]
|
|
204
|
+
# @param fqns [String, nil]
|
|
203
205
|
# @return [Array<Solargraph::Pin::Namespace>]
|
|
204
206
|
def fqns_pins fqns
|
|
205
207
|
return [] if fqns.nil?
|
|
@@ -217,7 +219,7 @@ module Solargraph
|
|
|
217
219
|
# Get all ancestors (superclasses, includes, prepends, extends) for a namespace
|
|
218
220
|
# @param fqns [String] The fully qualified namespace
|
|
219
221
|
# @return [Array<String>] Array of ancestor namespaces including the original
|
|
220
|
-
def get_ancestors
|
|
222
|
+
def get_ancestors fqns
|
|
221
223
|
return [] if fqns.nil? || fqns.empty?
|
|
222
224
|
|
|
223
225
|
ancestors = [fqns]
|
|
@@ -244,8 +246,11 @@ module Solargraph
|
|
|
244
246
|
next if refs.nil?
|
|
245
247
|
# @param ref [String]
|
|
246
248
|
refs.map(&:type).map(&:to_s).each do |ref|
|
|
249
|
+
# @sg-ignore flow sensitive typing should be able to handle redefinition
|
|
247
250
|
next if ref.nil? || ref.empty? || visited.include?(ref)
|
|
251
|
+
# @sg-ignore flow sensitive typing should be able to handle redefinition
|
|
248
252
|
ancestors << ref
|
|
253
|
+
# @sg-ignore flow sensitive typing should be able to handle redefinition
|
|
249
254
|
queue << ref
|
|
250
255
|
end
|
|
251
256
|
end
|
|
@@ -257,7 +262,7 @@ module Solargraph
|
|
|
257
262
|
# @param fqns [String]
|
|
258
263
|
#
|
|
259
264
|
# @return [Array<Solargraph::Pin::Reference>]
|
|
260
|
-
def get_ancestor_references
|
|
265
|
+
def get_ancestor_references fqns
|
|
261
266
|
(get_prepends(fqns) + get_includes(fqns) + [get_superclass(fqns)]).compact
|
|
262
267
|
end
|
|
263
268
|
|
|
@@ -275,7 +280,7 @@ module Solargraph
|
|
|
275
280
|
|
|
276
281
|
# @param pinsets [Array<Array<Pin::Base>>]
|
|
277
282
|
#
|
|
278
|
-
# @return [
|
|
283
|
+
# @return [true]
|
|
279
284
|
def catalog pinsets
|
|
280
285
|
@pinsets = pinsets
|
|
281
286
|
# @type [Array<Index>]
|
|
@@ -308,7 +313,7 @@ module Solargraph
|
|
|
308
313
|
index.pins_by_class(Pin::Symbol)
|
|
309
314
|
end
|
|
310
315
|
|
|
311
|
-
# @return [Hash{String => Array<
|
|
316
|
+
# @return [Hash{String => Array<Pin::Reference::Superclass>}]
|
|
312
317
|
def superclass_references
|
|
313
318
|
index.superclass_references
|
|
314
319
|
end
|
|
@@ -347,7 +352,7 @@ module Solargraph
|
|
|
347
352
|
|
|
348
353
|
# @param fqns [String]
|
|
349
354
|
# @return [Pin::Reference::Superclass, nil]
|
|
350
|
-
def try_special_superclasses
|
|
355
|
+
def try_special_superclasses fqns
|
|
351
356
|
return OBJECT_SUPERCLASS_PIN if fqns == 'Boolean'
|
|
352
357
|
return OBJECT_SUPERCLASS_PIN if !%w[BasicObject Object].include?(fqns) && namespace_exists?(fqns)
|
|
353
358
|
|