solargraph 0.52.0 → 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.
- checksums.yaml +4 -4
- data/.github/workflows/plugins.yml +40 -0
- data/.github/workflows/rspec.yml +1 -3
- data/.github/workflows/typecheck.yml +34 -0
- data/CHANGELOG.md +30 -0
- data/README.md +13 -16
- data/SPONSORS.md +1 -7
- data/lib/solargraph/api_map/cache.rb +59 -21
- data/lib/solargraph/api_map/store.rb +45 -9
- data/lib/solargraph/api_map.rb +152 -93
- data/lib/solargraph/bench.rb +2 -2
- data/lib/solargraph/cache.rb +29 -5
- data/lib/solargraph/complex_type/type_methods.rb +53 -8
- data/lib/solargraph/complex_type/unique_type.rb +149 -59
- data/lib/solargraph/complex_type.rb +62 -9
- data/lib/solargraph/convention.rb +0 -1
- data/lib/solargraph/converters/dd.rb +5 -0
- data/lib/solargraph/converters/dl.rb +3 -0
- data/lib/solargraph/converters/dt.rb +3 -0
- data/lib/solargraph/diagnostics/rubocop.rb +8 -7
- data/lib/solargraph/diagnostics/rubocop_helpers.rb +1 -0
- data/lib/solargraph/diagnostics/type_check.rb +1 -0
- data/lib/solargraph/diagnostics.rb +2 -2
- data/lib/solargraph/doc_map.rb +146 -0
- data/lib/solargraph/gem_pins.rb +64 -0
- data/lib/solargraph/language_server/host/cataloger.rb +1 -0
- data/lib/solargraph/language_server/host/diagnoser.rb +2 -2
- data/lib/solargraph/language_server/host/dispatch.rb +10 -4
- data/lib/solargraph/language_server/host/message_worker.rb +4 -0
- data/lib/solargraph/language_server/host/sources.rb +7 -4
- data/lib/solargraph/language_server/host.rb +15 -6
- data/lib/solargraph/language_server/message/completion_item/resolve.rb +3 -1
- data/lib/solargraph/language_server/message/extended/check_gem_version.rb +13 -1
- data/lib/solargraph/language_server/message/initialize.rb +5 -2
- data/lib/solargraph/language_server/message/text_document/hover.rb +2 -0
- data/lib/solargraph/language_server/message/text_document.rb +0 -1
- data/lib/solargraph/language_server/message/workspace/did_change_configuration.rb +5 -0
- data/lib/solargraph/language_server/transport/adapter.rb +16 -1
- data/lib/solargraph/language_server/transport/data_reader.rb +2 -0
- data/lib/solargraph/library.rb +58 -11
- data/lib/solargraph/location.rb +1 -0
- data/lib/solargraph/parser/comment_ripper.rb +3 -0
- data/lib/solargraph/parser/node_methods.rb +47 -8
- data/lib/solargraph/parser/node_processor/base.rb +9 -0
- data/lib/solargraph/parser/{legacy → parser_gem}/class_methods.rb +29 -3
- data/lib/solargraph/parser/{legacy → parser_gem}/flawed_builder.rb +3 -1
- data/lib/solargraph/parser/{legacy → parser_gem}/node_chainer.rb +42 -34
- data/lib/solargraph/parser/{legacy → parser_gem}/node_methods.rb +201 -29
- data/lib/solargraph/parser/{rubyvm → parser_gem}/node_processors/alias_node.rb +1 -1
- data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/args_node.rb +4 -1
- data/lib/solargraph/parser/{rubyvm → parser_gem}/node_processors/begin_node.rb +1 -1
- data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/block_node.rb +3 -2
- data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/casgn_node.rb +2 -2
- data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/cvasgn_node.rb +1 -1
- data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/def_node.rb +1 -1
- data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/defs_node.rb +2 -2
- data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/gvasgn_node.rb +1 -1
- data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/ivasgn_node.rb +2 -2
- data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/lvasgn_node.rb +2 -2
- data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/namespace_node.rb +2 -2
- data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/orasgn_node.rb +1 -1
- data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/resbody_node.rb +3 -3
- data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/sclass_node.rb +1 -1
- data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/send_node.rb +2 -2
- data/lib/solargraph/parser/{rubyvm → parser_gem}/node_processors/sym_node.rb +1 -1
- data/lib/solargraph/parser/parser_gem/node_processors.rb +54 -0
- data/lib/solargraph/parser/parser_gem.rb +12 -0
- data/lib/solargraph/parser/snippet.rb +2 -0
- data/lib/solargraph/parser.rb +8 -11
- data/lib/solargraph/pin/base.rb +63 -8
- data/lib/solargraph/pin/base_variable.rb +6 -2
- data/lib/solargraph/pin/block.rb +11 -6
- data/lib/solargraph/pin/closure.rb +17 -2
- data/lib/solargraph/pin/common.rb +7 -3
- data/lib/solargraph/pin/conversions.rb +33 -3
- data/lib/solargraph/pin/documenting.rb +25 -34
- data/lib/solargraph/pin/instance_variable.rb +4 -0
- data/lib/solargraph/pin/local_variable.rb +13 -1
- data/lib/solargraph/pin/method.rb +109 -15
- data/lib/solargraph/pin/namespace.rb +16 -10
- data/lib/solargraph/pin/parameter.rb +41 -10
- data/lib/solargraph/pin/reference/override.rb +2 -2
- data/lib/solargraph/pin/reference.rb +8 -0
- data/lib/solargraph/pin/search.rb +3 -3
- data/lib/solargraph/pin/signature.rb +114 -2
- data/lib/solargraph/pin.rb +0 -1
- data/lib/solargraph/range.rb +2 -2
- data/lib/solargraph/rbs_map/conversions.rb +212 -25
- data/lib/solargraph/rbs_map/core_fills.rb +4 -26
- data/lib/solargraph/rbs_map/core_map.rb +1 -0
- data/lib/solargraph/rbs_map/core_signs.rb +2 -0
- data/lib/solargraph/rbs_map/stdlib_map.rb +2 -8
- data/lib/solargraph/rbs_map.rb +19 -9
- data/lib/solargraph/shell.rb +62 -59
- data/lib/solargraph/source/chain/array.rb +4 -1
- data/lib/solargraph/source/chain/block_symbol.rb +13 -0
- data/lib/solargraph/source/chain/call.rb +95 -26
- data/lib/solargraph/source/chain/constant.rb +15 -1
- data/lib/solargraph/source/chain/if.rb +23 -0
- data/lib/solargraph/source/chain/link.rb +7 -1
- data/lib/solargraph/source/chain/or.rb +1 -1
- data/lib/solargraph/source/chain/z_super.rb +2 -2
- data/lib/solargraph/source/chain.rb +20 -4
- data/lib/solargraph/source/change.rb +3 -0
- data/lib/solargraph/source/cursor.rb +2 -0
- data/lib/solargraph/source/source_chainer.rb +6 -5
- data/lib/solargraph/source.rb +15 -16
- data/lib/solargraph/source_map/clip.rb +11 -7
- data/lib/solargraph/source_map/mapper.rb +10 -0
- data/lib/solargraph/source_map.rb +13 -3
- data/lib/solargraph/type_checker/checks.rb +10 -2
- data/lib/solargraph/type_checker.rb +74 -19
- data/lib/solargraph/version.rb +1 -1
- data/lib/solargraph/workspace/config.rb +8 -6
- data/lib/solargraph/workspace.rb +1 -1
- data/lib/solargraph/yard_map/cache.rb +6 -0
- data/lib/solargraph/yard_map/helpers.rb +1 -1
- data/lib/solargraph/yard_map/mapper/to_method.rb +11 -1
- data/lib/solargraph/yard_map/to_method.rb +11 -4
- data/lib/solargraph/yard_map.rb +0 -292
- data/lib/solargraph/yardoc.rb +52 -0
- data/lib/solargraph.rb +4 -1
- data/solargraph.gemspec +2 -2
- metadata +35 -57
- data/lib/solargraph/api_map/bundler_methods.rb +0 -22
- data/lib/solargraph/documentor.rb +0 -76
- data/lib/solargraph/parser/legacy/node_processors/alias_node.rb +0 -23
- data/lib/solargraph/parser/legacy/node_processors/begin_node.rb +0 -15
- data/lib/solargraph/parser/legacy/node_processors/sym_node.rb +0 -18
- data/lib/solargraph/parser/legacy/node_processors.rb +0 -55
- data/lib/solargraph/parser/legacy.rb +0 -12
- data/lib/solargraph/parser/rubyvm/class_methods.rb +0 -151
- data/lib/solargraph/parser/rubyvm/node_chainer.rb +0 -163
- data/lib/solargraph/parser/rubyvm/node_methods.rb +0 -317
- data/lib/solargraph/parser/rubyvm/node_processors/args_node.rb +0 -85
- data/lib/solargraph/parser/rubyvm/node_processors/block_node.rb +0 -42
- data/lib/solargraph/parser/rubyvm/node_processors/casgn_node.rb +0 -33
- data/lib/solargraph/parser/rubyvm/node_processors/cvasgn_node.rb +0 -23
- data/lib/solargraph/parser/rubyvm/node_processors/def_node.rb +0 -75
- data/lib/solargraph/parser/rubyvm/node_processors/defs_node.rb +0 -68
- data/lib/solargraph/parser/rubyvm/node_processors/gvasgn_node.rb +0 -23
- data/lib/solargraph/parser/rubyvm/node_processors/ivasgn_node.rb +0 -38
- data/lib/solargraph/parser/rubyvm/node_processors/kw_arg_node.rb +0 -39
- data/lib/solargraph/parser/rubyvm/node_processors/lit_node.rb +0 -20
- data/lib/solargraph/parser/rubyvm/node_processors/lvasgn_node.rb +0 -27
- data/lib/solargraph/parser/rubyvm/node_processors/namespace_node.rb +0 -39
- data/lib/solargraph/parser/rubyvm/node_processors/opt_arg_node.rb +0 -26
- data/lib/solargraph/parser/rubyvm/node_processors/orasgn_node.rb +0 -15
- data/lib/solargraph/parser/rubyvm/node_processors/resbody_node.rb +0 -51
- data/lib/solargraph/parser/rubyvm/node_processors/sclass_node.rb +0 -32
- data/lib/solargraph/parser/rubyvm/node_processors/scope_node.rb +0 -15
- data/lib/solargraph/parser/rubyvm/node_processors/send_node.rb +0 -279
- data/lib/solargraph/parser/rubyvm/node_processors.rb +0 -64
- data/lib/solargraph/parser/rubyvm/node_wrapper.rb +0 -47
- data/lib/solargraph/parser/rubyvm.rb +0 -40
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ea6f4539a04d35b759acc75c97b4af772a34877adf8dba07e0a9a109a75cb545
|
4
|
+
data.tar.gz: 3e6945e906e693884a19e3fb2504cf8508cdb9784fa015b27dd455fb2e4ddba7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
data/.github/workflows/rspec.yml
CHANGED
@@ -22,7 +22,7 @@ jobs:
|
|
22
22
|
runs-on: ubuntu-latest
|
23
23
|
strategy:
|
24
24
|
matrix:
|
25
|
-
ruby-version: ['
|
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/CHANGELOG.md
CHANGED
@@ -1,3 +1,33 @@
|
|
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
|
+
|
1
31
|
## 0.52.0 - February 28, 2025
|
2
32
|
- Chains resolve identical names with different contexts (#679)
|
3
33
|
- Handle symbol tags in method tag values (#744)
|
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
|
-
###
|
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
|
-
|
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
|
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.
|
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
|
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
|
-
-
|
14
|
-
- Joel Drapper
|
15
|
-
- Spencer
|
9
|
+
- Juan Carlos
|
16
10
|
- Vince Broz
|
@@ -6,66 +6,104 @@ module Solargraph
|
|
6
6
|
def initialize
|
7
7
|
# @type [Hash{Array => Array<Pin::Method>}]
|
8
8
|
@methods = {}
|
9
|
+
# @type [Hash{(String, Array<String>) => Array<Pin::Base>}]
|
9
10
|
@constants = {}
|
11
|
+
# @type [Hash{(String, String) => String}]
|
10
12
|
@qualified_namespaces = {}
|
13
|
+
# @type [Hash{String => Pin::Method}]
|
11
14
|
@receiver_definitions = {}
|
15
|
+
# @type [Hash{String => SourceMap::Clip}]
|
16
|
+
@clips = {}
|
12
17
|
end
|
13
18
|
|
19
|
+
# @param fqns [String]
|
20
|
+
# @param scope [Symbol]
|
21
|
+
# @param visibility [Array<Symbol>]
|
22
|
+
# @param deep [Boolean]
|
14
23
|
# @return [Array<Pin::Method>]
|
15
24
|
def get_methods fqns, scope, visibility, deep
|
16
|
-
@methods[
|
25
|
+
@methods["#{fqns}|#{scope}|#{visibility}|#{deep}"]
|
17
26
|
end
|
18
27
|
|
19
|
-
# @
|
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]
|
20
34
|
def set_methods fqns, scope, visibility, deep, value
|
21
|
-
@methods[
|
35
|
+
@methods["#{fqns}|#{scope}|#{visibility}|#{deep}"] = value
|
22
36
|
end
|
23
37
|
|
38
|
+
# @param namespace [String]
|
39
|
+
# @param contexts [Array<String>]
|
24
40
|
# @return [Array<Pin::Base>]
|
25
|
-
def get_constants namespace,
|
26
|
-
@constants[
|
41
|
+
def get_constants namespace, contexts
|
42
|
+
@constants["#{namespace}|#{contexts}"]
|
27
43
|
end
|
28
44
|
|
29
|
-
|
30
|
-
|
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
|
31
51
|
end
|
32
52
|
|
53
|
+
# @param name [String]
|
54
|
+
# @param context [String]
|
33
55
|
# @return [String]
|
34
56
|
def get_qualified_namespace name, context
|
35
|
-
@qualified_namespaces[
|
57
|
+
@qualified_namespaces["#{name}|#{context}"]
|
36
58
|
end
|
37
59
|
|
60
|
+
# @param name [String]
|
61
|
+
# @param context [String]
|
62
|
+
# @param value [String]
|
63
|
+
# @return [void]
|
38
64
|
def set_qualified_namespace name, context, value
|
39
|
-
@qualified_namespaces[
|
40
|
-
end
|
41
|
-
|
42
|
-
def receiver_defined? path
|
43
|
-
@receiver_definitions.key? path
|
65
|
+
@qualified_namespaces["#{name}|#{context}"] = value
|
44
66
|
end
|
45
67
|
|
68
|
+
# @param path [String]
|
46
69
|
# @return [Pin::Method]
|
47
70
|
def get_receiver_definition path
|
48
71
|
@receiver_definitions[path]
|
49
72
|
end
|
50
73
|
|
74
|
+
# @param path [String]
|
75
|
+
# @param pin [Pin::Method]
|
76
|
+
# @return [void]
|
51
77
|
def set_receiver_definition path, pin
|
52
78
|
@receiver_definitions[path] = pin
|
53
79
|
end
|
54
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
|
+
|
55
93
|
# @return [void]
|
56
94
|
def clear
|
57
|
-
|
58
|
-
@constants.clear
|
59
|
-
@qualified_namespaces.clear
|
60
|
-
@receiver_definitions.clear
|
95
|
+
all_caches.each(&:clear)
|
61
96
|
end
|
62
97
|
|
63
98
|
# @return [Boolean]
|
64
99
|
def empty?
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
100
|
+
all_caches.all?(&:empty?)
|
101
|
+
end
|
102
|
+
|
103
|
+
private
|
104
|
+
|
105
|
+
def all_caches
|
106
|
+
[@methods, @constants, @qualified_namespaces, @receiver_definitions, @clips]
|
69
107
|
end
|
70
108
|
end
|
71
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 [
|
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::
|
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 [
|
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,7 +143,9 @@ module Solargraph
|
|
144
143
|
# @param klass [Class]
|
145
144
|
# @return [Enumerable<Solargraph::Pin::Base>]
|
146
145
|
def pins_by_class klass
|
147
|
-
@
|
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
151
|
# @param fqns [String]
|
@@ -164,6 +165,7 @@ module Solargraph
|
|
164
165
|
|
165
166
|
private
|
166
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
|
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))
|