solargraph 0.50.0 → 0.58.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.
Files changed (264) hide show
  1. checksums.yaml +4 -4
  2. data/.gitattributes +2 -0
  3. data/.github/workflows/linting.yml +127 -0
  4. data/.github/workflows/plugins.yml +218 -0
  5. data/.github/workflows/rspec.yml +58 -12
  6. data/.github/workflows/typecheck.yml +39 -0
  7. data/.gitignore +8 -0
  8. data/.overcommit.yml +72 -0
  9. data/.rspec +1 -0
  10. data/.rubocop.yml +66 -0
  11. data/.rubocop_todo.yml +1279 -0
  12. data/.yardopts +3 -2
  13. data/CHANGELOG.md +306 -3
  14. data/README.md +29 -18
  15. data/Rakefile +125 -13
  16. data/SPONSORS.md +2 -9
  17. data/bin/solargraph +3 -0
  18. data/lib/solargraph/api_map/cache.rb +110 -70
  19. data/lib/solargraph/api_map/constants.rb +279 -0
  20. data/lib/solargraph/api_map/index.rb +193 -0
  21. data/lib/solargraph/api_map/source_to_yard.rb +97 -81
  22. data/lib/solargraph/api_map/store.rb +384 -268
  23. data/lib/solargraph/api_map.rb +945 -704
  24. data/lib/solargraph/bench.rb +21 -3
  25. data/lib/solargraph/complex_type/type_methods.rb +228 -134
  26. data/lib/solargraph/complex_type/unique_type.rb +482 -132
  27. data/lib/solargraph/complex_type.rb +444 -254
  28. data/lib/solargraph/convention/active_support_concern.rb +111 -0
  29. data/lib/solargraph/convention/base.rb +20 -3
  30. data/lib/solargraph/convention/data_definition/data_assignment_node.rb +61 -0
  31. data/lib/solargraph/convention/data_definition/data_definition_node.rb +91 -0
  32. data/lib/solargraph/convention/data_definition.rb +105 -0
  33. data/lib/solargraph/convention/gemspec.rb +3 -2
  34. data/lib/solargraph/convention/struct_definition/struct_assignment_node.rb +61 -0
  35. data/lib/solargraph/convention/struct_definition/struct_definition_node.rb +102 -0
  36. data/lib/solargraph/convention/struct_definition.rb +164 -0
  37. data/lib/solargraph/convention.rb +36 -7
  38. data/lib/solargraph/converters/dd.rb +5 -0
  39. data/lib/solargraph/converters/dl.rb +3 -0
  40. data/lib/solargraph/converters/dt.rb +3 -0
  41. data/lib/solargraph/diagnostics/require_not_found.rb +53 -53
  42. data/lib/solargraph/diagnostics/rubocop.rb +118 -112
  43. data/lib/solargraph/diagnostics/rubocop_helpers.rb +68 -65
  44. data/lib/solargraph/diagnostics/type_check.rb +55 -54
  45. data/lib/solargraph/diagnostics.rb +2 -2
  46. data/lib/solargraph/doc_map.rb +439 -0
  47. data/lib/solargraph/environ.rb +9 -2
  48. data/lib/solargraph/equality.rb +34 -0
  49. data/lib/solargraph/gem_pins.rb +98 -0
  50. data/lib/solargraph/language_server/host/diagnoser.rb +89 -89
  51. data/lib/solargraph/language_server/host/dispatch.rb +130 -111
  52. data/lib/solargraph/language_server/host/message_worker.rb +112 -59
  53. data/lib/solargraph/language_server/host/sources.rb +99 -156
  54. data/lib/solargraph/language_server/host.rb +878 -869
  55. data/lib/solargraph/language_server/message/base.rb +20 -12
  56. data/lib/solargraph/language_server/message/completion_item/resolve.rb +3 -1
  57. data/lib/solargraph/language_server/message/extended/check_gem_version.rb +114 -100
  58. data/lib/solargraph/language_server/message/extended/document.rb +23 -20
  59. data/lib/solargraph/language_server/message/extended/document_gems.rb +3 -3
  60. data/lib/solargraph/language_server/message/initialize.rb +28 -1
  61. data/lib/solargraph/language_server/message/initialized.rb +1 -0
  62. data/lib/solargraph/language_server/message/text_document/completion.rb +56 -59
  63. data/lib/solargraph/language_server/message/text_document/definition.rb +40 -38
  64. data/lib/solargraph/language_server/message/text_document/document_symbol.rb +26 -23
  65. data/lib/solargraph/language_server/message/text_document/formatting.rb +148 -126
  66. data/lib/solargraph/language_server/message/text_document/hover.rb +58 -56
  67. data/lib/solargraph/language_server/message/text_document/signature_help.rb +24 -24
  68. data/lib/solargraph/language_server/message/text_document/type_definition.rb +25 -0
  69. data/lib/solargraph/language_server/message/text_document.rb +1 -1
  70. data/lib/solargraph/language_server/message/workspace/did_change_configuration.rb +5 -0
  71. data/lib/solargraph/language_server/message/workspace/did_change_workspace_folders.rb +2 -0
  72. data/lib/solargraph/language_server/message/workspace/workspace_symbol.rb +23 -23
  73. data/lib/solargraph/language_server/message.rb +1 -0
  74. data/lib/solargraph/language_server/progress.rb +143 -0
  75. data/lib/solargraph/language_server/request.rb +4 -1
  76. data/lib/solargraph/language_server/transport/adapter.rb +16 -1
  77. data/lib/solargraph/language_server/transport/data_reader.rb +2 -0
  78. data/lib/solargraph/language_server.rb +1 -0
  79. data/lib/solargraph/library.rb +683 -551
  80. data/lib/solargraph/location.rb +82 -37
  81. data/lib/solargraph/logging.rb +37 -27
  82. data/lib/solargraph/page.rb +9 -0
  83. data/lib/solargraph/parser/comment_ripper.rb +69 -52
  84. data/lib/solargraph/parser/flow_sensitive_typing.rb +255 -0
  85. data/lib/solargraph/parser/node_processor/base.rb +92 -77
  86. data/lib/solargraph/parser/node_processor.rb +62 -43
  87. data/lib/solargraph/parser/{legacy → parser_gem}/class_methods.rb +149 -135
  88. data/lib/solargraph/parser/{legacy → parser_gem}/flawed_builder.rb +4 -1
  89. data/lib/solargraph/parser/{legacy → parser_gem}/node_chainer.rb +166 -148
  90. data/lib/solargraph/parser/{legacy → parser_gem}/node_methods.rb +486 -325
  91. data/lib/solargraph/parser/{rubyvm → parser_gem}/node_processors/alias_node.rb +3 -2
  92. data/lib/solargraph/parser/parser_gem/node_processors/and_node.rb +22 -0
  93. data/lib/solargraph/parser/parser_gem/node_processors/args_node.rb +59 -0
  94. data/lib/solargraph/parser/{rubyvm → parser_gem}/node_processors/begin_node.rb +15 -15
  95. data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/block_node.rb +46 -42
  96. data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/casgn_node.rb +4 -3
  97. data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/cvasgn_node.rb +3 -2
  98. data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/def_node.rb +53 -63
  99. data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/defs_node.rb +4 -3
  100. data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/gvasgn_node.rb +3 -2
  101. data/lib/solargraph/parser/parser_gem/node_processors/if_node.rb +23 -0
  102. data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/ivasgn_node.rb +40 -38
  103. data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/lvasgn_node.rb +29 -28
  104. data/lib/solargraph/parser/parser_gem/node_processors/masgn_node.rb +59 -0
  105. data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/namespace_node.rb +10 -9
  106. data/lib/solargraph/parser/parser_gem/node_processors/opasgn_node.rb +98 -0
  107. data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/orasgn_node.rb +17 -16
  108. data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/resbody_node.rb +38 -36
  109. data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/sclass_node.rb +52 -42
  110. data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/send_node.rb +291 -257
  111. data/lib/solargraph/parser/{rubyvm → parser_gem}/node_processors/sym_node.rb +4 -2
  112. data/lib/solargraph/parser/parser_gem/node_processors/until_node.rb +29 -0
  113. data/lib/solargraph/parser/parser_gem/node_processors/while_node.rb +29 -0
  114. data/lib/solargraph/parser/parser_gem/node_processors.rb +70 -0
  115. data/lib/solargraph/parser/parser_gem.rb +12 -0
  116. data/lib/solargraph/parser/region.rb +69 -66
  117. data/lib/solargraph/parser/snippet.rb +17 -13
  118. data/lib/solargraph/parser.rb +9 -12
  119. data/lib/solargraph/pin/base.rb +729 -299
  120. data/lib/solargraph/pin/base_variable.rb +126 -84
  121. data/lib/solargraph/pin/block.rb +104 -73
  122. data/lib/solargraph/pin/breakable.rb +9 -0
  123. data/lib/solargraph/pin/callable.rb +231 -0
  124. data/lib/solargraph/pin/closure.rb +72 -37
  125. data/lib/solargraph/pin/common.rb +79 -70
  126. data/lib/solargraph/pin/constant.rb +2 -0
  127. data/lib/solargraph/pin/conversions.rb +123 -92
  128. data/lib/solargraph/pin/delegated_method.rb +120 -0
  129. data/lib/solargraph/pin/documenting.rb +114 -105
  130. data/lib/solargraph/pin/instance_variable.rb +34 -30
  131. data/lib/solargraph/pin/keyword.rb +20 -15
  132. data/lib/solargraph/pin/local_variable.rb +75 -55
  133. data/lib/solargraph/pin/method.rb +672 -335
  134. data/lib/solargraph/pin/method_alias.rb +34 -31
  135. data/lib/solargraph/pin/namespace.rb +115 -94
  136. data/lib/solargraph/pin/parameter.rb +275 -206
  137. data/lib/solargraph/pin/proxy_type.rb +39 -29
  138. data/lib/solargraph/pin/reference/override.rb +47 -29
  139. data/lib/solargraph/pin/reference/require.rb +2 -2
  140. data/lib/solargraph/pin/reference/superclass.rb +15 -10
  141. data/lib/solargraph/pin/reference.rb +39 -14
  142. data/lib/solargraph/pin/search.rb +61 -56
  143. data/lib/solargraph/pin/signature.rb +61 -23
  144. data/lib/solargraph/pin/singleton.rb +1 -1
  145. data/lib/solargraph/pin/symbol.rb +53 -47
  146. data/lib/solargraph/pin/until.rb +18 -0
  147. data/lib/solargraph/pin/while.rb +18 -0
  148. data/lib/solargraph/pin.rb +44 -38
  149. data/lib/solargraph/pin_cache.rb +245 -0
  150. data/lib/solargraph/position.rb +132 -100
  151. data/lib/solargraph/range.rb +112 -95
  152. data/lib/solargraph/rbs_map/conversions.rb +823 -394
  153. data/lib/solargraph/rbs_map/core_fills.rb +53 -30
  154. data/lib/solargraph/rbs_map/core_map.rb +58 -38
  155. data/lib/solargraph/rbs_map/stdlib_map.rb +43 -36
  156. data/lib/solargraph/rbs_map.rb +163 -73
  157. data/lib/solargraph/shell.rb +352 -244
  158. data/lib/solargraph/source/chain/array.rb +37 -0
  159. data/lib/solargraph/source/chain/block_symbol.rb +13 -0
  160. data/lib/solargraph/source/chain/block_variable.rb +1 -1
  161. data/lib/solargraph/source/chain/call.rb +337 -215
  162. data/lib/solargraph/source/chain/constant.rb +26 -75
  163. data/lib/solargraph/source/chain/hash.rb +34 -28
  164. data/lib/solargraph/source/chain/head.rb +1 -1
  165. data/lib/solargraph/source/chain/if.rb +28 -0
  166. data/lib/solargraph/source/chain/instance_variable.rb +13 -13
  167. data/lib/solargraph/source/chain/link.rb +44 -6
  168. data/lib/solargraph/source/chain/literal.rb +48 -23
  169. data/lib/solargraph/source/chain/or.rb +23 -23
  170. data/lib/solargraph/source/chain/z_super.rb +4 -4
  171. data/lib/solargraph/source/chain.rb +291 -179
  172. data/lib/solargraph/source/change.rb +82 -79
  173. data/lib/solargraph/source/cursor.rb +166 -164
  174. data/lib/solargraph/source/encoding_fixes.rb +23 -23
  175. data/lib/solargraph/source/source_chainer.rb +194 -191
  176. data/lib/solargraph/source/updater.rb +55 -54
  177. data/lib/solargraph/source.rb +498 -522
  178. data/lib/solargraph/source_map/clip.rb +226 -229
  179. data/lib/solargraph/source_map/data.rb +34 -0
  180. data/lib/solargraph/source_map/mapper.rb +259 -243
  181. data/lib/solargraph/source_map.rb +212 -180
  182. data/lib/solargraph/type_checker/checks.rb +124 -112
  183. data/lib/solargraph/type_checker/param_def.rb +37 -35
  184. data/lib/solargraph/type_checker/problem.rb +32 -32
  185. data/lib/solargraph/type_checker/rules.rb +84 -57
  186. data/lib/solargraph/type_checker.rb +814 -549
  187. data/lib/solargraph/version.rb +5 -5
  188. data/lib/solargraph/views/_method.erb +10 -10
  189. data/lib/solargraph/views/_namespace.erb +3 -3
  190. data/lib/solargraph/views/document.erb +10 -10
  191. data/lib/solargraph/views/environment.erb +3 -5
  192. data/lib/solargraph/workspace/config.rb +255 -231
  193. data/lib/solargraph/workspace/require_paths.rb +97 -0
  194. data/lib/solargraph/workspace.rb +220 -212
  195. data/lib/solargraph/yard_map/cache.rb +6 -0
  196. data/lib/solargraph/yard_map/helpers.rb +44 -16
  197. data/lib/solargraph/yard_map/mapper/to_constant.rb +8 -5
  198. data/lib/solargraph/yard_map/mapper/to_method.rb +130 -81
  199. data/lib/solargraph/yard_map/mapper/to_namespace.rb +31 -27
  200. data/lib/solargraph/yard_map/mapper.rb +79 -77
  201. data/lib/solargraph/yard_map/to_method.rb +89 -79
  202. data/lib/solargraph/yard_map.rb +1 -284
  203. data/lib/solargraph/yard_tags.rb +20 -0
  204. data/lib/solargraph/yardoc.rb +87 -0
  205. data/lib/solargraph.rb +105 -69
  206. data/rbs/fills/bundler/0/bundler.rbs +4271 -0
  207. data/rbs/fills/open3/0/open3.rbs +172 -0
  208. data/rbs/fills/rubygems/0/basic_specification.rbs +326 -0
  209. data/rbs/fills/rubygems/0/errors.rbs +364 -0
  210. data/rbs/fills/rubygems/0/spec_fetcher.rbs +107 -0
  211. data/rbs/fills/rubygems/0/specification.rbs +1753 -0
  212. data/rbs/fills/tuple/tuple.rbs +149 -0
  213. data/rbs/shims/ast/0/node.rbs +5 -0
  214. data/rbs/shims/ast/2.4/.rbs_meta.yaml +9 -0
  215. data/rbs/shims/ast/2.4/ast.rbs +73 -0
  216. data/rbs/shims/parser/3.2.0.1/builders/default.rbs +195 -0
  217. data/rbs/shims/parser/3.2.0.1/manifest.yaml +7 -0
  218. data/rbs/shims/parser/3.2.0.1/parser.rbs +201 -0
  219. data/rbs/shims/parser/3.2.0.1/polyfill.rbs +4 -0
  220. data/rbs/shims/thor/1.2.0.1/.rbs_meta.yaml +9 -0
  221. data/rbs/shims/thor/1.2.0.1/manifest.yaml +7 -0
  222. data/rbs/shims/thor/1.2.0.1/thor.rbs +17 -0
  223. data/rbs_collection.yaml +19 -0
  224. data/solargraph.gemspec +39 -11
  225. metadata +354 -97
  226. data/lib/.rubocop.yml +0 -22
  227. data/lib/solargraph/api_map/bundler_methods.rb +0 -22
  228. data/lib/solargraph/cache.rb +0 -53
  229. data/lib/solargraph/convention/rspec.rb +0 -30
  230. data/lib/solargraph/documentor.rb +0 -76
  231. data/lib/solargraph/language_server/host/cataloger.rb +0 -56
  232. data/lib/solargraph/parser/legacy/node_processors/alias_node.rb +0 -23
  233. data/lib/solargraph/parser/legacy/node_processors/args_node.rb +0 -35
  234. data/lib/solargraph/parser/legacy/node_processors/begin_node.rb +0 -15
  235. data/lib/solargraph/parser/legacy/node_processors/sym_node.rb +0 -18
  236. data/lib/solargraph/parser/legacy/node_processors.rb +0 -54
  237. data/lib/solargraph/parser/legacy.rb +0 -12
  238. data/lib/solargraph/parser/node_methods.rb +0 -43
  239. data/lib/solargraph/parser/rubyvm/class_methods.rb +0 -149
  240. data/lib/solargraph/parser/rubyvm/node_chainer.rb +0 -160
  241. data/lib/solargraph/parser/rubyvm/node_methods.rb +0 -315
  242. data/lib/solargraph/parser/rubyvm/node_processors/args_node.rb +0 -85
  243. data/lib/solargraph/parser/rubyvm/node_processors/block_node.rb +0 -42
  244. data/lib/solargraph/parser/rubyvm/node_processors/casgn_node.rb +0 -33
  245. data/lib/solargraph/parser/rubyvm/node_processors/cvasgn_node.rb +0 -23
  246. data/lib/solargraph/parser/rubyvm/node_processors/def_node.rb +0 -75
  247. data/lib/solargraph/parser/rubyvm/node_processors/defs_node.rb +0 -68
  248. data/lib/solargraph/parser/rubyvm/node_processors/gvasgn_node.rb +0 -23
  249. data/lib/solargraph/parser/rubyvm/node_processors/ivasgn_node.rb +0 -38
  250. data/lib/solargraph/parser/rubyvm/node_processors/kw_arg_node.rb +0 -39
  251. data/lib/solargraph/parser/rubyvm/node_processors/lit_node.rb +0 -20
  252. data/lib/solargraph/parser/rubyvm/node_processors/lvasgn_node.rb +0 -27
  253. data/lib/solargraph/parser/rubyvm/node_processors/namespace_node.rb +0 -39
  254. data/lib/solargraph/parser/rubyvm/node_processors/opt_arg_node.rb +0 -26
  255. data/lib/solargraph/parser/rubyvm/node_processors/orasgn_node.rb +0 -15
  256. data/lib/solargraph/parser/rubyvm/node_processors/resbody_node.rb +0 -45
  257. data/lib/solargraph/parser/rubyvm/node_processors/sclass_node.rb +0 -32
  258. data/lib/solargraph/parser/rubyvm/node_processors/scope_node.rb +0 -15
  259. data/lib/solargraph/parser/rubyvm/node_processors/send_node.rb +0 -279
  260. data/lib/solargraph/parser/rubyvm/node_processors.rb +0 -63
  261. data/lib/solargraph/parser/rubyvm/node_wrapper.rb +0 -47
  262. data/lib/solargraph/parser/rubyvm.rb +0 -40
  263. data/lib/solargraph/rbs_map/core_signs.rb +0 -33
  264. data/lib/yard-solargraph.rb +0 -33
@@ -1,5 +1,5 @@
1
- # frozen_string_literal: true
2
-
3
- module Solargraph
4
- VERSION = '0.50.0'
5
- end
1
+ # frozen_string_literal: true
2
+
3
+ module Solargraph
4
+ VERSION = '0.58.2'
5
+ end
@@ -2,33 +2,33 @@
2
2
  Namespace:
3
3
  </h2>
4
4
  <p>
5
- <a href="solargraph:/document?query=<%= CGI.escape object.namespace.path %>"><%= object.namespace %></a>
5
+ <a href="solargraph:/document?query=<%= CGI.escape pin.namespace.path %>"><%= pin.namespace %></a>
6
6
  </p>
7
7
  <h2>
8
8
  Overview:
9
9
  </h2>
10
- <%= htmlify object.docstring %>
10
+ <%= htmlify pin.docstring %>
11
11
  <p class="document-section">
12
- <big><strong>Visibility:</strong></big> <%= object.visibility %>
12
+ <big><strong>Visibility:</strong></big> <%= pin.visibility %>
13
13
  </p>
14
- <% unless object.tags(:param).empty? %>
14
+ <% unless pin.docstring.tags(:param).empty? %>
15
15
  <h2>
16
16
  Parameters:
17
17
  </h2>
18
18
  <ul>
19
- <% object.tags(:param).each do |tag| %>
19
+ <% pin.docstring.tags(:param).each do |tag| %>
20
20
  <li>
21
21
  <%= erb :_name_type_tag, layout: false, locals: {tag: tag} %>
22
22
  </li>
23
23
  <% end %>
24
24
  </ul>
25
25
  <% end %>
26
- <% unless object.tags(:raise).empty? %>
26
+ <% unless pin.docstring.tags(:raise).empty? %>
27
27
  <h2>
28
28
  Raises:
29
29
  </h2>
30
30
  <ul>
31
- <% object.tags(:raise).each do |tag| %>
31
+ <% pin.docstring.tags(:raise).each do |tag| %>
32
32
  <li>
33
33
  <%= erb :_name_type_tag, layout: false, locals: {tag: tag} %>
34
34
  </li>
@@ -38,20 +38,20 @@
38
38
  <h2>
39
39
  Returns:
40
40
  </h2>
41
- <% if object.tag(:return).nil? %>
41
+ <% if pin.docstring.tag(:return).nil? %>
42
42
  <p>
43
43
  Undefined/unknown
44
44
  </p>
45
45
  <% else %>
46
46
  <ul>
47
- <% object.tags(:return).each do |tag| %>
47
+ <% pin.tags(:return).each do |tag| %>
48
48
  <li>
49
49
  <%= erb :_name_type_tag, layout: false, locals: {tag: tag} %>
50
50
  </li>
51
51
  <% end %>
52
52
  </ul>
53
53
  <% end %>
54
- <% examples = object.tags(:example) %>
54
+ <% examples = pin.docstring.tags(:example) %>
55
55
  <% unless examples.nil? %>
56
56
  <% examples.each do |example| %>
57
57
  <h2>
@@ -1,12 +1,12 @@
1
1
  <h2>
2
2
  Overview:
3
3
  </h2>
4
- <%= htmlify object.docstring %>
4
+ <%= htmlify pin.docstring %>
5
5
  <h2>
6
6
  Class Methods
7
7
  </h2>
8
8
  <ul class="doc-list">
9
- <% object.meths(scope: :class).sort{|a, b| a.name <=> b.name}.each do |meth| %>
9
+ <% api_map.get_methods(pin.path, scope: :class, deep: false).sort{|a, b| a.name <=> b.name}.each do |meth| %>
10
10
  <li>
11
11
  <a href="solargraph:/document?query=<%= CGI.escape(meth.path) %>"><%= meth.name %></a>
12
12
  </li>
@@ -16,7 +16,7 @@
16
16
  Instance Methods
17
17
  </h2>
18
18
  <ul class="doc-list">
19
- <% object.meths(scope: :instance).sort{|a, b| a.name <=> b.name}.each do |meth| %>
19
+ <% api_map.get_methods(pin.path, scope: :instance, deep: false).sort{|a, b| a.name <=> b.name}.each do |meth| %>
20
20
  <li>
21
21
  <a href="solargraph:/document?query=<%= CGI.escape(meth.path) %>"><%= meth.name %></a>
22
22
  </li>
@@ -1,23 +1,23 @@
1
- <% objects.reverse.each do |object| %>
1
+ <% pins.each do |pin| %>
2
2
  <h1>
3
- <%= object.name %>
4
- <% if object.is_a?(YARD::CodeObjects::MethodObject) and !object.parameters.empty? %>
5
- <small>(<%= object.parameters.map {|p| "#{p[0]}#{p[1] and p[0].end_with?(':') ? ' ' : (p[1] ? ' = ' : '')}#{p[1]}"}.join(', ') %>)</small>
3
+ <%= pin.name %>
4
+ <% if pin.is_a?(Solargraph::Pin::Method) && !pin.parameters.empty? %>
5
+ <small>(<%= pin.parameters.map {|p| "#{p[0]}#{p[1] and p[0].end_with?(':') ? ' ' : (p[1] ? ' = ' : '')}#{p[1]}"}.join(', ') %>)</small>
6
6
  <% end %>
7
7
  </h1>
8
- <% unless object.files.empty? %>
8
+ <% unless pins.map(&:location).compact.empty? %>
9
9
  <h2>
10
10
  Defined in:
11
11
  </h2>
12
12
  <ul>
13
- <% object.files.each do |f| %>
13
+ <% pins.map(&:location).compact.map(&:filename).each do |f| %>
14
14
  <li><%= f %></li>
15
15
  <% end %>
16
16
  </ul>
17
17
  <% end %>
18
- <% if object.is_a?(YARD::CodeObjects::NamespaceObject) %>
19
- <%= erb :_namespace, layout: false, locals: {object: object} %>
20
- <% elsif object.is_a?(YARD::CodeObjects::MethodObject) %>
21
- <%= erb :_method, layout: false, locals: {object: object} %>
18
+ <% if pin.is_a?(Solargraph::Pin::Namespace) %>
19
+ <%= erb :_namespace, layout: false, locals: {api_map: api_map, pin: pin} %>
20
+ <% elsif pin.is_a?(Solargraph::Pin::Method) %>
21
+ <%= erb :_method, layout: false, locals: {api_map: api_map, pin: pin} %>
22
22
  <% end %>
23
23
  <% end %>
@@ -35,11 +35,9 @@
35
35
  <li>
36
36
  Core Cache Directory: N/A <%# @todo Fix %>
37
37
  </li>
38
- <% unless Solargraph::Parser.rubyvm? %>
39
- <li>
40
- Parser Target Version: <%= Solargraph::Parser.version %>
41
- </li>
42
- <% end %>
38
+ <li>
39
+ Parser Target Version: <%= Solargraph::Parser.version %>
40
+ </li>
43
41
  <li>
44
42
  Using Bundler: <%= ENV.key?('BUNDLE_BIN_PATH') %>
45
43
  </li>
@@ -1,231 +1,255 @@
1
- # frozen_string_literal: true
2
-
3
- require 'yaml'
4
-
5
- module Solargraph
6
- class Workspace
7
- # Configuration data for a workspace.
8
- #
9
- class Config
10
- # The maximum number of files that can be added to a workspace.
11
- # The workspace's .solargraph.yml can override this value.
12
- MAX_FILES = 5000
13
-
14
- # @return [String]
15
- attr_reader :directory
16
-
17
- # @return [Hash]
18
- attr_reader :raw_data
19
-
20
- # @param directory [String]
21
- def initialize directory = ''
22
- @directory = directory
23
- @raw_data = config_data
24
- included
25
- excluded
26
- end
27
-
28
- # An array of files included in the workspace (before calculating excluded files).
29
- #
30
- # @return [Array<String>]
31
- def included
32
- return [] if directory.empty? || directory == '*'
33
- @included ||= process_globs(@raw_data['include'])
34
- end
35
-
36
- # An array of files excluded from the workspace.
37
- #
38
- # @return [Array<String>]
39
- def excluded
40
- return [] if directory.empty? || directory == '*'
41
- @excluded ||= process_exclusions(@raw_data['exclude'])
42
- end
43
-
44
- def allow? filename
45
- filename.start_with?(directory) &&
46
- !excluded.include?(filename) &&
47
- excluded_directories.none? { |d| filename.start_with?(d) }
48
- end
49
-
50
- # The calculated array of (included - excluded) files in the workspace.
51
- #
52
- # @return [Array<String>]
53
- def calculated
54
- Solargraph.logger.info "Indexing workspace files in #{directory}" unless @calculated || directory.empty? || directory == '*'
55
- @calculated ||= included - excluded
56
- end
57
-
58
- # An array of domains configured for the workspace.
59
- # A domain is a namespace that the ApiMap should include in the global
60
- # namespace. It's typically used to identify available DSLs.
61
- #
62
- # @return [Array<String>]
63
- def domains
64
- raw_data['domains']
65
- end
66
-
67
- # An array of required paths to add to the workspace.
68
- #
69
- # @return [Array<String>]
70
- def required
71
- raw_data['require']
72
- end
73
-
74
- # An array of load paths for required paths.
75
- #
76
- # @return [Array<String>]
77
- def require_paths
78
- raw_data['require_paths'] || []
79
- end
80
-
81
- # An array of reporters to use for diagnostics.
82
- #
83
- # @return [Array<String>]
84
- def reporters
85
- raw_data['reporters']
86
- end
87
-
88
- # A hash of options supported by the formatter
89
- #
90
- # @return [Hash]
91
- def formatter
92
- raw_data['formatter']
93
- end
94
-
95
- # An array of plugins to require.
96
- #
97
- # @return [Array<String>]
98
- def plugins
99
- raw_data['plugins']
100
- end
101
-
102
- # The maximum number of files to parse from the workspace.
103
- #
104
- # @return [Integer]
105
- def max_files
106
- raw_data['max_files']
107
- end
108
-
109
- private
110
-
111
- # @return [String]
112
- def global_config_path
113
- ENV['SOLARGRAPH_GLOBAL_CONFIG'] ||
114
- File.join(Dir.home, '.config', 'solargraph', 'config.yml')
115
- end
116
-
117
- # @return [String]
118
- def workspace_config_path
119
- return '' if @directory.empty?
120
- File.join(@directory, '.solargraph.yml')
121
- end
122
-
123
- # @return [Hash]
124
- def config_data
125
- workspace_config = read_config(workspace_config_path)
126
- global_config = read_config(global_config_path)
127
-
128
- defaults = default_config
129
- defaults.merge({'exclude' => []}) unless workspace_config.nil?
130
-
131
- defaults
132
- .merge(global_config || {})
133
- .merge(workspace_config || {})
134
- end
135
-
136
- # Read a .solargraph yaml config
137
- #
138
- # @param directory [String]
139
- # @return [Hash, nil]
140
- def read_config config_path = ''
141
- return nil if config_path.empty?
142
- return nil unless File.file?(config_path)
143
- YAML.safe_load(File.read(config_path))
144
- end
145
-
146
- # @return [Hash]
147
- def default_config
148
- {
149
- 'include' => ['**/*.rb'],
150
- 'exclude' => ['spec/**/*', 'test/**/*', 'vendor/**/*', '.bundle/**/*'],
151
- 'require' => [],
152
- 'domains' => [],
153
- 'reporters' => %w[rubocop require_not_found],
154
- 'formatter' => {
155
- 'rubocop' => {
156
- 'cops' => 'safe',
157
- 'except' => [],
158
- 'only' => [],
159
- 'extra_args' =>[]
160
- }
161
- },
162
- 'require_paths' => [],
163
- 'plugins' => [],
164
- 'max_files' => MAX_FILES
165
- }
166
- end
167
-
168
- # Get an array of files from the provided globs.
169
- #
170
- # @param globs [Array<String>]
171
- # @return [Array<String>]
172
- def process_globs globs
173
- result = globs.flat_map do |glob|
174
- Dir[File.join directory, glob]
175
- .map{ |f| f.gsub(/\\/, '/') }
176
- .select { |f| File.file?(f) }
177
- end
178
- result
179
- end
180
-
181
- # Modify the included files based on excluded directories and get an
182
- # array of additional files to exclude.
183
- #
184
- # @param globs [Array<String>]
185
- # @return [Array<String>]
186
- def process_exclusions globs
187
- remainder = globs.select do |glob|
188
- if glob_is_directory?(glob)
189
- exdir = File.join(directory, glob_to_directory(glob))
190
- included.delete_if { |file| file.start_with?(exdir) }
191
- false
192
- else
193
- true
194
- end
195
- end
196
- process_globs remainder
197
- end
198
-
199
- # True if the glob translates to a whole directory.
200
- #
201
- # @example
202
- # glob_is_directory?('path/to/dir') # => true
203
- # glob_is_directory?('path/to/dir/**/*) # => true
204
- # glob_is_directory?('path/to/file.txt') # => false
205
- # glob_is_directory?('path/to/*.txt') # => false
206
- #
207
- # @param glob [String]
208
- # @return [Boolean]
209
- def glob_is_directory? glob
210
- File.directory?(glob) || File.directory?(glob_to_directory(glob))
211
- end
212
-
213
- # Translate a glob to a base directory if applicable
214
- #
215
- # @example
216
- # glob_to_directory('path/to/dir/**/*') # => 'path/to/dir'
217
- #
218
- # @param glob [String]
219
- # @return [String]
220
- def glob_to_directory glob
221
- glob.gsub(/(\/\*|\/\*\*\/\*\*?)$/, '')
222
- end
223
-
224
- def excluded_directories
225
- @raw_data['exclude']
226
- .select { |g| glob_is_directory?(g) }
227
- .map { |g| File.join(directory, glob_to_directory(g)) }
228
- end
229
- end
230
- end
231
- end
1
+ # frozen_string_literal: true
2
+
3
+ require 'yaml'
4
+
5
+ module Solargraph
6
+ class Workspace
7
+ # Configuration data for a workspace.
8
+ #
9
+ class Config
10
+ # The maximum number of files that can be added to a workspace.
11
+ # The workspace's .solargraph.yml can override this value.
12
+ MAX_FILES = 5000
13
+
14
+ # @return [String]
15
+ attr_reader :directory
16
+
17
+ # @todo To make JSON strongly typed we'll need a record syntax
18
+ # @return [Hash{String => undefined, nil}]
19
+ attr_reader :raw_data
20
+
21
+ # @param directory [String]
22
+ def initialize directory = ''
23
+ @directory = File.absolute_path(directory)
24
+ @raw_data = config_data
25
+ included
26
+ excluded
27
+ end
28
+
29
+ # An array of files included in the workspace (before calculating excluded files).
30
+ #
31
+ # @return [Array<String>]
32
+ def included
33
+ return [] if directory.empty? || directory == '*'
34
+ @included ||= process_globs(@raw_data['include'])
35
+ end
36
+
37
+ # An array of files excluded from the workspace.
38
+ #
39
+ # @return [Array<String>]
40
+ def excluded
41
+ return [] if directory.empty? || directory == '*'
42
+ @excluded ||= process_exclusions(@raw_data['exclude'])
43
+ end
44
+
45
+ # @param filename [String]
46
+ def allow? filename
47
+ filename = File.absolute_path(filename, directory)
48
+ filename.start_with?(directory) &&
49
+ !excluded.include?(filename) &&
50
+ excluded_directories.none? { |d| filename.start_with?(d) }
51
+ end
52
+
53
+ # The calculated array of (included - excluded) files in the workspace.
54
+ #
55
+ # @return [Array<String>]
56
+ def calculated
57
+ Solargraph.logger.info "Indexing workspace files in #{directory}" unless @calculated || directory.empty? || directory == '*'
58
+ @calculated ||= included - excluded
59
+ end
60
+
61
+ # An array of domains configured for the workspace.
62
+ # A domain is a namespace that the ApiMap should include in the global
63
+ # namespace. It's typically used to identify available DSLs.
64
+ #
65
+ # @return [Array<String>]
66
+ # @sg-ignore Need to validate config
67
+ def domains
68
+ raw_data['domains']
69
+ end
70
+
71
+ # An array of required paths to add to the workspace.
72
+ #
73
+ # @return [Array<String>]
74
+ # @sg-ignore Need to validate config
75
+ def required
76
+ raw_data['require']
77
+ end
78
+
79
+ # An array of load paths for required paths.
80
+ #
81
+ # @return [Array<String>]
82
+ def require_paths
83
+ raw_data['require_paths'] || []
84
+ end
85
+
86
+ # An array of reporters to use for diagnostics.
87
+ #
88
+ # @sg-ignore Need to validate config
89
+ # @return [Array<String>]
90
+ def reporters
91
+ raw_data['reporters']
92
+ end
93
+
94
+ # A hash of options supported by the formatter
95
+ #
96
+ # @sg-ignore Need to validate config
97
+ # @return [Hash]
98
+ def formatter
99
+ raw_data['formatter']
100
+ end
101
+
102
+ # An array of plugins to require.
103
+ #
104
+ # @sg-ignore Need to validate config
105
+ # @return [Array<String>]
106
+ def plugins
107
+ raw_data['plugins']
108
+ end
109
+
110
+ # The maximum number of files to parse from the workspace.
111
+ #
112
+ # @sg-ignore Need to validate config
113
+ # @return [Integer]
114
+ def max_files
115
+ raw_data['max_files']
116
+ end
117
+
118
+ # @return [Hash{Symbol => Symbol}]
119
+ def type_checker_rules
120
+ # @type [Hash{String => String}]
121
+ raw_rules = raw_data.fetch('type_checker', {}).fetch('rules', {})
122
+ raw_rules.to_h do |k, v|
123
+ [k.to_sym, v.to_sym]
124
+ end
125
+ end
126
+
127
+ private
128
+
129
+ # @return [String]
130
+ def global_config_path
131
+ ENV['SOLARGRAPH_GLOBAL_CONFIG'] ||
132
+ File.join(Dir.home, '.config', 'solargraph', 'config.yml')
133
+ end
134
+
135
+ # @return [String]
136
+ def workspace_config_path
137
+ return '' if @directory.empty?
138
+ File.join(@directory, '.solargraph.yml')
139
+ end
140
+
141
+ # @return [Hash{String => undefined}]
142
+ def config_data
143
+ workspace_config = read_config(workspace_config_path)
144
+ global_config = read_config(global_config_path)
145
+
146
+ defaults = default_config
147
+ defaults.merge({'exclude' => []}) unless workspace_config.nil?
148
+
149
+ defaults
150
+ .merge(global_config || {})
151
+ .merge(workspace_config || {})
152
+ end
153
+
154
+ # Read a .solargraph yaml config
155
+ #
156
+ # @param config_path [String]
157
+ # @return [Hash{String => Array, Hash, Integer}, nil]
158
+ def read_config config_path = ''
159
+ return nil if config_path.empty?
160
+ return nil unless File.file?(config_path)
161
+ YAML.safe_load(File.read(config_path))
162
+ end
163
+
164
+ # @return [Hash{String => Array, Hash, Integer}]
165
+ def default_config
166
+ {
167
+ 'include' => ['Rakefile', 'Gemfile', '*.gemspec', '**/*.rb'],
168
+ 'exclude' => ['spec/**/*', 'test/**/*', 'vendor/**/*', '.bundle/**/*'],
169
+ 'require' => [],
170
+ 'domains' => [],
171
+ 'reporters' => %w[rubocop require_not_found],
172
+ 'formatter' => {
173
+ 'rubocop' => {
174
+ 'cops' => 'safe',
175
+ 'except' => [],
176
+ 'only' => [],
177
+ 'extra_args' =>[]
178
+ }
179
+ },
180
+ 'type_checker' => {
181
+ 'rules' => { }
182
+ },
183
+ 'require_paths' => [],
184
+ 'plugins' => [],
185
+ 'max_files' => MAX_FILES
186
+ }
187
+ end
188
+
189
+ # Get an array of files from the provided globs.
190
+ #
191
+ # @param globs [Array<String>]
192
+ # @return [Array<String>]
193
+ def process_globs globs
194
+ result = globs.flat_map do |glob|
195
+ Dir[File.absolute_path(glob, directory)]
196
+ .map{ |f| f.gsub(/\\/, '/') }
197
+ .select { |f| File.file?(f) }
198
+ end
199
+ result
200
+ end
201
+
202
+ # Modify the included files based on excluded directories and get an
203
+ # array of additional files to exclude.
204
+ #
205
+ # @param globs [Array<String>]
206
+ # @return [Array<String>]
207
+ def process_exclusions globs
208
+ remainder = globs.select do |glob|
209
+ if glob_is_directory?(glob)
210
+ exdir = File.absolute_path(glob_to_directory(glob), directory)
211
+ included.delete_if { |file| file.start_with?(exdir) }
212
+ false
213
+ else
214
+ true
215
+ end
216
+ end
217
+ process_globs remainder
218
+ end
219
+
220
+ # True if the glob translates to a whole directory.
221
+ #
222
+ # @example
223
+ # glob_is_directory?('path/to/dir') # => true
224
+ # glob_is_directory?('path/to/dir/**/*) # => true
225
+ # glob_is_directory?('path/to/file.txt') # => false
226
+ # glob_is_directory?('path/to/*.txt') # => false
227
+ #
228
+ # @param glob [String]
229
+ # @return [Boolean]
230
+ def glob_is_directory? glob
231
+ File.directory?(glob) || File.directory?(glob_to_directory(glob))
232
+ end
233
+
234
+ # Translate a glob to a base directory if applicable
235
+ #
236
+ # @example
237
+ # glob_to_directory('path/to/dir/**/*') # => 'path/to/dir'
238
+ #
239
+ # @param glob [String]
240
+ # @return [String]
241
+ def glob_to_directory glob
242
+ glob.gsub(/(\/\*|\/\*\*\/\*\*?)$/, '')
243
+ end
244
+
245
+ # @return [Array<String>]
246
+ def excluded_directories
247
+ # @type [Array<String>]
248
+ excluded = @raw_data['exclude']
249
+ excluded
250
+ .select { |g| glob_is_directory?(g) }
251
+ .map { |g| File.absolute_path(glob_to_directory(g), directory) }
252
+ end
253
+ end
254
+ end
255
+ end