solargraph 0.51.2 → 0.53.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (162) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/plugins.yml +40 -0
  3. data/.github/workflows/rspec.yml +1 -3
  4. data/.github/workflows/typecheck.yml +34 -0
  5. data/.yardopts +2 -2
  6. data/CHANGELOG.md +55 -5
  7. data/README.md +13 -16
  8. data/SPONSORS.md +1 -7
  9. data/lib/solargraph/api_map/cache.rb +60 -20
  10. data/lib/solargraph/api_map/store.rb +47 -11
  11. data/lib/solargraph/api_map.rb +161 -95
  12. data/lib/solargraph/bench.rb +2 -2
  13. data/lib/solargraph/cache.rb +29 -5
  14. data/lib/solargraph/complex_type/type_methods.rb +54 -9
  15. data/lib/solargraph/complex_type/unique_type.rb +155 -58
  16. data/lib/solargraph/complex_type.rb +73 -16
  17. data/lib/solargraph/convention.rb +0 -1
  18. data/lib/solargraph/converters/dd.rb +5 -0
  19. data/lib/solargraph/converters/dl.rb +3 -0
  20. data/lib/solargraph/converters/dt.rb +3 -0
  21. data/lib/solargraph/diagnostics/rubocop.rb +8 -7
  22. data/lib/solargraph/diagnostics/rubocop_helpers.rb +1 -0
  23. data/lib/solargraph/diagnostics/type_check.rb +1 -0
  24. data/lib/solargraph/diagnostics.rb +2 -2
  25. data/lib/solargraph/doc_map.rb +146 -0
  26. data/lib/solargraph/gem_pins.rb +64 -0
  27. data/lib/solargraph/language_server/host/cataloger.rb +1 -0
  28. data/lib/solargraph/language_server/host/diagnoser.rb +2 -2
  29. data/lib/solargraph/language_server/host/dispatch.rb +10 -4
  30. data/lib/solargraph/language_server/host/message_worker.rb +4 -0
  31. data/lib/solargraph/language_server/host/sources.rb +7 -4
  32. data/lib/solargraph/language_server/host.rb +15 -6
  33. data/lib/solargraph/language_server/message/completion_item/resolve.rb +3 -1
  34. data/lib/solargraph/language_server/message/extended/check_gem_version.rb +13 -1
  35. data/lib/solargraph/language_server/message/initialize.rb +5 -2
  36. data/lib/solargraph/language_server/message/text_document/hover.rb +2 -0
  37. data/lib/solargraph/language_server/message/text_document.rb +0 -1
  38. data/lib/solargraph/language_server/message/workspace/did_change_configuration.rb +5 -0
  39. data/lib/solargraph/language_server/transport/adapter.rb +16 -1
  40. data/lib/solargraph/language_server/transport/data_reader.rb +2 -0
  41. data/lib/solargraph/library.rb +70 -16
  42. data/lib/solargraph/location.rb +1 -0
  43. data/lib/solargraph/parser/comment_ripper.rb +4 -0
  44. data/lib/solargraph/parser/node_methods.rb +47 -7
  45. data/lib/solargraph/parser/node_processor/base.rb +9 -0
  46. data/lib/solargraph/parser/{legacy → parser_gem}/class_methods.rb +31 -5
  47. data/lib/solargraph/parser/{legacy → parser_gem}/flawed_builder.rb +3 -1
  48. data/lib/solargraph/parser/{legacy → parser_gem}/node_chainer.rb +49 -36
  49. data/lib/solargraph/parser/parser_gem/node_methods.rb +499 -0
  50. data/lib/solargraph/parser/{rubyvm → parser_gem}/node_processors/alias_node.rb +1 -1
  51. data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/args_node.rb +4 -1
  52. data/lib/solargraph/parser/{rubyvm → parser_gem}/node_processors/begin_node.rb +1 -1
  53. data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/block_node.rb +3 -2
  54. data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/casgn_node.rb +2 -2
  55. data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/cvasgn_node.rb +1 -1
  56. data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/def_node.rb +1 -1
  57. data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/defs_node.rb +2 -2
  58. data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/gvasgn_node.rb +1 -1
  59. data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/ivasgn_node.rb +2 -2
  60. data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/lvasgn_node.rb +2 -2
  61. data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/namespace_node.rb +2 -2
  62. data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/orasgn_node.rb +1 -1
  63. data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/resbody_node.rb +3 -3
  64. data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/sclass_node.rb +1 -1
  65. data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/send_node.rb +2 -2
  66. data/lib/solargraph/parser/{rubyvm → parser_gem}/node_processors/sym_node.rb +1 -1
  67. data/lib/solargraph/parser/parser_gem/node_processors.rb +54 -0
  68. data/lib/solargraph/parser/parser_gem.rb +12 -0
  69. data/lib/solargraph/parser/region.rb +1 -1
  70. data/lib/solargraph/parser/snippet.rb +2 -0
  71. data/lib/solargraph/parser.rb +8 -9
  72. data/lib/solargraph/pin/base.rb +64 -9
  73. data/lib/solargraph/pin/base_variable.rb +6 -2
  74. data/lib/solargraph/pin/block.rb +13 -8
  75. data/lib/solargraph/pin/closure.rb +17 -2
  76. data/lib/solargraph/pin/common.rb +7 -3
  77. data/lib/solargraph/pin/conversions.rb +33 -3
  78. data/lib/solargraph/pin/delegated_method.rb +1 -1
  79. data/lib/solargraph/pin/documenting.rb +25 -34
  80. data/lib/solargraph/pin/instance_variable.rb +4 -0
  81. data/lib/solargraph/pin/local_variable.rb +13 -1
  82. data/lib/solargraph/pin/method.rb +169 -18
  83. data/lib/solargraph/pin/namespace.rb +18 -5
  84. data/lib/solargraph/pin/parameter.rb +44 -14
  85. data/lib/solargraph/pin/reference/override.rb +2 -2
  86. data/lib/solargraph/pin/reference.rb +8 -0
  87. data/lib/solargraph/pin/search.rb +3 -3
  88. data/lib/solargraph/pin/signature.rb +123 -3
  89. data/lib/solargraph/pin.rb +0 -1
  90. data/lib/solargraph/range.rb +2 -2
  91. data/lib/solargraph/rbs_map/conversions.rb +287 -45
  92. data/lib/solargraph/rbs_map/core_fills.rb +6 -29
  93. data/lib/solargraph/rbs_map/core_map.rb +2 -1
  94. data/lib/solargraph/rbs_map/core_signs.rb +2 -0
  95. data/lib/solargraph/rbs_map/stdlib_map.rb +2 -8
  96. data/lib/solargraph/rbs_map.rb +20 -11
  97. data/lib/solargraph/shell.rb +62 -59
  98. data/lib/solargraph/source/chain/array.rb +32 -0
  99. data/lib/solargraph/source/chain/block_symbol.rb +13 -0
  100. data/lib/solargraph/source/chain/call.rb +99 -46
  101. data/lib/solargraph/source/chain/constant.rb +15 -1
  102. data/lib/solargraph/source/chain/if.rb +23 -0
  103. data/lib/solargraph/source/chain/link.rb +8 -2
  104. data/lib/solargraph/source/chain/or.rb +1 -1
  105. data/lib/solargraph/source/chain/z_super.rb +3 -3
  106. data/lib/solargraph/source/chain.rb +29 -14
  107. data/lib/solargraph/source/change.rb +3 -0
  108. data/lib/solargraph/source/cursor.rb +2 -0
  109. data/lib/solargraph/source/source_chainer.rb +8 -5
  110. data/lib/solargraph/source.rb +18 -19
  111. data/lib/solargraph/source_map/clip.rb +11 -23
  112. data/lib/solargraph/source_map/mapper.rb +12 -1
  113. data/lib/solargraph/source_map.rb +15 -5
  114. data/lib/solargraph/type_checker/checks.rb +10 -2
  115. data/lib/solargraph/type_checker.rb +92 -26
  116. data/lib/solargraph/version.rb +1 -1
  117. data/lib/solargraph/workspace/config.rb +8 -6
  118. data/lib/solargraph/workspace.rb +3 -2
  119. data/lib/solargraph/yard_map/cache.rb +6 -0
  120. data/lib/solargraph/yard_map/helpers.rb +1 -1
  121. data/lib/solargraph/yard_map/mapper/to_method.rb +11 -1
  122. data/lib/solargraph/yard_map/mapper.rb +1 -1
  123. data/lib/solargraph/yard_map/to_method.rb +11 -4
  124. data/lib/solargraph/yard_map.rb +1 -292
  125. data/lib/solargraph/yard_tags.rb +20 -0
  126. data/lib/solargraph/yardoc.rb +52 -0
  127. data/lib/solargraph.rb +6 -4
  128. data/solargraph.gemspec +3 -2
  129. metadata +51 -58
  130. data/lib/solargraph/api_map/bundler_methods.rb +0 -22
  131. data/lib/solargraph/documentor.rb +0 -76
  132. data/lib/solargraph/parser/legacy/node_methods.rb +0 -325
  133. data/lib/solargraph/parser/legacy/node_processors/alias_node.rb +0 -23
  134. data/lib/solargraph/parser/legacy/node_processors/begin_node.rb +0 -15
  135. data/lib/solargraph/parser/legacy/node_processors/sym_node.rb +0 -18
  136. data/lib/solargraph/parser/legacy/node_processors.rb +0 -55
  137. data/lib/solargraph/parser/legacy.rb +0 -12
  138. data/lib/solargraph/parser/rubyvm/class_methods.rb +0 -153
  139. data/lib/solargraph/parser/rubyvm/node_chainer.rb +0 -160
  140. data/lib/solargraph/parser/rubyvm/node_methods.rb +0 -317
  141. data/lib/solargraph/parser/rubyvm/node_processors/args_node.rb +0 -85
  142. data/lib/solargraph/parser/rubyvm/node_processors/block_node.rb +0 -42
  143. data/lib/solargraph/parser/rubyvm/node_processors/casgn_node.rb +0 -33
  144. data/lib/solargraph/parser/rubyvm/node_processors/cvasgn_node.rb +0 -23
  145. data/lib/solargraph/parser/rubyvm/node_processors/def_node.rb +0 -75
  146. data/lib/solargraph/parser/rubyvm/node_processors/defs_node.rb +0 -68
  147. data/lib/solargraph/parser/rubyvm/node_processors/gvasgn_node.rb +0 -23
  148. data/lib/solargraph/parser/rubyvm/node_processors/ivasgn_node.rb +0 -38
  149. data/lib/solargraph/parser/rubyvm/node_processors/kw_arg_node.rb +0 -39
  150. data/lib/solargraph/parser/rubyvm/node_processors/lit_node.rb +0 -20
  151. data/lib/solargraph/parser/rubyvm/node_processors/lvasgn_node.rb +0 -27
  152. data/lib/solargraph/parser/rubyvm/node_processors/namespace_node.rb +0 -39
  153. data/lib/solargraph/parser/rubyvm/node_processors/opt_arg_node.rb +0 -26
  154. data/lib/solargraph/parser/rubyvm/node_processors/orasgn_node.rb +0 -15
  155. data/lib/solargraph/parser/rubyvm/node_processors/resbody_node.rb +0 -51
  156. data/lib/solargraph/parser/rubyvm/node_processors/sclass_node.rb +0 -32
  157. data/lib/solargraph/parser/rubyvm/node_processors/scope_node.rb +0 -15
  158. data/lib/solargraph/parser/rubyvm/node_processors/send_node.rb +0 -279
  159. data/lib/solargraph/parser/rubyvm/node_processors.rb +0 -64
  160. data/lib/solargraph/parser/rubyvm/node_wrapper.rb +0 -47
  161. data/lib/solargraph/parser/rubyvm.rb +0 -40
  162. data/lib/yard-solargraph.rb +0 -33
@@ -1,75 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Solargraph
4
- module Parser
5
- module Rubyvm
6
- module NodeProcessors
7
- class DefNode < Parser::NodeProcessor::Base
8
- def process
9
- anon_splat = node_has_anon_splat?
10
-
11
- methpin = Solargraph::Pin::Method.new(
12
- location: get_node_location(node),
13
- closure: region.closure,
14
- name: node.children[0].to_s,
15
- comments: comments_for(node),
16
- scope: region.scope || (region.closure.is_a?(Pin::Singleton) ? :class : :instance),
17
- visibility: region.visibility,
18
- node: node,
19
- anon_splat: anon_splat
20
- )
21
- if methpin.name == 'initialize' && methpin.scope == :instance
22
- pins.push Solargraph::Pin::Method.new(
23
- location: methpin.location,
24
- closure: methpin.closure,
25
- name: 'new',
26
- comments: methpin.comments,
27
- scope: :class,
28
- parameters: methpin.parameters,
29
- anon_splat: anon_splat
30
- )
31
- # @todo Smelly instance variable access.
32
- pins.last.instance_variable_set(:@return_type, ComplexType::SELF)
33
- pins.push methpin
34
- # @todo Smelly instance variable access.
35
- methpin.instance_variable_set(:@visibility, :private)
36
- methpin.instance_variable_set(:@return_type, ComplexType::VOID)
37
- elsif region.visibility == :module_function
38
- pins.push Solargraph::Pin::Method.new(
39
- location: methpin.location,
40
- closure: methpin.closure,
41
- name: methpin.name,
42
- comments: methpin.comments,
43
- scope: :class,
44
- visibility: :public,
45
- parameters: methpin.parameters,
46
- node: methpin.node,
47
- anon_splat: anon_splat
48
- )
49
- pins.push Solargraph::Pin::Method.new(
50
- location: methpin.location,
51
- closure: methpin.closure,
52
- name: methpin.name,
53
- comments: methpin.comments,
54
- scope: :instance,
55
- visibility: :private,
56
- parameters: methpin.parameters,
57
- node: methpin.node,
58
- anon_splat: anon_splat
59
- )
60
- else
61
- pins.push methpin
62
- end
63
- process_children region.update(closure: methpin, scope: methpin.scope)
64
- end
65
-
66
- private
67
-
68
- def node_has_anon_splat?
69
- node.children[1]&.children&.first == [nil]
70
- end
71
- end
72
- end
73
- end
74
- end
75
- end
@@ -1,68 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Solargraph
4
- module Parser
5
- module Rubyvm
6
- module NodeProcessors
7
- class DefsNode < DefNode
8
- include NodeMethods
9
-
10
- def process
11
- s_visi = region.visibility
12
- s_visi = :public if region.scope != :class
13
- loc = get_node_location(node)
14
- anon_splat = node_has_anon_splat?
15
-
16
- if node.children[0].is_a?(RubyVM::AbstractSyntaxTree::Node) && node.children[0].type == :SELF
17
- closure = region.closure
18
- else
19
- closure = Solargraph::Pin::Namespace.new(
20
- name: unpack_name(node.children[0])
21
- )
22
- end
23
- if s_visi == :module_function
24
- pins.push Solargraph::Pin::Method.new(
25
- location: loc,
26
- closure: closure,
27
- name: node.children[1].to_s,
28
- comments: comments_for(node),
29
- scope: :class,
30
- visibility: :public,
31
- node: node,
32
- anon_splat: anon_splat
33
- )
34
- pins.push Solargraph::Pin::Method.new(
35
- location: loc,
36
- closure: closure,
37
- name: node.children[1].to_s,
38
- comments: comments_for(node),
39
- scope: :instance,
40
- visibility: :private,
41
- node: node,
42
- anon_splat: anon_splat
43
- )
44
- else
45
- pins.push Solargraph::Pin::Method.new(
46
- location: loc,
47
- closure: closure,
48
- name: node.children[1].to_s,
49
- comments: comments_for(node),
50
- scope: :class,
51
- visibility: s_visi,
52
- node: node,
53
- anon_splat: anon_splat
54
- )
55
- end
56
- process_children region.update(closure: pins.last, scope: :class)
57
- end
58
-
59
- private
60
-
61
- def node_has_anon_splat?
62
- node.children[2]&.children&.first == [nil]
63
- end
64
- end
65
- end
66
- end
67
- end
68
- end
@@ -1,23 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Solargraph
4
- module Parser
5
- module Rubyvm
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
- )
17
- process_children
18
- end
19
- end
20
- end
21
- end
22
- end
23
- end
@@ -1,38 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Solargraph
4
- module Parser
5
- module Rubyvm
6
- module NodeProcessors
7
- class IvasgnNode < Parser::NodeProcessor::Base
8
- include Rubyvm::NodeMethods
9
-
10
- def process
11
- loc = get_node_location(node)
12
- pins.push Solargraph::Pin::InstanceVariable.new(
13
- location: loc,
14
- closure: region.closure,
15
- name: node.children[0].to_s,
16
- comments: comments_for(node),
17
- assignment: node.children[1]
18
- )
19
- if region.visibility == :module_function
20
- rng = Range.from_node(node)
21
- named_path = named_path_pin(rng.start)
22
- if named_path.is_a?(Pin::Method)
23
- pins.push Solargraph::Pin::InstanceVariable.new(
24
- location: loc,
25
- closure: Pin::Namespace.new(type: :module, closure: region.closure.closure, name: region.closure.name),
26
- name: node.children[0].to_s,
27
- comments: comments_for(node),
28
- assignment: node.children[1]
29
- )
30
- end
31
- end
32
- process_children
33
- end
34
- end
35
- end
36
- end
37
- end
38
- end
@@ -1,39 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Solargraph
4
- module Parser
5
- module Rubyvm
6
- module NodeProcessors
7
- class KwArgNode < Parser::NodeProcessor::Base
8
- def process
9
- locals.push Solargraph::Pin::Parameter.new(
10
- location: region.closure.location,
11
- closure: region.closure,
12
- comments: comments_for(node),
13
- name: node.children[0].children[0].to_s,
14
- assignment: require_keyword?(node) ? nil : node.children[0].children[1],
15
- asgn_code: require_keyword?(node) ? nil : region.code_for(node.children[0].children[1]),
16
- presence: region.closure.location.range,
17
- decl: require_keyword?(node) ? :kwarg : :kwoptarg
18
- )
19
- idx = region.closure.parameters.find_index { |par| [:kwrestarg, :blockarg].include?(par.decl) }
20
- if idx
21
- region.closure.parameters.insert idx, locals.last
22
- else
23
- region.closure.parameters.push locals.last
24
- end
25
- node.children[1] && NodeProcessor.process(node.children[1], region, pins, locals)
26
- end
27
-
28
- private
29
-
30
- def require_keyword? node
31
- # Ruby 2.7 changed required keywords to use a magic symbol instead
32
- # of nil in the assignment node
33
- node.children[0].children[1].nil? || node.children[0].children[1] == :NODE_SPECIAL_REQUIRED_KEYWORD
34
- end
35
- end
36
- end
37
- end
38
- end
39
- end
@@ -1,20 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Solargraph
4
- module Parser
5
- module Rubyvm
6
- module NodeProcessors
7
- class LitNode < Parser::NodeProcessor::Base
8
- def process
9
- if node.children[0].is_a?(Symbol)
10
- pins.push Solargraph::Pin::Symbol.new(
11
- get_node_location(node),
12
- ":#{node.children[0]}"
13
- )
14
- end
15
- end
16
- end
17
- end
18
- end
19
- end
20
- end
@@ -1,27 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Solargraph
4
- module Parser
5
- module Rubyvm
6
- module NodeProcessors
7
- class LvasgnNode < Parser::NodeProcessor::Base
8
- def process
9
- # here = get_node_start_position(node)
10
- here = Position.new(node.first_lineno - 1, node.first_column)
11
- presence = Range.new(here, region.closure.location.range.ending)
12
- loc = get_node_location(node)
13
- locals.push Solargraph::Pin::LocalVariable.new(
14
- location: loc,
15
- closure: region.closure,
16
- name: node.children[0].to_s,
17
- assignment: node.children[1],
18
- comments: comments_for(node),
19
- presence: presence
20
- )
21
- process_children
22
- end
23
- end
24
- end
25
- end
26
- end
27
- end
@@ -1,39 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Solargraph
4
- module Parser
5
- module Rubyvm
6
- module NodeProcessors
7
- class NamespaceNode < Parser::NodeProcessor::Base
8
- include NodeMethods
9
-
10
- def process
11
- sc = nil
12
- if node.type == :CLASS && !node.children[1].nil?
13
- sc = unpack_name(node.children[1])
14
- end
15
- loc = get_node_location(node)
16
- nspin = Solargraph::Pin::Namespace.new(
17
- type: node.type.to_s.downcase.to_sym,
18
- location: loc,
19
- closure: region.closure,
20
- name: unpack_name(node.children[0]),
21
- comments: comments_for(node),
22
- visibility: :public,
23
- gates: region.closure.gates.freeze
24
- )
25
- pins.push nspin
26
- unless sc.nil?
27
- pins.push Pin::Reference::Superclass.new(
28
- location: loc,
29
- closure: pins.last,
30
- name: sc
31
- )
32
- end
33
- process_children region.update(closure: nspin, visibility: :public)
34
- end
35
- end
36
- end
37
- end
38
- end
39
- end
@@ -1,26 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Solargraph
4
- module Parser
5
- module Rubyvm
6
- module NodeProcessors
7
- class OptArgNode < Parser::NodeProcessor::Base
8
- def process
9
- locals.push Solargraph::Pin::Parameter.new(
10
- location: region.closure.location,
11
- closure: region.closure,
12
- comments: comments_for(node),
13
- name: node.children[0].children[0].to_s,
14
- assignment: node.children[0].children[1],
15
- asgn_code: node.children[0].children[1] ? region.code_for(node.children[0].children[1]) : nil,
16
- presence: region.closure.location.range,
17
- decl: :optarg
18
- )
19
- region.closure.parameters.push locals.last
20
- node.children[1] && NodeProcessor.process(node.children[1], region, pins, locals)
21
- end
22
- end
23
- end
24
- end
25
- end
26
- end
@@ -1,15 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Solargraph
4
- module Parser
5
- module Rubyvm
6
- module NodeProcessors
7
- class OrasgnNode < Parser::NodeProcessor::Base
8
- def process
9
- NodeProcessor.process(node.children[2], region, pins, locals)
10
- end
11
- end
12
- end
13
- end
14
- end
15
- end
@@ -1,51 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Solargraph
4
- module Parser
5
- module Rubyvm
6
- module NodeProcessors
7
- class ResbodyNode < Parser::NodeProcessor::Base
8
- include Rubyvm::NodeMethods
9
-
10
- def process
11
- presence = Range.from_node(node)
12
- loc = get_node_location(node.children[1])
13
- if node.children[1] && node.children[1].children.first
14
- types = if !node.children.first || node.children.first.children.empty?
15
- ['Exception']
16
- else
17
- node.children.first.children[0..-2].map do |child|
18
- unpack_name(child)
19
- end
20
- end
21
- if exception_variable?
22
- locals.push Solargraph::Pin::LocalVariable.new(
23
- location: loc,
24
- closure: region.closure,
25
- name: node.children[1].children.first.to_s,
26
- comments: "@type [#{types.join(',')}]",
27
- presence: presence
28
- )
29
- end
30
- end
31
- NodeProcessor.process(node.children[1], region, pins, locals)
32
- end
33
-
34
- private
35
-
36
- def exception_variable?
37
- if RUBY_VERSION =~ /^3\.4\./
38
- Parser.is_ast_node?(node.children[1]) &&
39
- # Parser.is_ast_node?(node.children[1].children.first) &&
40
- node.children[1].type == :LASGN
41
- else
42
- Parser.is_ast_node?(node.children[1]) &&
43
- Parser.is_ast_node?(node.children[1].children.first) &&
44
- node.children[1].children.first.type == :LASGN
45
- end
46
- end
47
- end
48
- end
49
- end
50
- end
51
- end
@@ -1,32 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Solargraph
4
- module Parser
5
- module Rubyvm
6
- module NodeProcessors
7
- class SclassNode < Parser::NodeProcessor::Base
8
- def process
9
- sclass = node.children[0]
10
- if sclass.is_a?(RubyVM::AbstractSyntaxTree::Node) && sclass.type == :SELF
11
- closure = region.closure
12
- elsif sclass.is_a?(RubyVM::AbstractSyntaxTree::Node) && %i[CDECL CONST].include?(sclass.type)
13
- names = [region.closure.namespace, region.closure.name]
14
- if names.last != sclass.children[0].to_s
15
- names << sclass.children[0].to_s
16
- end
17
- name = names.reject(&:empty?).join('::')
18
- closure = Solargraph::Pin::Namespace.new(name: name, location: region.closure.location)
19
- else
20
- return
21
- end
22
- pins.push Solargraph::Pin::Singleton.new(
23
- location: get_node_location(node),
24
- closure: closure
25
- )
26
- process_children region.update(visibility: :public, scope: :class, closure: pins.last)
27
- end
28
- end
29
- end
30
- end
31
- end
32
- end
@@ -1,15 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Solargraph
4
- module Parser
5
- module Rubyvm
6
- module NodeProcessors
7
- class ScopeNode < Parser::NodeProcessor::Base
8
- def process
9
- process_children region.update(lvars: node.children[0])
10
- end
11
- end
12
- end
13
- end
14
- end
15
- end