solargraph 0.46.0 → 0.54.5

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 (279) 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 +37 -41
  5. data/.github/workflows/typecheck.yml +34 -0
  6. data/.gitignore +9 -9
  7. data/.rspec +2 -2
  8. data/.yardopts +2 -2
  9. data/CHANGELOG.md +1338 -1115
  10. data/Gemfile +0 -0
  11. data/LICENSE +1 -1
  12. data/README.md +131 -128
  13. data/Rakefile +0 -0
  14. data/SPONSORS.md +10 -18
  15. data/bin/solargraph +0 -0
  16. data/lib/solargraph/api_map/cache.rb +109 -70
  17. data/lib/solargraph/api_map/index.rb +167 -0
  18. data/lib/solargraph/api_map/source_to_yard.rb +88 -81
  19. data/lib/solargraph/api_map/store.rb +260 -256
  20. data/lib/solargraph/api_map.rb +870 -686
  21. data/lib/solargraph/bench.rb +44 -27
  22. data/lib/solargraph/cache.rb +77 -0
  23. data/lib/solargraph/complex_type/type_methods.rb +217 -130
  24. data/lib/solargraph/complex_type/unique_type.rb +386 -75
  25. data/lib/solargraph/complex_type.rb +394 -221
  26. data/lib/solargraph/convention/base.rb +33 -33
  27. data/lib/solargraph/convention/gemfile.rb +15 -15
  28. data/lib/solargraph/convention/gemspec.rb +22 -22
  29. data/lib/solargraph/convention/rakefile.rb +17 -0
  30. data/lib/solargraph/convention.rb +47 -47
  31. data/lib/solargraph/converters/dd.rb +17 -12
  32. data/lib/solargraph/converters/dl.rb +15 -12
  33. data/lib/solargraph/converters/dt.rb +15 -12
  34. data/lib/solargraph/converters/misc.rb +1 -1
  35. data/lib/solargraph/diagnostics/base.rb +29 -29
  36. data/lib/solargraph/diagnostics/require_not_found.rb +53 -53
  37. data/lib/solargraph/diagnostics/rubocop.rb +113 -98
  38. data/lib/solargraph/diagnostics/rubocop_helpers.rb +66 -63
  39. data/lib/solargraph/diagnostics/severities.rb +15 -15
  40. data/lib/solargraph/diagnostics/type_check.rb +55 -54
  41. data/lib/solargraph/diagnostics/update_errors.rb +41 -41
  42. data/lib/solargraph/diagnostics.rb +55 -55
  43. data/lib/solargraph/doc_map.rb +188 -0
  44. data/lib/solargraph/environ.rb +45 -45
  45. data/lib/solargraph/equality.rb +33 -0
  46. data/lib/solargraph/gem_pins.rb +72 -0
  47. data/lib/solargraph/language_server/completion_item_kinds.rb +35 -35
  48. data/lib/solargraph/language_server/error_codes.rb +20 -20
  49. data/lib/solargraph/language_server/host/diagnoser.rb +89 -89
  50. data/lib/solargraph/language_server/host/dispatch.rb +128 -111
  51. data/lib/solargraph/language_server/host/message_worker.rb +106 -59
  52. data/lib/solargraph/language_server/host/sources.rb +99 -156
  53. data/lib/solargraph/language_server/host.rb +861 -865
  54. data/lib/solargraph/language_server/message/base.rb +96 -89
  55. data/lib/solargraph/language_server/message/cancel_request.rb +13 -13
  56. data/lib/solargraph/language_server/message/client/register_capability.rb +15 -15
  57. data/lib/solargraph/language_server/message/client.rb +11 -11
  58. data/lib/solargraph/language_server/message/completion_item/resolve.rb +60 -58
  59. data/lib/solargraph/language_server/message/completion_item.rb +11 -11
  60. data/lib/solargraph/language_server/message/exit_notification.rb +13 -13
  61. data/lib/solargraph/language_server/message/extended/check_gem_version.rb +112 -100
  62. data/lib/solargraph/language_server/message/extended/document.rb +20 -20
  63. data/lib/solargraph/language_server/message/extended/document_gems.rb +32 -32
  64. data/lib/solargraph/language_server/message/extended/download_core.rb +19 -23
  65. data/lib/solargraph/language_server/message/extended/environment.rb +25 -25
  66. data/lib/solargraph/language_server/message/extended/search.rb +20 -20
  67. data/lib/solargraph/language_server/message/extended.rb +21 -21
  68. data/lib/solargraph/language_server/message/initialize.rb +191 -162
  69. data/lib/solargraph/language_server/message/initialized.rb +28 -27
  70. data/lib/solargraph/language_server/message/method_not_found.rb +16 -16
  71. data/lib/solargraph/language_server/message/method_not_implemented.rb +14 -14
  72. data/lib/solargraph/language_server/message/shutdown.rb +13 -13
  73. data/lib/solargraph/language_server/message/text_document/base.rb +19 -19
  74. data/lib/solargraph/language_server/message/text_document/code_action.rb +17 -17
  75. data/lib/solargraph/language_server/message/text_document/completion.rb +56 -59
  76. data/lib/solargraph/language_server/message/text_document/definition.rb +38 -38
  77. data/lib/solargraph/language_server/message/text_document/did_change.rb +15 -15
  78. data/lib/solargraph/language_server/message/text_document/did_close.rb +15 -15
  79. data/lib/solargraph/language_server/message/text_document/did_open.rb +15 -15
  80. data/lib/solargraph/language_server/message/text_document/did_save.rb +17 -17
  81. data/lib/solargraph/language_server/message/text_document/document_highlight.rb +16 -16
  82. data/lib/solargraph/language_server/message/text_document/document_symbol.rb +26 -23
  83. data/lib/solargraph/language_server/message/text_document/folding_range.rb +26 -26
  84. data/lib/solargraph/language_server/message/text_document/formatting.rb +131 -126
  85. data/lib/solargraph/language_server/message/text_document/hover.rb +58 -54
  86. data/lib/solargraph/language_server/message/text_document/on_type_formatting.rb +34 -34
  87. data/lib/solargraph/language_server/message/text_document/prepare_rename.rb +11 -11
  88. data/lib/solargraph/language_server/message/text_document/references.rb +16 -16
  89. data/lib/solargraph/language_server/message/text_document/rename.rb +19 -19
  90. data/lib/solargraph/language_server/message/text_document/signature_help.rb +24 -29
  91. data/lib/solargraph/language_server/message/text_document/type_definition.rb +24 -0
  92. data/lib/solargraph/language_server/message/text_document.rb +28 -28
  93. data/lib/solargraph/language_server/message/workspace/did_change_configuration.rb +35 -30
  94. data/lib/solargraph/language_server/message/workspace/did_change_watched_files.rb +40 -33
  95. data/lib/solargraph/language_server/message/workspace/did_change_workspace_folders.rb +24 -24
  96. data/lib/solargraph/language_server/message/workspace/workspace_symbol.rb +23 -23
  97. data/lib/solargraph/language_server/message/workspace.rb +14 -14
  98. data/lib/solargraph/language_server/message.rb +94 -93
  99. data/lib/solargraph/language_server/message_types.rb +14 -14
  100. data/lib/solargraph/language_server/progress.rb +135 -0
  101. data/lib/solargraph/language_server/request.rb +24 -24
  102. data/lib/solargraph/language_server/symbol_kinds.rb +36 -36
  103. data/lib/solargraph/language_server/transport/adapter.rb +68 -53
  104. data/lib/solargraph/language_server/transport/data_reader.rb +74 -72
  105. data/lib/solargraph/language_server/transport.rb +13 -13
  106. data/lib/solargraph/language_server/uri_helpers.rb +49 -49
  107. data/lib/solargraph/language_server.rb +20 -19
  108. data/lib/solargraph/library.rb +663 -546
  109. data/lib/solargraph/location.rb +58 -37
  110. data/lib/solargraph/logging.rb +27 -27
  111. data/lib/solargraph/page.rb +89 -83
  112. data/lib/solargraph/parser/comment_ripper.rb +56 -52
  113. data/lib/solargraph/parser/node_methods.rb +83 -43
  114. data/lib/solargraph/parser/node_processor/base.rb +87 -77
  115. data/lib/solargraph/parser/node_processor.rb +45 -43
  116. data/lib/solargraph/parser/{legacy → parser_gem}/class_methods.rb +153 -135
  117. data/lib/solargraph/parser/{legacy → parser_gem}/flawed_builder.rb +18 -16
  118. data/lib/solargraph/parser/{legacy → parser_gem}/node_chainer.rb +164 -148
  119. data/lib/solargraph/parser/parser_gem/node_methods.rb +495 -0
  120. data/lib/solargraph/parser/{rubyvm → parser_gem}/node_processors/alias_node.rb +23 -23
  121. data/lib/solargraph/parser/parser_gem/node_processors/args_node.rb +57 -0
  122. data/lib/solargraph/parser/{rubyvm → parser_gem}/node_processors/begin_node.rb +15 -15
  123. data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/block_node.rb +43 -42
  124. data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/casgn_node.rb +35 -25
  125. data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/cvasgn_node.rb +23 -23
  126. data/lib/solargraph/parser/{rubyvm → parser_gem}/node_processors/def_node.rb +50 -63
  127. data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/defs_node.rb +36 -36
  128. data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/gvasgn_node.rb +23 -23
  129. data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/ivasgn_node.rb +38 -38
  130. data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/lvasgn_node.rb +28 -28
  131. data/lib/solargraph/parser/parser_gem/node_processors/masgn_node.rb +53 -0
  132. data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/namespace_node.rb +39 -39
  133. data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/orasgn_node.rb +16 -16
  134. data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/resbody_node.rb +36 -36
  135. data/lib/solargraph/parser/parser_gem/node_processors/sclass_node.rb +42 -0
  136. data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/send_node.rb +259 -257
  137. data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/sym_node.rb +18 -18
  138. data/lib/solargraph/parser/parser_gem/node_processors.rb +56 -0
  139. data/lib/solargraph/parser/parser_gem.rb +12 -0
  140. data/lib/solargraph/parser/region.rb +66 -66
  141. data/lib/solargraph/parser/snippet.rb +15 -13
  142. data/lib/solargraph/parser.rb +22 -26
  143. data/lib/solargraph/pin/base.rb +378 -296
  144. data/lib/solargraph/pin/base_variable.rb +118 -84
  145. data/lib/solargraph/pin/block.rb +101 -72
  146. data/lib/solargraph/pin/callable.rb +147 -0
  147. data/lib/solargraph/pin/class_variable.rb +8 -8
  148. data/lib/solargraph/pin/closure.rb +57 -37
  149. data/lib/solargraph/pin/common.rb +70 -70
  150. data/lib/solargraph/pin/constant.rb +43 -43
  151. data/lib/solargraph/pin/conversions.rb +123 -96
  152. data/lib/solargraph/pin/delegated_method.rb +101 -0
  153. data/lib/solargraph/pin/documenting.rb +98 -105
  154. data/lib/solargraph/pin/duck_method.rb +16 -16
  155. data/lib/solargraph/pin/global_variable.rb +8 -8
  156. data/lib/solargraph/pin/instance_variable.rb +34 -30
  157. data/lib/solargraph/pin/keyword.rb +15 -15
  158. data/lib/solargraph/pin/keyword_param.rb +8 -8
  159. data/lib/solargraph/pin/local_variable.rb +67 -55
  160. data/lib/solargraph/pin/method.rb +527 -245
  161. data/lib/solargraph/pin/method_alias.rb +31 -31
  162. data/lib/solargraph/pin/namespace.rb +107 -91
  163. data/lib/solargraph/pin/parameter.rb +212 -201
  164. data/lib/solargraph/pin/proxy_type.rb +29 -29
  165. data/lib/solargraph/pin/reference/extend.rb +10 -10
  166. data/lib/solargraph/pin/reference/include.rb +10 -10
  167. data/lib/solargraph/pin/reference/override.rb +29 -29
  168. data/lib/solargraph/pin/reference/prepend.rb +10 -10
  169. data/lib/solargraph/pin/reference/require.rb +14 -14
  170. data/lib/solargraph/pin/reference/superclass.rb +10 -10
  171. data/lib/solargraph/pin/reference.rb +22 -14
  172. data/lib/solargraph/pin/search.rb +56 -56
  173. data/lib/solargraph/pin/signature.rb +17 -0
  174. data/lib/solargraph/pin/singleton.rb +11 -11
  175. data/lib/solargraph/pin/symbol.rb +47 -47
  176. data/lib/solargraph/pin.rb +41 -37
  177. data/lib/solargraph/position.rb +107 -100
  178. data/lib/solargraph/range.rb +98 -95
  179. data/lib/solargraph/rbs_map/conversions.rb +646 -0
  180. data/lib/solargraph/rbs_map/core_fills.rb +50 -0
  181. data/lib/solargraph/rbs_map/core_map.rb +28 -0
  182. data/lib/solargraph/rbs_map/stdlib_map.rb +33 -0
  183. data/lib/solargraph/rbs_map.rb +93 -0
  184. data/lib/solargraph/server_methods.rb +16 -16
  185. data/lib/solargraph/shell.rb +269 -226
  186. data/lib/solargraph/source/chain/array.rb +33 -0
  187. data/lib/solargraph/source/chain/block_symbol.rb +13 -0
  188. data/lib/solargraph/source/chain/block_variable.rb +13 -13
  189. data/lib/solargraph/source/chain/call.rb +303 -204
  190. data/lib/solargraph/source/chain/class_variable.rb +13 -13
  191. data/lib/solargraph/source/chain/constant.rb +89 -75
  192. data/lib/solargraph/source/chain/global_variable.rb +13 -13
  193. data/lib/solargraph/source/chain/hash.rb +33 -28
  194. data/lib/solargraph/source/chain/head.rb +19 -19
  195. data/lib/solargraph/source/chain/if.rb +28 -0
  196. data/lib/solargraph/source/chain/instance_variable.rb +13 -13
  197. data/lib/solargraph/source/chain/link.rb +98 -71
  198. data/lib/solargraph/source/chain/literal.rb +28 -23
  199. data/lib/solargraph/source/chain/or.rb +23 -23
  200. data/lib/solargraph/source/chain/q_call.rb +11 -11
  201. data/lib/solargraph/source/chain/variable.rb +13 -13
  202. data/lib/solargraph/source/chain/z_super.rb +30 -30
  203. data/lib/solargraph/source/chain.rb +252 -164
  204. data/lib/solargraph/source/change.rb +82 -79
  205. data/lib/solargraph/source/cursor.rb +167 -164
  206. data/lib/solargraph/source/source_chainer.rb +194 -191
  207. data/lib/solargraph/source/updater.rb +55 -54
  208. data/lib/solargraph/source.rb +495 -522
  209. data/lib/solargraph/source_map/clip.rb +232 -224
  210. data/lib/solargraph/source_map/completion.rb +23 -23
  211. data/lib/solargraph/source_map/data.rb +30 -0
  212. data/lib/solargraph/source_map/mapper.rb +255 -212
  213. data/lib/solargraph/source_map.rb +217 -180
  214. data/lib/solargraph/type_checker/checks.rb +120 -99
  215. data/lib/solargraph/type_checker/param_def.rb +35 -35
  216. data/lib/solargraph/type_checker/problem.rb +32 -32
  217. data/lib/solargraph/type_checker/rules.rb +62 -57
  218. data/lib/solargraph/type_checker.rb +672 -543
  219. data/lib/solargraph/version.rb +5 -5
  220. data/lib/solargraph/views/environment.erb +56 -58
  221. data/lib/solargraph/workspace/config.rb +239 -231
  222. data/lib/solargraph/workspace.rb +239 -215
  223. data/lib/solargraph/yard_map/cache.rb +25 -19
  224. data/lib/solargraph/yard_map/helpers.rb +16 -16
  225. data/lib/solargraph/yard_map/mapper/to_constant.rb +26 -25
  226. data/lib/solargraph/yard_map/mapper/to_method.rb +94 -78
  227. data/lib/solargraph/yard_map/mapper/to_namespace.rb +28 -27
  228. data/lib/solargraph/yard_map/mapper.rb +78 -77
  229. data/lib/solargraph/yard_map/to_method.rb +86 -79
  230. data/lib/solargraph/yard_map.rb +18 -460
  231. data/lib/solargraph/yard_tags.rb +20 -0
  232. data/lib/solargraph/yardoc.rb +52 -0
  233. data/lib/solargraph.rb +72 -69
  234. data/solargraph.gemspec +21 -10
  235. metadata +184 -115
  236. data/.travis.yml +0 -19
  237. data/lib/solargraph/api_map/bundler_methods.rb +0 -22
  238. data/lib/solargraph/compat.rb +0 -37
  239. data/lib/solargraph/convention/rspec.rb +0 -30
  240. data/lib/solargraph/documentor.rb +0 -76
  241. data/lib/solargraph/language_server/host/cataloger.rb +0 -56
  242. data/lib/solargraph/parser/legacy/node_methods.rb +0 -325
  243. data/lib/solargraph/parser/legacy/node_processors/alias_node.rb +0 -23
  244. data/lib/solargraph/parser/legacy/node_processors/args_node.rb +0 -35
  245. data/lib/solargraph/parser/legacy/node_processors/begin_node.rb +0 -15
  246. data/lib/solargraph/parser/legacy/node_processors/def_node.rb +0 -63
  247. data/lib/solargraph/parser/legacy/node_processors/sclass_node.rb +0 -21
  248. data/lib/solargraph/parser/legacy/node_processors.rb +0 -54
  249. data/lib/solargraph/parser/legacy.rb +0 -12
  250. data/lib/solargraph/parser/rubyvm/class_methods.rb +0 -144
  251. data/lib/solargraph/parser/rubyvm/node_chainer.rb +0 -160
  252. data/lib/solargraph/parser/rubyvm/node_methods.rb +0 -315
  253. data/lib/solargraph/parser/rubyvm/node_processors/args_node.rb +0 -85
  254. data/lib/solargraph/parser/rubyvm/node_processors/block_node.rb +0 -42
  255. data/lib/solargraph/parser/rubyvm/node_processors/casgn_node.rb +0 -22
  256. data/lib/solargraph/parser/rubyvm/node_processors/cvasgn_node.rb +0 -23
  257. data/lib/solargraph/parser/rubyvm/node_processors/defs_node.rb +0 -57
  258. data/lib/solargraph/parser/rubyvm/node_processors/gvasgn_node.rb +0 -23
  259. data/lib/solargraph/parser/rubyvm/node_processors/ivasgn_node.rb +0 -38
  260. data/lib/solargraph/parser/rubyvm/node_processors/kw_arg_node.rb +0 -39
  261. data/lib/solargraph/parser/rubyvm/node_processors/lit_node.rb +0 -20
  262. data/lib/solargraph/parser/rubyvm/node_processors/lvasgn_node.rb +0 -27
  263. data/lib/solargraph/parser/rubyvm/node_processors/namespace_node.rb +0 -39
  264. data/lib/solargraph/parser/rubyvm/node_processors/opt_arg_node.rb +0 -26
  265. data/lib/solargraph/parser/rubyvm/node_processors/orasgn_node.rb +0 -15
  266. data/lib/solargraph/parser/rubyvm/node_processors/resbody_node.rb +0 -45
  267. data/lib/solargraph/parser/rubyvm/node_processors/sclass_node.rb +0 -21
  268. data/lib/solargraph/parser/rubyvm/node_processors/scope_node.rb +0 -15
  269. data/lib/solargraph/parser/rubyvm/node_processors/send_node.rb +0 -277
  270. data/lib/solargraph/parser/rubyvm/node_processors/sym_node.rb +0 -18
  271. data/lib/solargraph/parser/rubyvm/node_processors.rb +0 -63
  272. data/lib/solargraph/parser/rubyvm.rb +0 -40
  273. data/lib/solargraph/yard_map/core_docs.rb +0 -170
  274. data/lib/solargraph/yard_map/core_fills.rb +0 -208
  275. data/lib/solargraph/yard_map/core_gen.rb +0 -76
  276. data/lib/solargraph/yard_map/rdoc_to_yard.rb +0 -140
  277. data/lib/solargraph/yard_map/stdlib_fills.rb +0 -43
  278. data/lib/yard-solargraph.rb +0 -33
  279. data/yardoc/2.2.2.tar.gz +0 -0
data/Gemfile CHANGED
File without changes
data/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2017-2019 by Fred Snyder for Castwide Technologies
3
+ Copyright (c) 2017-2023 by Fred Snyder for Castwide Technologies
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -1,128 +1,131 @@
1
- # Solargraph
2
-
3
- [![RSpec](https://github.com/castwide/solargraph/actions/workflows/rspec.yml/badge.svg)](https://github.com/castwide/solargraph/actions/workflows/rspec.yml)
4
-
5
- ## A Ruby Language Server
6
-
7
- Solargraph provides a comprehensive suite of tools for Ruby programming: intellisense, diagnostics, inline documentation, and type checking.
8
-
9
- ## Online Demo
10
-
11
- A web-based demonstration of Solargraph's autocomplete is available at https://solargraph.org/demo.
12
-
13
- ## Installation
14
-
15
- Install the gem from the command line:
16
-
17
- gem install solargraph
18
-
19
- Or add it to your Gemfile:
20
-
21
- gem 'solargraph', group: :development
22
-
23
- ## Using Solargraph
24
-
25
- Plug-ins and extensions are available for the following editors:
26
-
27
- * **Visual Studio Code**
28
- * Extension: https://marketplace.visualstudio.com/items?itemName=castwide.solargraph
29
- * GitHub: https://github.com/castwide/vscode-solargraph
30
-
31
- * **Atom**
32
- * Package: https://atom.io/packages/ruby-solargraph
33
- * GitHub: https://github.com/castwide/atom-solargraph
34
-
35
- * **Vim**
36
- * GitHub: `LanguageClient-neovim`, https://github.com/autozimu/LanguageClient-neovim
37
- * GitHub: `coc`, https://github.com/neoclide/coc-solargraph
38
- * GitHub: `Vim-EasyComplete`, https://github.com/jayli/vim-easycomplete
39
-
40
- * **Emacs**
41
- * GitHub: `eglot.el`, https://github.com/joaotavora/eglot
42
- * GitHub: `lsp-mode.el`, https://github.com/emacs-lsp/lsp-mode
43
-
44
- * **Eclipse**
45
- * Plugin: https://marketplace.eclipse.org/content/ruby-solargraph
46
- * GitHub: https://github.com/PyvesB/eclipse-solargraph
47
-
48
- ### Configuration
49
-
50
- Solargraph's behavior can be controlled via optional [configuration](https://solargraph.org/guides/configuration) files. The highest priority file is a `.solargraph.yml` file at the root of the project. If not present, any global configuration at `~/.config/solargraph/config.yml` will apply. The path to the global configuration can be overridden with the `SOLARGRAPH_GLOBAL_CONFIG` environment variable.
51
-
52
- ### Gem Support
53
-
54
- Solargraph is capable of providing code completion and documentation for gems that have YARD documentation. You can make sure your gems are documented by running `yard gems` from the command line. (YARD is included as one of Solargraph's gem dependencies. The first time you run it might take a while if you have a lot of gems installed).
55
-
56
- When editing code, a `require` call that references a gem will pull the documentation into the code maps and include the gem's API in code completion and intellisense.
57
-
58
- If your project automatically requires bundled gems (e.g., `require 'bundler/require'`), Solargraph will add all of the Gemfile's default dependencies to the map.
59
-
60
- ### Type Checking
61
-
62
- As of version 0.33.0, Solargraph includes a [type checker](https://github.com/castwide/solargraph/issues/192) that uses a combination of YARD tags and code analysis to report missing type definitions. In strict mode, it performs type inference to determine whether the tags match the types it detects from code.
63
-
64
- ### Updating Core Documentation
65
-
66
- The Solargraph gem ships with documentation for Ruby 2.2.2. You can download documentation for other Ruby versions from the command line.
67
-
68
- $ solargraph list-cores # List the installed documentation versions
69
- $ solargraph available-cores # List the versions available for download
70
- $ solargraph download-core # Install the best match for your Ruby version
71
- $ solargraph clear # Reset the documentation cache
72
-
73
- ### The Documentation Cache
74
-
75
- Solargraph uses a cache directory to store documentation for the Ruby core and customized documentation for certain gems. The default location is `~/.solargraph/cache`, e.g., `/home/<username>/.solargraph/cache` on Linux or `C:\Users\<username>\.solargraph` on Windows.
76
-
77
- You can change the location of the cache directory with the `SOLARGRAPH_CACHE` environment variable. This can be useful if you want the cache to comply with the XDG Base Directory Specification.
78
-
79
- ### Solargraph and Bundler
80
-
81
- If you're using the language server with a project that uses Bundler, the most comprehensive way to use your bundled gems is to bundle Solargraph.
82
-
83
- In the Gemfile:
84
-
85
- gem 'solargraph', group: :development
86
-
87
- Run `bundle install` and use `bundle exec yard gems` to generate the documentation. This process documents cached or vendored gems, or even gems that are installed from a local path.
88
-
89
- In order to make sure you're using the correct dependencies, you can start the language server with Bundler. In VS Code, there's a `solargraph.useBundler` option. Other clients will vary, but the command you probably want to run is `bundle exec solargraph socket` or `bundle exec solargraph stdio`.
90
-
91
- ### Rubocop Version
92
-
93
- If you have multiple versions of [`rubocop`](https://rubygems.org/gems/rubocop) installed and you would like to choose a version other than the latest to use, this specific version can be configured.
94
-
95
- In `.solargraph.yml`:
96
-
97
- ```yaml
98
- ---
99
- reporters:
100
- - rubocop:version=0.61.0 # diagnostics
101
- formatter:
102
- rubocop:
103
- version: 0.61.0 # formatting
104
- ```
105
-
106
- ### Integrating Other Editors
107
-
108
- The [language server protocol](https://microsoft.github.io/language-server-protocol/specification) is the recommended way for integrating Solargraph into editors and IDEs. Clients can connect using either stdio or TCP. Language client developers should refer to [https://solargraph.org/guides/language-server](https://solargraph.org/guides/language-server).
109
-
110
- ### More Information
111
-
112
- See [https://solargraph.org/guides](https://solargraph.org/guides) for more tips and tutorials about Solargraph.
113
-
114
- ## Contributing to Solargraph
115
-
116
- ### Bug Reports and Feature Requests
117
-
118
- [GitHub Issues](https://github.com/castwide/solargraph/issues) are the best place to ask questions, report problems, and suggest improvements.
119
-
120
- ### Development
121
-
122
- Code contributions are always appreciated. Feel free to fork the repo and submit pull requests. Check for open issues that could use help. Start new issues to discuss changes that have a major impact on the code or require large time commitments.
123
-
124
- ### Sponsorship and Donation
125
-
126
- Use Patreon to support ongoing development of Solargraph at [https://www.patreon.com/castwide](https://www.patreon.com/castwide).
127
-
128
- You can also make one-time donations via PayPal at [https://www.paypal.me/castwide](https://www.paypal.me/castwide).
1
+ # Solargraph
2
+
3
+ [![RSpec](https://github.com/castwide/solargraph/actions/workflows/rspec.yml/badge.svg)](https://github.com/castwide/solargraph/actions/workflows/rspec.yml)
4
+
5
+ ## A Ruby Language Server
6
+
7
+ Solargraph provides a comprehensive suite of tools for Ruby programming: intellisense, diagnostics, inline documentation, and type checking.
8
+
9
+ ## Online Demo
10
+
11
+ A web-based demonstration of Solargraph's autocomplete is available at https://solargraph.org/demo.
12
+
13
+ ## Installation
14
+
15
+ Install the gem from the command line:
16
+
17
+ gem install solargraph
18
+
19
+ Or add it to your Gemfile:
20
+
21
+ gem 'solargraph', group: :development
22
+
23
+ ## Using Solargraph
24
+
25
+ Plug-ins and extensions are available for the following editors:
26
+
27
+ * **Visual Studio Code**
28
+ * Extension: https://marketplace.visualstudio.com/items?itemName=castwide.solargraph
29
+ * GitHub: https://github.com/castwide/vscode-solargraph
30
+
31
+ * **Sublime Text**
32
+ * Extension: https://packagecontrol.io/packages/LSP
33
+ * GitHub: https://github.com/sublimelsp/LSP
34
+ * Instructions: https://lsp.sublimetext.io/language_servers/#solargraph
35
+
36
+ * **Vim**
37
+ * Github: `nvim-lspconfig`, https://github.com/neovim/nvim-lspconfig/blob/master/doc/configs.md#solargraph
38
+ * GitHub: `LanguageClient-neovim`, https://github.com/autozimu/LanguageClient-neovim
39
+ * GitHub: `coc`, https://github.com/neoclide/coc-solargraph
40
+ * GitHub: `Vim-EasyComplete`, https://github.com/jayli/vim-easycomplete
41
+
42
+ * **Emacs**
43
+ * GitHub: `eglot.el`, https://github.com/joaotavora/eglot
44
+ * GitHub: `lsp-mode.el`, https://github.com/emacs-lsp/lsp-mode
45
+
46
+ * **Eclipse**
47
+ * Plugin: https://marketplace.eclipse.org/content/ruby-solargraph
48
+ * GitHub: https://github.com/PyvesB/eclipse-solargraph
49
+
50
+ ### Configuration
51
+
52
+ Solargraph's behavior can be controlled via optional [configuration](https://solargraph.org/guides/configuration) files. The highest priority file is a `.solargraph.yml` file at the root of the project. If not present, any global configuration at `~/.config/solargraph/config.yml` will apply. The path to the global configuration can be overridden with the `SOLARGRAPH_GLOBAL_CONFIG` environment variable.
53
+
54
+ ### Plugins
55
+
56
+ Solargraph supports [plugins](https://solargraph.org/guides/plugins) that implements their own Solargraph features, such as diagnostics reporters and conventions to provide LSP features and type-checking, e.g. for frameworks which use metaprogramming and/or DSLs.
57
+
58
+ For better Rails support, please consider using [solargraph-rails](https://github.com/iftheshoefritz/solargraph-rails/)
59
+
60
+ The RSpec framework is supported via [solargraph-rspec](https://github.com/lekemula/solargraph-rspec/)
61
+
62
+ ### Gem Support
63
+
64
+ **Note: Before version 0.53.0, it was recommended to run `yard gems` periodically or automate it with `yard config` to ensure that Solargraph had access to gem documentation. These steps are no longer necessary. Solargraph maintains its own gem documentation cache independent of the yardocs in your gem installations.**
65
+
66
+ Solargraph automatically generates code maps from installed gems. You can also manage your cached gem documentation with the `solargraph gems` command.
67
+
68
+ When editing code, a `require` call that references a gem will pull the documentation into the code maps and include the gem's API in code completion and intellisense.
69
+
70
+ If your project automatically requires bundled gems (e.g., `require 'bundler/require'`), Solargraph will add all of the Gemfile's default dependencies to the map.
71
+
72
+ ### Type Checking
73
+
74
+ As of version 0.33.0, Solargraph includes a [type checker](https://github.com/castwide/solargraph/issues/192) that uses a combination of YARD tags and code analysis to report missing type definitions. In strict mode, it performs type inference to determine whether the tags match the types it detects from code.
75
+
76
+ ### The Documentation Cache
77
+
78
+ Solargraph uses a cache directory to store documentation for the Ruby core and gems. The default location is `~/.cache/solargraph`, e.g., `/home/<username>/.cache/solargraph` on Linux or `C:\Users\<username>\.cache\solargraph` on Windows.
79
+
80
+ You can change the location of the cache directory with the `SOLARGRAPH_CACHE` environment variable.
81
+
82
+ ### Solargraph and Bundler
83
+
84
+ If you're using the language server with a project that uses Bundler, the most comprehensive way to use your bundled gems is to bundle Solargraph.
85
+
86
+ In the Gemfile:
87
+
88
+ gem 'solargraph', group: :development
89
+
90
+ Run `bundle install` and optionally use `bundle exec solargraph gems` to generate the documentation. This process documents cached or vendored gems, or even gems that are installed from a local path.
91
+
92
+ In order to make sure you're using the correct dependencies, you can start the language server with Bundler. In VS Code, there's a `solargraph.useBundler` option. Other clients will vary, but the command you probably want to run is `bundle exec solargraph socket` or `bundle exec solargraph stdio`.
93
+
94
+ ### Rubocop Version
95
+
96
+ If you have multiple versions of [`rubocop`](https://rubygems.org/gems/rubocop) installed and you would like to choose a version other than the latest to use, this specific version can be configured.
97
+
98
+ In `.solargraph.yml`:
99
+
100
+ ```yaml
101
+ ---
102
+ reporters:
103
+ - rubocop:version=0.61.0 # diagnostics
104
+ formatter:
105
+ rubocop:
106
+ version: 0.61.0 # formatting
107
+ ```
108
+
109
+ ### Integrating Other Editors
110
+
111
+ The [language server protocol](https://microsoft.github.io/language-server-protocol/specification) is the recommended way for integrating Solargraph into editors and IDEs. Clients can connect using either stdio or TCP. Language client developers should refer to [https://solargraph.org/guides/language-server](https://solargraph.org/guides/language-server).
112
+
113
+ ### More Information
114
+
115
+ See [https://solargraph.org/guides](https://solargraph.org/guides) for more tips and tutorials about Solargraph.
116
+
117
+ ## Contributing to Solargraph
118
+
119
+ ### Bug Reports and Feature Requests
120
+
121
+ [GitHub Issues](https://github.com/castwide/solargraph/issues) are the best place to ask questions, report problems, and suggest improvements.
122
+
123
+ ### Development
124
+
125
+ Code contributions are always appreciated. Feel free to fork the repo and submit pull requests. Check for open issues that could use help. Start new issues to discuss changes that have a major impact on the code or require large time commitments.
126
+
127
+ ### Sponsorship and Donation
128
+
129
+ Use Patreon to support ongoing development of Solargraph at [https://www.patreon.com/castwide](https://www.patreon.com/castwide).
130
+
131
+ You can also make one-time donations via PayPal at [https://www.paypal.me/castwide](https://www.paypal.me/castwide).
data/Rakefile CHANGED
File without changes
data/SPONSORS.md CHANGED
@@ -1,18 +1,10 @@
1
- # Sponsors
2
-
3
- Solargraph is developed and maintained by [Castwide Technologies](https://castwide.com).
4
-
5
- The following people and organizations provide funding or other resources. [Become a sponsor](https://patreon.com/castwide)
6
-
7
- ## Linked Sponsors
8
-
9
- - **[Calyptix Security](https://www.calyptix.com/)**
10
-
11
- ## Named Sponsors
12
-
13
- - Tom de Grunt
14
- - Akira Yamada
15
- - Erlend Finvåg
16
- - Matt Massicotte
17
- - Hasan Kumar
18
- - Oscar Rivas
1
+ # Sponsors
2
+
3
+ Solargraph is developed and maintained by [Castwide Technologies](https://castwide.com).
4
+
5
+ The following people and organizations provide funding or other resources. [Become a sponsor](https://patreon.com/castwide)
6
+
7
+ ## Named Sponsors
8
+
9
+ - Juan Carlos
10
+ - Vince Broz
data/bin/solargraph CHANGED
File without changes
@@ -1,70 +1,109 @@
1
- # frozen_string_literal: true
2
-
3
- module Solargraph
4
- class ApiMap
5
- class Cache
6
- def initialize
7
- @methods = {}
8
- @constants = {}
9
- @qualified_namespaces = {}
10
- @receiver_definitions = {}
11
- end
12
-
13
- # @return [Array<Pin::Method>]
14
- def get_methods fqns, scope, visibility, deep
15
- @methods[[fqns, scope, visibility.sort, deep]]
16
- end
17
-
18
- def set_methods fqns, scope, visibility, deep, value
19
- @methods[[fqns, scope, visibility.sort, deep]] = value
20
- end
21
-
22
- # @return [Array<Pin::Base>]
23
- def get_constants namespace, context
24
- @constants[[namespace, context]]
25
- end
26
-
27
- def set_constants namespace, context, value
28
- @constants[[namespace, context]] = value
29
- end
30
-
31
- # @return [String]
32
- def get_qualified_namespace name, context
33
- @qualified_namespaces[[name, context]]
34
- end
35
-
36
- def set_qualified_namespace name, context, value
37
- @qualified_namespaces[[name, context]] = value
38
- end
39
-
40
- def receiver_defined? path
41
- @receiver_definitions.key? path
42
- end
43
-
44
- # @return [Pin::Method]
45
- def get_receiver_definition path
46
- @receiver_definitions[path]
47
- end
48
-
49
- def set_receiver_definition path, pin
50
- @receiver_definitions[path] = pin
51
- end
52
-
53
- # @return [void]
54
- def clear
55
- @methods.clear
56
- @constants.clear
57
- @qualified_namespaces.clear
58
- @receiver_definitions.clear
59
- end
60
-
61
- # @return [Boolean]
62
- def empty?
63
- @methods.empty? &&
64
- @constants.empty? &&
65
- @qualified_namespaces.empty? &&
66
- @receiver_definitions.empty?
67
- end
68
- end
69
- end
70
- end
1
+ # frozen_string_literal: true
2
+
3
+ module Solargraph
4
+ class ApiMap
5
+ class Cache
6
+ def initialize
7
+ # @type [Hash{Array => Array<Pin::Method>}]
8
+ @methods = {}
9
+ # @type [Hash{(String, Array<String>) => Array<Pin::Base>}]
10
+ @constants = {}
11
+ # @type [Hash{String => String}]
12
+ @qualified_namespaces = {}
13
+ # @type [Hash{String => Pin::Method}]
14
+ @receiver_definitions = {}
15
+ # @type [Hash{String => SourceMap::Clip}]
16
+ @clips = {}
17
+ end
18
+
19
+ def to_s
20
+ self.class.to_s
21
+ end
22
+
23
+ # avoid enormous dump
24
+ def inspect
25
+ to_s
26
+ end
27
+
28
+ # @param fqns [String]
29
+ # @param scope [Symbol]
30
+ # @param visibility [Array<Symbol>]
31
+ # @param deep [Boolean]
32
+ # @return [Array<Pin::Method>]
33
+ def get_methods fqns, scope, visibility, deep
34
+ @methods["#{fqns}|#{scope}|#{visibility}|#{deep}"]
35
+ end
36
+
37
+ # @param fqns [String]
38
+ # @param scope [Symbol]
39
+ # @param visibility [Array<Symbol>]
40
+ # @param deep [Boolean]
41
+ # @param value [Array<Pin::Method>]
42
+ # @return [void]
43
+ def set_methods fqns, scope, visibility, deep, value
44
+ @methods["#{fqns}|#{scope}|#{visibility}|#{deep}"] = value
45
+ end
46
+
47
+ # @param namespace [String]
48
+ # @param contexts [Array<String>]
49
+ # @return [Array<Pin::Base>]
50
+ def get_constants namespace, contexts
51
+ @constants["#{namespace}|#{contexts}"]
52
+ end
53
+
54
+ # @param namespace [String]
55
+ # @param contexts [Array<String>]
56
+ # @param value [Array<Pin::Base>]
57
+ # @return [void]
58
+ def set_constants namespace, contexts, value
59
+ @constants["#{namespace}|#{contexts}"] = value
60
+ end
61
+
62
+ # @param name [String]
63
+ # @param context [String]
64
+ # @return [String]
65
+ def get_qualified_namespace name, context
66
+ @qualified_namespaces["#{name}|#{context}"]
67
+ end
68
+
69
+ # @param name [String]
70
+ # @param context [String]
71
+ # @param value [String]
72
+ # @return [void]
73
+ def set_qualified_namespace name, context, value
74
+ @qualified_namespaces["#{name}|#{context}"] = value
75
+ end
76
+
77
+ # @param path [String]
78
+ # @return [Pin::Method]
79
+ def get_receiver_definition path
80
+ @receiver_definitions[path]
81
+ end
82
+
83
+ # @param path [String]
84
+ # @param pin [Pin::Method]
85
+ # @return [void]
86
+ def set_receiver_definition path, pin
87
+ @receiver_definitions[path] = pin
88
+ end
89
+
90
+ # @return [void]
91
+ def clear
92
+ return if empty?
93
+
94
+ all_caches.each(&:clear)
95
+ end
96
+
97
+ # @return [Boolean]
98
+ def empty?
99
+ all_caches.all?(&:empty?)
100
+ end
101
+
102
+ private
103
+
104
+ def all_caches
105
+ [@methods, @constants, @qualified_namespaces, @receiver_definitions, @clips]
106
+ end
107
+ end
108
+ end
109
+ end
@@ -0,0 +1,167 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Solargraph
4
+ class ApiMap
5
+ class Index
6
+ # @param pins [Array<Pin::Base>]
7
+ def initialize pins = []
8
+ catalog pins
9
+ end
10
+
11
+ # @return [Array<Pin::Base>]
12
+ def pins
13
+ @pins ||= []
14
+ end
15
+
16
+ # @return [Hash{String => Array<Pin::Namespace>}]
17
+ def namespace_hash
18
+ @namespace_hash ||= Hash.new { |h, k| h[k] = [] }
19
+ end
20
+
21
+ # @return [Hash{String => Array<Pin::Base>}]
22
+ def pin_class_hash
23
+ @pin_class_hash ||= Hash.new { |h, k| h[k] = [] }
24
+ end
25
+
26
+ # @return [Hash{String => Array<Pin::Base>}]
27
+ def path_pin_hash
28
+ @path_pin_hash ||= Hash.new { |h, k| h[k] = [] }
29
+ end
30
+
31
+ # @generic T
32
+ # @param klass [Class<generic<T>>]
33
+ # @return [Set<generic<T>>]
34
+ def pins_by_class klass
35
+ # @type [Set<Solargraph::Pin::Base>]
36
+ s = Set.new
37
+ @pin_select_cache[klass] ||= pin_class_hash.each_with_object(s) { |(key, o), n| n.merge(o) if key <= klass }
38
+ end
39
+
40
+ # @return [Hash{String => Array<Pin::Reference::Include>}]
41
+ def include_references
42
+ @include_references ||= Hash.new { |h, k| h[k] = [] }
43
+ end
44
+
45
+ # @return [Hash{String => Array<Pin::Reference::Extend>}]
46
+ def extend_references
47
+ @extend_references ||= Hash.new { |h, k| h[k] = [] }
48
+ end
49
+
50
+ # @return [Hash{String => Array<Pin::Reference::Prepend>}]
51
+ def prepend_references
52
+ @prepend_references ||= Hash.new { |h, k| h[k] = [] }
53
+ end
54
+
55
+ # @return [Hash{String => Array<Pin::Reference::Superclass>}]
56
+ def superclass_references
57
+ @superclass_references ||= Hash.new { |h, k| h[k] = [] }
58
+ end
59
+
60
+ # @param pins [Array<Pin::Base>]
61
+ def merge pins
62
+ deep_clone.catalog pins
63
+ end
64
+
65
+ protected
66
+
67
+ attr_writer :pins, :pin_select_cache, :namespace_hash, :pin_class_hash, :path_pin_hash, :include_references,
68
+ :extend_references, :prepend_references, :superclass_references
69
+
70
+ def deep_clone
71
+ Index.allocate.tap do |copy|
72
+ copy.pin_select_cache = {}
73
+ copy.pins = pins.clone
74
+ %i[
75
+ namespace_hash pin_class_hash path_pin_hash include_references extend_references prepend_references
76
+ superclass_references
77
+ ].each do |sym|
78
+ copy.send("#{sym}=", send(sym).clone)
79
+ copy.send(sym)&.transform_values!(&:clone)
80
+ end
81
+ end
82
+ end
83
+
84
+ # @param new_pins [Array<Pin::Base>]
85
+ def catalog new_pins
86
+ @pin_select_cache = {}
87
+ pins.concat new_pins
88
+ set = new_pins.to_set
89
+ set.classify(&:class)
90
+ .map { |k, v| pin_class_hash[k].concat v.to_a }
91
+ set.classify(&:namespace)
92
+ .map { |k, v| namespace_hash[k].concat v.to_a }
93
+ set.classify(&:path)
94
+ .map { |k, v| path_pin_hash[k].concat v.to_a }
95
+ @namespaces = path_pin_hash.keys.compact.to_set
96
+ map_references Pin::Reference::Include, include_references
97
+ map_references Pin::Reference::Prepend, prepend_references
98
+ map_references Pin::Reference::Extend, extend_references
99
+ map_references Pin::Reference::Superclass, superclass_references
100
+ map_overrides
101
+ self
102
+ end
103
+
104
+ # @param klass [Class<Pin::Reference>]
105
+ # @param hash [Hash{String => Array<Pin::Reference>}]
106
+ # @return [void]
107
+ def map_references klass, hash
108
+ pins_by_class(klass).each do |pin|
109
+ store_parametric_reference(hash, pin)
110
+ end
111
+ end
112
+
113
+ # Add references to a map
114
+ #
115
+ # @param hash [Hash{String => Array<Pin::Reference>}]
116
+ # @param reference_pin [Pin::Reference]
117
+ #
118
+ # @return [void]
119
+ def store_parametric_reference(hash, reference_pin)
120
+ referenced_ns = reference_pin.name
121
+ referenced_tag_params = reference_pin.generic_values
122
+ referenced_tag = referenced_ns +
123
+ if referenced_tag_params && referenced_tag_params.length > 0
124
+ "<" + referenced_tag_params.join(', ') + ">"
125
+ else
126
+ ''
127
+ end
128
+ referencing_ns = reference_pin.namespace
129
+ hash[referencing_ns].push referenced_tag
130
+ end
131
+
132
+ # @return [void]
133
+ def map_overrides
134
+ pins_by_class(Pin::Reference::Override).each do |ovr|
135
+ pin = path_pin_hash[ovr.name].first
136
+ next if pin.nil?
137
+ new_pin = if pin.path.end_with?('#initialize')
138
+ path_pin_hash[pin.path.sub(/#initialize/, '.new')].first
139
+ end
140
+ (ovr.tags.map(&:tag_name) + ovr.delete).uniq.each do |tag|
141
+ pin.docstring.delete_tags tag
142
+ new_pin.docstring.delete_tags tag if new_pin
143
+ end
144
+ ovr.tags.each do |tag|
145
+ pin.docstring.add_tag(tag)
146
+ redefine_return_type pin, tag
147
+ if new_pin
148
+ new_pin.docstring.add_tag(tag)
149
+ redefine_return_type new_pin, tag
150
+ end
151
+ end
152
+ end
153
+ end
154
+
155
+ # @param pin [Pin::Method]
156
+ # @param tag [YARD::Tags::Tag]
157
+ # @return [void]
158
+ def redefine_return_type pin, tag
159
+ return unless pin && tag.tag_name == 'return'
160
+ pin.instance_variable_set(:@return_type, ComplexType.try_parse(tag.type))
161
+ pin.signatures.each do |sig|
162
+ sig.instance_variable_set(:@return_type, ComplexType.try_parse(tag.type))
163
+ end
164
+ end
165
+ end
166
+ end
167
+ end