solargraph 0.31.0 → 0.31.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7e808b8b4e3550a64f5737991858a16cfb43c1d4d839fa0be4c7018d9740783f
4
- data.tar.gz: 7a90449ea2b30e07234f89bfb468eaf0e33e28711799b15064a9ae9dbcf83bc3
3
+ metadata.gz: a170a254c51b9119d68f9542bb621eee41831b814e94d5f987eb2c7d78f412ba
4
+ data.tar.gz: 9beff1ee445b21b89dbbcee0d2a68bed60911940a8587a58c6c361aa0ca7ffad
5
5
  SHA512:
6
- metadata.gz: d87b8b907a0c33376f138381ad1b70c8c49be1ce504aec7e098bcac84030f53c9c469ea87b3b0e2fdaebe04bc51cf0b338ac3074fa1064be47f87e60c82499c4
7
- data.tar.gz: 5888e2114dfea0da7dd3681d800400f7393cb63804f8d4f043aac2f74b0bf9bce1f986f34ae9d85bcc9753e49f5c773ad7ec3791257fbe372f632f3deb81ee04
6
+ metadata.gz: 79d0c51c0b65bf9f10f816b3821aa463d4f767a6ef926a948574e7c33b6f24eb8be5eda8a93bb41ad8d8e56bd73800b57fcc1e79cf85cf05efcf5279bff34319
7
+ data.tar.gz: a6ddfcd658534c8f6c01d1b5f9ab25d13c9bc0abb2f437e783e6a89a280048d8886b8b105afc37f428ac25ecf403f9ad9e1a26dff5a7903c1eac28d04f10f953
@@ -129,7 +129,7 @@ module Solargraph
129
129
  # @param uri [String] The file uri.
130
130
  # @return [void]
131
131
  def delete uri
132
- sources.close uri
132
+ # sources.close uri # @todo It's possible for a deleted file to be open in an editor
133
133
  filename = uri_to_file(uri)
134
134
  libraries.each do |lib|
135
135
  # lib.delete filename
@@ -534,7 +534,10 @@ module Solargraph
534
534
  # @return [Array<Solargraph::Pin::Base>]
535
535
  def document_symbols uri
536
536
  library = library_for(uri)
537
- library.document_symbols(uri_to_file(uri))
537
+ # At this level, document symbols should be unique; e.g., a
538
+ # module_function method should return the location for Module.method
539
+ # or Module#method, but not both.
540
+ library.document_symbols(uri_to_file(uri)).uniq(&:location)
538
541
  end
539
542
 
540
543
  # Send a notification to the client.
@@ -73,6 +73,7 @@ module Solargraph
73
73
  response[:result] = nil if result.nil? and error.nil?
74
74
  json = response.to_json
75
75
  envelope = "Content-Length: #{json.bytesize}\r\n\r\n#{json}"
76
+ Solargraph.logger.debug envelope
76
77
  host.queue envelope
77
78
  host.clear id
78
79
  end
@@ -3,6 +3,7 @@ require 'uri'
3
3
  module Solargraph::LanguageServer::Message::Workspace
4
4
  class DidChangeConfiguration < Solargraph::LanguageServer::Message::Base
5
5
  def process
6
+ return unless params['settings']
6
7
  update = params['settings']['solargraph']
7
8
  host.configure update
8
9
  register_from_options
@@ -1,11 +1,11 @@
1
+ require 'backport'
2
+
1
3
  module Solargraph
2
4
  module LanguageServer
3
5
  module Transport
4
6
  # A common module for running language servers in Backport.
5
7
  #
6
8
  module Adapter
7
- @@timer_is_running = false
8
-
9
9
  def opening
10
10
  @host = Solargraph::LanguageServer::Host.new
11
11
  @host.start
@@ -52,7 +52,7 @@ module Solargraph
52
52
  msg = JSON.parse(@buffer)
53
53
  @message_handler.call msg unless @message_handler.nil?
54
54
  rescue JSON::ParserError => e
55
- Solargraph::Logging.logger.info "Failed to parse request: #{e.message}"
55
+ Solargraph::Logging.logger.warn "Failed to parse request: #{e.message}"
56
56
  Solargraph::Logging.logger.debug "Buffer: #{@buffer}"
57
57
  ensure
58
58
  @buffer.clear
@@ -207,7 +207,9 @@ module Solargraph
207
207
  found = source.references(pin.name)
208
208
  found.select! do |loc|
209
209
  referenced = definitions_at(loc.filename, loc.range.ending.line, loc.range.ending.character)
210
- referenced.any?{|r| r == pin}
210
+ # HACK: The additional location comparison is necessary because
211
+ # Clip#define can return proxies for parameter pins
212
+ referenced.any?{|r| r == pin || r.location == pin.location}
211
213
  end
212
214
  # HACK: for language clients that exclude special characters from the start of variable names
213
215
  if strip && match = cursor.word.match(/^[^a-z0-9_]+/i)
@@ -200,7 +200,8 @@ module Solargraph
200
200
  # @return [Boolean]
201
201
  def comment_at? position
202
202
  comment_ranges.each do |range|
203
- return true if range.include?(position)
203
+ return true if range.include?(position) ||
204
+ (range.ending.line == position.line && range.ending.column < position.column)
204
205
  break if range.ending.line > position.line
205
206
  end
206
207
  false
@@ -257,7 +258,7 @@ module Solargraph
257
258
  end
258
259
 
259
260
  FOLDING_NODE_TYPES = %i[
260
- class sclass module def defs if str dstr array while unless kwbegin hash
261
+ class sclass module def defs if str dstr array while unless kwbegin hash block
261
262
  ].freeze
262
263
 
263
264
  # Get an array of ranges that can be folded, e.g., the range of a class
@@ -334,9 +335,9 @@ module Solargraph
334
335
  num = cur if cur < num
335
336
  end
336
337
  # Include blank lines between comments
337
- ctxt += ("\n" * (l.loc.first_line - last_line - 1)) unless last_line.nil?
338
+ ctxt += ("\n" * (l.loc.first_line - last_line - 1)) unless last_line.nil? || l.loc.first_line - last_line <= 0
338
339
  ctxt += "#{p[num..-1]}\n" if started
339
- last_line = l.loc.last_line
340
+ last_line = l.loc.last_line if last_line.nil? || l.loc.last_line > last_line
340
341
  }
341
342
  ctxt
342
343
  end
@@ -33,16 +33,14 @@ module Solargraph
33
33
  return Chain.new([Chain::Literal.new('Symbol')]) if phrase.start_with?(':') && !phrase.start_with?('::')
34
34
  begin
35
35
  return Chain.new([]) if phrase.end_with?('..')
36
- if source.synchronized?
37
- if !source.repaired? && source.parsed?
38
- node = source.node_at(position.line, position.column)
39
- else
40
- node = nil
41
- node = source.node_at(fixed_position.line, fixed_position.column) unless source.error_ranges.any?{|r| r.nil? || r.include?(fixed_position)}
42
- node = Source.parse(fixed_phrase) if node.nil?
43
- end
36
+ if !source.repaired? && source.parsed? && source.synchronized?
37
+ node = source.node_at(position.line, position.column)
44
38
  else
45
- node = Source.parse(fixed_phrase)
39
+ node = nil
40
+ node = source.node_at(fixed_position.line, fixed_position.column) unless source.error_ranges.any?{|r| r.nil? || r.include?(fixed_position)}
41
+ # Exception for positions that chain literal nodes in unsynchronized sources
42
+ node = nil unless source.synchronized? || !infer_literal_node_type(node).nil?
43
+ node = Source.parse(fixed_phrase) if node.nil?
46
44
  end
47
45
  rescue Parser::SyntaxError
48
46
  return Chain.new([Chain::UNDEFINED_CALL])
@@ -1,3 +1,3 @@
1
1
  module Solargraph
2
- VERSION = '0.31.0'
2
+ VERSION = '0.31.1'
3
3
  end
@@ -45,7 +45,7 @@ module Solargraph
45
45
  #
46
46
  # @return [Array<String>]
47
47
  def included
48
- return [] if directory.empty?
48
+ return [] if directory.empty? || directory == '*'
49
49
  @included ||= process_globs(@raw_data['include'])
50
50
  end
51
51
 
@@ -53,7 +53,7 @@ module Solargraph
53
53
  #
54
54
  # @return [Array<String>]
55
55
  def excluded
56
- return [] if directory.empty?
56
+ return [] if directory.empty? || directory == '*'
57
57
  @excluded ||= process_exclusions(@raw_data['exclude'])
58
58
  end
59
59
 
@@ -61,6 +61,7 @@ module Solargraph
61
61
  #
62
62
  # @return [Array<String>]
63
63
  def calculated
64
+ Solargraph.logger.info "Indexing workspace files in #{directory}" unless @calculated || directory.empty? || directory == '*'
64
65
  @calculated ||= included - excluded
65
66
  end
66
67
 
@@ -1,6 +1,8 @@
1
1
  require 'fileutils'
2
2
  require 'tmpdir'
3
3
  require 'pathname'
4
+ require 'rubygems/package'
5
+ require 'shellwords'
4
6
 
5
7
  module Solargraph
6
8
  class YardMap
@@ -17,28 +19,55 @@ module Solargraph
17
19
  path_name = Pathname.new(Dir.pwd).join(dest_dir).to_s
18
20
  FileUtils.mkdir_p path_name
19
21
  Dir.chdir(ruby_dir) do
20
- `yardoc --plugin coregen -b #{File.join(path_name, 'yardoc')} -n *.c`
22
+ `yardoc --plugin coregen -b "#{File.join(path_name, 'yardoc')}" -n *.c`
21
23
  raise 'An error occurred generating the core yardoc.' unless $?.success?
22
- `yardoc -b #{File.join(path_name, 'yardoc-stdlib')} -n lib ext`
24
+ # YARD::CLI::Yardoc.run('--plugin', 'coregen', '-b', "#{File.join(path_name, 'yardoc')}", '-n', File.join(ruby_dir, '*.c'))
25
+ `yardoc -b "#{File.join(path_name, 'yardoc-stdlib')}" -n lib ext`
23
26
  raise 'An error occurred generating the stdlib yardoc.' unless $?.success?
27
+ # YARD::CLI::Yardoc.run('-b', "#{File.join(path_name, 'yardoc-stdlib')}", '-n', File.join(ruby_dir, 'lib', '**', '*.rb'), File.join(ruby_dir, 'ext', '**', '*.c'), File.join(ruby_dir, 'ext', '**', '*.rb'))
24
28
  end
25
29
  end
26
30
 
27
- # Generate a gzip of documentation from the specified Ruby source directory.
31
+ # Generate a gzip of documentation from the specified Ruby source
32
+ # directory.
33
+ #
34
+ # This method is designed to generate the directory architecture that
35
+ # YardMap core docs expect.
28
36
  #
29
37
  # @param ruby_dir [String] The Ruby source directory
30
- # @param gzip_name [String] The gzip file name
38
+ # @param ver_name [String, nil] The version name
39
+ # @param dest_dir [String] The destination directory
31
40
  # @return [void]
32
- def generate_gzip ruby_dir, gzip_name
41
+ def generate_gzip ruby_dir, ver_name = nil, dest_dir = Dir.pwd
33
42
  Dir.mktmpdir do |tmp|
34
- gzip_name += '.tar.gz' unless gzip_name.end_with?('.tar.gz')
35
- base_name = gzip_name[0..-8]
36
- path_name = Pathname.new(Dir.pwd).join(base_name).to_s
37
- generate_docs ruby_dir, tmp
38
- `cd #{tmp} && tar -cf #{path_name}.tar *`
39
- raise 'An error occurred generating the documentation tar.' unless $?.success?
40
- `gzip #{path_name}.tar`
41
- raise 'An error occurred generating the documentation gzip.' unless $?.success?
43
+ base_name = ver_name || begin
44
+ match = ruby_dir.match(/\d+\.\d+\.\d+$/)
45
+ raise "Unable to determine version name from #{ruby_dir}" if match.nil?
46
+ match[0]
47
+ end
48
+ path_name = Pathname.new(tmp).join(base_name).to_s
49
+ generate_docs ruby_dir, path_name
50
+ gzip path_name, Pathname.new(dest_dir).join("#{base_name}.tar.gz").to_s
51
+ end
52
+ end
53
+
54
+ private
55
+
56
+ # @param dir [String] The directory to compress
57
+ # @param dst [String] The destination file
58
+ def gzip dir, dst
59
+ File.open(dst, 'wb') do |file|
60
+ Zlib::GzipWriter.wrap(file) do |gzip|
61
+ Gem::Package::TarWriter.new(gzip) do |tar|
62
+ Dir["#{dir}/**/*"].each do |filename|
63
+ next if File.directory?(filename)
64
+ relname = File.join(File.basename(dir), filename[dir.length+1..-1])
65
+ tar.add_file_simple(relname, 0o644, File.size(filename)) do |io|
66
+ io.write File.read_binary(filename)
67
+ end
68
+ end
69
+ end
70
+ end
42
71
  end
43
72
  end
44
73
  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.31.0
4
+ version: 0.31.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fred Snyder
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-01-14 00:00:00.000000000 Z
11
+ date: 2019-01-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: backport
@@ -44,6 +44,20 @@ dependencies:
44
44
  - - ">="
45
45
  - !ruby/object:Gem::Version
46
46
  version: 4.3.4
47
+ - !ruby/object:Gem::Dependency
48
+ name: jaro_winkler
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '1.5'
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: '1.5'
47
61
  - !ruby/object:Gem::Dependency
48
62
  name: kramdown
49
63
  requirement: !ruby/object:Gem::Requirement
@@ -154,20 +168,6 @@ dependencies:
154
168
  - - "~>"
155
169
  - !ruby/object:Gem::Version
156
170
  version: '0.9'
157
- - !ruby/object:Gem::Dependency
158
- name: jaro_winkler
159
- requirement: !ruby/object:Gem::Requirement
160
- requirements:
161
- - - "~>"
162
- - !ruby/object:Gem::Version
163
- version: '1.5'
164
- type: :runtime
165
- prerelease: false
166
- version_requirements: !ruby/object:Gem::Requirement
167
- requirements:
168
- - - "~>"
169
- - !ruby/object:Gem::Version
170
- version: '1.5'
171
171
  - !ruby/object:Gem::Dependency
172
172
  name: pry
173
173
  requirement: !ruby/object:Gem::Requirement