solargraph 0.29.3 → 0.29.4

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: e54a4cf3c7dfa6b68a345b08958c7bf2663792962ad6a9176b3cee642324278a
4
- data.tar.gz: 6f494588dc4440ed5ef8d455d52e89e1626e3f5c4fdeb569a260aeba1f776418
3
+ metadata.gz: 60d754493bfc4ef0b40c6fd5b7c872b67e9ee5caa83930f9ede99389bb4b9007
4
+ data.tar.gz: '077452469bb99c0b6b7fede9bcadf8fb115d1b9889733c52170800f4b2a953f3'
5
5
  SHA512:
6
- metadata.gz: 448855a77c7b65ae2018f325f9d381476ac3a3bba3d3e0e3c6de0bb8961a48915218016fa4b0d09104068db82610e5eac1ca88acc75204848c441d471ded8728
7
- data.tar.gz: 527b35bb211a2820acf74e18daf00097f62858911b70e2ba5b62d613a09433c0271f274b9aadef7d1b936854ce887dcf3b3e4ea91e5a7c19e6ef926fb0e0279a
6
+ metadata.gz: 066a7d0a1b04ba6c9cba7cac8cbb8339a2c2b5a47bd387ab8fdc11b40a6b9ec3cd076c8f2672efb08be8d90db5df32575fea5cf3516e0d0d9e844a169b778580
7
+ data.tar.gz: 16a58b9ffc792406b3c95b4ab7d0b5835334a8851c6bb9ab89657606bde490c5184ca7bc5228dc122d39d70a71cb94d459d8a868bde0501c0ebba3cf6804c906
@@ -22,6 +22,7 @@ module Solargraph
22
22
  end
23
23
 
24
24
  def path
25
+ return name if namespace.empty?
25
26
  "#{namespace}::#{name}"
26
27
  end
27
28
  end
@@ -20,7 +20,9 @@ module Solargraph
20
20
  else
21
21
  ns = ''
22
22
  end
23
- api_map.get_constants(ns, context).select{|p| p.path.end_with?(bottom)}
23
+ result = api_map.get_constants(ns, context)
24
+ last_name = bottom.split('::').last
25
+ result.select{ |p| p.name == last_name }
24
26
  end
25
27
  end
26
28
  end
@@ -109,6 +109,22 @@ module Solargraph
109
109
  signature
110
110
  end
111
111
 
112
+ # Find all the nodes within the provided node that potentially return a
113
+ # value.
114
+ #
115
+ # The node parameter typically represents a method's logic, e.g., the
116
+ # second child (after the :args node) of a :def node. A simple one-line
117
+ # method would typically return itself, while a node with conditions
118
+ # would return the resulting node from each conditional branch. Nodes
119
+ # that follow a :return node are assumed to be unreachable. Implicit nil
120
+ # values are ignored.
121
+ #
122
+ # @todo Maybe this method should include implicit nil values in results.
123
+ # For example, a bare `return` would return a :nil node instead of an
124
+ # empty array.
125
+ #
126
+ # @param node [AST::Node]
127
+ # @return [Array<AST::Node>]
112
128
  def returns_from node
113
129
  DeepInference.get_return_nodes(node)
114
130
  end
@@ -120,11 +136,14 @@ module Solargraph
120
136
  SKIPPABLE = [:def, :defs, :class, :sclass, :module]
121
137
 
122
138
  def get_return_nodes node
139
+ return [] unless node.is_a?(Parser::AST::Node)
123
140
  result = []
124
141
  if REDUCEABLE.include?(node.type)
125
142
  result.concat get_return_nodes_from_children(node)
126
143
  elsif CONDITIONAL.include?(node.type)
127
144
  result.concat reduce_to_value_nodes(node.children[1..-1])
145
+ elsif node.type == :return
146
+ result.concat reduce_to_value_nodes([node.children[0]])
128
147
  else
129
148
  result.push node
130
149
  end
@@ -140,8 +159,8 @@ module Solargraph
140
159
  next if SKIPPABLE.include?(node.type)
141
160
  if node.type == :return
142
161
  result.concat reduce_to_value_nodes([node.children[0]])
143
- # @todo Maybe return the result here because the rest of the code is
144
- # unreachable
162
+ # Return the result here because the rest of the code is
163
+ # unreachable
145
164
  return result
146
165
  else
147
166
  result.concat get_return_nodes_only(node)
@@ -158,8 +177,9 @@ module Solargraph
158
177
  next if SKIPPABLE.include?(node.type)
159
178
  if node.type == :return
160
179
  result.concat reduce_to_value_nodes([node.children[0]])
161
- # @todo Maybe return the result here because the rest of the code is
162
- # unreachable
180
+ # Return the result here because the rest of the code is
181
+ # unreachable
182
+ return result
163
183
  else
164
184
  result.concat get_return_nodes_only(node)
165
185
  end
@@ -170,11 +190,9 @@ module Solargraph
170
190
  def reduce_to_value_nodes nodes
171
191
  result = []
172
192
  nodes.each do |node|
193
+ next unless node.is_a?(Parser::AST::Node)
173
194
  if REDUCEABLE.include?(node.type)
174
195
  result.concat get_return_nodes_from_children(node)
175
- # node.children.each do |child|
176
- # result.concat reduce_to_value_nodes(child)
177
- # end
178
196
  elsif CONDITIONAL.include?(node.type)
179
197
  result.concat reduce_to_value_nodes(node.children[1..-1])
180
198
  elsif node.type == :return
@@ -186,7 +204,7 @@ module Solargraph
186
204
  result
187
205
  end
188
206
  end
189
- end
207
+ end
190
208
  end
191
209
  end
192
210
  end
@@ -1,3 +1,3 @@
1
1
  module Solargraph
2
- VERSION = '0.29.3'
2
+ VERSION = '0.29.4'
3
3
  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.29.3
4
+ version: 0.29.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fred Snyder
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-12-05 00:00:00.000000000 Z
11
+ date: 2018-12-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: eventmachine