solargraph 0.58.3 → 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/.envrc +3 -0
- data/.github/workflows/linting.yml +12 -5
- data/.github/workflows/plugins.yml +54 -34
- data/.github/workflows/rspec.yml +15 -28
- data/.github/workflows/typecheck.yml +6 -3
- data/.rubocop.yml +38 -6
- data/.rubocop_todo.yml +53 -966
- data/CHANGELOG.md +24 -0
- 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 +12 -3
- data/lib/solargraph/api_map/index.rb +29 -18
- data/lib/solargraph/api_map/source_to_yard.rb +22 -9
- data/lib/solargraph/api_map/store.rb +40 -30
- data/lib/solargraph/api_map.rb +160 -78
- data/lib/solargraph/bench.rb +2 -3
- data/lib/solargraph/complex_type/conformance.rb +176 -0
- data/lib/solargraph/complex_type/type_methods.rb +31 -18
- data/lib/solargraph/complex_type/unique_type.rb +221 -63
- data/lib/solargraph/complex_type.rb +173 -59
- data/lib/solargraph/convention/active_support_concern.rb +111 -111
- data/lib/solargraph/convention/base.rb +50 -50
- data/lib/solargraph/convention/data_definition/data_assignment_node.rb +1 -1
- 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 +1 -1
- data/lib/solargraph/convention/gemspec.rb +1 -1
- data/lib/solargraph/convention/rakefile.rb +1 -1
- 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 +2 -2
- data/lib/solargraph/converters/dd.rb +2 -0
- data/lib/solargraph/converters/dl.rb +2 -0
- data/lib/solargraph/converters/dt.rb +2 -0
- data/lib/solargraph/converters/misc.rb +2 -0
- 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 +4 -8
- data/lib/solargraph/diagnostics.rb +55 -55
- data/lib/solargraph/doc_map.rb +38 -39
- data/lib/solargraph/environ.rb +52 -52
- data/lib/solargraph/equality.rb +4 -4
- data/lib/solargraph/gem_pins.rb +4 -15
- data/lib/solargraph/language_server/error_codes.rb +10 -10
- 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 +35 -28
- data/lib/solargraph/language_server/message/base.rb +1 -1
- data/lib/solargraph/language_server/message/client/register_capability.rb +1 -3
- data/lib/solargraph/language_server/message/completion_item/resolve.rb +6 -8
- 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 +7 -7
- data/lib/solargraph/language_server/message/extended/download_core.rb +2 -1
- data/lib/solargraph/language_server/message/extended/environment.rb +25 -25
- data/lib/solargraph/language_server/message/extended/search.rb +1 -1
- data/lib/solargraph/language_server/message/initialize.rb +20 -14
- data/lib/solargraph/language_server/message/initialized.rb +28 -28
- 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 +17 -10
- 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 +13 -6
- data/lib/solargraph/language_server/message/text_document/references.rb +17 -10
- data/lib/solargraph/language_server/message/text_document/rename.rb +20 -13
- 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/text_document.rb +28 -28
- data/lib/solargraph/language_server/message/workspace/did_change_configuration.rb +34 -28
- data/lib/solargraph/language_server/message/workspace/did_change_watched_files.rb +38 -30
- data/lib/solargraph/language_server/message/workspace/did_change_workspace_folders.rb +23 -17
- data/lib/solargraph/language_server/message/workspace/workspace_symbol.rb +27 -17
- data/lib/solargraph/language_server/message.rb +1 -1
- data/lib/solargraph/language_server/progress.rb +143 -143
- data/lib/solargraph/language_server/request.rb +4 -2
- data/lib/solargraph/language_server/transport/adapter.rb +68 -68
- data/lib/solargraph/language_server/transport/data_reader.rb +11 -13
- data/lib/solargraph/language_server/uri_helpers.rb +2 -2
- data/lib/solargraph/language_server.rb +20 -20
- data/lib/solargraph/library.rb +57 -38
- data/lib/solargraph/location.rb +17 -14
- data/lib/solargraph/logging.rb +22 -4
- data/lib/solargraph/page.rb +1 -1
- data/lib/solargraph/parser/comment_ripper.rb +19 -4
- data/lib/solargraph/parser/flow_sensitive_typing.rb +324 -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 +30 -14
- data/lib/solargraph/parser/parser_gem/flawed_builder.rb +1 -1
- data/lib/solargraph/parser/parser_gem/node_chainer.rb +51 -25
- data/lib/solargraph/parser/parser_gem/node_methods.rb +181 -73
- data/lib/solargraph/parser/parser_gem/node_processors/alias_node.rb +24 -24
- 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 +11 -12
- 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/def_node.rb +10 -3
- data/lib/solargraph/parser/parser_gem/node_processors/defs_node.rb +9 -8
- data/lib/solargraph/parser/parser_gem/node_processors/gvasgn_node.rb +24 -24
- 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/namespace_node.rb +40 -40
- 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/sym_node.rb +20 -20
- data/lib/solargraph/parser/parser_gem/node_processors/until_node.rb +1 -1
- 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 +2 -0
- data/lib/solargraph/parser/region.rb +9 -3
- data/lib/solargraph/parser/snippet.rb +3 -1
- data/lib/solargraph/parser.rb +2 -0
- data/lib/solargraph/pin/base.rb +126 -82
- 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 +3 -5
- 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 +158 -104
- data/lib/solargraph/pin/method_alias.rb +8 -0
- data/lib/solargraph/pin/namespace.rb +19 -12
- data/lib/solargraph/pin/parameter.rb +102 -36
- data/lib/solargraph/pin/proxy_type.rb +4 -1
- data/lib/solargraph/pin/reference/override.rb +1 -1
- data/lib/solargraph/pin/reference/require.rb +14 -14
- data/lib/solargraph/pin/reference/superclass.rb +2 -0
- data/lib/solargraph/pin/reference/type_alias.rb +16 -0
- data/lib/solargraph/pin/reference.rb +20 -0
- data/lib/solargraph/pin/search.rb +8 -7
- data/lib/solargraph/pin/signature.rb +15 -12
- data/lib/solargraph/pin/singleton.rb +11 -11
- 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 +22 -19
- data/lib/solargraph/position.rb +17 -10
- data/lib/solargraph/range.rb +16 -15
- data/lib/solargraph/rbs_map/conversions.rb +367 -231
- data/lib/solargraph/rbs_map/core_fills.rb +18 -11
- 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 +76 -32
- data/lib/solargraph/server_methods.rb +1 -1
- data/lib/solargraph/shell.rb +258 -66
- data/lib/solargraph/source/chain/array.rb +3 -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/call.rb +96 -56
- data/lib/solargraph/source/chain/class_variable.rb +1 -1
- data/lib/solargraph/source/chain/constant.rb +5 -1
- data/lib/solargraph/source/chain/global_variable.rb +1 -1
- data/lib/solargraph/source/chain/hash.rb +8 -5
- data/lib/solargraph/source/chain/head.rb +19 -19
- 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 +12 -22
- data/lib/solargraph/source/chain/literal.rb +22 -15
- data/lib/solargraph/source/chain/or.rb +10 -4
- data/lib/solargraph/source/chain/q_call.rb +2 -0
- data/lib/solargraph/source/chain/variable.rb +3 -1
- data/lib/solargraph/source/chain/z_super.rb +1 -3
- data/lib/solargraph/source/chain.rb +51 -38
- data/lib/solargraph/source/change.rb +12 -5
- data/lib/solargraph/source/cursor.rb +33 -18
- 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 +54 -30
- data/lib/solargraph/source_map/data.rb +4 -1
- data/lib/solargraph/source_map/mapper.rb +69 -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 +196 -122
- data/lib/solargraph/version.rb +1 -1
- data/lib/solargraph/workspace/config.rb +14 -11
- data/lib/solargraph/workspace/gemspecs.rb +367 -0
- data/lib/solargraph/workspace/require_paths.rb +1 -0
- data/lib/solargraph/workspace.rb +50 -28
- data/lib/solargraph/yard_map/cache.rb +25 -25
- data/lib/solargraph/yard_map/helpers.rb +8 -3
- data/lib/solargraph/yard_map/mapper/to_constant.rb +28 -28
- 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_map.rb +17 -18
- data/lib/solargraph/yard_tags.rb +2 -2
- data/lib/solargraph/yardoc.rb +7 -4
- data/lib/solargraph.rb +33 -10
- data/rbs/fills/rubygems/0/dependency.rbs +193 -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 +37 -35
- metadata +41 -42
- 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/rbs/fills/tuple/tuple.rbs +0 -149
|
@@ -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
|
|
@@ -8,38 +8,45 @@ module Solargraph
|
|
|
8
8
|
def process
|
|
9
9
|
name = node.children[0].to_s
|
|
10
10
|
scope = region.scope || (region.closure.is_a?(Pin::Singleton) ? :class : :instance)
|
|
11
|
+
# specify context explicitly instead of relying on
|
|
12
|
+
# closure, as they may differ (e.g., defs inside
|
|
13
|
+
# class_eval)
|
|
14
|
+
method_context = scope == :instance ? region.closure.binder.namespace_type : region.closure.binder
|
|
11
15
|
methpin = Solargraph::Pin::Method.new(
|
|
12
16
|
location: get_node_location(node),
|
|
13
17
|
closure: region.closure,
|
|
14
18
|
name: name,
|
|
19
|
+
context: method_context,
|
|
15
20
|
comments: comments_for(node),
|
|
16
21
|
scope: scope,
|
|
17
22
|
visibility: scope == :instance && name == 'initialize' ? :private : region.visibility,
|
|
18
23
|
node: node,
|
|
19
|
-
source: :parser
|
|
24
|
+
source: :parser
|
|
20
25
|
)
|
|
21
26
|
if region.visibility == :module_function
|
|
22
27
|
pins.push Solargraph::Pin::Method.new(
|
|
23
28
|
location: methpin.location,
|
|
24
29
|
closure: methpin.closure,
|
|
25
30
|
name: methpin.name,
|
|
31
|
+
context: method_context,
|
|
26
32
|
comments: methpin.comments,
|
|
27
33
|
scope: :class,
|
|
28
34
|
visibility: :public,
|
|
29
35
|
parameters: methpin.parameters,
|
|
30
36
|
node: methpin.node,
|
|
31
|
-
source: :parser
|
|
37
|
+
source: :parser
|
|
32
38
|
)
|
|
33
39
|
pins.push Solargraph::Pin::Method.new(
|
|
34
40
|
location: methpin.location,
|
|
35
41
|
closure: methpin.closure,
|
|
36
42
|
name: methpin.name,
|
|
43
|
+
context: method_context,
|
|
37
44
|
comments: methpin.comments,
|
|
38
45
|
scope: :instance,
|
|
39
46
|
visibility: :private,
|
|
40
47
|
parameters: methpin.parameters,
|
|
41
48
|
node: methpin.node,
|
|
42
|
-
source: :parser
|
|
49
|
+
source: :parser
|
|
43
50
|
)
|
|
44
51
|
else
|
|
45
52
|
pins.push methpin
|
|
@@ -11,13 +11,14 @@ module Solargraph
|
|
|
11
11
|
s_visi = region.visibility
|
|
12
12
|
s_visi = :public if s_visi == :module_function || region.scope != :class
|
|
13
13
|
loc = get_node_location(node)
|
|
14
|
-
if node.children[0].is_a?(AST::Node) && node.children[0].type == :self
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
14
|
+
closure = if node.children[0].is_a?(AST::Node) && node.children[0].type == :self
|
|
15
|
+
region.closure
|
|
16
|
+
else
|
|
17
|
+
Solargraph::Pin::Namespace.new(
|
|
18
|
+
name: unpack_name(node.children[0]),
|
|
19
|
+
source: :parser
|
|
20
|
+
)
|
|
21
|
+
end
|
|
21
22
|
pins.push Solargraph::Pin::Method.new(
|
|
22
23
|
location: loc,
|
|
23
24
|
closure: closure,
|
|
@@ -26,7 +27,7 @@ module Solargraph
|
|
|
26
27
|
scope: :class,
|
|
27
28
|
visibility: s_visi,
|
|
28
29
|
node: node,
|
|
29
|
-
source: :parser
|
|
30
|
+
source: :parser
|
|
30
31
|
)
|
|
31
32
|
process_children region.update(closure: pins.last, scope: :class)
|
|
32
33
|
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
|
|
@@ -8,13 +8,43 @@ module Solargraph
|
|
|
8
8
|
include ParserGem::NodeMethods
|
|
9
9
|
|
|
10
10
|
def process
|
|
11
|
-
|
|
11
|
+
FlowSensitiveTyping.new(locals,
|
|
12
|
+
ivars,
|
|
13
|
+
enclosing_breakable_pin,
|
|
14
|
+
enclosing_compound_statement_pin).process_if(node)
|
|
15
|
+
condition_node = node.children[0]
|
|
16
|
+
if condition_node
|
|
17
|
+
pins.push Solargraph::Pin::CompoundStatement.new(
|
|
18
|
+
location: get_node_location(condition_node),
|
|
19
|
+
closure: region.closure,
|
|
20
|
+
node: condition_node,
|
|
21
|
+
source: :parser
|
|
22
|
+
)
|
|
23
|
+
NodeProcessor.process(condition_node, region, pins, locals, ivars)
|
|
24
|
+
end
|
|
25
|
+
then_node = node.children[1]
|
|
26
|
+
if then_node
|
|
27
|
+
pins.push Solargraph::Pin::CompoundStatement.new(
|
|
28
|
+
location: get_node_location(then_node),
|
|
29
|
+
closure: region.closure,
|
|
30
|
+
node: then_node,
|
|
31
|
+
source: :parser
|
|
32
|
+
)
|
|
33
|
+
NodeProcessor.process(then_node, region, pins, locals, ivars)
|
|
34
|
+
end
|
|
12
35
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
36
|
+
else_node = node.children[2]
|
|
37
|
+
if else_node
|
|
38
|
+
pins.push Solargraph::Pin::CompoundStatement.new(
|
|
39
|
+
location: get_node_location(else_node),
|
|
40
|
+
closure: region.closure,
|
|
41
|
+
node: else_node,
|
|
42
|
+
source: :parser
|
|
43
|
+
)
|
|
44
|
+
NodeProcessor.process(else_node, region, pins, locals, ivars)
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
true
|
|
18
48
|
end
|
|
19
49
|
end
|
|
20
50
|
end
|
|
@@ -9,7 +9,7 @@ module Solargraph
|
|
|
9
9
|
|
|
10
10
|
def process
|
|
11
11
|
loc = get_node_location(node)
|
|
12
|
-
|
|
12
|
+
ivars.push Solargraph::Pin::InstanceVariable.new(
|
|
13
13
|
location: loc,
|
|
14
14
|
closure: region.closure,
|
|
15
15
|
name: node.children[0].to_s,
|
|
@@ -19,11 +19,13 @@ module Solargraph
|
|
|
19
19
|
)
|
|
20
20
|
if region.visibility == :module_function
|
|
21
21
|
here = get_node_start_position(node)
|
|
22
|
+
# @type [Pin::Closure, nil]
|
|
22
23
|
named_path = named_path_pin(here)
|
|
23
24
|
if named_path.is_a?(Pin::Method)
|
|
24
|
-
|
|
25
|
+
ivars.push Solargraph::Pin::InstanceVariable.new(
|
|
25
26
|
location: loc,
|
|
26
|
-
closure: Pin::Namespace.new(type: :module, closure: region.closure.closure,
|
|
27
|
+
closure: Pin::Namespace.new(type: :module, closure: region.closure.closure,
|
|
28
|
+
name: region.closure.name),
|
|
27
29
|
name: node.children[0].to_s,
|
|
28
30
|
comments: comments_for(node),
|
|
29
31
|
assignment: node.children[1],
|
|
@@ -9,6 +9,7 @@ module Solargraph
|
|
|
9
9
|
|
|
10
10
|
def process
|
|
11
11
|
here = get_node_start_position(node)
|
|
12
|
+
# @sg-ignore Need to add nil check here
|
|
12
13
|
presence = Range.new(here, region.closure.location.range.ending)
|
|
13
14
|
loc = get_node_location(node)
|
|
14
15
|
locals.push Solargraph::Pin::LocalVariable.new(
|
|
@@ -37,8 +37,10 @@ module Solargraph
|
|
|
37
37
|
pin = if lhs.type == :lvasgn
|
|
38
38
|
# lvasgn is a local variable
|
|
39
39
|
locals.find { |l| l.location == location }
|
|
40
|
+
elsif lhs.type == :ivasgn
|
|
41
|
+
# ivasgn is an instance variable assignment
|
|
42
|
+
ivars.find { |iv| iv.location == location }
|
|
40
43
|
else
|
|
41
|
-
# e.g., ivasgn is an instance variable, etc
|
|
42
44
|
pins.find { |iv| iv.location == location && iv.is_a?(Pin::BaseVariable) }
|
|
43
45
|
end
|
|
44
46
|
# @todo in line below, nothing in typechecking alerts
|
|
@@ -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
|
|
@@ -57,7 +57,7 @@ module Solargraph
|
|
|
57
57
|
[callee,
|
|
58
58
|
asgn_method,
|
|
59
59
|
node.updated(:send, [call, operator, argument])])
|
|
60
|
-
NodeProcessor.process(new_send, region, pins, locals)
|
|
60
|
+
NodeProcessor.process(new_send, region, pins, locals, ivars)
|
|
61
61
|
end
|
|
62
62
|
|
|
63
63
|
# @param asgn [Parser::AST::Node] the target of the assignment
|
|
@@ -88,8 +88,8 @@ module Solargraph
|
|
|
88
88
|
argument
|
|
89
89
|
]
|
|
90
90
|
send_node = node.updated(:send, send_children)
|
|
91
|
-
new_asgn = node.updated(asgn.type, [variable_name,
|
|
92
|
-
NodeProcessor.process(new_asgn, region, pins, locals)
|
|
91
|
+
new_asgn = node.updated(asgn.type, [variable_name, send_node])
|
|
92
|
+
NodeProcessor.process(new_asgn, region, pins, locals, ivars)
|
|
93
93
|
end
|
|
94
94
|
end
|
|
95
95
|
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Solargraph
|
|
4
|
+
module Parser
|
|
5
|
+
module ParserGem
|
|
6
|
+
module NodeProcessors
|
|
7
|
+
class OrNode < Parser::NodeProcessor::Base
|
|
8
|
+
include ParserGem::NodeMethods
|
|
9
|
+
|
|
10
|
+
def process
|
|
11
|
+
process_children
|
|
12
|
+
|
|
13
|
+
FlowSensitiveTyping.new(locals,
|
|
14
|
+
ivars,
|
|
15
|
+
enclosing_breakable_pin,
|
|
16
|
+
enclosing_compound_statement_pin).process_or(node)
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -8,7 +8,7 @@ module Solargraph
|
|
|
8
8
|
# @return [void]
|
|
9
9
|
def process
|
|
10
10
|
new_node = node.updated(node.children[0].type, node.children[0].children + [node.children[1]])
|
|
11
|
-
NodeProcessor.process(new_node, region, pins, locals)
|
|
11
|
+
NodeProcessor.process(new_node, region, pins, locals, ivars)
|
|
12
12
|
end
|
|
13
13
|
end
|
|
14
14
|
end
|
|
@@ -11,6 +11,7 @@ module Solargraph
|
|
|
11
11
|
def process
|
|
12
12
|
if node.children[1] # Exception local variable name
|
|
13
13
|
here = get_node_start_position(node.children[1])
|
|
14
|
+
# @sg-ignore Need to add nil check here
|
|
14
15
|
presence = Range.new(here, region.closure.location.range.ending)
|
|
15
16
|
loc = get_node_location(node.children[1])
|
|
16
17
|
types = if node.children[0].nil?
|
|
@@ -29,7 +30,7 @@ module Solargraph
|
|
|
29
30
|
source: :parser
|
|
30
31
|
)
|
|
31
32
|
end
|
|
32
|
-
NodeProcessor.process(node.children[2], region, pins, locals)
|
|
33
|
+
NodeProcessor.process(node.children[2], region, pins, locals, ivars)
|
|
33
34
|
end
|
|
34
35
|
end
|
|
35
36
|
end
|
|
@@ -5,6 +5,7 @@ module Solargraph
|
|
|
5
5
|
module ParserGem
|
|
6
6
|
module NodeProcessors
|
|
7
7
|
class SclassNode < Parser::NodeProcessor::Base
|
|
8
|
+
# @sg-ignore @override is adding, not overriding
|
|
8
9
|
def process
|
|
9
10
|
sclass = node.children[0]
|
|
10
11
|
# @todo Changing Parser::AST::Node to AST::Node below will
|
|
@@ -23,16 +24,14 @@ module Solargraph
|
|
|
23
24
|
if sclass.children[0].nil? && names.last != sclass.children[1].to_s
|
|
24
25
|
names << sclass.children[1].to_s
|
|
25
26
|
else
|
|
26
|
-
names.
|
|
27
|
+
names.push NodeMethods.unpack_name(sclass.children[0]), sclass.children[1].to_s
|
|
27
28
|
end
|
|
28
29
|
name = names.reject(&:empty?).join('::')
|
|
29
30
|
closure = Solargraph::Pin::Namespace.new(name: name, location: region.closure.location, source: :parser)
|
|
30
31
|
elsif sclass.is_a?(::Parser::AST::Node) && sclass.type == :const
|
|
31
32
|
names = [region.closure.namespace, region.closure.name]
|
|
32
33
|
also = NodeMethods.unpack_name(sclass)
|
|
33
|
-
if also != region.closure.name
|
|
34
|
-
names << also
|
|
35
|
-
end
|
|
34
|
+
names << also if also != region.closure.name
|
|
36
35
|
name = names.reject(&:empty?).join('::')
|
|
37
36
|
closure = Solargraph::Pin::Namespace.new(name: name, location: region.closure.location, source: :parser)
|
|
38
37
|
else
|
|
@@ -41,7 +40,7 @@ module Solargraph
|
|
|
41
40
|
pins.push Solargraph::Pin::Singleton.new(
|
|
42
41
|
location: get_node_location(node),
|
|
43
42
|
closure: closure,
|
|
44
|
-
source: :parser
|
|
43
|
+
source: :parser
|
|
45
44
|
)
|
|
46
45
|
process_children region.update(visibility: :public, scope: :class, closure: pins.last)
|
|
47
46
|
end
|