solargraph 0.47.2 → 0.53.3

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 (185) hide show
  1. checksums.yaml +4 -4
  2. data/.github/FUNDING.yml +1 -0
  3. data/.github/workflows/plugins.yml +40 -0
  4. data/.github/workflows/rspec.yml +4 -8
  5. data/.github/workflows/typecheck.yml +34 -0
  6. data/.yardopts +2 -2
  7. data/CHANGELOG.md +137 -3
  8. data/LICENSE +1 -1
  9. data/README.md +19 -16
  10. data/SPONSORS.md +2 -9
  11. data/lib/solargraph/api_map/cache.rb +60 -20
  12. data/lib/solargraph/api_map/source_to_yard.rb +17 -10
  13. data/lib/solargraph/api_map/store.rb +60 -12
  14. data/lib/solargraph/api_map.rb +171 -99
  15. data/lib/solargraph/bench.rb +3 -2
  16. data/lib/solargraph/cache.rb +77 -0
  17. data/lib/solargraph/complex_type/type_methods.rb +61 -12
  18. data/lib/solargraph/complex_type/unique_type.rb +193 -16
  19. data/lib/solargraph/complex_type.rb +113 -10
  20. data/lib/solargraph/convention/rakefile.rb +17 -0
  21. data/lib/solargraph/convention.rb +2 -3
  22. data/lib/solargraph/converters/dd.rb +5 -0
  23. data/lib/solargraph/converters/dl.rb +3 -0
  24. data/lib/solargraph/converters/dt.rb +3 -0
  25. data/lib/solargraph/diagnostics/rubocop.rb +23 -8
  26. data/lib/solargraph/diagnostics/rubocop_helpers.rb +4 -1
  27. data/lib/solargraph/diagnostics/type_check.rb +1 -0
  28. data/lib/solargraph/diagnostics.rb +2 -2
  29. data/lib/solargraph/doc_map.rb +171 -0
  30. data/lib/solargraph/gem_pins.rb +64 -0
  31. data/lib/solargraph/language_server/host/cataloger.rb +2 -1
  32. data/lib/solargraph/language_server/host/diagnoser.rb +2 -2
  33. data/lib/solargraph/language_server/host/dispatch.rb +15 -5
  34. data/lib/solargraph/language_server/host/message_worker.rb +4 -0
  35. data/lib/solargraph/language_server/host/sources.rb +7 -4
  36. data/lib/solargraph/language_server/host.rb +50 -26
  37. data/lib/solargraph/language_server/message/completion_item/resolve.rb +3 -1
  38. data/lib/solargraph/language_server/message/extended/check_gem_version.rb +13 -1
  39. data/lib/solargraph/language_server/message/extended/download_core.rb +1 -5
  40. data/lib/solargraph/language_server/message/initialize.rb +13 -0
  41. data/lib/solargraph/language_server/message/initialized.rb +1 -0
  42. data/lib/solargraph/language_server/message/text_document/document_symbol.rb +4 -1
  43. data/lib/solargraph/language_server/message/text_document/formatting.rb +4 -4
  44. data/lib/solargraph/language_server/message/text_document/hover.rb +2 -0
  45. data/lib/solargraph/language_server/message/text_document/signature_help.rb +1 -6
  46. data/lib/solargraph/language_server/message/text_document/type_definition.rb +24 -0
  47. data/lib/solargraph/language_server/message/text_document.rb +1 -1
  48. data/lib/solargraph/language_server/message/workspace/did_change_configuration.rb +5 -0
  49. data/lib/solargraph/language_server/message/workspace/did_change_watched_files.rb +10 -3
  50. data/lib/solargraph/language_server/message.rb +1 -0
  51. data/lib/solargraph/language_server/transport/adapter.rb +16 -1
  52. data/lib/solargraph/language_server/transport/data_reader.rb +2 -0
  53. data/lib/solargraph/library.rb +124 -37
  54. data/lib/solargraph/location.rb +1 -0
  55. data/lib/solargraph/page.rb +6 -0
  56. data/lib/solargraph/parser/comment_ripper.rb +4 -0
  57. data/lib/solargraph/parser/node_methods.rb +47 -7
  58. data/lib/solargraph/parser/node_processor/base.rb +9 -0
  59. data/lib/solargraph/parser/{legacy → parser_gem}/class_methods.rb +31 -5
  60. data/lib/solargraph/parser/{legacy → parser_gem}/flawed_builder.rb +3 -1
  61. data/lib/solargraph/parser/{legacy → parser_gem}/node_chainer.rb +57 -41
  62. data/lib/solargraph/parser/parser_gem/node_methods.rb +499 -0
  63. data/lib/solargraph/parser/{rubyvm → parser_gem}/node_processors/alias_node.rb +1 -1
  64. data/lib/solargraph/parser/parser_gem/node_processors/args_node.rb +53 -0
  65. data/lib/solargraph/parser/{rubyvm → parser_gem}/node_processors/begin_node.rb +1 -1
  66. data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/block_node.rb +3 -2
  67. data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/casgn_node.rb +14 -4
  68. data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/cvasgn_node.rb +1 -1
  69. data/lib/solargraph/parser/{rubyvm → parser_gem}/node_processors/def_node.rb +7 -20
  70. data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/defs_node.rb +2 -2
  71. data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/gvasgn_node.rb +1 -1
  72. data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/ivasgn_node.rb +2 -2
  73. data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/lvasgn_node.rb +2 -2
  74. data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/namespace_node.rb +2 -2
  75. data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/orasgn_node.rb +1 -1
  76. data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/resbody_node.rb +3 -3
  77. data/lib/solargraph/parser/parser_gem/node_processors/sclass_node.rb +42 -0
  78. data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/send_node.rb +2 -2
  79. data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/sym_node.rb +1 -1
  80. data/lib/solargraph/parser/parser_gem/node_processors.rb +54 -0
  81. data/lib/solargraph/parser/parser_gem.rb +12 -0
  82. data/lib/solargraph/parser/region.rb +1 -1
  83. data/lib/solargraph/parser/snippet.rb +2 -0
  84. data/lib/solargraph/parser.rb +9 -10
  85. data/lib/solargraph/pin/base.rb +69 -11
  86. data/lib/solargraph/pin/base_variable.rb +8 -4
  87. data/lib/solargraph/pin/block.rb +21 -28
  88. data/lib/solargraph/pin/closure.rb +17 -2
  89. data/lib/solargraph/pin/common.rb +7 -3
  90. data/lib/solargraph/pin/conversions.rb +34 -8
  91. data/lib/solargraph/pin/delegated_method.rb +97 -0
  92. data/lib/solargraph/pin/documenting.rb +25 -34
  93. data/lib/solargraph/pin/instance_variable.rb +4 -0
  94. data/lib/solargraph/pin/local_variable.rb +13 -1
  95. data/lib/solargraph/pin/method.rb +270 -16
  96. data/lib/solargraph/pin/namespace.rb +17 -1
  97. data/lib/solargraph/pin/parameter.rb +52 -17
  98. data/lib/solargraph/pin/reference/override.rb +2 -2
  99. data/lib/solargraph/pin/reference.rb +8 -0
  100. data/lib/solargraph/pin/search.rb +4 -4
  101. data/lib/solargraph/pin/signature.rb +143 -0
  102. data/lib/solargraph/pin.rb +2 -1
  103. data/lib/solargraph/range.rb +4 -6
  104. data/lib/solargraph/rbs_map/conversions.rb +601 -0
  105. data/lib/solargraph/rbs_map/core_fills.rb +47 -0
  106. data/lib/solargraph/rbs_map/core_map.rb +28 -0
  107. data/lib/solargraph/rbs_map/stdlib_map.rb +33 -0
  108. data/lib/solargraph/rbs_map.rb +84 -0
  109. data/lib/solargraph/shell.rb +69 -48
  110. data/lib/solargraph/source/chain/array.rb +32 -0
  111. data/lib/solargraph/source/chain/block_symbol.rb +13 -0
  112. data/lib/solargraph/source/chain/call.rb +125 -61
  113. data/lib/solargraph/source/chain/constant.rb +15 -1
  114. data/lib/solargraph/source/chain/if.rb +23 -0
  115. data/lib/solargraph/source/chain/link.rb +8 -2
  116. data/lib/solargraph/source/chain/or.rb +1 -1
  117. data/lib/solargraph/source/chain/z_super.rb +3 -3
  118. data/lib/solargraph/source/chain.rb +44 -14
  119. data/lib/solargraph/source/change.rb +3 -0
  120. data/lib/solargraph/source/cursor.rb +2 -0
  121. data/lib/solargraph/source/source_chainer.rb +8 -5
  122. data/lib/solargraph/source.rb +18 -19
  123. data/lib/solargraph/source_map/clip.rb +30 -23
  124. data/lib/solargraph/source_map/mapper.rb +20 -5
  125. data/lib/solargraph/source_map.rb +28 -13
  126. data/lib/solargraph/type_checker/checks.rb +10 -2
  127. data/lib/solargraph/type_checker.rb +201 -98
  128. data/lib/solargraph/version.rb +1 -1
  129. data/lib/solargraph/views/environment.erb +2 -2
  130. data/lib/solargraph/workspace/config.rb +14 -11
  131. data/lib/solargraph/workspace.rb +28 -17
  132. data/lib/solargraph/yard_map/cache.rb +6 -0
  133. data/lib/solargraph/yard_map/helpers.rb +1 -1
  134. data/lib/solargraph/yard_map/mapper/to_method.rb +18 -5
  135. data/lib/solargraph/yard_map/mapper.rb +1 -1
  136. data/lib/solargraph/yard_map/to_method.rb +11 -4
  137. data/lib/solargraph/yard_map.rb +1 -443
  138. data/lib/solargraph/yard_tags.rb +20 -0
  139. data/lib/solargraph/yardoc.rb +52 -0
  140. data/lib/solargraph.rb +8 -6
  141. data/solargraph.gemspec +19 -8
  142. metadata +162 -98
  143. data/.travis.yml +0 -19
  144. data/lib/solargraph/api_map/bundler_methods.rb +0 -22
  145. data/lib/solargraph/compat.rb +0 -37
  146. data/lib/solargraph/convention/rspec.rb +0 -30
  147. data/lib/solargraph/documentor.rb +0 -76
  148. data/lib/solargraph/parser/legacy/node_methods.rb +0 -325
  149. data/lib/solargraph/parser/legacy/node_processors/alias_node.rb +0 -23
  150. data/lib/solargraph/parser/legacy/node_processors/args_node.rb +0 -35
  151. data/lib/solargraph/parser/legacy/node_processors/begin_node.rb +0 -15
  152. data/lib/solargraph/parser/legacy/node_processors/def_node.rb +0 -63
  153. data/lib/solargraph/parser/legacy/node_processors/sclass_node.rb +0 -21
  154. data/lib/solargraph/parser/legacy/node_processors.rb +0 -54
  155. data/lib/solargraph/parser/legacy.rb +0 -12
  156. data/lib/solargraph/parser/rubyvm/class_methods.rb +0 -144
  157. data/lib/solargraph/parser/rubyvm/node_chainer.rb +0 -160
  158. data/lib/solargraph/parser/rubyvm/node_methods.rb +0 -315
  159. data/lib/solargraph/parser/rubyvm/node_processors/args_node.rb +0 -85
  160. data/lib/solargraph/parser/rubyvm/node_processors/block_node.rb +0 -42
  161. data/lib/solargraph/parser/rubyvm/node_processors/casgn_node.rb +0 -22
  162. data/lib/solargraph/parser/rubyvm/node_processors/cvasgn_node.rb +0 -23
  163. data/lib/solargraph/parser/rubyvm/node_processors/defs_node.rb +0 -57
  164. data/lib/solargraph/parser/rubyvm/node_processors/gvasgn_node.rb +0 -23
  165. data/lib/solargraph/parser/rubyvm/node_processors/ivasgn_node.rb +0 -38
  166. data/lib/solargraph/parser/rubyvm/node_processors/kw_arg_node.rb +0 -39
  167. data/lib/solargraph/parser/rubyvm/node_processors/lit_node.rb +0 -20
  168. data/lib/solargraph/parser/rubyvm/node_processors/lvasgn_node.rb +0 -27
  169. data/lib/solargraph/parser/rubyvm/node_processors/namespace_node.rb +0 -39
  170. data/lib/solargraph/parser/rubyvm/node_processors/opt_arg_node.rb +0 -26
  171. data/lib/solargraph/parser/rubyvm/node_processors/orasgn_node.rb +0 -15
  172. data/lib/solargraph/parser/rubyvm/node_processors/resbody_node.rb +0 -45
  173. data/lib/solargraph/parser/rubyvm/node_processors/sclass_node.rb +0 -21
  174. data/lib/solargraph/parser/rubyvm/node_processors/scope_node.rb +0 -15
  175. data/lib/solargraph/parser/rubyvm/node_processors/send_node.rb +0 -277
  176. data/lib/solargraph/parser/rubyvm/node_processors/sym_node.rb +0 -18
  177. data/lib/solargraph/parser/rubyvm/node_processors.rb +0 -63
  178. data/lib/solargraph/parser/rubyvm.rb +0 -40
  179. data/lib/solargraph/yard_map/core_docs.rb +0 -170
  180. data/lib/solargraph/yard_map/core_fills.rb +0 -208
  181. data/lib/solargraph/yard_map/core_gen.rb +0 -76
  182. data/lib/solargraph/yard_map/rdoc_to_yard.rb +0 -140
  183. data/lib/solargraph/yard_map/stdlib_fills.rb +0 -43
  184. data/lib/yard-solargraph.rb +0 -33
  185. data/yardoc/2.2.2.tar.gz +0 -0
@@ -1,277 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Solargraph
4
- module Parser
5
- module Rubyvm
6
- module NodeProcessors
7
- class SendNode < Parser::NodeProcessor::Base
8
- include Rubyvm::NodeMethods
9
-
10
- def process
11
- if [:private, :public, :protected].include?(node.children[0])
12
- process_visibility
13
- elsif node.children[0] == :module_function
14
- process_module_function
15
- elsif node.children[0] == :require
16
- process_require
17
- elsif node.children[0] == :autoload
18
- process_autoload
19
- elsif node.children[0] == :alias_method
20
- process_alias_method
21
- elsif node.children[0] == :private_class_method
22
- process_private_class_method
23
- elsif [:attr_reader, :attr_writer, :attr_accessor].include?(node.children[0])
24
- process_attribute
25
- elsif node.children[0] == :include
26
- process_include
27
- elsif node.children[0] == :extend
28
- process_extend
29
- elsif node.children[0] == :prepend
30
- process_prepend
31
- elsif node.children[0] == :private_constant
32
- process_private_constant
33
- elsif node.children[1] == :require && unpack_name(node.children[0]) == 'Bundler'
34
- pins.push Pin::Reference::Require.new(Solargraph::Location.new(region.filename, Solargraph::Range.from_to(0, 0, 0, 0)), 'bundler/require')
35
- end
36
- process_children
37
- end
38
-
39
- private
40
-
41
- # @return [void]
42
- def process_visibility
43
- if node.type == :FCALL && Parser.is_ast_node?(node.children.last)
44
- node.children.last.children[0..-2].each do |child|
45
- # next unless child.is_a?(AST::Node) && (child.type == :sym || child.type == :str)
46
- if child.type == :LIT || child.type == :STR
47
- name = child.children[0].to_s
48
- matches = pins.select{ |pin| pin.is_a?(Pin::Method) && pin.name == name && pin.namespace == region.closure.full_context.namespace && pin.context.scope == (region.scope || :instance)}
49
- matches.each do |pin|
50
- # @todo Smelly instance variable access
51
- pin.instance_variable_set(:@visibility, node.children[0])
52
- end
53
- else
54
- process_children region.update(visibility: node.children[0])
55
- end
56
- end
57
- else
58
- # @todo Smelly instance variable access
59
- region.instance_variable_set(:@visibility, node.children[0])
60
- end
61
- end
62
-
63
- # @return [void]
64
- def process_attribute
65
- return unless Parser.is_ast_node?(node.children[1])
66
- node.children[1].children[0..-2].each do |a|
67
- next unless a.type == :LIT
68
- loc = get_node_location(node)
69
- clos = region.closure
70
- cmnt = comments_for(node)
71
- if node.children[0] == :attr_reader || node.children[0] == :attr_accessor
72
- pins.push Solargraph::Pin::Method.new(
73
- location: loc,
74
- closure: clos,
75
- name: a.children[0].to_s,
76
- comments: cmnt,
77
- scope: region.scope || :instance,
78
- visibility: region.visibility,
79
- attribute: true
80
- )
81
- end
82
- if node.children[0] == :attr_writer || node.children[0] == :attr_accessor
83
- pins.push Solargraph::Pin::Method.new(
84
- location: loc,
85
- closure: clos,
86
- name: "#{a.children[0]}=",
87
- comments: cmnt,
88
- scope: region.scope || :instance,
89
- visibility: region.visibility,
90
- attribute: true
91
- )
92
- pins.last.parameters.push Pin::Parameter.new(name: 'value', decl: :arg, closure: pins.last)
93
- if pins.last.return_type.defined?
94
- pins.last.docstring.add_tag YARD::Tags::Tag.new(:param, '', pins.last.return_type.to_s.split(', '), 'value')
95
- end
96
- end
97
- end
98
- end
99
-
100
- # @return [void]
101
- def process_include
102
- return unless Parser.is_ast_node?(node.children.last)
103
- node.children.last.children[0..-2].each do |i|
104
- next unless [:COLON2, :COLON3, :CONST].include?(i.type)
105
- type = region.scope == :class ? Pin::Reference::Extend : Pin::Reference::Include
106
- pins.push type.new(
107
- location: get_node_location(i),
108
- closure: region.closure,
109
- name: unpack_name(i)
110
- )
111
- end
112
- end
113
-
114
- # @return [void]
115
- def process_prepend
116
- return unless Parser.is_ast_node?(node.children.last)
117
- node.children.last.children[0..-2].each do |i|
118
- next unless [:COLON2, :COLON3, :CONST].include?(i.type)
119
- pins.push Pin::Reference::Prepend.new(
120
- location: get_node_location(i),
121
- closure: region.closure,
122
- name: unpack_name(i)
123
- )
124
- end
125
- end
126
-
127
- # @return [void]
128
- def process_extend
129
- return unless Parser.is_ast_node?(node.children.last)
130
- node.children.last.children[0..-2].each do |i|
131
- next unless [:COLON2, :COLON3, :CONST, :SELF].include?(i.type)
132
- loc = get_node_location(node)
133
- if i.type == :SELF
134
- pins.push Pin::Reference::Extend.new(
135
- location: loc,
136
- closure: region.closure,
137
- name: region.closure.full_context.namespace
138
- )
139
- else
140
- pins.push Pin::Reference::Extend.new(
141
- location: loc,
142
- closure: region.closure,
143
- name: unpack_name(i)
144
- )
145
- end
146
- end
147
- end
148
-
149
- # @return [void]
150
- def process_require
151
- return unless Parser.is_ast_node?(node.children[1])
152
- node.children[1].children.each do |arg|
153
- next unless Parser.is_ast_node?(arg)
154
- if arg.type == :STR
155
- pins.push Pin::Reference::Require.new(get_node_location(arg), arg.children[0])
156
- end
157
- end
158
- end
159
-
160
- # @return [void]
161
- def process_autoload
162
- return unless Parser.is_ast_node?(node.children[1]) && Parser.is_ast_node?(node.children[1].children[1])
163
- arg = node.children[1].children[1]
164
- if arg.type == :STR
165
- pins.push Pin::Reference::Require.new(get_node_location(arg), arg.children[0])
166
- end
167
- end
168
-
169
- # @return [void]
170
- def process_module_function
171
- if node.type == :VCALL
172
- # @todo Smelly instance variable access
173
- region.instance_variable_set(:@visibility, :module_function)
174
- elsif node.children.last.children[0].type == :DEFN
175
- NodeProcessor.process node.children.last.children[0], region.update(visibility: :module_function), pins, locals
176
- else
177
- node.children.last.children[0..-2].each do |x|
178
- next unless [:LIT, :STR].include?(x.type)
179
- cn = x.children[0].to_s
180
- ref = pins.select { |p| p.is_a?(Pin::Method) && p.namespace == region.closure.full_context.namespace && p.name == cn }.first
181
- unless ref.nil?
182
- pins.delete ref
183
- mm = Solargraph::Pin::Method.new(
184
- location: ref.location,
185
- closure: ref.closure,
186
- name: ref.name,
187
- comments: ref.comments,
188
- scope: :class,
189
- visibility: :public,
190
- parameters: ref.parameters,
191
- node: ref.node
192
- )
193
- cm = Solargraph::Pin::Method.new(
194
- location: ref.location,
195
- closure: ref.closure,
196
- name: ref.name,
197
- comments: ref.comments,
198
- scope: :instance,
199
- visibility: :private,
200
- parameters: ref.parameters,
201
- node: ref.node)
202
- pins.push mm, cm
203
- pins.select{|pin| pin.is_a?(Pin::InstanceVariable) && pin.closure.path == ref.path}.each do |ivar|
204
- pins.delete ivar
205
- pins.push Solargraph::Pin::InstanceVariable.new(
206
- location: ivar.location,
207
- closure: cm,
208
- name: ivar.name,
209
- comments: ivar.comments,
210
- assignment: ivar.assignment
211
- # scope: :instance
212
- )
213
- pins.push Solargraph::Pin::InstanceVariable.new(
214
- location: ivar.location,
215
- closure: mm,
216
- name: ivar.name,
217
- comments: ivar.comments,
218
- assignment: ivar.assignment
219
- # scope: :class
220
- )
221
- end
222
- end
223
- end
224
- end
225
- end
226
-
227
- # @return [void]
228
- def process_private_constant
229
- return unless Parser.is_ast_node?(node.children.last)
230
- node.children.last.children[0..-2].each do |child|
231
- if [:LIT, :STR].include?(child.type)
232
- cn = child.children[0].to_s
233
- ref = pins.select{|p| [Solargraph::Pin::Namespace, Solargraph::Pin::Constant].include?(p.class) && p.namespace == region.closure.full_context.namespace && p.name == cn}.first
234
- # HACK: Smelly instance variable access
235
- ref.instance_variable_set(:@visibility, :private) unless ref.nil?
236
- end
237
- end
238
- end
239
-
240
- # @return [void]
241
- def process_alias_method
242
- arr = node.children[1]
243
- return if arr.nil?
244
- first = arr.children[0]
245
- second = arr.children[1]
246
- return unless first && second && [:LIT, :STR].include?(first.type) && [:LIT, :STR].include?(second.type)
247
- loc = get_node_location(node)
248
- pins.push Solargraph::Pin::MethodAlias.new(
249
- location: get_node_location(node),
250
- closure: region.closure,
251
- name: first.children[0].to_s,
252
- original: second.children[0].to_s,
253
- scope: region.scope || :instance
254
- )
255
- end
256
-
257
- # @return [void]
258
- def process_private_class_method
259
- return false unless Parser.is_ast_node?(node.children.last)
260
- if node.children.last.children.first.type == :DEFN
261
- process_children region.update(scope: :class, visibility: :private)
262
- else
263
- node.children.last.children[0..-2].each do |child|
264
- if child.type == :LIT && child.children.first.is_a?(::Symbol)
265
- sym_name = child.children.first.to_s
266
- ref = pins.select { |p| p.is_a?(Pin::Method) && p.namespace == region.closure.full_context.namespace && p.name == sym_name }.first
267
- # HACK: Smelly instance variable access
268
- ref.instance_variable_set(:@visibility, :private) unless ref.nil?
269
- end
270
- end
271
- end
272
- end
273
- end
274
- end
275
- end
276
- end
277
- end
@@ -1,18 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Solargraph
4
- module Parser
5
- module Rubyvm
6
- module NodeProcessors
7
- class SymNode < Parser::NodeProcessor::Base
8
- def process
9
- pins.push Solargraph::Pin::Symbol.new(
10
- get_node_location(node),
11
- ":#{node.children[0]}"
12
- )
13
- end
14
- end
15
- end
16
- end
17
- end
18
- end
@@ -1,63 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'solargraph/parser/node_processor'
4
-
5
- module Solargraph
6
- module Parser
7
- module Rubyvm
8
- module NodeProcessors
9
- autoload :ScopeNode, 'solargraph/parser/rubyvm/node_processors/scope_node'
10
- autoload :BeginNode, 'solargraph/parser/rubyvm/node_processors/begin_node'
11
- autoload :DefNode, 'solargraph/parser/rubyvm/node_processors/def_node'
12
- autoload :DefsNode, 'solargraph/parser/rubyvm/node_processors/defs_node'
13
- autoload :SendNode, 'solargraph/parser/rubyvm/node_processors/send_node'
14
- autoload :NamespaceNode, 'solargraph/parser/rubyvm/node_processors/namespace_node'
15
- autoload :SclassNode, 'solargraph/parser/rubyvm/node_processors/sclass_node'
16
- autoload :ModuleNode, 'solargraph/parser/rubyvm/node_processors/module_node'
17
- autoload :IvasgnNode, 'solargraph/parser/rubyvm/node_processors/ivasgn_node'
18
- autoload :CvasgnNode, 'solargraph/parser/rubyvm/node_processors/cvasgn_node'
19
- autoload :LvasgnNode, 'solargraph/parser/rubyvm/node_processors/lvasgn_node'
20
- autoload :GvasgnNode, 'solargraph/parser/rubyvm/node_processors/gvasgn_node'
21
- autoload :CasgnNode, 'solargraph/parser/rubyvm/node_processors/casgn_node'
22
- autoload :AliasNode, 'solargraph/parser/rubyvm/node_processors/alias_node'
23
- autoload :ArgsNode, 'solargraph/parser/rubyvm/node_processors/args_node'
24
- autoload :OptArgNode, 'solargraph/parser/rubyvm/node_processors/opt_arg_node'
25
- autoload :KwArgNode, 'solargraph/parser/rubyvm/node_processors/kw_arg_node'
26
- autoload :BlockNode, 'solargraph/parser/rubyvm/node_processors/block_node'
27
- autoload :OrasgnNode, 'solargraph/parser/rubyvm/node_processors/orasgn_node'
28
- autoload :SymNode, 'solargraph/parser/rubyvm/node_processors/sym_node'
29
- autoload :LitNode, 'solargraph/parser/rubyvm/node_processors/lit_node'
30
- autoload :ResbodyNode, 'solargraph/parser/rubyvm/node_processors/resbody_node'
31
- end
32
- end
33
-
34
- module NodeProcessor
35
- register :SCOPE, Rubyvm::NodeProcessors::ScopeNode
36
- register :RESBODY, Rubyvm::NodeProcessors::ResbodyNode
37
- register :DEFN, Rubyvm::NodeProcessors::DefNode
38
- register :DEFS, Rubyvm::NodeProcessors::DefsNode
39
- register :CALL, Rubyvm::NodeProcessors::SendNode
40
- register :FCALL, Rubyvm::NodeProcessors::SendNode
41
- register :VCALL, Rubyvm::NodeProcessors::SendNode
42
- register :CLASS, Rubyvm::NodeProcessors::NamespaceNode
43
- register :MODULE, Rubyvm::NodeProcessors::NamespaceNode
44
- register :SCLASS, Rubyvm::NodeProcessors::SclassNode
45
- register :IASGN, Rubyvm::NodeProcessors::IvasgnNode
46
- register :CVASGN, Rubyvm::NodeProcessors::CvasgnNode
47
- register :LASGN, Rubyvm::NodeProcessors::LvasgnNode
48
- register :DASGN, Rubyvm::NodeProcessors::LvasgnNode
49
- register :DASGN_CURR, Rubyvm::NodeProcessors::LvasgnNode
50
- register :GASGN, Rubyvm::NodeProcessors::GvasgnNode
51
- register :CDECL, Rubyvm::NodeProcessors::CasgnNode
52
- register :ALIAS, Rubyvm::NodeProcessors::AliasNode
53
- register :ARGS, Rubyvm::NodeProcessors::ArgsNode
54
- register :OPT_ARG, Rubyvm::NodeProcessors::OptArgNode
55
- register :KW_ARG, Rubyvm::NodeProcessors::KwArgNode
56
- register :ITER, Rubyvm::NodeProcessors::BlockNode
57
- register :LAMBDA, Rubyvm::NodeProcessors::BlockNode
58
- register :FOR, Rubyvm::NodeProcessors::BlockNode
59
- register :OP_ASGN_OR, Rubyvm::NodeProcessors::OrasgnNode
60
- register :LIT, Rubyvm::NodeProcessors::LitNode
61
- end
62
- end
63
- end
@@ -1,40 +0,0 @@
1
- module Solargraph
2
- module Parser
3
- module Rubyvm
4
- autoload :ClassMethods, 'solargraph/parser/rubyvm/class_methods'
5
- autoload :NodeChainer, 'solargraph/parser/rubyvm/node_chainer'
6
- autoload :NodeMethods, 'solargraph/parser/rubyvm/node_methods'
7
- end
8
- end
9
- end
10
-
11
- require 'solargraph/parser/rubyvm/node_processors'
12
-
13
- class RubyVM::AbstractSyntaxTree::Node
14
- def to_sexp
15
- sexp self
16
- end
17
-
18
- def == other
19
- return false unless other.is_a?(self.class)
20
- here = Solargraph::Range.from_node(self)
21
- there = Solargraph::Range.from_node(other)
22
- here == there && to_sexp == other.to_sexp
23
- end
24
-
25
- private
26
-
27
- def sexp node, depth = 0
28
- result = ''
29
- if node.is_a?(RubyVM::AbstractSyntaxTree::Node)
30
- result += "#{' ' * depth}(:#{node.type}"
31
- node.children.each do |child|
32
- result += "\n" + sexp(child, depth + 1)
33
- end
34
- result += ")"
35
- else
36
- result += "#{' ' * depth}#{node.inspect}"
37
- end
38
- result
39
- end
40
- end
@@ -1,170 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'net/http'
4
- require 'uri'
5
- require 'json'
6
- require 'fileutils'
7
-
8
- module Solargraph
9
- class YardMap
10
- # Tools for managing core documentation.
11
- #
12
- module CoreDocs
13
- # The URL for downloading core documentation
14
- SOURCE = 'https://solargraph.org/download'
15
-
16
- # The default core documentation version
17
- DEFAULT = '2.2.2'
18
-
19
- class << self
20
- # The directory where core documentation is installed.
21
- #
22
- # @return [String]
23
- def cache_dir
24
- # The directory is not stored in a variable so it can be overridden
25
- # in specs.
26
- ENV['SOLARGRAPH_CACHE'] || File.join(Dir.home, '.solargraph', 'cache')
27
- end
28
-
29
- # Ensure installation of minimum documentation.
30
- #
31
- # @return [void]
32
- def require_minimum
33
- FileUtils.mkdir_p File.join(cache_dir, 'gems')
34
- return unless best_match.nil?
35
- FileUtils.cp File.join(Solargraph::YARDOC_PATH, "#{DEFAULT}.tar.gz"), cache_dir
36
- install_archive File.join(cache_dir, "#{DEFAULT}.tar.gz")
37
- end
38
-
39
- # True if core documentation is installed for the specified version
40
- # number.
41
- #
42
- # @param ver [String] The version number to check
43
- # @return [Boolean]
44
- def valid?(ver)
45
- dir = File.join(cache_dir, ver)
46
- return false unless File.directory?(dir)
47
- return false unless File.directory?(File.join(dir, 'yardoc'))
48
- return false unless File.directory?(File.join(dir, 'yardoc-stdlib'))
49
- true
50
- end
51
-
52
- # Get a list of version numbers for currently installed core
53
- # documentation.
54
- #
55
- # @return [Array<String>] The installed version numbers
56
- def versions
57
- dirs = Dir[File.join(cache_dir, '*')].map{|d| File.basename(d)}
58
- dirs.keep_if{|d| valid?(d)}
59
- dirs.sort!{|a, b| Gem::Version.new(b) <=> Gem::Version.new(a)}
60
- dirs
61
- end
62
-
63
- # Get the version number of the installed core documentation that is
64
- # the closest match for the current Ruby version.
65
- #
66
- # @return [String] The closest match
67
- def best_match
68
- avail = versions
69
- cur = Gem::Version.new(RUBY_VERSION)
70
- avail.each do |v|
71
- return v if Gem::Version.new(v) <= cur
72
- end
73
- avail.last
74
- end
75
-
76
- # Get a list of core documentation versions that are available for
77
- # download.
78
- #
79
- # @return [Array<String>] The version numbers
80
- def available
81
- uri = URI.parse("#{SOURCE}/versions.json")
82
- response = Net::HTTP.get_response(uri)
83
- obj = JSON.parse(response.body)
84
- raise SourceNotAvailableError, "Error connecting to #{SOURCE}" unless obj['status'] == 'ok'
85
- obj['cores']
86
- end
87
-
88
- # Get the version number of core documentation available for download
89
- # that is the closest match for the current Ruby version.
90
- #
91
- # @param current [String] The version to compare
92
- # @return [String] The version number of the best match
93
- def best_download current = RUBY_VERSION
94
- rv = Gem::Version.new(current)
95
- found = available
96
- found.each do |ver|
97
- return ver if Gem::Version.new(ver) <= rv
98
- end
99
- found.last
100
- end
101
-
102
- # Get the path to a yardoc file for Ruby core documentation.
103
- #
104
- # @param ver [String] The version number (best match is default)
105
- # @return [String] The path to the yardoc
106
- def yardoc_file(ver = best_match)
107
- raise ArgumentError, "Invalid core yardoc version #{ver}" unless valid?(ver)
108
- File.join(cache_dir, ver, 'yardoc')
109
- end
110
-
111
- # Get the path to a yardoc file for Ruby stdlib documentation.
112
- #
113
- # @param ver [String] The version number (best match is default)
114
- # @return [String] The path to the yardoc
115
- def yardoc_stdlib_file(ver = best_match)
116
- raise ArgumentError, "Invalid core yardoc version #{ver}" unless valid?(ver)
117
- File.join(cache_dir, ver, 'yardoc-stdlib')
118
- end
119
-
120
- # Download the specified version of core documentation.
121
- #
122
- # @param version [String]
123
- # @return [void]
124
- def download version
125
- FileUtils.mkdir_p cache_dir
126
- uri = URI.parse("#{SOURCE}/#{version}.tar.gz")
127
- # @type [Net::HTTPResponse]
128
- response = Net::HTTP.get_response(uri)
129
- if response.code == '404'
130
- raise ArgumentError, "Version #{version} is not available from #{SOURCE}"
131
- else
132
- zipfile = File.join(cache_dir, "#{version}.tar.gz")
133
- File.binwrite zipfile, response.body
134
- install_archive zipfile
135
- end
136
- end
137
-
138
- # Reset the core documentation cache to the minimum requirement.
139
- #
140
- # @return [void]
141
- def clear
142
- FileUtils.rm_rf cache_dir, secure: true
143
- require_minimum
144
- end
145
-
146
- private
147
-
148
- # Extract the specified archive to the core cache directory.
149
- #
150
- # @param filename [String]
151
- # @return [void]
152
- def install_archive filename
153
- tar_extract = Gem::Package::TarReader.new(Zlib::GzipReader.open(filename))
154
- tar_extract.rewind
155
- tar_extract.each do |entry|
156
- if entry.directory?
157
- FileUtils.mkdir_p File.join(cache_dir, entry.full_name)
158
- else
159
- FileUtils.mkdir_p File.join(cache_dir, File.dirname(entry.full_name))
160
- File.open(File.join(cache_dir, entry.full_name), 'wb') do |f|
161
- f << entry.read
162
- end
163
- end
164
- end
165
- tar_extract.close
166
- end
167
- end
168
- end
169
- end
170
- end