solargraph 0.51.2 → 0.53.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (162) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/plugins.yml +40 -0
  3. data/.github/workflows/rspec.yml +1 -3
  4. data/.github/workflows/typecheck.yml +34 -0
  5. data/.yardopts +2 -2
  6. data/CHANGELOG.md +55 -5
  7. data/README.md +13 -16
  8. data/SPONSORS.md +1 -7
  9. data/lib/solargraph/api_map/cache.rb +60 -20
  10. data/lib/solargraph/api_map/store.rb +47 -11
  11. data/lib/solargraph/api_map.rb +161 -95
  12. data/lib/solargraph/bench.rb +2 -2
  13. data/lib/solargraph/cache.rb +29 -5
  14. data/lib/solargraph/complex_type/type_methods.rb +54 -9
  15. data/lib/solargraph/complex_type/unique_type.rb +155 -58
  16. data/lib/solargraph/complex_type.rb +73 -16
  17. data/lib/solargraph/convention.rb +0 -1
  18. data/lib/solargraph/converters/dd.rb +5 -0
  19. data/lib/solargraph/converters/dl.rb +3 -0
  20. data/lib/solargraph/converters/dt.rb +3 -0
  21. data/lib/solargraph/diagnostics/rubocop.rb +8 -7
  22. data/lib/solargraph/diagnostics/rubocop_helpers.rb +1 -0
  23. data/lib/solargraph/diagnostics/type_check.rb +1 -0
  24. data/lib/solargraph/diagnostics.rb +2 -2
  25. data/lib/solargraph/doc_map.rb +146 -0
  26. data/lib/solargraph/gem_pins.rb +64 -0
  27. data/lib/solargraph/language_server/host/cataloger.rb +1 -0
  28. data/lib/solargraph/language_server/host/diagnoser.rb +2 -2
  29. data/lib/solargraph/language_server/host/dispatch.rb +10 -4
  30. data/lib/solargraph/language_server/host/message_worker.rb +4 -0
  31. data/lib/solargraph/language_server/host/sources.rb +7 -4
  32. data/lib/solargraph/language_server/host.rb +15 -6
  33. data/lib/solargraph/language_server/message/completion_item/resolve.rb +3 -1
  34. data/lib/solargraph/language_server/message/extended/check_gem_version.rb +13 -1
  35. data/lib/solargraph/language_server/message/initialize.rb +5 -2
  36. data/lib/solargraph/language_server/message/text_document/hover.rb +2 -0
  37. data/lib/solargraph/language_server/message/text_document.rb +0 -1
  38. data/lib/solargraph/language_server/message/workspace/did_change_configuration.rb +5 -0
  39. data/lib/solargraph/language_server/transport/adapter.rb +16 -1
  40. data/lib/solargraph/language_server/transport/data_reader.rb +2 -0
  41. data/lib/solargraph/library.rb +70 -16
  42. data/lib/solargraph/location.rb +1 -0
  43. data/lib/solargraph/parser/comment_ripper.rb +4 -0
  44. data/lib/solargraph/parser/node_methods.rb +47 -7
  45. data/lib/solargraph/parser/node_processor/base.rb +9 -0
  46. data/lib/solargraph/parser/{legacy → parser_gem}/class_methods.rb +31 -5
  47. data/lib/solargraph/parser/{legacy → parser_gem}/flawed_builder.rb +3 -1
  48. data/lib/solargraph/parser/{legacy → parser_gem}/node_chainer.rb +49 -36
  49. data/lib/solargraph/parser/parser_gem/node_methods.rb +499 -0
  50. data/lib/solargraph/parser/{rubyvm → parser_gem}/node_processors/alias_node.rb +1 -1
  51. data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/args_node.rb +4 -1
  52. data/lib/solargraph/parser/{rubyvm → parser_gem}/node_processors/begin_node.rb +1 -1
  53. data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/block_node.rb +3 -2
  54. data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/casgn_node.rb +2 -2
  55. data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/cvasgn_node.rb +1 -1
  56. data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/def_node.rb +1 -1
  57. data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/defs_node.rb +2 -2
  58. data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/gvasgn_node.rb +1 -1
  59. data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/ivasgn_node.rb +2 -2
  60. data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/lvasgn_node.rb +2 -2
  61. data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/namespace_node.rb +2 -2
  62. data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/orasgn_node.rb +1 -1
  63. data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/resbody_node.rb +3 -3
  64. data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/sclass_node.rb +1 -1
  65. data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/send_node.rb +2 -2
  66. data/lib/solargraph/parser/{rubyvm → parser_gem}/node_processors/sym_node.rb +1 -1
  67. data/lib/solargraph/parser/parser_gem/node_processors.rb +54 -0
  68. data/lib/solargraph/parser/parser_gem.rb +12 -0
  69. data/lib/solargraph/parser/region.rb +1 -1
  70. data/lib/solargraph/parser/snippet.rb +2 -0
  71. data/lib/solargraph/parser.rb +8 -9
  72. data/lib/solargraph/pin/base.rb +64 -9
  73. data/lib/solargraph/pin/base_variable.rb +6 -2
  74. data/lib/solargraph/pin/block.rb +13 -8
  75. data/lib/solargraph/pin/closure.rb +17 -2
  76. data/lib/solargraph/pin/common.rb +7 -3
  77. data/lib/solargraph/pin/conversions.rb +33 -3
  78. data/lib/solargraph/pin/delegated_method.rb +1 -1
  79. data/lib/solargraph/pin/documenting.rb +25 -34
  80. data/lib/solargraph/pin/instance_variable.rb +4 -0
  81. data/lib/solargraph/pin/local_variable.rb +13 -1
  82. data/lib/solargraph/pin/method.rb +169 -18
  83. data/lib/solargraph/pin/namespace.rb +18 -5
  84. data/lib/solargraph/pin/parameter.rb +44 -14
  85. data/lib/solargraph/pin/reference/override.rb +2 -2
  86. data/lib/solargraph/pin/reference.rb +8 -0
  87. data/lib/solargraph/pin/search.rb +3 -3
  88. data/lib/solargraph/pin/signature.rb +123 -3
  89. data/lib/solargraph/pin.rb +0 -1
  90. data/lib/solargraph/range.rb +2 -2
  91. data/lib/solargraph/rbs_map/conversions.rb +287 -45
  92. data/lib/solargraph/rbs_map/core_fills.rb +6 -29
  93. data/lib/solargraph/rbs_map/core_map.rb +2 -1
  94. data/lib/solargraph/rbs_map/core_signs.rb +2 -0
  95. data/lib/solargraph/rbs_map/stdlib_map.rb +2 -8
  96. data/lib/solargraph/rbs_map.rb +20 -11
  97. data/lib/solargraph/shell.rb +62 -59
  98. data/lib/solargraph/source/chain/array.rb +32 -0
  99. data/lib/solargraph/source/chain/block_symbol.rb +13 -0
  100. data/lib/solargraph/source/chain/call.rb +99 -46
  101. data/lib/solargraph/source/chain/constant.rb +15 -1
  102. data/lib/solargraph/source/chain/if.rb +23 -0
  103. data/lib/solargraph/source/chain/link.rb +8 -2
  104. data/lib/solargraph/source/chain/or.rb +1 -1
  105. data/lib/solargraph/source/chain/z_super.rb +3 -3
  106. data/lib/solargraph/source/chain.rb +29 -14
  107. data/lib/solargraph/source/change.rb +3 -0
  108. data/lib/solargraph/source/cursor.rb +2 -0
  109. data/lib/solargraph/source/source_chainer.rb +8 -5
  110. data/lib/solargraph/source.rb +18 -19
  111. data/lib/solargraph/source_map/clip.rb +11 -23
  112. data/lib/solargraph/source_map/mapper.rb +12 -1
  113. data/lib/solargraph/source_map.rb +15 -5
  114. data/lib/solargraph/type_checker/checks.rb +10 -2
  115. data/lib/solargraph/type_checker.rb +92 -26
  116. data/lib/solargraph/version.rb +1 -1
  117. data/lib/solargraph/workspace/config.rb +8 -6
  118. data/lib/solargraph/workspace.rb +3 -2
  119. data/lib/solargraph/yard_map/cache.rb +6 -0
  120. data/lib/solargraph/yard_map/helpers.rb +1 -1
  121. data/lib/solargraph/yard_map/mapper/to_method.rb +11 -1
  122. data/lib/solargraph/yard_map/mapper.rb +1 -1
  123. data/lib/solargraph/yard_map/to_method.rb +11 -4
  124. data/lib/solargraph/yard_map.rb +1 -292
  125. data/lib/solargraph/yard_tags.rb +20 -0
  126. data/lib/solargraph/yardoc.rb +52 -0
  127. data/lib/solargraph.rb +6 -4
  128. data/solargraph.gemspec +3 -2
  129. metadata +51 -58
  130. data/lib/solargraph/api_map/bundler_methods.rb +0 -22
  131. data/lib/solargraph/documentor.rb +0 -76
  132. data/lib/solargraph/parser/legacy/node_methods.rb +0 -325
  133. data/lib/solargraph/parser/legacy/node_processors/alias_node.rb +0 -23
  134. data/lib/solargraph/parser/legacy/node_processors/begin_node.rb +0 -15
  135. data/lib/solargraph/parser/legacy/node_processors/sym_node.rb +0 -18
  136. data/lib/solargraph/parser/legacy/node_processors.rb +0 -55
  137. data/lib/solargraph/parser/legacy.rb +0 -12
  138. data/lib/solargraph/parser/rubyvm/class_methods.rb +0 -153
  139. data/lib/solargraph/parser/rubyvm/node_chainer.rb +0 -160
  140. data/lib/solargraph/parser/rubyvm/node_methods.rb +0 -317
  141. data/lib/solargraph/parser/rubyvm/node_processors/args_node.rb +0 -85
  142. data/lib/solargraph/parser/rubyvm/node_processors/block_node.rb +0 -42
  143. data/lib/solargraph/parser/rubyvm/node_processors/casgn_node.rb +0 -33
  144. data/lib/solargraph/parser/rubyvm/node_processors/cvasgn_node.rb +0 -23
  145. data/lib/solargraph/parser/rubyvm/node_processors/def_node.rb +0 -75
  146. data/lib/solargraph/parser/rubyvm/node_processors/defs_node.rb +0 -68
  147. data/lib/solargraph/parser/rubyvm/node_processors/gvasgn_node.rb +0 -23
  148. data/lib/solargraph/parser/rubyvm/node_processors/ivasgn_node.rb +0 -38
  149. data/lib/solargraph/parser/rubyvm/node_processors/kw_arg_node.rb +0 -39
  150. data/lib/solargraph/parser/rubyvm/node_processors/lit_node.rb +0 -20
  151. data/lib/solargraph/parser/rubyvm/node_processors/lvasgn_node.rb +0 -27
  152. data/lib/solargraph/parser/rubyvm/node_processors/namespace_node.rb +0 -39
  153. data/lib/solargraph/parser/rubyvm/node_processors/opt_arg_node.rb +0 -26
  154. data/lib/solargraph/parser/rubyvm/node_processors/orasgn_node.rb +0 -15
  155. data/lib/solargraph/parser/rubyvm/node_processors/resbody_node.rb +0 -51
  156. data/lib/solargraph/parser/rubyvm/node_processors/sclass_node.rb +0 -32
  157. data/lib/solargraph/parser/rubyvm/node_processors/scope_node.rb +0 -15
  158. data/lib/solargraph/parser/rubyvm/node_processors/send_node.rb +0 -279
  159. data/lib/solargraph/parser/rubyvm/node_processors.rb +0 -64
  160. data/lib/solargraph/parser/rubyvm/node_wrapper.rb +0 -47
  161. data/lib/solargraph/parser/rubyvm.rb +0 -40
  162. data/lib/yard-solargraph.rb +0 -33
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c031e57a0f9eb482a517ed584966ecfff9fd431aaee66d6c97d624393b56fb99
4
- data.tar.gz: d6cc56999dc9da2073584a54f5b2ed045e24e573c84408359a9c7f94f8bd8571
3
+ metadata.gz: ea6f4539a04d35b759acc75c97b4af772a34877adf8dba07e0a9a109a75cb545
4
+ data.tar.gz: 3e6945e906e693884a19e3fb2504cf8508cdb9784fa015b27dd455fb2e4ddba7
5
5
  SHA512:
6
- metadata.gz: aa5be8998891287e3a92429f2317c3bc64235d71977476248cbf3ba1167842b2e65c666b7f1bb49254bcc9c1ad67b2f4ea7f4cd1c50ef3c16723bdbd5286049a
7
- data.tar.gz: 30b453fc424796b8b776d2c79b014d19645dd2f091fb6cb6822a6f373e1df719809d845bef66fc3146c821c42a7268f60ff65e034a93f5d51708e5a0028f7fb1
6
+ metadata.gz: 561c956490d3231c79cd89163c162364793baca6c1a86c0dddb3b4896b965d08e4e86e4a4766a297c7d71b5f1573336d3d9c99aa271d7fa9fbde3061a8b7d338
7
+ data.tar.gz: 683c8d6df19fbc1abcbc1420a4f78157d032ca91a1bbec9c2b77b3a429a88d6f2f754d0b1def057a807f90ea6e026ee11725eb22290c286e0019bc0aaba13d07
@@ -0,0 +1,40 @@
1
+ name: Plugin Backwards Compatibility Tests
2
+
3
+ on:
4
+ push:
5
+ branches: [ master ]
6
+ pull_request:
7
+ branches: [ master ]
8
+
9
+ permissions:
10
+ contents: read
11
+
12
+ jobs:
13
+ test:
14
+ runs-on: ubuntu-latest
15
+
16
+ steps:
17
+ - uses: actions/checkout@v3
18
+ - name: Set up Ruby
19
+ uses: ruby/setup-ruby@v1
20
+ with:
21
+ ruby-version: '3.0'
22
+ bundler-cache: false
23
+ - uses: awalsh128/cache-apt-pkgs-action@latest
24
+ with:
25
+ packages: yq
26
+ version: 1.0
27
+ - name: Install gems
28
+ run: |
29
+ echo 'gem "solargraph-rails"' > .Gemfile
30
+ echo 'gem "solargraph-rspec"' >> .Gemfile
31
+ bundle install
32
+ - name: Configure to use plugins
33
+ run: |
34
+ bundle exec solargraph config
35
+ yq -yi '.plugins += ["solargraph-rails"]' .solargraph.yml
36
+ yq -yi '.plugins += ["solargraph-rspec"]' .solargraph.yml
37
+ - name: Ensure typechecking still works
38
+ run: bundle exec solargraph typecheck --level typed
39
+ - name: Ensure specs still run
40
+ run: bundle exec rake spec
@@ -22,7 +22,7 @@ jobs:
22
22
  runs-on: ubuntu-latest
23
23
  strategy:
24
24
  matrix:
25
- ruby-version: ['2.6', '2.7', '3.0', '3.1', '3.2', '3.3', '3.4', 'head']
25
+ ruby-version: ['3.0', '3.1', '3.2', '3.3', '3.4', 'head']
26
26
 
27
27
  steps:
28
28
  - uses: actions/checkout@v3
@@ -33,7 +33,5 @@ jobs:
33
33
  bundler-cache: false
34
34
  - name: Install gems
35
35
  run: bundle install
36
- - name: Set up yardocs
37
- run: bundle exec yard gems
38
36
  - name: Run tests
39
37
  run: bundle exec rspec
@@ -0,0 +1,34 @@
1
+ # This workflow uses actions that are not certified by GitHub.
2
+ # They are provided by a third-party and are governed by
3
+ # separate terms of service, privacy policy, and support
4
+ # documentation.
5
+ # This workflow will download a prebuilt Ruby version, install dependencies and run tests with rspec.
6
+ # For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
7
+
8
+ name: Typecheck
9
+
10
+ on:
11
+ push:
12
+ branches: [ master ]
13
+ pull_request:
14
+ branches: [ master ]
15
+
16
+ permissions:
17
+ contents: read
18
+
19
+ jobs:
20
+ test:
21
+
22
+ runs-on: ubuntu-latest
23
+
24
+ steps:
25
+ - uses: actions/checkout@v3
26
+ - name: Set up Ruby
27
+ uses: ruby/setup-ruby@v1
28
+ with:
29
+ ruby-version: 3.4
30
+ bundler-cache: false
31
+ - name: Install gems
32
+ run: bundle install
33
+ - name: Typecheck self
34
+ run: bundle exec solargraph typecheck --level typed
data/.yardopts CHANGED
@@ -1,2 +1,2 @@
1
- lib/**/*.rb
2
- -e lib/yard-solargraph.rb
1
+ lib/**/*.rb
2
+ --plugin yard-solargraph
data/CHANGELOG.md CHANGED
@@ -1,3 +1,53 @@
1
+ ## 0.53.0 - March 25, 2025
2
+ - Fix crash on generic methods (#762)
3
+ - Add more type annotations to the codebase (#763 et al.)
4
+ - Address remaining typecheck issues at 'typed' level and add CI task (#764)
5
+ - Fix crash during strict typechecking (#766)
6
+ - DeepInference: Fix some bugs, add docs, refactor (#767)
7
+ - Include "self type" methods like Enumerable#each from RBS files (#769)
8
+ - Handle RBS global, module alias, class variable and class instance variable declarations (#770)
9
+ - Add support for generic includes via RBS (#773)
10
+ - Handle parsing tuples of tuples in tags (#775)
11
+ - Retire the RubyVM parser (#776)
12
+ - Improve block handling in signature selection (#780)
13
+ - Require Ruby >= 3 (#791)
14
+ - Cache YARD and RBS (#781)
15
+ - Language server generates gem documentation in the background
16
+ - Fix bug handling Array(A, B) syntax while resolving generics (#784)
17
+ - Fix typeDefinitions for neovim (#792)
18
+ - Infer block-pass symbols (#793)
19
+ - Add #to_rbs methods to pins, use for better .inspect() output (#789)
20
+ - Remove deprecated commands (#790)
21
+ - Add :if support to NodeChainer for if statements as lvalues (#805)
22
+ - Fix ApiMap::Cache (#806)
23
+ - Map mixins from RBS (#808)
24
+ - Fix issue with wrong signature selection by call with block node (#815)
25
+ - Keep gem pins in memory (#811)
26
+ - Refactor gems command (#816)
27
+ - Use return type of literal blocks in inference (#818)
28
+ - Insert Module methods (#820)
29
+ - Revise documentation formatting (#823)
30
+
31
+ ## 0.52.0 - February 28, 2025
32
+ - Chains resolve identical names with different contexts (#679)
33
+ - Handle symbol tags in method tag values (#744)
34
+ - Infer more specific Array types when possible (#745)
35
+ - Handle interpolated symbol literals (#747)
36
+ - Handle combined conditions, else clauses in case statements (#746)
37
+ - fix: support find require xxx.rb in local workspace. (#722)
38
+ - Don't require redundant attribute @return and @param tags (#748)
39
+ - Use @yieldreturn tags for type inference (#749)
40
+ - Fix type annotations identified at 'typed' level (#750)
41
+ - Support RBS class aliases (#751)
42
+ - Better support for generics via Class @param tags (#743)
43
+ - Generic module support through RBS (#757)
44
+ - Fix inference of begin expression types (#754)
45
+ - Add argument to satisfy typechecker on which signature to use (#755)
46
+ - Fix RBS ingestion implicit initializer issues, missing param types (#756)
47
+ - Validate zsuper arity
48
+ - Use yard-solargraph plugin (#759)
49
+ - Add missing RBS types
50
+
1
51
  ## 0.51.2 - February 1, 2025
2
52
  - Fix exception from parser when anonymous block forwarding is used (#740)
3
53
  - Parameterized Object types
@@ -5,10 +55,10 @@
5
55
 
6
56
  ## 0.51.1 - January 23, 2025
7
57
  - Format example code
8
- - Block infers yieldself from chain
58
+ - Block infers yieldreceiver from chain
9
59
 
10
60
  ## 0.51.0 - January 19, 2025
11
- - Resolve self in yieldself tags
61
+ - Resolve self in yieldreceiver tags
12
62
  - Include absolute paths in config (#674)
13
63
  - Enable diagnostics by default
14
64
  - Fix cache resolution (#704)
@@ -597,7 +647,7 @@
597
647
  ## 0.31.2 - January 27, 2019
598
648
  - Use YARD documentation rules to associate directives with namespaces
599
649
  - Handle non-unique pin locations in completionItem/resolve
600
- - Clip#complete handles @yieldself and @yieldpublic contexts
650
+ - Clip#complete handles @yieldreceiver and @yieldpublic contexts
601
651
  - Host::Dispatch filters library updates (castwide/vscode-solargraph#99)
602
652
  - Qualify included namespaces (#148)
603
653
 
@@ -953,7 +1003,7 @@
953
1003
 
954
1004
  ## 0.17.0 - February 1, 2018
955
1005
  - Support Solargraph configurations in workspace folders.
956
- - Use @yieldself tag to change block contexts.
1006
+ - Use @yieldreceiver tag to change block contexts.
957
1007
  - Handle whitespace in signatures.
958
1008
  - Convert 'self' when inferring signature types.
959
1009
  - Handle bare periods without signatures.
@@ -996,7 +1046,7 @@
996
1046
  - Map pins to code objects.
997
1047
  - Infer return types from domain (DSL) methods.
998
1048
  - Fixed visibility and results for superclasses.
999
- - Experimental @yieldself tag.
1049
+ - Experimental @yieldreceiver tag.
1000
1050
  - Improved syntax error handling in Source.fix.
1001
1051
  - Gem ships with Ruby 2.2.2 yardocs.
1002
1052
  - Experimental plugin architecture and Runtime plugin.
data/README.md CHANGED
@@ -34,6 +34,7 @@ Plug-ins and extensions are available for the following editors:
34
34
  * Instructions: https://lsp.sublimetext.io/language_servers/#solargraph
35
35
 
36
36
  * **Vim**
37
+ * Github: `nvim-lspconfig`, https://github.com/neovim/nvim-lspconfig/blob/master/doc/configs.md#solargraph
37
38
  * GitHub: `LanguageClient-neovim`, https://github.com/autozimu/LanguageClient-neovim
38
39
  * GitHub: `coc`, https://github.com/neoclide/coc-solargraph
39
40
  * GitHub: `Vim-EasyComplete`, https://github.com/jayli/vim-easycomplete
@@ -50,12 +51,19 @@ Plug-ins and extensions are available for the following editors:
50
51
 
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.
52
53
 
53
- ### Rails Support
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
+
54
58
  For better Rails support, please consider using [solargraph-rails](https://github.com/iftheshoefritz/solargraph-rails/)
55
59
 
60
+ The RSpec framework is supported via [solargraph-rspec](https://github.com/lekemula/solargraph-rspec/)
61
+
56
62
  ### Gem Support
57
63
 
58
- 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).
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.
59
67
 
60
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.
61
69
 
@@ -65,22 +73,11 @@ If your project automatically requires bundled gems (e.g., `require 'bundler/req
65
73
 
66
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.
67
75
 
68
- ### Updating Core Documentation
69
-
70
- As of version 0.49.0, Solargraph uses [rbs](https://github.com/ruby/rbs) for core and stdlib documentation. The following only applies to prior versions.
71
-
72
- The Solargraph gem ships with documentation for Ruby 2.2.2. You can download documentation for other Ruby versions from the command line.
73
-
74
- $ solargraph list-cores # List the installed documentation versions
75
- $ solargraph available-cores # List the versions available for download
76
- $ solargraph download-core # Install the best match for your Ruby version
77
- $ solargraph clear # Reset the documentation cache
78
-
79
76
  ### The Documentation Cache
80
77
 
81
- 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.
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.
82
79
 
83
- 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.
80
+ You can change the location of the cache directory with the `SOLARGRAPH_CACHE` environment variable.
84
81
 
85
82
  ### Solargraph and Bundler
86
83
 
@@ -90,7 +87,7 @@ In the Gemfile:
90
87
 
91
88
  gem 'solargraph', group: :development
92
89
 
93
- 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.
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.
94
91
 
95
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`.
96
93
 
data/SPONSORS.md CHANGED
@@ -4,13 +4,7 @@ Solargraph is developed and maintained by [Castwide Technologies](https://castwi
4
4
 
5
5
  The following people and organizations provide funding or other resources. [Become a sponsor](https://patreon.com/castwide)
6
6
 
7
- ## Linked Sponsors
8
-
9
- - **[Calyptix Security](https://www.calyptix.com/)**
10
-
11
7
  ## Named Sponsors
12
8
 
13
- - Akira Yamada
14
- - Joel Drapper
15
- - Spencer
9
+ - Juan Carlos
16
10
  - Vince Broz
@@ -4,66 +4,106 @@ module Solargraph
4
4
  class ApiMap
5
5
  class Cache
6
6
  def initialize
7
+ # @type [Hash{Array => Array<Pin::Method>}]
7
8
  @methods = {}
9
+ # @type [Hash{(String, Array<String>) => Array<Pin::Base>}]
8
10
  @constants = {}
11
+ # @type [Hash{(String, String) => String}]
9
12
  @qualified_namespaces = {}
13
+ # @type [Hash{String => Pin::Method}]
10
14
  @receiver_definitions = {}
15
+ # @type [Hash{String => SourceMap::Clip}]
16
+ @clips = {}
11
17
  end
12
18
 
19
+ # @param fqns [String]
20
+ # @param scope [Symbol]
21
+ # @param visibility [Array<Symbol>]
22
+ # @param deep [Boolean]
13
23
  # @return [Array<Pin::Method>]
14
24
  def get_methods fqns, scope, visibility, deep
15
- @methods[[fqns, scope, visibility.sort, deep]]
25
+ @methods["#{fqns}|#{scope}|#{visibility}|#{deep}"]
16
26
  end
17
27
 
28
+ # @param fqns [String]
29
+ # @param scope [Symbol]
30
+ # @param visibility [Array<Symbol>]
31
+ # @param deep [Boolean]
32
+ # @param value [Array<Pin::Method>]
33
+ # @return [void]
18
34
  def set_methods fqns, scope, visibility, deep, value
19
- @methods[[fqns, scope, visibility.sort, deep]] = value
35
+ @methods["#{fqns}|#{scope}|#{visibility}|#{deep}"] = value
20
36
  end
21
37
 
38
+ # @param namespace [String]
39
+ # @param contexts [Array<String>]
22
40
  # @return [Array<Pin::Base>]
23
- def get_constants namespace, context
24
- @constants[[namespace, context]]
41
+ def get_constants namespace, contexts
42
+ @constants["#{namespace}|#{contexts}"]
25
43
  end
26
44
 
27
- def set_constants namespace, context, value
28
- @constants[[namespace, context]] = value
45
+ # @param namespace [String]
46
+ # @param contexts [Array<String>]
47
+ # @param value [Array<Pin::Base>]
48
+ # @return [void]
49
+ def set_constants namespace, contexts, value
50
+ @constants["#{namespace}|#{contexts}"] = value
29
51
  end
30
52
 
53
+ # @param name [String]
54
+ # @param context [String]
31
55
  # @return [String]
32
56
  def get_qualified_namespace name, context
33
- @qualified_namespaces[[name, context]]
57
+ @qualified_namespaces["#{name}|#{context}"]
34
58
  end
35
59
 
60
+ # @param name [String]
61
+ # @param context [String]
62
+ # @param value [String]
63
+ # @return [void]
36
64
  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
65
+ @qualified_namespaces["#{name}|#{context}"] = value
42
66
  end
43
67
 
68
+ # @param path [String]
44
69
  # @return [Pin::Method]
45
70
  def get_receiver_definition path
46
71
  @receiver_definitions[path]
47
72
  end
48
73
 
74
+ # @param path [String]
75
+ # @param pin [Pin::Method]
76
+ # @return [void]
49
77
  def set_receiver_definition path, pin
50
78
  @receiver_definitions[path] = pin
51
79
  end
52
80
 
81
+ # @param cursor [Source::Cursor]
82
+ # @return [SourceMap::Clip, nil]
83
+ def get_clip(cursor)
84
+ @clips["#{cursor.filename}|#{cursor.range.inspect}|#{cursor.node&.to_sexp}"]
85
+ end
86
+
87
+ # @param cursor [Source::Cursor]
88
+ # @param clip [SourceMap::Clip]
89
+ def set_clip(cursor, clip)
90
+ @clips["#{cursor.filename}|#{cursor.range.inspect}|#{cursor.node&.to_sexp}"] = clip
91
+ end
92
+
53
93
  # @return [void]
54
94
  def clear
55
- @methods.clear
56
- @constants.clear
57
- @qualified_namespaces.clear
58
- @receiver_definitions.clear
95
+ all_caches.each(&:clear)
59
96
  end
60
97
 
61
98
  # @return [Boolean]
62
99
  def empty?
63
- @methods.empty? &&
64
- @constants.empty? &&
65
- @qualified_namespaces.empty? &&
66
- @receiver_definitions.empty?
100
+ all_caches.all?(&:empty?)
101
+ end
102
+
103
+ private
104
+
105
+ def all_caches
106
+ [@methods, @constants, @qualified_namespaces, @receiver_definitions, @clips]
67
107
  end
68
108
  end
69
109
  end
@@ -1,11 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'set'
4
3
 
5
4
  module Solargraph
6
5
  class ApiMap
7
6
  class Store
8
- # @return [Enumerable<Solargraph::Pin::Base>]
7
+ # @return [Array<Solargraph::Pin::Base>]
9
8
  attr_reader :pins
10
9
 
11
10
  # @param pins [Enumerable<Solargraph::Pin::Base>]
@@ -26,7 +25,7 @@ module Solargraph
26
25
  # @param fqns [String]
27
26
  # @param scope [Symbol]
28
27
  # @param visibility [Array<Symbol>]
29
- # @return [Enumerable<Solargraph::Pin::Base>]
28
+ # @return [Enumerable<Solargraph::Pin::Method>]
30
29
  def get_methods fqns, scope: :instance, visibility: [:public]
31
30
  namespace_children(fqns).select do |pin|
32
31
  pin.is_a?(Pin::Method) && pin.scope == scope && visibility.include?(pin.visibility)
@@ -61,7 +60,7 @@ module Solargraph
61
60
  end
62
61
 
63
62
  # @param path [String]
64
- # @return [Enumerable<Solargraph::Pin::Base>]
63
+ # @return [Array<Solargraph::Pin::Base>]
65
64
  def get_path_pins path
66
65
  path_pin_hash[path] || []
67
66
  end
@@ -117,7 +116,7 @@ module Solargraph
117
116
  result
118
117
  end
119
118
 
120
- # @return [Hash]
119
+ # @return [Hash{String => YARD::Tags::MacroDirective}]
121
120
  def named_macros
122
121
  @named_macros ||= begin
123
122
  result = {}
@@ -144,11 +143,11 @@ module Solargraph
144
143
  # @param klass [Class]
145
144
  # @return [Enumerable<Solargraph::Pin::Base>]
146
145
  def pins_by_class klass
147
- @pin_select_cache[klass] ||= @pin_class_hash.each_with_object(Set.new) { |(key, o), n| n.merge(o) if key <= klass }
146
+ # @type [Set<Solargraph::Pin::Base>]
147
+ s = Set.new
148
+ @pin_select_cache[klass] ||= @pin_class_hash.each_with_object(s) { |(key, o), n| n.merge(o) if key <= klass }
148
149
  end
149
150
 
150
- private
151
-
152
151
  # @param fqns [String]
153
152
  # @return [Array<Solargraph::Pin::Namespace>]
154
153
  def fqns_pins fqns
@@ -164,6 +163,9 @@ module Solargraph
164
163
  fqns_pins_map[[base, name]]
165
164
  end
166
165
 
166
+ private
167
+
168
+ # @return [Hash{Array(String, String) => Array<Pin::Namespace>}]
167
169
  def fqns_pins_map
168
170
  @fqns_pins_map ||= Hash.new do |h, (base, name)|
169
171
  value = namespace_children(base).select { |pin| pin.name == name && pin.is_a?(Pin::Namespace) }
@@ -176,18 +178,22 @@ module Solargraph
176
178
  pins_by_class(Pin::Symbol)
177
179
  end
178
180
 
181
+ # @return [Hash{String => Enumerable<String>}]
179
182
  def superclass_references
180
183
  @superclass_references ||= {}
181
184
  end
182
185
 
186
+ # @return [Hash{String => Array<String>}]
183
187
  def include_references
184
188
  @include_references ||= {}
185
189
  end
186
190
 
191
+ # @return [Hash{String => Array<String>}]
187
192
  def prepend_references
188
193
  @prepend_references ||= {}
189
194
  end
190
195
 
196
+ # @return [Hash{String => Array<String>}]
191
197
  def extend_references
192
198
  @extend_references ||= {}
193
199
  end
@@ -198,31 +204,58 @@ module Solargraph
198
204
  namespace_map[name] || []
199
205
  end
200
206
 
201
- # @return [Hash]
207
+ # @return [Hash{String => Enumerable<Pin::Base>}
202
208
  def namespace_map
203
209
  @namespace_map ||= {}
204
210
  end
205
211
 
212
+ # @return [Enumerable<Pin::InstanceVariable>]
206
213
  def all_instance_variables
207
214
  pins_by_class(Pin::InstanceVariable)
208
215
  end
209
216
 
217
+ # @return [Hash{String => Array<Pin::Base>}]
210
218
  def path_pin_hash
211
219
  @path_pin_hash ||= {}
212
220
  end
213
221
 
222
+ # Add references to a map
223
+ #
224
+ # @param h [Hash{String => Pin:Base}]
225
+ # @param reference_pin [Pin::Reference]
226
+ #
227
+ # @return [void]
228
+ def store_parametric_reference(h, reference_pin)
229
+ referenced_ns = reference_pin.name
230
+ referenced_tag_params = reference_pin.generic_values
231
+ referenced_tag = referenced_ns +
232
+ if referenced_tag_params && referenced_tag_params.length > 0
233
+ "<" + referenced_tag_params.join(', ') + ">"
234
+ else
235
+ ''
236
+ end
237
+ referencing_ns = reference_pin.namespace
238
+ h[referencing_ns] ||= []
239
+ h[referencing_ns].push referenced_tag
240
+ end
241
+
214
242
  # @return [void]
215
243
  def index
216
244
  set = pins.to_set
217
245
  @pin_class_hash = set.classify(&:class).transform_values(&:to_a)
246
+ # @type [Hash{Class => Enumerable<Solargraph::Pin::Base>}]
218
247
  @pin_select_cache = {}
219
248
  @namespace_map = set.classify(&:namespace)
220
249
  @path_pin_hash = set.classify(&:path)
221
250
  @namespaces = @path_pin_hash.keys.compact.to_set
222
251
  pins_by_class(Pin::Reference::Include).each do |pin|
223
- include_references[pin.namespace] ||= []
224
- include_references[pin.namespace].push pin.name
252
+ store_parametric_reference(include_references, pin)
225
253
  end
254
+ # @todo move the rest of these reference pins over to use
255
+ # generic types, adding rbs_map/conversions.rb code to
256
+ # populate type parameters and adding related specs ensuring
257
+ # the generics get resolved, along with any api_map.rb
258
+ # changes needed in
226
259
  pins_by_class(Pin::Reference::Prepend).each do |pin|
227
260
  prepend_references[pin.namespace] ||= []
228
261
  prepend_references[pin.namespace].push pin.name
@@ -256,6 +289,9 @@ module Solargraph
256
289
  end
257
290
  end
258
291
 
292
+ # @param pin [Pin::Base]
293
+ # @param tag [String]
294
+ # @return [void]
259
295
  def redefine_return_type pin, tag
260
296
  return unless pin && tag.tag_name == 'return'
261
297
  pin.instance_variable_set(:@return_type, ComplexType.try_parse(tag.type))