solargraph 0.39.4 → 0.39.5

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: 1a45c7684317779d321e953079f5da5532f7b7eecc852b73e609ce03dafc81dc
4
- data.tar.gz: '08f96cb16887491e334fa276959cd019da3c356656a9a670c6133e491745fa55'
3
+ metadata.gz: 42d82e12b3dbc74f908e6fd15757e8856c7c3af088ccbfbc6724f390884f878d
4
+ data.tar.gz: df04fa34d85b0633d05ab8fd216873264a4cdaa148089ffa3af909ec68a227a7
5
5
  SHA512:
6
- metadata.gz: 5a9d7ec1fb35b5d870d33f16a9bf6b229b1f62a6221f7fac5d1d35e65620ac030cef5bd53c558a1ee007c37b4e187a43315abfa4cecaf146c3746e9b97a46f3f
7
- data.tar.gz: 7537aa6bd14209895350f40830dd5986683982609c8e18d257eaca8993b0ab759b2e635ec6c952499a0d8559663b870c1db9b9a3c1955bd8dd096eaedde04d73
6
+ metadata.gz: d1972e824e94ad830815eb780629ef985a5be4b21247f426b603e209cecc60d6c5c02219c63cdc2c6c9ab184013d72e1798c29ef90b5a91d77a92f8dd35e1295
7
+ data.tar.gz: 7f5564c3de416999a40e381d853746e759898da6fa09eb6d967735478a24635f1af3cee6695894b7213c8b6746e73d8e3d57d3adc141ab505040e0eb4c8134cd
@@ -5,6 +5,7 @@ require 'json'
5
5
  require 'open3'
6
6
  require 'shellwords'
7
7
  require 'yard'
8
+ require 'fileutils'
8
9
 
9
10
  module Solargraph
10
11
  class Documentor
@@ -25,6 +26,7 @@ module Solargraph
25
26
  Documentor.specs_from_bundle(@directory).each_pair do |name, version|
26
27
  yd = YARD::Registry.yardoc_file_for_gem(name, "= #{version}")
27
28
  if !yd || @rebuild
29
+ FileUtils.safe_unlink File.join(YardMap::CoreDocs.cache_dir, 'gems', "#{name}-#{version}.ser")
28
30
  @out.puts "Documenting #{name} #{version}"
29
31
  `yard gems #{name} #{version} #{@rebuild ? '--rebuild' : ''}`
30
32
  yd = YARD::Registry.yardoc_file_for_gem(name, "= #{version}")
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'uri'
3
+ require 'cgi'
4
4
 
5
5
  module Solargraph
6
6
  module LanguageServer
@@ -14,7 +14,7 @@ module Solargraph
14
14
  # @param uri [String]
15
15
  # @return [String]
16
16
  def uri_to_file uri
17
- URI.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.
@@ -22,7 +22,26 @@ module Solargraph
22
22
  # @param file [String]
23
23
  # @return [String]
24
24
  def file_to_uri file
25
- "file://#{URI.encode(file.gsub(/^([a-z]\:)/i, '/\1'))}"
25
+ "file://#{encode(file.gsub(/^([a-z]\:)/i, '/\1'))}"
26
+ end
27
+
28
+ # Encode text to be used as a URI path component in LSP.
29
+ #
30
+ # @param text [String]
31
+ # @return [String]
32
+ def encode text
33
+ CGI.escape(text)
34
+ .gsub('%3A', ':')
35
+ .gsub('%5C', '\\')
36
+ .gsub('%2F', '/')
37
+ end
38
+
39
+ # Decode text from a URI path component in LSP.
40
+ #
41
+ # @param text [String]
42
+ # @return [String]
43
+ def decode text
44
+ CGI.unescape(text)
26
45
  end
27
46
  end
28
47
  end
@@ -36,6 +36,7 @@ module Solargraph
36
36
  register :RESBODY, Rubyvm::NodeProcessors::ResbodyNode
37
37
  register :DEFN, Rubyvm::NodeProcessors::DefNode
38
38
  register :DEFS, Rubyvm::NodeProcessors::DefsNode
39
+ register :CALL, Rubyvm::NodeProcessors::SendNode
39
40
  register :FCALL, Rubyvm::NodeProcessors::SendNode
40
41
  register :VCALL, Rubyvm::NodeProcessors::SendNode
41
42
  register :CLASS, Rubyvm::NodeProcessors::NamespaceNode
@@ -43,45 +43,7 @@ module Solargraph
43
43
  process_prepend
44
44
  elsif node.children[0] == :private_constant
45
45
  process_private_constant
46
- end
47
- process_children
48
- return
49
- # @todo Get rid of legacy
50
- if node.children[0].nil?
51
- if [:private, :public, :protected].include?(node.children[1])
52
- if (node.children.length > 2)
53
- node.children[2..-1].each do |child|
54
- next unless child.is_a?(AST::Node) && (child.type == :sym || child.type == :str)
55
- name = child.children[0].to_s
56
- matches = pins.select{ |pin| pin.is_a?(Pin::BaseMethod) && pin.name == name && pin.namespace == region.closure.full_context.namespace && pin.context.scope == (region.scope || :instance)}
57
- matches.each do |pin|
58
- # @todo Smelly instance variable access
59
- pin.instance_variable_set(:@visibility, node.children[1])
60
- end
61
- end
62
- else
63
- # @todo Smelly instance variable access
64
- region.instance_variable_set(:@visibility, node.children[1])
65
- end
66
- elsif node.children[1] == :module_function
67
- process_module_function
68
- elsif [:attr_reader, :attr_writer, :attr_accessor].include?(node.children[1])
69
- process_attribute
70
- elsif node.children[1] == :include
71
- process_include
72
- elsif node.children[1] == :extend
73
- process_extend
74
- elsif node.children[1] == :require
75
- process_require
76
- elsif node.children[1] == :private_constant
77
- process_private_constant
78
- elsif node.children[1] == :alias_method && node.children[2] && node.children[2] && node.children[2].type == :sym && node.children[3] && node.children[3].type == :sym
79
- process_alias_method
80
- elsif node.children[1] == :private_class_method && node.children[2].is_a?(AST::Node)
81
- # Processing a private class can potentially handle children on its own
82
- return if process_private_class_method
83
- end
84
- elsif node.children[1] == :require && node.children[0].to_s == '(const nil :Bundler)'
46
+ elsif node.children[1] == :require && unpack_name(node.children[0]) == 'Bundler'
85
47
  pins.push Pin::Reference::Require.new(Solargraph::Location.new(region.filename, Solargraph::Range.from_to(0, 0, 0, 0)), 'bundler/require')
86
48
  end
87
49
  process_children
@@ -8,7 +8,7 @@ module Solargraph
8
8
 
9
9
  # @param access [::Symbol] :reader or :writer
10
10
  def initialize access: :reader, **splat
11
- super(splat)
11
+ super(**splat)
12
12
  @access = access
13
13
  if access == :writer
14
14
  parameters.push(
@@ -14,7 +14,7 @@ module Solargraph
14
14
  # @param visibility [::Symbol] :public, :protected, or :private
15
15
  # @param explicit [Boolean]
16
16
  def initialize visibility: :public, explicit: true, **splat
17
- super(splat)
17
+ super(**splat)
18
18
  @visibility = visibility
19
19
  @explicit = explicit
20
20
  end
@@ -11,7 +11,7 @@ module Solargraph
11
11
 
12
12
  # @param assignment [Parser::AST::Node, nil]
13
13
  def initialize assignment: nil, **splat
14
- super(splat)
14
+ super(**splat)
15
15
  @assignment = assignment
16
16
  end
17
17
 
@@ -9,7 +9,7 @@ module Solargraph
9
9
  attr_reader :receiver
10
10
 
11
11
  def initialize receiver: nil, args: [], **splat
12
- super(splat)
12
+ super(**splat)
13
13
  @receiver = receiver
14
14
  @parameters = args
15
15
  end
@@ -7,7 +7,7 @@ module Solargraph
7
7
  attr_reader :scope
8
8
 
9
9
  def initialize scope: :class, **splat
10
- super(splat)
10
+ super(**splat)
11
11
  @scope = scope
12
12
  end
13
13
 
@@ -6,7 +6,7 @@ module Solargraph
6
6
  attr_reader :visibility
7
7
 
8
8
  def initialize visibility: :public, **splat
9
- super(splat)
9
+ super(**splat)
10
10
  @visibility = visibility
11
11
  end
12
12
 
@@ -6,7 +6,7 @@ module Solargraph
6
6
  include Localized
7
7
 
8
8
  def initialize assignment: nil, presence: nil, **splat
9
- super(splat)
9
+ super(**splat)
10
10
  @assignment = assignment
11
11
  @presence = presence
12
12
  end
@@ -11,7 +11,7 @@ module Solargraph
11
11
  # @param args [Array<String>]
12
12
  # @param node [Parser::AST::Node, nil]
13
13
  def initialize parameters: [], node: nil, **splat
14
- super(splat)
14
+ super(**splat)
15
15
  @parameters = parameters
16
16
  @node = node
17
17
  end
@@ -14,7 +14,7 @@ module Solargraph
14
14
  attr_reader :original
15
15
 
16
16
  def initialize scope: :instance, original: nil, **splat
17
- super(splat)
17
+ super(**splat)
18
18
  @scope = scope
19
19
  @original = original
20
20
  end
@@ -14,7 +14,7 @@ module Solargraph
14
14
  # @param gates [Array<String>]
15
15
  def initialize type: :class, visibility: :public, gates: [''], **splat
16
16
  # super(location, namespace, name, comments)
17
- super(splat)
17
+ super(**splat)
18
18
  @type = type
19
19
  @visibility = visibility
20
20
  if name.start_with?('::')
@@ -8,7 +8,7 @@ module Solargraph
8
8
  attr_reader :asgn_code
9
9
 
10
10
  def initialize decl: :arg, asgn_code: nil, **splat
11
- super(splat)
11
+ super(**splat)
12
12
  @asgn_code = asgn_code
13
13
  @decl = decl
14
14
  end
@@ -5,7 +5,7 @@ module Solargraph
5
5
  class ProxyType < Base
6
6
  # @param return_type [ComplexType]
7
7
  def initialize return_type: ComplexType::UNDEFINED, **splat
8
- super(splat)
8
+ super(**splat)
9
9
  @return_type = return_type
10
10
  end
11
11
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Solargraph
4
- VERSION = '0.39.4'
4
+ VERSION = '0.39.5'
5
5
  end
@@ -2,7 +2,7 @@
2
2
  <% unless tag.types.nil? or tag.types.empty? %>
3
3
  [<%= escape(tag.types.join(', ')) %>]
4
4
  <% end %>
5
- <% unless tag.text.empty? %>
5
+ <% unless tag.text.nil? || tag.text.empty? %>
6
6
  <% unless (tag.name.nil? or tag.name.empty?) and (tag.types.nil? or tag.types.empty?) %>
7
7
  -
8
8
  <% end %>
@@ -170,7 +170,7 @@ module Solargraph
170
170
  Dir.chdir base do
171
171
  begin
172
172
  # @type [Gem::Specification]
173
- spec = eval(File.read(file), binding, file)
173
+ spec = eval(File.read(file), nil, file)
174
174
  next unless Gem::Specification === spec
175
175
  @gemnames.push spec.name
176
176
  result.concat(spec.require_paths.map { |path| File.join(base, path) })
@@ -17,6 +17,9 @@ module Solargraph
17
17
  @code_objects.each do |co|
18
18
  @pins.concat generate_pins co
19
19
  end
20
+ # Some yardocs contain documentation for dependencies that can be
21
+ # ignored here. The YardMap will load dependencies separately.
22
+ @pins.keep_if { |pin| pin.location.nil? || File.file?(pin.location.filename) } if @spec
20
23
  @pins
21
24
  end
22
25
 
@@ -95,6 +95,8 @@ module Solargraph
95
95
  FileUtils.mkdir_p cache_dir
96
96
  # @todo Should merge be true?
97
97
  YARD::Registry.save true, cache_dir
98
+ # Clear the serialized cache if it exists
99
+ FileUtils.safe_unlink File.join(CoreDocs.cache_dir, 'gems', "#{spec.name}-#{spec.version}.ser")
98
100
  end
99
101
  end
100
102
  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.39.4
4
+ version: 0.39.5
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-05-01 00:00:00.000000000 Z
11
+ date: 2020-05-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: backport