solargraph 0.44.1 → 0.45.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/rspec.yml +41 -0
- data/CHANGELOG.md +25 -0
- data/README.md +10 -2
- data/SPONSORS.md +2 -0
- data/lib/solargraph/api_map.rb +2 -2
- data/lib/solargraph/convention/rspec.rb +13 -4
- data/lib/solargraph/language_server/uri_helpers.rb +1 -1
- data/lib/solargraph/parser/legacy/class_methods.rb +9 -8
- data/lib/solargraph/parser/legacy/node_processors/block_node.rb +13 -17
- data/lib/solargraph/parser/rubyvm/class_methods.rb +1 -12
- data/lib/solargraph/parser/rubyvm/node_processors/block_node.rb +13 -17
- data/lib/solargraph/parser/rubyvm/node_processors.rb +1 -0
- data/lib/solargraph/pin/local_variable.rb +1 -1
- data/lib/solargraph/pin/namespace.rb +2 -2
- data/lib/solargraph/pin/parameter.rb +1 -4
- data/lib/solargraph/range.rb +1 -1
- data/lib/solargraph/source.rb +1 -1
- data/lib/solargraph/type_checker.rb +20 -1
- data/lib/solargraph/version.rb +1 -1
- data/lib/solargraph/yard_map/core_fills.rb +7 -2
- data/lib/solargraph/yard_map.rb +3 -1
- data/lib/solargraph.rb +2 -2
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 99cf1c663bb1a93324ff9c860b82e60d47988a4c48e9c0e977176cb94852f29c
|
4
|
+
data.tar.gz: 9b10324bcf7493f9ed5f8a67a8d47e4f0a379b76ed2aeb31514d1fa06b88dbf6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a981e45a500d2469972d0fab1e4bcfdbde99dc46de7ef7b377d486a9a027ce617b8806790ed3565a673fbf3d3fd206d246408b5ce744a0b575e02ee3a3a9b699
|
7
|
+
data.tar.gz: 0bcb7a9957581cac9c066076938dbbdcbcc596bf7ddc8f4cd4539d71dadabab68cfdbc18f59df8daedd02dcff8f45b671a0a742c6ec1afbd39ede15fb3db381b
|
@@ -0,0 +1,41 @@
|
|
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: RSpec
|
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
|
+
strategy:
|
24
|
+
matrix:
|
25
|
+
ruby-version: ['2.4', '2.5', '2.6', '2.7', '3.0']
|
26
|
+
|
27
|
+
steps:
|
28
|
+
- uses: actions/checkout@v3
|
29
|
+
- name: Set up Ruby
|
30
|
+
# To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
|
31
|
+
# change this to (see https://github.com/ruby/setup-ruby#versioning):
|
32
|
+
# uses: ruby/setup-ruby@v1
|
33
|
+
uses: ruby/setup-ruby@2b019609e2b0f1ea1a2bc8ca11cb82ab46ada124
|
34
|
+
with:
|
35
|
+
ruby-version: ${{ matrix.ruby-version }}
|
36
|
+
bundler-cache: false
|
37
|
+
- run: bundle install
|
38
|
+
- name: Set up yardocs
|
39
|
+
run: bundle exec yard gems
|
40
|
+
- name: Run tests
|
41
|
+
run: bundle exec rspec
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,28 @@
|
|
1
|
+
## 0.45.0 - May 23, 2022
|
2
|
+
- Basic support for RSpec #describe and #it
|
3
|
+
- fix: domain can complete private method (#490)
|
4
|
+
- Update README.md (#533)
|
5
|
+
- Doc: update readme.md for add solargraph support (#536)
|
6
|
+
- Process DASGN node in Ruby 3
|
7
|
+
- File.open core fill
|
8
|
+
- replace with_unbundled_env with with_original_env (#489)
|
9
|
+
- Require specific version of gem (#509)
|
10
|
+
- Support URIs prefixed with single slashed file scheme (#529)
|
11
|
+
- Fix typo in README.md (#549)
|
12
|
+
- details on config behavior (#556)
|
13
|
+
- Consider overloads in arity checks
|
14
|
+
- ENV core fill for Hash-like methods (#537)
|
15
|
+
- Fix string ranges with substitutions (#463)
|
16
|
+
|
17
|
+
## 0.44.3 - January 22, 2022
|
18
|
+
- TypeChecker validates aliased namespaces (#497)
|
19
|
+
- Always use reference YARD tags when resolving param types (#515) (#516)
|
20
|
+
- Skip method aliases in strict type checking
|
21
|
+
|
22
|
+
## 0.44.2 - November 23, 2021
|
23
|
+
- Scope local variables in class_eval blocks (#503)
|
24
|
+
- Fix invalid UTF-8 in node comments (#504)
|
25
|
+
|
1
26
|
## 0.44.1 - November 18, 2021
|
2
27
|
- Chain nil safety navigation operator (#420)
|
3
28
|
- Update closure and context for class_eval receiver (#487)
|
data/README.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# Solargraph
|
2
2
|
|
3
|
+
[](https://github.com/castwide/solargraph/actions/workflows/rspec.yml)
|
4
|
+
|
3
5
|
## A Ruby Language Server
|
4
6
|
|
5
7
|
Solargraph provides a comprehensive suite of tools for Ruby programming: intellisense, diagnostics, inline documentation, and type checking.
|
@@ -31,7 +33,9 @@ Plug-ins and extensions are available for the following editors:
|
|
31
33
|
* GitHub: https://github.com/castwide/atom-solargraph
|
32
34
|
|
33
35
|
* **Vim**
|
34
|
-
* GitHub: https://github.com/autozimu/LanguageClient-neovim
|
36
|
+
* GitHub: `LanguageClient-neovim`, https://github.com/autozimu/LanguageClient-neovim
|
37
|
+
* GitHub: `coc`, https://github.com/neoclide/coc-solargraph
|
38
|
+
* GitHub: `Vim-EasyComplete`, https://github.com/jayli/vim-easycomplete
|
35
39
|
|
36
40
|
* **Emacs**
|
37
41
|
* GitHub: `eglot.el`, https://github.com/joaotavora/eglot
|
@@ -41,13 +45,17 @@ Plug-ins and extensions are available for the following editors:
|
|
41
45
|
* Plugin: https://marketplace.eclipse.org/content/ruby-solargraph
|
42
46
|
* GitHub: https://github.com/PyvesB/eclipse-solargraph
|
43
47
|
|
48
|
+
### Configuration
|
49
|
+
|
50
|
+
Solargraph's behavior can be controlled via optional [configuration](https://solargraph.org/guides/configuration) files. The highest priority file is a `.solargraph.yml` file at the root of the project. If not present, any global configuration at `~/.config/solargraph/config.yml` will apply. The path to the global configuration can be overridden with the `SOLARGRAPH_GLOBAL_CONFIG` environment variable.
|
51
|
+
|
44
52
|
### Gem Support
|
45
53
|
|
46
54
|
Solargraph is capable of providing code completion and documentation for gems that have YARD documentation. You can make sure your gems are documented by running `yard gems` from the command line. (YARD is included as one of Solargraph's gem dependencies. The first time you run it might take a while if you have a lot of gems installed).
|
47
55
|
|
48
56
|
When editing code, a `require` call that references a gem will pull the documentation into the code maps and include the gem's API in code completion and intellisense.
|
49
57
|
|
50
|
-
If your project automatically requires bundled gems (e.g., `require 'bundler/require'`), Solargraph will add all of the Gemfile's default
|
58
|
+
If your project automatically requires bundled gems (e.g., `require 'bundler/require'`), Solargraph will add all of the Gemfile's default dependencies to the map.
|
51
59
|
|
52
60
|
### Type Checking
|
53
61
|
|
data/SPONSORS.md
CHANGED
data/lib/solargraph/api_map.rb
CHANGED
@@ -255,7 +255,7 @@ module Solargraph
|
|
255
255
|
implicit.domains.each do |domain|
|
256
256
|
type = ComplexType.try_parse(domain)
|
257
257
|
next if type.undefined?
|
258
|
-
result.concat inner_get_methods(type.name, type.scope,
|
258
|
+
result.concat inner_get_methods(type.name, type.scope, visibility, deep, skip)
|
259
259
|
end
|
260
260
|
result.concat inner_get_methods(fqns, :class, visibility, deep, skip)
|
261
261
|
result.concat inner_get_methods(fqns, :instance, visibility, deep, skip)
|
@@ -525,7 +525,7 @@ module Solargraph
|
|
525
525
|
end
|
526
526
|
store.domains(fqns).each do |d|
|
527
527
|
dt = ComplexType.try_parse(d)
|
528
|
-
result.concat inner_get_methods(dt.namespace, dt.scope,
|
528
|
+
result.concat inner_get_methods(dt.namespace, dt.scope, visibility, deep, skip)
|
529
529
|
end
|
530
530
|
end
|
531
531
|
result
|
@@ -8,14 +8,23 @@ module Solargraph
|
|
8
8
|
@environ ||= Environ.new(
|
9
9
|
requires: ['rspec'],
|
10
10
|
domains: ['RSpec::Matchers', 'RSpec::ExpectationGroups'],
|
11
|
-
# This override is necessary due to an erroneous @return tag in
|
12
|
-
# rspec's YARD documentation.
|
13
|
-
# @todo The return types have been fixed (https://github.com/rspec/rspec-expectations/pull/1121)
|
14
11
|
pins: [
|
12
|
+
# This override is necessary due to an erroneous @return tag in
|
13
|
+
# rspec's YARD documentation.
|
14
|
+
# @todo The return types have been fixed (https://github.com/rspec/rspec-expectations/pull/1121)
|
15
15
|
Solargraph::Pin::Reference::Override.method_return('RSpec::Matchers#expect', 'RSpec::Expectations::ExpectationTarget')
|
16
|
-
]
|
16
|
+
].concat(extras)
|
17
17
|
)
|
18
18
|
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def extras
|
23
|
+
@@extras ||= SourceMap.load_string(%(
|
24
|
+
def describe(*args); end
|
25
|
+
def it(*args); end
|
26
|
+
)).pins
|
27
|
+
end
|
19
28
|
end
|
20
29
|
end
|
21
30
|
end
|
@@ -14,7 +14,7 @@ module Solargraph
|
|
14
14
|
# @param uri [String]
|
15
15
|
# @return [String]
|
16
16
|
def uri_to_file uri
|
17
|
-
decode(uri).sub(/^file
|
17
|
+
decode(uri).sub(/^file\:(?:\/\/)?/, '').sub(/^\/([a-z]\:)/i, '\1')
|
18
18
|
end
|
19
19
|
|
20
20
|
# Convert a file path to a URI.
|
@@ -48,10 +48,16 @@ module Solargraph
|
|
48
48
|
end
|
49
49
|
|
50
50
|
def references source, name
|
51
|
+
if name.end_with?("=")
|
52
|
+
reg = /#{Regexp.escape name[0..-2]}\s*=/
|
53
|
+
extract_offset = ->(code, offset) { reg.match(code, offset).offset(0) }
|
54
|
+
else
|
55
|
+
extract_offset = ->(code, offset) { [soff = code.index(name, offset), soff + name.length] }
|
56
|
+
end
|
51
57
|
inner_node_references(name, source.node).map do |n|
|
52
|
-
|
53
|
-
|
54
|
-
eoff =
|
58
|
+
rng = Range.from_node(n)
|
59
|
+
offset = Position.to_offset(source.code, rng.start)
|
60
|
+
soff, eoff = extract_offset[source.code, offset]
|
55
61
|
Location.new(
|
56
62
|
source.filename,
|
57
63
|
Range.new(
|
@@ -109,16 +115,11 @@ module Solargraph
|
|
109
115
|
result = []
|
110
116
|
if node.type == :str
|
111
117
|
result.push Range.from_node(node)
|
112
|
-
elsif node.type == :dstr
|
113
|
-
here = Range.from_node(node)
|
114
|
-
there = Range.from_node(node.children[1])
|
115
|
-
result.push Range.new(here.start, there.start)
|
116
118
|
end
|
117
119
|
node.children.each do |child|
|
118
120
|
result.concat string_ranges(child)
|
119
121
|
end
|
120
122
|
if node.type == :dstr && node.children.last.nil?
|
121
|
-
# result.push Range.new(result.last.ending, result.last.ending)
|
122
123
|
last = node.children[-2]
|
123
124
|
unless last.nil?
|
124
125
|
rng = Range.from_node(last)
|
@@ -8,17 +8,24 @@ module Solargraph
|
|
8
8
|
include Legacy::NodeMethods
|
9
9
|
|
10
10
|
def process
|
11
|
-
|
12
|
-
|
11
|
+
location = get_node_location(node)
|
12
|
+
parent = if other_class_eval?
|
13
|
+
Solargraph::Pin::Namespace.new(
|
14
|
+
location: location,
|
13
15
|
type: :class,
|
14
16
|
name: unpack_name(node.children[0].children[0])
|
15
17
|
)
|
16
|
-
make_block_in other_class.context
|
17
|
-
process_children region.update(closure: other_class)
|
18
18
|
else
|
19
|
-
|
20
|
-
process_children region.update(closure: pins.last)
|
19
|
+
region.closure
|
21
20
|
end
|
21
|
+
pins.push Solargraph::Pin::Block.new(
|
22
|
+
location: location,
|
23
|
+
closure: parent,
|
24
|
+
receiver: node.children[0],
|
25
|
+
comments: comments_for(node),
|
26
|
+
scope: region.scope || region.closure.context.scope
|
27
|
+
)
|
28
|
+
process_children region.update(closure: pins.last)
|
22
29
|
end
|
23
30
|
|
24
31
|
private
|
@@ -28,17 +35,6 @@ module Solargraph
|
|
28
35
|
node.children[0].children[1] == :class_eval &&
|
29
36
|
[:cbase, :const].include?(node.children[0].children[0]&.type)
|
30
37
|
end
|
31
|
-
|
32
|
-
def make_block_in context
|
33
|
-
pins.push Solargraph::Pin::Block.new(
|
34
|
-
location: get_node_location(node),
|
35
|
-
context: context,
|
36
|
-
closure: region.closure,
|
37
|
-
receiver: node.children[0],
|
38
|
-
comments: comments_for(node),
|
39
|
-
scope: region.scope || region.closure.context.scope
|
40
|
-
)
|
41
|
-
end
|
42
38
|
end
|
43
39
|
end
|
44
40
|
end
|
@@ -29,16 +29,6 @@ module Solargraph
|
|
29
29
|
NodeProcessor.process(source.node, Region.new(source: source))
|
30
30
|
end
|
31
31
|
|
32
|
-
# def returns_from node
|
33
|
-
# return [] unless Parser.is_ast_node?(node)
|
34
|
-
# if node.type == :SCOPE
|
35
|
-
# # node.children.select { |n| n.is_a?(RubyVM::AbstractSyntaxTree::Node) }.map { |n| DeepInference.get_return_nodes(n) }.flatten
|
36
|
-
# DeepInference.get_return_nodes(node.children[2])
|
37
|
-
# else
|
38
|
-
# DeepInference.get_return_nodes(node)
|
39
|
-
# end
|
40
|
-
# end
|
41
|
-
|
42
32
|
def references source, name
|
43
33
|
if name.end_with?("=")
|
44
34
|
reg = /#{Regexp.escape name[0..-2]}\s*=/
|
@@ -133,13 +123,12 @@ module Solargraph
|
|
133
123
|
elsif node.type == :DSTR
|
134
124
|
here = Range.from_node(node)
|
135
125
|
there = Range.from_node(node.children[1])
|
136
|
-
result.push Range.new(here.start, there.
|
126
|
+
result.push Range.new(here.start, there&.start || here.ending)
|
137
127
|
end
|
138
128
|
node.children.each do |child|
|
139
129
|
result.concat string_ranges(child)
|
140
130
|
end
|
141
131
|
if node.type == :DSTR && node.children.last.nil?
|
142
|
-
# result.push Range.new(result.last.ending, result.last.ending)
|
143
132
|
last = node.children[-2]
|
144
133
|
unless last.nil?
|
145
134
|
rng = Range.from_node(last)
|
@@ -8,17 +8,24 @@ module Solargraph
|
|
8
8
|
include NodeMethods
|
9
9
|
|
10
10
|
def process
|
11
|
-
|
12
|
-
|
11
|
+
location = get_node_location(node)
|
12
|
+
parent = if other_class_eval?
|
13
|
+
Solargraph::Pin::Namespace.new(
|
14
|
+
location: location,
|
13
15
|
type: :class,
|
14
16
|
name: unpack_name(node.children[0].children[0])
|
15
17
|
)
|
16
|
-
make_block_in other_class.context
|
17
|
-
process_children region.update(closure: other_class)
|
18
18
|
else
|
19
|
-
|
20
|
-
process_children region.update(closure: pins.last)
|
19
|
+
region.closure
|
21
20
|
end
|
21
|
+
pins.push Solargraph::Pin::Block.new(
|
22
|
+
location: location,
|
23
|
+
closure: parent,
|
24
|
+
receiver: node.children[0],
|
25
|
+
comments: comments_for(node),
|
26
|
+
scope: region.scope || region.closure.context.scope
|
27
|
+
)
|
28
|
+
process_children region.update(closure: pins.last)
|
22
29
|
end
|
23
30
|
|
24
31
|
private
|
@@ -28,17 +35,6 @@ module Solargraph
|
|
28
35
|
node.children[0].children[1] == :class_eval &&
|
29
36
|
[:COLON2, :CONST].include?(node.children[0].children[0].type)
|
30
37
|
end
|
31
|
-
|
32
|
-
def make_block_in context
|
33
|
-
pins.push Solargraph::Pin::Block.new(
|
34
|
-
location: get_node_location(node),
|
35
|
-
context: context,
|
36
|
-
closure: region.closure,
|
37
|
-
receiver: node.children[0],
|
38
|
-
comments: comments_for(node),
|
39
|
-
scope: region.scope || region.closure.context.scope
|
40
|
-
)
|
41
|
-
end
|
42
38
|
end
|
43
39
|
end
|
44
40
|
end
|
@@ -45,6 +45,7 @@ module Solargraph
|
|
45
45
|
register :IASGN, Rubyvm::NodeProcessors::IvasgnNode
|
46
46
|
register :CVASGN, Rubyvm::NodeProcessors::CvasgnNode
|
47
47
|
register :LASGN, Rubyvm::NodeProcessors::LvasgnNode
|
48
|
+
register :DASGN, Rubyvm::NodeProcessors::LvasgnNode
|
48
49
|
register :DASGN_CURR, Rubyvm::NodeProcessors::LvasgnNode
|
49
50
|
register :GASGN, Rubyvm::NodeProcessors::GvasgnNode
|
50
51
|
register :CDECL, Rubyvm::NodeProcessors::CasgnNode
|
@@ -41,7 +41,7 @@ module Solargraph
|
|
41
41
|
end
|
42
42
|
|
43
43
|
def match_named_closure needle, haystack
|
44
|
-
return true if needle == haystack
|
44
|
+
return true if needle == haystack || haystack.is_a?(Pin::Block)
|
45
45
|
cursor = haystack
|
46
46
|
until cursor.nil?
|
47
47
|
return true if needle.path == cursor.path
|
@@ -9,8 +9,8 @@ module Solargraph
|
|
9
9
|
# @return [::Symbol] :class or :module
|
10
10
|
attr_reader :type
|
11
11
|
|
12
|
-
# @param type [Symbol] :class or :module
|
13
|
-
# @param visibility [Symbol] :public or :private
|
12
|
+
# @param type [::Symbol] :class or :module
|
13
|
+
# @param visibility [::Symbol] :public or :private
|
14
14
|
# @param gates [Array<String>]
|
15
15
|
def initialize type: :class, visibility: :public, gates: [''], **splat
|
16
16
|
# super(location, namespace, name, comments)
|
@@ -145,10 +145,7 @@ module Solargraph
|
|
145
145
|
# meths.shift # Ignore the first one
|
146
146
|
meths.each do |meth|
|
147
147
|
found = nil
|
148
|
-
params = meth.docstring.tags(:param)
|
149
|
-
if params.empty?
|
150
|
-
params = see_reference(docstring, api_map)
|
151
|
-
end
|
148
|
+
params = meth.docstring.tags(:param) + see_reference(docstring, api_map)
|
152
149
|
params.each do |p|
|
153
150
|
next unless p.name == name
|
154
151
|
found = p
|
data/lib/solargraph/range.rb
CHANGED
@@ -69,7 +69,7 @@ module Solargraph
|
|
69
69
|
if node.is_a?(RubyVM::AbstractSyntaxTree::Node)
|
70
70
|
Solargraph::Range.from_to(node.first_lineno - 1, node.first_column, node.last_lineno - 1, node.last_column)
|
71
71
|
end
|
72
|
-
elsif node
|
72
|
+
elsif node&.loc && node.loc.expression
|
73
73
|
from_expr(node.loc.expression)
|
74
74
|
end
|
75
75
|
end
|
data/lib/solargraph/source.rb
CHANGED
@@ -360,7 +360,7 @@ module Solargraph
|
|
360
360
|
skip = nil
|
361
361
|
comments.lines.each { |l|
|
362
362
|
# Trim the comment and minimum leading whitespace
|
363
|
-
p = l.gsub(/^#+/, '')
|
363
|
+
p = l.encode('UTF-8', invalid: :replace, replace: '?').gsub(/^#+/, '')
|
364
364
|
if p.strip.empty?
|
365
365
|
next unless started
|
366
366
|
ctxt.concat p
|
@@ -84,12 +84,13 @@ module Solargraph
|
|
84
84
|
# @param pin [Pin::Method]
|
85
85
|
# @return [Array<Problem>]
|
86
86
|
def method_return_type_problems_for pin
|
87
|
+
return [] if pin.is_a?(Pin::MethodAlias)
|
87
88
|
result = []
|
88
89
|
declared = pin.typify(api_map).self_to(pin.full_context.namespace)
|
89
90
|
if declared.undefined?
|
90
91
|
if pin.return_type.undefined? && rules.require_type_tags?
|
91
92
|
result.push Problem.new(pin.location, "Missing @return tag for #{pin.path}", pin: pin)
|
92
|
-
elsif pin.return_type.defined?
|
93
|
+
elsif pin.return_type.defined? && !resolved_constant?(pin)
|
93
94
|
result.push Problem.new(pin.location, "Unresolved return type #{pin.return_type} for #{pin.path}", pin: pin)
|
94
95
|
elsif rules.must_tag_or_infer? && pin.probe(api_map).undefined?
|
95
96
|
result.push Problem.new(pin.location, "Untyped method #{pin.path} could not be inferred")
|
@@ -111,6 +112,15 @@ module Solargraph
|
|
111
112
|
result
|
112
113
|
end
|
113
114
|
|
115
|
+
# @todo This is not optimal. A better solution would probably be to mix
|
116
|
+
# namespace alias into types at the ApiMap level.
|
117
|
+
#
|
118
|
+
# @param pin [Pin::Base]
|
119
|
+
# @return [Boolean]
|
120
|
+
def resolved_constant? pin
|
121
|
+
api_map.get_constants('', pin.binder.tag).any? { |pin| pin.name == pin.return_type.namespace && ['Class', 'Module'].include?(pin.return_type.name) }
|
122
|
+
end
|
123
|
+
|
114
124
|
def virtual_pin? pin
|
115
125
|
pin.location && source_map.source.comment_at?(pin.location.range.ending)
|
116
126
|
end
|
@@ -402,6 +412,15 @@ module Solargraph
|
|
402
412
|
|
403
413
|
# @param pin [Pin::Method]
|
404
414
|
def arity_problems_for(pin, arguments, location)
|
415
|
+
([pin] + pin.overloads).map do |p|
|
416
|
+
result = pin_arity_problems_for(p, arguments, location)
|
417
|
+
return [] if result.empty?
|
418
|
+
result
|
419
|
+
end.flatten.uniq(&:message)
|
420
|
+
end
|
421
|
+
|
422
|
+
# @param pin [Pin::Method]
|
423
|
+
def pin_arity_problems_for(pin, arguments, location)
|
405
424
|
return [] unless pin.explicit?
|
406
425
|
return [] if pin.parameters.empty? && arguments.empty?
|
407
426
|
if pin.parameters.empty?
|
data/lib/solargraph/version.rb
CHANGED
@@ -101,6 +101,7 @@ module Solargraph
|
|
101
101
|
Override.method_return('File.dirname', 'String'),
|
102
102
|
Override.method_return('File.extname', 'String'),
|
103
103
|
Override.method_return('File.join', 'String'),
|
104
|
+
Override.method_return('File.open', 'File'),
|
104
105
|
|
105
106
|
Override.from_comment('Float#+', %(
|
106
107
|
@param y [Numeric]
|
@@ -110,14 +111,15 @@ module Solargraph
|
|
110
111
|
Override.from_comment('Hash#[]', %(
|
111
112
|
@return_value_parameter
|
112
113
|
)),
|
113
|
-
|
114
114
|
# @todo This override isn't robust enough. It needs to allow for
|
115
115
|
# parameterized Hash types, e.g., [Hash{Symbol => String}].
|
116
116
|
Override.from_comment('Hash#[]=', %(
|
117
117
|
@param_tuple
|
118
118
|
)),
|
119
|
-
|
120
119
|
Override.method_return('Hash#merge', 'Hash'),
|
120
|
+
Override.from_comment('Hash#store', %{
|
121
|
+
@overload store(key, value)
|
122
|
+
}),
|
121
123
|
|
122
124
|
Override.from_comment('Integer#+', %(
|
123
125
|
@param y [Numeric]
|
@@ -181,6 +183,9 @@ module Solargraph
|
|
181
183
|
)
|
182
184
|
|
183
185
|
PINS = [
|
186
|
+
# HACK: Extending Hash is not accurate to the implementation, but
|
187
|
+
# accurate enough to the behavior
|
188
|
+
Pin::Reference::Extend.new(closure: Pin::Namespace.new(name: 'ENV'), name: 'Hash'),
|
184
189
|
Pin::Reference::Superclass.new(closure: Pin::Namespace.new(name: 'File'), name: 'IO'),
|
185
190
|
Pin::Reference::Superclass.new(closure: Pin::Namespace.new(name: 'Integer'), name: 'Numeric'),
|
186
191
|
Pin::Reference::Superclass.new(closure: Pin::Namespace.new(name: 'Float'), name: 'Numeric')
|
data/lib/solargraph/yard_map.rb
CHANGED
@@ -343,7 +343,9 @@ module Solargraph
|
|
343
343
|
# @param path [String]
|
344
344
|
# @return [Gem::Specification]
|
345
345
|
def spec_for_require path
|
346
|
-
|
346
|
+
name = path.split('/').first
|
347
|
+
spec = Gem::Specification.find_by_name(name, @gemset[name])
|
348
|
+
|
347
349
|
# Avoid loading the spec again if it's going to be skipped anyway
|
348
350
|
return spec if @source_gems.include?(spec.name)
|
349
351
|
# Avoid loading the spec again if it's already the correct version
|
data/lib/solargraph.rb
CHANGED
@@ -59,8 +59,8 @@ module Solargraph
|
|
59
59
|
#
|
60
60
|
# @return [void]
|
61
61
|
def self.with_clean_env &block
|
62
|
-
meth = if Bundler.respond_to?(:
|
63
|
-
:
|
62
|
+
meth = if Bundler.respond_to?(:with_original_env)
|
63
|
+
:with_original_env
|
64
64
|
else
|
65
65
|
:with_clean_env
|
66
66
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: solargraph
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.45.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Fred Snyder
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-05-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: backport
|
@@ -301,6 +301,7 @@ executables:
|
|
301
301
|
extensions: []
|
302
302
|
extra_rdoc_files: []
|
303
303
|
files:
|
304
|
+
- ".github/workflows/rspec.yml"
|
304
305
|
- ".gitignore"
|
305
306
|
- ".rspec"
|
306
307
|
- ".travis.yml"
|
@@ -572,7 +573,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
572
573
|
- !ruby/object:Gem::Version
|
573
574
|
version: '0'
|
574
575
|
requirements: []
|
575
|
-
rubygems_version: 3.
|
576
|
+
rubygems_version: 3.3.7
|
576
577
|
signing_key:
|
577
578
|
specification_version: 4
|
578
579
|
summary: A Ruby language server
|