solargraph 0.38.1 → 0.38.2

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: 0dbf36f40f7b87b541abe48c7e624999b44730cd5165f53ca8e7878311da7dcd
4
- data.tar.gz: 0c12fa0cc1008eaf172fb964e6fac8fbc0b46333247b273b0e4ea9d840a81862
3
+ metadata.gz: 389f64ff08e6e1eda0eb13d13e7ff3a8c41650436b02d693995b15dbc3d955c7
4
+ data.tar.gz: eaffccfef362bbb580ea5c57a3bc99d0fb576ec422b11963e8b7490ea035a578
5
5
  SHA512:
6
- metadata.gz: b7d4bb938698bf682bbb418a6489b4544451ad91039d0fe0e0720339d8b2f9e6c394cc7d8354cc1b2cf6b5505867e93ca26071c177ecae69eab2cf5c1e2e601d
7
- data.tar.gz: 368ad36e47cc109a9e3c428a743617771a69e14ce7730e4889bb7bab44c3c3aa13643608d6286497f7ea38b99c1f6da130a3401ae0a167a31cf07fb96197fac0
6
+ metadata.gz: 0d9779fe5645a9ad1d6375795875219405cc637de5fcd28c51c11ead54838ce4a5a22f49993d91d0649a6153b045eacb97f079f44ffaa888a33513c8de639573
7
+ data.tar.gz: 53dfdef740ad7d4a5fc5c80798f7cca2116b7ae5960878357e1a0516f4cc4783f3ed521a2ba86959d044e1588b2492b3f3751d7812454b37c8d6597e51bc266b
data/.travis.yml CHANGED
@@ -10,12 +10,16 @@ rvm:
10
10
  - jruby-head
11
11
  matrix:
12
12
  include:
13
- - rvm: 2.5
13
+ - rvm: 2.4
14
14
  os: osx
15
15
  - rvm: 2.6
16
16
  os: osx
17
+ - rvm: 2.7
18
+ os: osx
17
19
  allow_failures:
18
- - rvm: jruby-head
20
+ - rvm: 2.7
21
+ os: osx
22
+
19
23
  # Update RubyGems and Bundler due to error with Bundler 1.16.1 and RubyGems 2.7.3
20
24
  # See https://github.com/travis-ci/travis-ci/issues/8978
21
25
  before_install:
data/lib/solargraph.rb CHANGED
@@ -51,4 +51,16 @@ module Solargraph
51
51
  def self.logger
52
52
  Solargraph::Logging.logger
53
53
  end
54
+
55
+ # A helper method that runs Bundler.with_unbundled_env or falls back to
56
+ # Bundler.with_clean env for earlier versions of Bundler.
57
+ #
58
+ def self.with_clean_env &block
59
+ meth = if Bundler.respond_to?(:with_unbundled_env)
60
+ :with_unbundled_env
61
+ else
62
+ :with_clean_env
63
+ end
64
+ Bundler.send meth, &block
65
+ end
54
66
  end
@@ -603,14 +603,14 @@ module Solargraph
603
603
  # @param skip [Array<String>]
604
604
  # @return [Array<Pin::Base>]
605
605
  def inner_get_constants fqns, visibility, skip
606
- return [] if skip.include?(fqns)
606
+ return [] if fqns.nil? || skip.include?(fqns)
607
607
  skip.push fqns
608
- result = []
609
- result.concat store.get_constants(fqns, visibility).sort{ |a, b| a.name <=> b.name }
608
+ result = store.get_constants(fqns, visibility)
609
+ .sort { |a, b| a.name <=> b.name }
610
610
  store.get_includes(fqns).each do |is|
611
- fqis = qualify(is, fqns)
612
- result.concat inner_get_constants(fqis, [:public], skip) unless fqis.nil?
611
+ result.concat inner_get_constants(qualify(is, fqns), [:public], skip)
613
612
  end
613
+ result.concat inner_get_constants(store.get_superclass(fqns), [:public], skip)
614
614
  result
615
615
  end
616
616
 
@@ -7,6 +7,8 @@ module Solargraph
7
7
 
8
8
  # True if the source qualifies for this convention.
9
9
  # Subclasses should override this method.
10
+ #
11
+ # @param source [Source]
10
12
  def match? source
11
13
  false
12
14
  end
@@ -90,6 +90,7 @@ module Solargraph
90
90
  Override.method_return('Object#clone', 'self', delete: [:overload]),
91
91
  Override.method_return('Object#dup', 'self'),
92
92
  Override.method_return('Object#freeze', 'self', delete: [:overload]),
93
+ Override.method_return('Object#inspect', 'String'),
93
94
  Override.method_return('Object#taint', 'self'),
94
95
  Override.method_return('Object#to_s', 'String'),
95
96
  Override.method_return('Object#untaint', 'self'),
@@ -98,16 +99,27 @@ module Solargraph
98
99
  @yieldparam [self]
99
100
  )),
100
101
 
102
+ Override.from_comment('STDERR', %(
103
+ @type [IO]
104
+ )),
105
+
106
+ Override.from_comment('STDIN', %(
107
+ @type [IO]
108
+ )),
109
+
110
+ Override.from_comment('STDOUT', %(
111
+ @type [IO]
112
+ )),
113
+
101
114
  Override.method_return('String#freeze', 'self'),
102
115
  Override.method_return('String#split', 'Array<String>'),
103
116
  Override.method_return('String#lines', 'Array<String>')
104
- ].concat(
105
- methods_with_yieldparam_subtypes.map do |path|
106
- Override.from_comment(path, %(
117
+ ].concat(
118
+ methods_with_yieldparam_subtypes.map do |path|
119
+ Override.from_comment(path, %(
107
120
  @yieldparam_single_parameter
108
121
  ))
109
- end
110
- )
122
+ end
123
+ )
111
124
  end
112
125
  end
113
-
@@ -53,7 +53,7 @@ module Solargraph
53
53
  end
54
54
 
55
55
  def self.specs_from_bundle directory
56
- Bundler.with_clean_env do
56
+ Solargraph.with_clean_env do
57
57
  Dir.chdir directory do
58
58
  cmd = [
59
59
  'bundle', 'exec', 'ruby', '-e',
@@ -473,7 +473,8 @@ module Solargraph
473
473
  if params['data']['path']
474
474
  result.concat library.path_pins(params['data']['path'])
475
475
  end
476
- result.uniq
476
+ # Selecting by both location and path can result in duplicate pins
477
+ result.uniq { |p| [p.path, p.location] }
477
478
  end
478
479
 
479
480
  # @param uri [String]
@@ -1,7 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'solargraph'
4
- require 'uri'
5
4
 
6
5
  module Solargraph
7
6
  module LanguageServer
@@ -20,7 +20,6 @@ module Solargraph
20
20
  return params if pins.empty?
21
21
  docs = pins
22
22
  .reject { |pin| pin.documentation.empty? && pin.return_type.undefined? }
23
- # docs = filt.map { |pin| pin.resolve_completion_item[:documentation] }
24
23
  result = params
25
24
  .merge(pins.first.resolve_completion_item)
26
25
  .merge(documentation: markup_content(join_docs(docs)))
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'uri'
4
-
5
3
  module Solargraph::LanguageServer::Message::TextDocument
6
4
  class Definition < Base
7
5
  def process
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'uri'
4
-
5
3
  module Solargraph
6
4
  module LanguageServer
7
5
  module Message
@@ -20,7 +18,7 @@ module Solargraph
20
18
  parts.push this_link
21
19
  end
22
20
  parts.push pin.detail.gsub(':', '\\:') unless pin.is_a?(Pin::Namespace) || pin.detail.nil?
23
- parts.push pin.documentation unless pin.documentation.nil? or pin.documentation.empty?
21
+ parts.push pin.documentation unless pin.documentation.nil? || pin.documentation.empty?
24
22
  contents.push parts.join("\n\n") unless parts.empty?
25
23
  last_link = this_link unless this_link.nil?
26
24
  end
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'uri'
4
-
5
3
  module Solargraph::LanguageServer::Message::Workspace
6
4
  class DidChangeConfiguration < Solargraph::LanguageServer::Message::Base
7
5
  def process
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'uri'
4
-
5
3
  module Solargraph::LanguageServer::Message::Workspace
6
4
  class DidChangeWatchedFiles < Solargraph::LanguageServer::Message::Base
7
5
  CREATED = 1
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'uri'
4
-
5
3
  module Solargraph::LanguageServer::Message::Workspace
6
4
  class DidChangeWorkspaceFolders < Solargraph::LanguageServer::Message::Base
7
5
  def process
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'uri'
4
+
3
5
  module Solargraph
4
6
  module LanguageServer
5
7
  # Methods to handle conversions between file URIs and paths.
@@ -40,6 +40,28 @@ module Solargraph
40
40
  []
41
41
  end
42
42
 
43
+ def documentation
44
+ if @documentation.nil?
45
+ @documentation ||= super || ''
46
+ param_tags = docstring.tags(:param)
47
+ unless param_tags.nil? or param_tags.empty?
48
+ @documentation += "\n\n" unless @documentation.empty?
49
+ @documentation += "Params:\n"
50
+ lines = []
51
+ param_tags.each do |p|
52
+ l = "* #{p.name}"
53
+ l += " [#{escape_brackets(p.types.join(', '))}]" unless p.types.nil? or p.types.empty?
54
+ l += " #{p.text}"
55
+ lines.push l
56
+ end
57
+ @documentation += lines.join("\n")
58
+ end
59
+ @documentation += "\n\n" unless @documentation.empty?
60
+ @documentation += "Visibility: #{visibility}"
61
+ end
62
+ @documentation.to_s
63
+ end
64
+
43
65
  private
44
66
 
45
67
  # @return [ComplexType]
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'cgi'
4
+
3
5
  module Solargraph
4
6
  module Pin
5
7
  # @todo Move this stuff. It should be the responsibility of the language server.
@@ -81,7 +83,7 @@ module Solargraph
81
83
  this_path = path || return_type.tag
82
84
  return nil if this_path == 'undefined'
83
85
  return nil if this_path.nil? || this_path == 'undefined'
84
- "[#{escape_brackets(this_path).gsub('_', '\\\\_')}](solargraph:/document?query=#{URI.escape(this_path)})"
86
+ "[#{escape_brackets(this_path).gsub('_', '\\\\_')}](solargraph:/document?query=#{CGI.escape(this_path)})"
85
87
  end
86
88
 
87
89
  # @param text [String]
@@ -32,26 +32,6 @@ module Solargraph
32
32
  LanguageServer::SymbolKinds::METHOD
33
33
  end
34
34
 
35
- def documentation
36
- if @documentation.nil?
37
- @documentation ||= super || ''
38
- param_tags = docstring.tags(:param)
39
- unless param_tags.nil? or param_tags.empty?
40
- @documentation += "\n\n" unless @documentation.empty?
41
- @documentation += "Params:\n"
42
- lines = []
43
- param_tags.each do |p|
44
- l = "* #{p.name}"
45
- l += " [#{escape_brackets(p.types.join(', '))}]" unless p.types.nil? or p.types.empty?
46
- l += " #{p.text}"
47
- lines.push l
48
- end
49
- @documentation += lines.join("\n")
50
- end
51
- end
52
- @documentation.to_s
53
- end
54
-
55
35
  def nearly? other
56
36
  return false unless super
57
37
  parameters == other.parameters and
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Solargraph
4
- VERSION = '0.38.1'
4
+ VERSION = '0.38.2'
5
5
  end
@@ -2,7 +2,7 @@
2
2
  Namespace:
3
3
  </h2>
4
4
  <p>
5
- <a href="command:solargraph._openDocument?<%= URI.escape "\"solargraph:/document?query=#{object.namespace}\"" %>"><%= object.namespace %></a>
5
+ <a href="command:solargraph._openDocument?<%= CGI.escape "\"solargraph:/document?query=#{object.namespace}\"" %>"><%= object.namespace %></a>
6
6
  </p>
7
7
  <h2>
8
8
  Overview:
@@ -8,7 +8,7 @@
8
8
  <ul class="doc-list">
9
9
  <% object.meths(scope: :class).sort{|a, b| a.name <=> b.name}.each do |meth| %>
10
10
  <li>
11
- <a href="solargraph:/document?query=<%= URI.escape(meth.path) %>"><%= meth.name %></a>
11
+ <a href="solargraph:/document?query=<%= CGI.escape(meth.path) %>"><%= meth.name %></a>
12
12
  </li>
13
13
  <% end %>
14
14
  </ul>
@@ -18,7 +18,7 @@
18
18
  <ul class="doc-list">
19
19
  <% object.meths(scope: :instance).sort{|a, b| a.name <=> b.name}.each do |meth| %>
20
20
  <li>
21
- <a href="solargraph:/document?query=<%= URI.escape(meth.path) %>"><%= meth.name %></a>
21
+ <a href="solargraph:/document?query=<%= CGI.escape(meth.path) %>"><%= meth.name %></a>
22
22
  </li>
23
23
  <% end %>
24
24
  </ul>
@@ -30,8 +30,12 @@ module Solargraph
30
30
  # @return [Array<String>]
31
31
  attr_reader :required
32
32
 
33
+ # @return [Boolean]
33
34
  attr_writer :with_dependencies
34
35
 
36
+ # A hash of gem names and the version numbers to include in the map.
37
+ #
38
+ # @return [Hash{String => String}]
35
39
  attr_reader :gemset
36
40
 
37
41
  # @param required [Array<String>]
@@ -59,6 +63,7 @@ module Solargraph
59
63
  end
60
64
 
61
65
  # @param new_requires [Array<String>]
66
+ # @param new_gemset [Hash{String => String}]
62
67
  # @return [Boolean]
63
68
  def change new_requires, new_gemset
64
69
  if new_requires.uniq.sort == required.uniq.sort && new_gemset == gemset
@@ -145,7 +150,7 @@ module Solargraph
145
150
  @cache ||= YardMap::Cache.new
146
151
  end
147
152
 
148
- # @param ns [YARD::CodeObjects::Namespace]
153
+ # @param ns [YARD::CodeObjects::NamespaceObject]
149
154
  # @return [Array<YARD::CodeObjects::Base>]
150
155
  def recurse_namespace_object ns
151
156
  result = []
@@ -256,6 +261,7 @@ module Solargraph
256
261
  end
257
262
 
258
263
  # @param y [String, nil]
264
+ # @param spec [Gem::Specification, nil]
259
265
  # @return [Array<Pin::Base>]
260
266
  def process_yardoc y, spec = nil
261
267
  return [] if y.nil?
@@ -270,6 +276,8 @@ module Solargraph
270
276
  Mapper.new(YARD::Registry.all, spec).map
271
277
  end
272
278
 
279
+ # @param spec [Gem::Specification]
280
+ # @return [String]
273
281
  def yardoc_file_for_spec spec
274
282
  cache_dir = File.join(Solargraph::YardMap::CoreDocs.cache_dir, 'gems', "#{spec.name}-#{spec.version}", 'yardoc')
275
283
  if File.exist?(cache_dir)
@@ -280,6 +288,8 @@ module Solargraph
280
288
  end
281
289
  end
282
290
 
291
+ # @param path [String]
292
+ # @return [Gem::Specification]
283
293
  def spec_for_require path
284
294
  spec = Gem::Specification.find_by_path(path) || Gem::Specification.find_by_name(path.split('/').first)
285
295
  if @gemset[spec.name]
data/solargraph.gemspec CHANGED
@@ -20,7 +20,9 @@ Gem::Specification.new do |s|
20
20
  s.required_ruby_version = '>= 2.1'
21
21
 
22
22
  s.add_runtime_dependency 'backport', '~> 1.1'
23
+ s.add_runtime_dependency 'benchmark'
23
24
  s.add_runtime_dependency 'bundler', '>= 1.17.2'
25
+ s.add_runtime_dependency 'e2mmap'
24
26
  s.add_runtime_dependency 'jaro_winkler', '~> 1.5'
25
27
  s.add_runtime_dependency 'maruku', '~> 0.7', '>= 0.7.3'
26
28
  s.add_runtime_dependency 'nokogiri', '~> 1.9', '>= 1.9.1'
@@ -30,9 +32,6 @@ Gem::Specification.new do |s|
30
32
  s.add_runtime_dependency 'thor', '~> 1.0'
31
33
  s.add_runtime_dependency 'tilt', '~> 2.0'
32
34
  s.add_runtime_dependency 'yard', '~> 0.9'
33
- s.add_runtime_dependency 'e2mmap'
34
- s.add_runtime_dependency 'irb', '<= 1.1.0'
35
- s.add_runtime_dependency 'benchmark'
36
35
 
37
36
  s.add_development_dependency 'pry', '~> 0.11.3'
38
37
  s.add_development_dependency 'rspec', '~> 3.5', '>= 3.5.0'
data/yardoc/2.2.2.tar.gz CHANGED
Binary file
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.38.1
4
+ version: 0.38.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fred Snyder
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-01-02 00:00:00.000000000 Z
11
+ date: 2020-01-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: backport
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.1'
27
+ - !ruby/object:Gem::Dependency
28
+ name: benchmark
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: bundler
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -38,6 +52,20 @@ dependencies:
38
52
  - - ">="
39
53
  - !ruby/object:Gem::Version
40
54
  version: 1.17.2
55
+ - !ruby/object:Gem::Dependency
56
+ name: e2mmap
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
41
69
  - !ruby/object:Gem::Dependency
42
70
  name: jaro_winkler
43
71
  requirement: !ruby/object:Gem::Requirement
@@ -182,48 +210,6 @@ dependencies:
182
210
  - - "~>"
183
211
  - !ruby/object:Gem::Version
184
212
  version: '0.9'
185
- - !ruby/object:Gem::Dependency
186
- name: e2mmap
187
- requirement: !ruby/object:Gem::Requirement
188
- requirements:
189
- - - ">="
190
- - !ruby/object:Gem::Version
191
- version: '0'
192
- type: :runtime
193
- prerelease: false
194
- version_requirements: !ruby/object:Gem::Requirement
195
- requirements:
196
- - - ">="
197
- - !ruby/object:Gem::Version
198
- version: '0'
199
- - !ruby/object:Gem::Dependency
200
- name: irb
201
- requirement: !ruby/object:Gem::Requirement
202
- requirements:
203
- - - "<="
204
- - !ruby/object:Gem::Version
205
- version: 1.1.0
206
- type: :runtime
207
- prerelease: false
208
- version_requirements: !ruby/object:Gem::Requirement
209
- requirements:
210
- - - "<="
211
- - !ruby/object:Gem::Version
212
- version: 1.1.0
213
- - !ruby/object:Gem::Dependency
214
- name: benchmark
215
- requirement: !ruby/object:Gem::Requirement
216
- requirements:
217
- - - ">="
218
- - !ruby/object:Gem::Version
219
- version: '0'
220
- type: :runtime
221
- prerelease: false
222
- version_requirements: !ruby/object:Gem::Requirement
223
- requirements:
224
- - - ">="
225
- - !ruby/object:Gem::Version
226
- version: '0'
227
213
  - !ruby/object:Gem::Dependency
228
214
  name: pry
229
215
  requirement: !ruby/object:Gem::Requirement