solargraph 0.44.3 → 0.45.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f8ff2cf72eecc4a36760b60491151cbedb17e11ac665ef20609e0291b2e4b64e
4
- data.tar.gz: ea35a1bb406f5c185df0943b483676360b3c0e3df9f4fb476a246174dc37b542
3
+ metadata.gz: 99cf1c663bb1a93324ff9c860b82e60d47988a4c48e9c0e977176cb94852f29c
4
+ data.tar.gz: 9b10324bcf7493f9ed5f8a67a8d47e4f0a379b76ed2aeb31514d1fa06b88dbf6
5
5
  SHA512:
6
- metadata.gz: 152ad48cda1f002d12f4e27e11bbc090be72a113246521d1a03e4a82f0d920e885f39cf8eef46d12c588d66afe0b4835cb16b2192ceaa16f1ad6d8c9631a9677
7
- data.tar.gz: ef1f6ecfa30e9eb58080cdf09c94e1611f35f8f2f64ecc8fcfb0e359aa4b95551cf5cfb7d1ec749e023bcd9045118bb33fc0bc1756c4449aa8959ce6aa73b6d8
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,19 @@
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
+
1
17
  ## 0.44.3 - January 22, 2022
2
18
  - TypeChecker validates aliased namespaces (#497)
3
19
  - Always use reference YARD tags when resolving param types (#515) (#516)
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # Solargraph
2
2
 
3
+ [![RSpec](https://github.com/castwide/solargraph/actions/workflows/rspec.yml/badge.svg)](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 dependecies to the map.
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
@@ -13,3 +13,5 @@ The following people and organizations provide funding or other resources. [Beco
13
13
  - Emily Strickland
14
14
  - Tom de Grunt
15
15
  - Akira Yamada
16
+ - Erlend Finvåg
17
+ - Matt Massicotte
@@ -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, [:public], deep, skip)
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, [:public], deep, skip)
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\:\/\//, '').sub(/^\/([a-z]\:)/i, '\1')
17
+ decode(uri).sub(/^file\:(?:\/\/)?/, '').sub(/^\/([a-z]\:)/i, '\1')
18
18
  end
19
19
 
20
20
  # Convert a file path to a URI.
@@ -115,16 +115,11 @@ module Solargraph
115
115
  result = []
116
116
  if node.type == :str
117
117
  result.push Range.from_node(node)
118
- elsif node.type == :dstr
119
- here = Range.from_node(node)
120
- there = Range.from_node(node.children[1])
121
- result.push Range.new(here.start, there.start)
122
118
  end
123
119
  node.children.each do |child|
124
120
  result.concat string_ranges(child)
125
121
  end
126
122
  if node.type == :dstr && node.children.last.nil?
127
- # result.push Range.new(result.last.ending, result.last.ending)
128
123
  last = node.children[-2]
129
124
  unless last.nil?
130
125
  rng = Range.from_node(last)
@@ -123,13 +123,12 @@ module Solargraph
123
123
  elsif node.type == :DSTR
124
124
  here = Range.from_node(node)
125
125
  there = Range.from_node(node.children[1])
126
- result.push Range.new(here.start, there.start)
126
+ result.push Range.new(here.start, there&.start || here.ending)
127
127
  end
128
128
  node.children.each do |child|
129
129
  result.concat string_ranges(child)
130
130
  end
131
131
  if node.type == :DSTR && node.children.last.nil?
132
- # result.push Range.new(result.last.ending, result.last.ending)
133
132
  last = node.children[-2]
134
133
  unless last.nil?
135
134
  rng = Range.from_node(last)
@@ -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
@@ -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.loc && node.loc.expression
72
+ elsif node&.loc && node.loc.expression
73
73
  from_expr(node.loc.expression)
74
74
  end
75
75
  end
@@ -412,6 +412,15 @@ module Solargraph
412
412
 
413
413
  # @param pin [Pin::Method]
414
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)
415
424
  return [] unless pin.explicit?
416
425
  return [] if pin.parameters.empty? && arguments.empty?
417
426
  if pin.parameters.empty?
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Solargraph
4
- VERSION = '0.44.3'
4
+ VERSION = '0.45.0'
5
5
  end
@@ -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')
@@ -343,7 +343,9 @@ module Solargraph
343
343
  # @param path [String]
344
344
  # @return [Gem::Specification]
345
345
  def spec_for_require path
346
- spec = Gem::Specification.find_by_path(path) || Gem::Specification.find_by_name(path.split('/').first)
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?(:with_unbundled_env)
63
- :with_unbundled_env
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.44.3
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: 2022-01-22 00:00:00.000000000 Z
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.1.6
576
+ rubygems_version: 3.3.7
576
577
  signing_key:
577
578
  specification_version: 4
578
579
  summary: A Ruby language server