solargraph 0.56.0 → 0.58.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitattributes +2 -0
- data/.github/workflows/linting.yml +127 -0
- data/.github/workflows/plugins.yml +183 -7
- data/.github/workflows/rspec.yml +55 -5
- data/.github/workflows/typecheck.yml +6 -3
- data/.gitignore +6 -0
- data/.overcommit.yml +72 -0
- data/.rspec +1 -0
- data/.rubocop.yml +66 -0
- data/.rubocop_todo.yml +1279 -0
- data/.yardopts +1 -0
- data/CHANGELOG.md +92 -1
- data/README.md +8 -4
- data/Rakefile +125 -13
- data/bin/solargraph +3 -0
- data/lib/solargraph/api_map/cache.rb +110 -109
- data/lib/solargraph/api_map/constants.rb +279 -0
- data/lib/solargraph/api_map/index.rb +193 -175
- data/lib/solargraph/api_map/source_to_yard.rb +97 -88
- data/lib/solargraph/api_map/store.rb +384 -266
- data/lib/solargraph/api_map.rb +945 -973
- data/lib/solargraph/bench.rb +1 -0
- data/lib/solargraph/complex_type/type_methods.rb +228 -222
- data/lib/solargraph/complex_type/unique_type.rb +482 -475
- data/lib/solargraph/complex_type.rb +444 -423
- data/lib/solargraph/convention/active_support_concern.rb +111 -0
- data/lib/solargraph/convention/base.rb +17 -0
- data/lib/solargraph/convention/data_definition/data_assignment_node.rb +61 -0
- data/lib/solargraph/convention/data_definition/data_definition_node.rb +91 -0
- data/lib/solargraph/convention/data_definition.rb +105 -0
- data/lib/solargraph/convention/gemspec.rb +3 -2
- data/lib/solargraph/convention/struct_definition/struct_assignment_node.rb +61 -60
- data/lib/solargraph/convention/struct_definition/struct_definition_node.rb +102 -100
- data/lib/solargraph/convention/struct_definition.rb +164 -101
- data/lib/solargraph/convention.rb +32 -2
- data/lib/solargraph/diagnostics/require_not_found.rb +53 -53
- data/lib/solargraph/diagnostics/rubocop.rb +118 -113
- data/lib/solargraph/diagnostics/rubocop_helpers.rb +68 -66
- data/lib/solargraph/diagnostics/type_check.rb +55 -55
- data/lib/solargraph/doc_map.rb +439 -405
- data/lib/solargraph/environ.rb +9 -2
- data/lib/solargraph/equality.rb +34 -33
- data/lib/solargraph/gem_pins.rb +98 -88
- data/lib/solargraph/language_server/host/diagnoser.rb +89 -89
- data/lib/solargraph/language_server/host/dispatch.rb +130 -128
- data/lib/solargraph/language_server/host/message_worker.rb +112 -109
- data/lib/solargraph/language_server/host/sources.rb +99 -99
- data/lib/solargraph/language_server/host.rb +878 -871
- data/lib/solargraph/language_server/message/base.rb +2 -1
- data/lib/solargraph/language_server/message/extended/check_gem_version.rb +114 -114
- data/lib/solargraph/language_server/message/extended/document.rb +23 -23
- data/lib/solargraph/language_server/message/text_document/completion.rb +56 -56
- data/lib/solargraph/language_server/message/text_document/definition.rb +40 -38
- data/lib/solargraph/language_server/message/text_document/document_symbol.rb +26 -26
- data/lib/solargraph/language_server/message/text_document/formatting.rb +148 -131
- data/lib/solargraph/language_server/message/text_document/hover.rb +58 -58
- data/lib/solargraph/language_server/message/text_document/signature_help.rb +24 -24
- data/lib/solargraph/language_server/message/text_document/type_definition.rb +25 -24
- data/lib/solargraph/language_server/message/workspace/did_change_workspace_folders.rb +2 -0
- data/lib/solargraph/language_server/message/workspace/workspace_symbol.rb +23 -23
- data/lib/solargraph/language_server/progress.rb +8 -0
- data/lib/solargraph/language_server/request.rb +4 -1
- data/lib/solargraph/library.rb +683 -666
- data/lib/solargraph/location.rb +82 -79
- data/lib/solargraph/logging.rb +37 -28
- data/lib/solargraph/page.rb +3 -0
- data/lib/solargraph/parser/comment_ripper.rb +69 -62
- data/lib/solargraph/parser/flow_sensitive_typing.rb +255 -227
- data/lib/solargraph/parser/node_processor/base.rb +92 -87
- data/lib/solargraph/parser/node_processor.rb +62 -46
- data/lib/solargraph/parser/parser_gem/class_methods.rb +149 -159
- data/lib/solargraph/parser/parser_gem/flawed_builder.rb +1 -0
- data/lib/solargraph/parser/parser_gem/node_chainer.rb +166 -164
- data/lib/solargraph/parser/parser_gem/node_methods.rb +486 -497
- data/lib/solargraph/parser/parser_gem/node_processors/and_node.rb +22 -21
- data/lib/solargraph/parser/parser_gem/node_processors/args_node.rb +59 -59
- data/lib/solargraph/parser/parser_gem/node_processors/begin_node.rb +15 -15
- data/lib/solargraph/parser/parser_gem/node_processors/block_node.rb +46 -45
- data/lib/solargraph/parser/parser_gem/node_processors/casgn_node.rb +1 -21
- data/lib/solargraph/parser/parser_gem/node_processors/def_node.rb +53 -53
- data/lib/solargraph/parser/parser_gem/node_processors/if_node.rb +23 -21
- data/lib/solargraph/parser/parser_gem/node_processors/ivasgn_node.rb +40 -40
- data/lib/solargraph/parser/parser_gem/node_processors/lvasgn_node.rb +29 -29
- data/lib/solargraph/parser/parser_gem/node_processors/masgn_node.rb +59 -53
- data/lib/solargraph/parser/parser_gem/node_processors/namespace_node.rb +0 -22
- data/lib/solargraph/parser/parser_gem/node_processors/opasgn_node.rb +98 -41
- data/lib/solargraph/parser/parser_gem/node_processors/orasgn_node.rb +17 -16
- data/lib/solargraph/parser/parser_gem/node_processors/resbody_node.rb +38 -37
- data/lib/solargraph/parser/parser_gem/node_processors/sclass_node.rb +52 -43
- data/lib/solargraph/parser/parser_gem/node_processors/send_node.rb +291 -271
- data/lib/solargraph/parser/parser_gem/node_processors/sym_node.rb +1 -0
- data/lib/solargraph/parser/parser_gem/node_processors/while_node.rb +29 -29
- data/lib/solargraph/parser/parser_gem/node_processors.rb +70 -66
- data/lib/solargraph/parser/region.rb +69 -66
- data/lib/solargraph/parser/snippet.rb +17 -15
- data/lib/solargraph/pin/base.rb +729 -651
- data/lib/solargraph/pin/base_variable.rb +126 -125
- data/lib/solargraph/pin/block.rb +104 -103
- data/lib/solargraph/pin/breakable.rb +9 -9
- data/lib/solargraph/pin/callable.rb +231 -218
- data/lib/solargraph/pin/closure.rb +72 -74
- data/lib/solargraph/pin/common.rb +79 -75
- data/lib/solargraph/pin/constant.rb +2 -0
- data/lib/solargraph/pin/conversions.rb +123 -123
- data/lib/solargraph/pin/delegated_method.rb +120 -120
- data/lib/solargraph/pin/documenting.rb +114 -114
- data/lib/solargraph/pin/instance_variable.rb +34 -34
- data/lib/solargraph/pin/keyword.rb +20 -20
- data/lib/solargraph/pin/local_variable.rb +75 -76
- data/lib/solargraph/pin/method.rb +672 -651
- data/lib/solargraph/pin/method_alias.rb +34 -31
- data/lib/solargraph/pin/namespace.rb +115 -115
- data/lib/solargraph/pin/parameter.rb +275 -261
- data/lib/solargraph/pin/proxy_type.rb +39 -35
- data/lib/solargraph/pin/reference/override.rb +47 -33
- data/lib/solargraph/pin/reference/superclass.rb +15 -10
- data/lib/solargraph/pin/reference.rb +39 -22
- data/lib/solargraph/pin/search.rb +61 -56
- data/lib/solargraph/pin/signature.rb +61 -59
- data/lib/solargraph/pin/symbol.rb +53 -48
- data/lib/solargraph/pin/until.rb +18 -18
- data/lib/solargraph/pin/while.rb +18 -18
- data/lib/solargraph/pin.rb +44 -44
- data/lib/solargraph/pin_cache.rb +245 -185
- data/lib/solargraph/position.rb +132 -116
- data/lib/solargraph/range.rb +112 -107
- data/lib/solargraph/rbs_map/conversions.rb +823 -773
- data/lib/solargraph/rbs_map/core_fills.rb +18 -0
- data/lib/solargraph/rbs_map/core_map.rb +58 -51
- data/lib/solargraph/rbs_map/stdlib_map.rb +43 -43
- data/lib/solargraph/rbs_map.rb +163 -150
- data/lib/solargraph/shell.rb +352 -268
- data/lib/solargraph/source/chain/call.rb +337 -333
- data/lib/solargraph/source/chain/constant.rb +26 -89
- data/lib/solargraph/source/chain/hash.rb +34 -34
- data/lib/solargraph/source/chain/if.rb +28 -28
- data/lib/solargraph/source/chain/instance_variable.rb +13 -13
- data/lib/solargraph/source/chain/link.rb +11 -2
- data/lib/solargraph/source/chain/literal.rb +48 -48
- data/lib/solargraph/source/chain/or.rb +23 -23
- data/lib/solargraph/source/chain.rb +291 -282
- data/lib/solargraph/source/change.rb +82 -82
- data/lib/solargraph/source/cursor.rb +166 -167
- data/lib/solargraph/source/encoding_fixes.rb +23 -23
- data/lib/solargraph/source/source_chainer.rb +194 -194
- data/lib/solargraph/source/updater.rb +55 -55
- data/lib/solargraph/source.rb +498 -495
- data/lib/solargraph/source_map/clip.rb +226 -234
- data/lib/solargraph/source_map/data.rb +34 -30
- data/lib/solargraph/source_map/mapper.rb +259 -259
- data/lib/solargraph/source_map.rb +212 -200
- data/lib/solargraph/type_checker/checks.rb +124 -124
- data/lib/solargraph/type_checker/param_def.rb +37 -35
- data/lib/solargraph/type_checker/problem.rb +32 -32
- data/lib/solargraph/type_checker/rules.rb +84 -62
- data/lib/solargraph/type_checker.rb +814 -699
- data/lib/solargraph/version.rb +5 -5
- data/lib/solargraph/workspace/config.rb +255 -239
- data/lib/solargraph/workspace/require_paths.rb +97 -0
- data/lib/solargraph/workspace.rb +220 -249
- data/lib/solargraph/yard_map/helpers.rb +44 -16
- data/lib/solargraph/yard_map/mapper/to_constant.rb +5 -5
- data/lib/solargraph/yard_map/mapper/to_method.rb +130 -134
- data/lib/solargraph/yard_map/mapper/to_namespace.rb +31 -30
- data/lib/solargraph/yard_map/mapper.rb +79 -79
- data/lib/solargraph/yard_map/to_method.rb +89 -88
- data/lib/solargraph/yardoc.rb +87 -49
- data/lib/solargraph.rb +105 -90
- data/rbs/fills/bundler/0/bundler.rbs +4271 -0
- data/rbs/fills/open3/0/open3.rbs +172 -0
- data/rbs/fills/rubygems/0/basic_specification.rbs +326 -0
- data/rbs/fills/rubygems/0/errors.rbs +364 -0
- data/rbs/fills/rubygems/0/spec_fetcher.rbs +107 -0
- data/rbs/fills/rubygems/0/specification.rbs +1753 -0
- data/rbs/fills/{tuple.rbs → tuple/tuple.rbs} +2 -3
- data/rbs/shims/ast/0/node.rbs +5 -0
- data/rbs/shims/ast/2.4/.rbs_meta.yaml +9 -0
- data/rbs/shims/ast/2.4/ast.rbs +73 -0
- data/rbs/shims/parser/3.2.0.1/builders/default.rbs +195 -0
- data/rbs/shims/parser/3.2.0.1/manifest.yaml +7 -0
- data/rbs/shims/parser/3.2.0.1/parser.rbs +201 -0
- data/rbs/shims/parser/3.2.0.1/polyfill.rbs +4 -0
- data/rbs/shims/thor/1.2.0.1/.rbs_meta.yaml +9 -0
- data/rbs/shims/thor/1.2.0.1/manifest.yaml +7 -0
- data/rbs/shims/thor/1.2.0.1/thor.rbs +17 -0
- data/rbs_collection.yaml +4 -4
- data/solargraph.gemspec +26 -5
- metadata +187 -15
- data/lib/.rubocop.yml +0 -22
- data/lib/solargraph/parser/node_methods.rb +0 -97
data/.yardopts
CHANGED
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,96 @@
|
|
|
1
|
+
## 0.58.2 - January 19, 2026
|
|
2
|
+
- Avoid rbs pollution (#1146)
|
|
3
|
+
- Fix 'solargraph pin --references ClassName' private method call (#1150)
|
|
4
|
+
- Improve memory efficiency of Position class (#1054)
|
|
5
|
+
- Raise InvalidOffsetError for offsets > text (#1155)
|
|
6
|
+
|
|
7
|
+
## 0.58.1 - January 2, 2026
|
|
8
|
+
- Normalize line endings to LF (#1142)
|
|
9
|
+
|
|
10
|
+
## 0.58.0 - January 1, 2026
|
|
11
|
+
- Faster constant resolution (#1083)
|
|
12
|
+
- [regression] Handle RBS static method aliases (#1094)
|
|
13
|
+
- More type fills and shims (#1005)
|
|
14
|
+
- Fix resolution in blocks in type checker (#890)
|
|
15
|
+
- Annotation fixes for strong typechecking (#1057)
|
|
16
|
+
- Remove dead code (#1077)
|
|
17
|
+
- Fix flakey spec (#1080)
|
|
18
|
+
- Fix bad sexpr generation in op_asgn (#1089)
|
|
19
|
+
- Opt-in for MFA requirement (#730)
|
|
20
|
+
- [regression] Fix resolution issues with namespaces from YARD (#1097)
|
|
21
|
+
- Improve a pin combination case around selfy types (#1024)
|
|
22
|
+
- Rescue reference errors in hosts (#1105)
|
|
23
|
+
- Relax bundler runtime dependency version constraint to support newer versions (#1125)
|
|
24
|
+
- Remove stale Pathname test (#1135)
|
|
25
|
+
- Enable strong type checking in CI (#928)
|
|
26
|
+
- Stale sg-ignore
|
|
27
|
+
- Use rbs 3.9.5 in tests (#1136)
|
|
28
|
+
- Drop broken 'namespaces' method (#1065)
|
|
29
|
+
- Add ActiveRecord example from RBS (#1074)
|
|
30
|
+
- Keep workspace directories as absolute paths (#1076)
|
|
31
|
+
- Handle bad gem_dir from gemspec object (#1079)
|
|
32
|
+
- Test for absolute require paths (#1137)
|
|
33
|
+
- [regression] Fix resolution of ambiguous argument types (#1098)
|
|
34
|
+
- Remove sg-ignore for String#=~ (#1138)
|
|
35
|
+
- Allow levels to be changed for typechecking rules in .solargraph.yml (#1126)
|
|
36
|
+
|
|
37
|
+
## 0.57.0 - September 16, 2025
|
|
38
|
+
- Support ActiveSupport::Concern pattern for class methods (#948)
|
|
39
|
+
- More CI checks (#996)
|
|
40
|
+
- Linting / type annotation fixes (#999)
|
|
41
|
+
- Avoid overlapping chdir calls in multiple threads (#1007)
|
|
42
|
+
- Fix kwarg generation in ApiMap::SourceToYard (#1003)
|
|
43
|
+
- Enable Steep typechecking of Solargraph code (#1004)
|
|
44
|
+
- Fix convention requires (#1008)
|
|
45
|
+
- Plugin Util: Add Combination Priority (#1010)
|
|
46
|
+
- [regression] Fix crash while typechecking files with Struct use (#1031)
|
|
47
|
+
- Remove yard reference from gemfile (#1033)
|
|
48
|
+
- Allow newer RBS gem versions, exclude incompatible ones (#995)
|
|
49
|
+
- Look for external requires before cataloging bench (#1021)
|
|
50
|
+
- Remove Library#folding_ranges (#904)
|
|
51
|
+
- Complain in strong type-checking if an @sg-ignore line is not needed (#1011)
|
|
52
|
+
- Document a log level env variable (#894)
|
|
53
|
+
- Fix hole in type checking evaluation (#1009)
|
|
54
|
+
- Improve typechecking error message (#1014)
|
|
55
|
+
- Internal strict type-checking fixes (#1013)
|
|
56
|
+
- Reproduce and fix a ||= (or-asgn) evaluation issue (#1017)
|
|
57
|
+
- Define closure for Pin::Symbol, for completeness (#1027)
|
|
58
|
+
- Fix 'all!' config to reporters (#1018)
|
|
59
|
+
- Fix DocMap.all_rbs_collection_gems_in_memory return type (#1037)
|
|
60
|
+
- Fix RuboCop linting errors in regular expressions (#1038)
|
|
61
|
+
- Resolve class aliases via Constant pins (#1029)
|
|
62
|
+
- Speed-up LSP completion response times (#1035)
|
|
63
|
+
- Revert "Resolve class aliases via Constant pins (#1029)" (#1041)
|
|
64
|
+
- Avoid stack errors when resolving method aliases (#1040)
|
|
65
|
+
- [regression] Refine order of object convention method pins (#1036)
|
|
66
|
+
- Fix crash while generating activesupport pins (#1043)
|
|
67
|
+
- Type annotation improvements (#1016)
|
|
68
|
+
- Resolve class aliases via Constant pins (#1048)
|
|
69
|
+
- Understand "Parser::AST::Node < AST::Node" in RBS (#1060)
|
|
70
|
+
- Factor out require_paths logic to its own class (#1062)
|
|
71
|
+
- Fix type errors found in strong typechecking (#1045)
|
|
72
|
+
- Run plugin specs separately for perf insights (#1046)
|
|
73
|
+
- Run specs from solargraph-rails configured against current code in CI (#892)
|
|
74
|
+
- Fix Convention/Plugin pins not being updated on file change (#1028)
|
|
75
|
+
- Fix solargraph-rails check (#1073)
|
|
76
|
+
- Flow sensitive typing handles x.is_a? without an argument (#1070)
|
|
77
|
+
- Refactor reference pin handling (#1058)
|
|
78
|
+
|
|
79
|
+
## 0.56.2 - July 29, 2025
|
|
80
|
+
- Add support for Ruby Data.define (#970)
|
|
81
|
+
- Ensure that pin locations are always populated (#965)
|
|
82
|
+
- Improve struct support (#992)
|
|
83
|
+
- Include Rakefile, Gemfile, and gemspec files in config by default (#984)
|
|
84
|
+
- Use Open3 to cache gemspecs (#1000)
|
|
85
|
+
- Eager load node processors (#1002)
|
|
86
|
+
|
|
87
|
+
## 0.56.1 - July 13, 2025
|
|
88
|
+
- Library avoids blocking on pending yardoc caches (#990)
|
|
89
|
+
- DocMap checks for default Gemfile (#989)
|
|
90
|
+
- [Bug fix] Fixed an error in rbs/fills/tuple.rbs (#993)
|
|
91
|
+
|
|
1
92
|
## 0.56.0 - July 1, 2025
|
|
2
|
-
- [regression] Gem caching perf and logging fixes #983
|
|
93
|
+
- [regression] Gem caching perf and logging fixes #983
|
|
3
94
|
|
|
4
95
|
## 0.55.5 - July 1, 2025
|
|
5
96
|
- Flatten results of DocMap external bundle query (#981)
|
data/README.md
CHANGED
|
@@ -53,7 +53,7 @@ Solargraph's behavior can be controlled via optional [configuration](https://sol
|
|
|
53
53
|
|
|
54
54
|
### Plugins
|
|
55
55
|
|
|
56
|
-
Solargraph supports [plugins](https://solargraph.org/guides/plugins) that
|
|
56
|
+
Solargraph supports [plugins](https://solargraph.org/guides/plugins) that implement 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
57
|
|
|
58
58
|
For better Rails support, please consider using [solargraph-rails](https://github.com/iftheshoefritz/solargraph-rails/)
|
|
59
59
|
|
|
@@ -65,7 +65,7 @@ The RSpec framework is supported via [solargraph-rspec](https://github.com/lekem
|
|
|
65
65
|
|
|
66
66
|
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. Solargraph automatically generates code maps from installed gems, based on the YARD or RBS type information inside the gem. You can also eagerly cache gem documentation with the `solargraph gems` command.
|
|
67
67
|
|
|
68
|
-
If your project automatically requires bundled
|
|
68
|
+
If your project automatically requires bundled gem with the `Bundler.require` statement, Solargraph will add all of the Gemfile's default dependencies to the map.
|
|
69
69
|
|
|
70
70
|
To ensure you have types for gems which contain neither RBS nor YARD
|
|
71
71
|
information, use
|
|
@@ -81,7 +81,7 @@ Once installed, you can also insert your own local overrides and definitions in
|
|
|
81
81
|
|
|
82
82
|
### Type Checking
|
|
83
83
|
|
|
84
|
-
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.
|
|
84
|
+
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. In strong mode it will ask you to clarify your intentions by adding annotations for better validation.
|
|
85
85
|
|
|
86
86
|
### The Documentation Cache
|
|
87
87
|
|
|
@@ -101,7 +101,7 @@ Run `bundle install` and optionally use `bundle exec solargraph gems` to generat
|
|
|
101
101
|
|
|
102
102
|
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`.
|
|
103
103
|
|
|
104
|
-
###
|
|
104
|
+
### RuboCop Version
|
|
105
105
|
|
|
106
106
|
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.
|
|
107
107
|
|
|
@@ -132,6 +132,10 @@ See [https://solargraph.org/guides](https://solargraph.org/guides) for more tips
|
|
|
132
132
|
|
|
133
133
|
### Development
|
|
134
134
|
|
|
135
|
+
To see more logging when typechecking or running specs, set the
|
|
136
|
+
`SOLARGRAPH_LOG` environment variable to `debug` or `info`. `warn` is
|
|
137
|
+
the default value.
|
|
138
|
+
|
|
135
139
|
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.
|
|
136
140
|
|
|
137
141
|
### Sponsorship and Donation
|
data/Rakefile
CHANGED
|
@@ -1,12 +1,7 @@
|
|
|
1
1
|
require 'rake'
|
|
2
|
-
require 'rspec/core/rake_task'
|
|
3
2
|
require 'bundler/gem_tasks'
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
require 'rspec/core/rake_task'
|
|
7
|
-
RSpec::Core::RakeTask.new(:spec)
|
|
8
|
-
rescue LoadError
|
|
9
|
-
end
|
|
3
|
+
require 'fileutils'
|
|
4
|
+
require 'open3'
|
|
10
5
|
|
|
11
6
|
desc "Open a Pry session preloaded with this library"
|
|
12
7
|
task :console do
|
|
@@ -14,12 +9,129 @@ task :console do
|
|
|
14
9
|
end
|
|
15
10
|
|
|
16
11
|
desc "Run the type checker"
|
|
17
|
-
task :
|
|
18
|
-
|
|
12
|
+
task typecheck: [:typecheck_strong]
|
|
13
|
+
|
|
14
|
+
desc "Run the type checker at typed level - return code issues provable without annotations being correct"
|
|
15
|
+
task :typecheck_typed do
|
|
16
|
+
sh "SOLARGRAPH_ASSERTS=on bundle exec solargraph typecheck --level typed"
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
desc "Run the type checker at strict level - report issues using type annotations"
|
|
20
|
+
task :typecheck_strict do
|
|
21
|
+
sh "SOLARGRAPH_ASSERTS=on bundle exec solargraph typecheck --level strict"
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
desc "Run the type checker at strong level - enforce that type annotations exist"
|
|
25
|
+
task :typecheck_strong do
|
|
26
|
+
sh "SOLARGRAPH_ASSERTS=on bundle exec solargraph typecheck --level strong"
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
desc "Run the type checker at alpha level - run high-false-alarm checks"
|
|
30
|
+
task :typecheck_alpha do
|
|
31
|
+
sh "SOLARGRAPH_ASSERTS=on bundle exec solargraph typecheck --level alpha"
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
desc "Run RSpec tests, starting with the ones that failed last time"
|
|
35
|
+
task spec: %i[spec_failed undercover_no_fail full_spec] do
|
|
36
|
+
undercover
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
desc "Run all RSpec tests"
|
|
40
|
+
task :full_spec do
|
|
41
|
+
warn 'starting spec'
|
|
42
|
+
sh 'TEST_COVERAGE_COMMAND_NAME=full-new bundle exec rspec' # --profile'
|
|
43
|
+
warn 'ending spec'
|
|
44
|
+
# move coverage/full-new to coverage/full on success so that we
|
|
45
|
+
# always have the last successful run's 'coverage info
|
|
46
|
+
FileUtils.rm_rf('coverage/full')
|
|
47
|
+
FileUtils.mv('coverage/full-new', 'coverage/full')
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
# @sg-ignore #undercover return type could not be inferred
|
|
51
|
+
# @return [Process::Status]
|
|
52
|
+
def undercover
|
|
53
|
+
simplecov_collate
|
|
54
|
+
cmd = 'bundle exec undercover ' \
|
|
55
|
+
'--simplecov coverage/combined/coverage.json ' \
|
|
56
|
+
'--exclude-files "Rakefile,spec/*,spec/**/*,lib/solargraph/version.rb" ' \
|
|
57
|
+
'--compare origin/master'
|
|
58
|
+
output, status = Bundler.with_unbundled_env do
|
|
59
|
+
Open3.capture2e(cmd)
|
|
60
|
+
end
|
|
61
|
+
puts output
|
|
62
|
+
$stdout.flush
|
|
63
|
+
status
|
|
64
|
+
rescue StandardError => e
|
|
65
|
+
warn "hit error: #{e.message}"
|
|
66
|
+
warn "Backtrace:\n#{e.backtrace.join("\n")}"
|
|
67
|
+
warn "output: #{output}"
|
|
68
|
+
puts "Flushing"
|
|
69
|
+
$stdout.flush
|
|
70
|
+
raise
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
desc "Check PR coverage"
|
|
74
|
+
task :undercover do
|
|
75
|
+
raise "Undercover failed" unless undercover.success?
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
desc "Branch-focused fast-feedback quality/spec/coverage checks"
|
|
79
|
+
task test: %i[overcommit spec typecheck] do
|
|
80
|
+
# do these in order
|
|
81
|
+
Rake::Task['typecheck_strict'].invoke
|
|
82
|
+
Rake::Task['typecheck_strong'].invoke
|
|
83
|
+
Rake::Task['typecheck_alpha'].invoke
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
desc "Re-run failed specs. Add --fail-fast in your .rspec-local file if desired."
|
|
87
|
+
task :spec_failed do
|
|
88
|
+
# allow user to check out any persistent failures while looking for
|
|
89
|
+
# more in the whole test suite
|
|
90
|
+
sh 'TEST_COVERAGE_COMMAND_NAME=next-failure bundle exec rspec --only-failures || true'
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
desc "Run undercover and show output without failing the task if it fails"
|
|
94
|
+
task :undercover_no_fail do
|
|
95
|
+
undercover
|
|
96
|
+
rescue StandardError
|
|
97
|
+
puts "Undercover failed, but continuing with other tasks."
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
# @return [void]
|
|
101
|
+
def simplecov_collate
|
|
102
|
+
require 'simplecov'
|
|
103
|
+
require 'simplecov-lcov'
|
|
104
|
+
require 'undercover/simplecov_formatter'
|
|
105
|
+
|
|
106
|
+
SimpleCov.collate(Dir["coverage/{next-failure,full,ad-hoc}/.resultset.json"]) do
|
|
107
|
+
cname = 'combined'
|
|
108
|
+
command_name cname
|
|
109
|
+
new_dir = File.join('coverage', cname)
|
|
110
|
+
coverage_dir new_dir
|
|
111
|
+
|
|
112
|
+
formatter \
|
|
113
|
+
SimpleCov::Formatter::MultiFormatter
|
|
114
|
+
.new([
|
|
115
|
+
SimpleCov::Formatter::HTMLFormatter,
|
|
116
|
+
SimpleCov::Formatter::Undercover,
|
|
117
|
+
SimpleCov::Formatter::LcovFormatter
|
|
118
|
+
])
|
|
119
|
+
SimpleCov::Formatter::LcovFormatter.config.report_with_single_file = true
|
|
120
|
+
end
|
|
121
|
+
puts "Simplecov collated results into coverage/combined/.resultset.json"
|
|
122
|
+
rescue StandardError => e
|
|
123
|
+
puts "Simplecov collate failed: #{e.message}"
|
|
124
|
+
ensure
|
|
125
|
+
$stdout.flush
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
desc 'Add incremental coverage for rapid iteration with undercover'
|
|
129
|
+
task :simplecov_collate do
|
|
130
|
+
simplecov_collate
|
|
19
131
|
end
|
|
20
132
|
|
|
21
|
-
desc "
|
|
22
|
-
task :
|
|
23
|
-
|
|
24
|
-
|
|
133
|
+
desc "Show quality checks on this development branch so far, including any staged files"
|
|
134
|
+
task :overcommit do
|
|
135
|
+
# OVERCOMMIT_DEBUG=1 will show more detail
|
|
136
|
+
sh 'SOLARGRAPH_ASSERTS=on bundle exec overcommit --run --diff origin/master'
|
|
25
137
|
end
|
data/bin/solargraph
CHANGED
|
@@ -1,109 +1,110 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Solargraph
|
|
4
|
-
class ApiMap
|
|
5
|
-
class Cache
|
|
6
|
-
def initialize
|
|
7
|
-
# @type [Hash{
|
|
8
|
-
@methods = {}
|
|
9
|
-
# @type [Hash{
|
|
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
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
end
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Solargraph
|
|
4
|
+
class ApiMap
|
|
5
|
+
class Cache
|
|
6
|
+
def initialize
|
|
7
|
+
# @type [Hash{String => 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
|
+
# @return [Array<Object>]
|
|
105
|
+
def all_caches
|
|
106
|
+
[@methods, @constants, @qualified_namespaces, @receiver_definitions, @clips]
|
|
107
|
+
end
|
|
108
|
+
end
|
|
109
|
+
end
|
|
110
|
+
end
|